diff --git a/src/main/java/xyz/wagyourtail/jvmdg/classloader/DowngradingClassLoader.java b/src/main/java/xyz/wagyourtail/jvmdg/classloader/DowngradingClassLoader.java index a982809e..0595a610 100644 --- a/src/main/java/xyz/wagyourtail/jvmdg/classloader/DowngradingClassLoader.java +++ b/src/main/java/xyz/wagyourtail/jvmdg/classloader/DowngradingClassLoader.java @@ -25,7 +25,7 @@ public class DowngradingClassLoader extends ClassLoader implements Closeable { public DowngradingClassLoader(ClassDowngrader downgrader) throws IOException { super(); - Set apiJar = downgrader.flags.findJavaApi(); + List apiJar = downgrader.flags.findJavaApi(); if (apiJar != null) { for (File file : apiJar) { delegates.add(new JarFileResourceProvider(new JarFile(file))); @@ -42,7 +42,7 @@ public DowngradingClassLoader(ClassDowngrader downgrader) throws IOException { public DowngradingClassLoader(ClassDowngrader downgrader, ClassLoader parent) throws IOException { super(parent); - Set apiJar = downgrader.flags.findJavaApi(); + List apiJar = downgrader.flags.findJavaApi(); if (apiJar != null) { for (File file : apiJar) { delegates.add(new JarFileResourceProvider(new JarFile(file))); diff --git a/src/main/java/xyz/wagyourtail/jvmdg/cli/Flags.java b/src/main/java/xyz/wagyourtail/jvmdg/cli/Flags.java index b5d271f4..b2d4fac2 100644 --- a/src/main/java/xyz/wagyourtail/jvmdg/cli/Flags.java +++ b/src/main/java/xyz/wagyourtail/jvmdg/cli/Flags.java @@ -19,6 +19,7 @@ import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.security.MessageDigest; +import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -162,9 +163,9 @@ public Logger.Level getLogLevel() { /** * internal method to resolve the java api jar */ - private static Set foundApi = null; + private static List foundApi = null; - public Set findJavaApi() { + public List findJavaApi() { try { if (api != null) { return api; @@ -176,7 +177,7 @@ public Set findJavaApi() { synchronized (Flags.class) { Constants.DIR.mkdirs(); Path tmp = Constants.DIR.toPath().resolve("jvmdg-api- " + jvmdgVersion + " .jar"); - Set prop = getJavaApiFromSystemProperty(); + List prop = getJavaApiFromSystemProperty(); if (prop != null) { foundApi = prop; return prop; @@ -184,13 +185,13 @@ public Set findJavaApi() { URL url = getJavaApiFromShade(); if (Files.exists(tmp)) { if (url == null) { - foundApi = Collections.singleton(tmp.toFile()); + foundApi = Collections.singletonList(tmp.toFile()); return foundApi; } else { try (InputStream in = url.openStream()) { try (InputStream in2 = Files.newInputStream(tmp)) { if (hash(in).equals(hash(in2))) { - foundApi = Collections.singleton(tmp.toFile()); + foundApi = Collections.singletonList(tmp.toFile()); return foundApi; } } @@ -204,7 +205,7 @@ public Set findJavaApi() { if (url != null) { try (InputStream in = url.openStream()) { Files.copy(in, tmp, StandardCopyOption.REPLACE_EXISTING); - foundApi = Collections.singleton(tmp.toFile()); + foundApi = Collections.singletonList(tmp.toFile()); return foundApi; } } @@ -276,12 +277,12 @@ private URL getJavaApiFromShade() throws IOException { return ClassDowngrader.class.getResource("/META-INF/lib/java-api.jar"); } - private Set getJavaApiFromSystemProperty() throws IOException { + private List getJavaApiFromSystemProperty() throws IOException { String api = System.getProperty(Constants.JAVA_API); if (api == null) { return null; } - Set files = new HashSet<>(); + List files = new ArrayList<>(); for (String s : api.split(File.pathSeparator)) { files.add(new File(s)); }