diff --git a/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/ClassFileLocator.java b/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/ClassFileLocator.java index 56ba441d41..bae3214cff 100644 --- a/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/ClassFileLocator.java +++ b/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/ClassFileLocator.java @@ -1068,10 +1068,11 @@ class ForFolder implements ClassFileLocator { private final File folder; /** - * Indicates the existing multi-release jar folders that are available for the current JVM. + * Contains the existing multi-release jar folders that are available for the + * current JVM version in decreasing order. */ @HashCodeAndEqualsPlugin.ValueHandling(HashCodeAndEqualsPlugin.ValueHandling.Sort.IGNORE) - private final int[] multiRelease; + private final int[] version; /** * Creates a new class file locator for a folder structure of class files. @@ -1083,21 +1084,21 @@ public ForFolder(File folder) throws IOException { this.folder = folder; int current = ClassFileVersion.ofThisVm().getJavaVersion(); if (current < 9) { - multiRelease = new int[0]; + version = new int[0]; } else { File manifest = new File(folder, "META-INF" + File.separatorChar + "MANIFEST.MF"); - boolean mr; + boolean multiRelease; if (manifest.exists()) { InputStream inputStream = new FileInputStream(manifest); try { - mr = Boolean.parseBoolean(new Manifest(inputStream).getMainAttributes().getValue("Multi-Release")); + multiRelease = Boolean.parseBoolean(new Manifest(inputStream).getMainAttributes().getValue("Multi-Release")); } finally { inputStream.close(); } } else { - mr = false; + multiRelease = false; } - if (mr) { + if (multiRelease) { File[] file = new File(folder, "META-INF" + File.separatorChar + "versions").listFiles(); if (file != null) { SortedSet versions = new TreeSet(); @@ -1111,16 +1112,16 @@ public ForFolder(File folder) throws IOException { /* do nothing */ } } - multiRelease = new int[versions.size()]; + version = new int[versions.size()]; Iterator iterator = versions.iterator(); for (int index = 0; index < versions.size(); index++) { - multiRelease[versions.size() - index - 1] = iterator.next(); + version[versions.size() - index - 1] = iterator.next(); } } else { - multiRelease = new int[0]; + version = new int[0]; } } else { - multiRelease = new int[0]; + version = new int[0]; } } } @@ -1130,10 +1131,10 @@ public ForFolder(File folder) throws IOException { */ public Resolution locate(String name) throws IOException { String path = name.replace('.', File.separatorChar) + CLASS_FILE_EXTENSION; - for (int index = 0; index < multiRelease.length + 1; index++) { - File file = new File(folder, index == multiRelease.length ? path : "META-INF" + for (int index = 0; index < version.length + 1; index++) { + File file = new File(folder, index == version.length ? path : "META-INF" + File.separatorChar + "versions" - + File.separatorChar + multiRelease[index] + + File.separatorChar + version[index] + File.separatorChar + path); if (file.exists()) { InputStream inputStream = new FileInputStream(file);