Skip to content

Commit

Permalink
Add class file versions on relevant factories.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Sep 24, 2024
1 parent aab9010 commit f96b589
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -968,13 +968,14 @@ public static ClassFileLocator ofClassPath() throws IOException {
* @throws IOException If an I/O exception occurs.
*/
public static ClassFileLocator ofClassPath(String classPath) throws IOException {
ClassFileVersion classFileVersion = ClassFileVersion.ofThisVm();
List<ClassFileLocator> classFileLocators = new ArrayList<ClassFileLocator>();
for (String element : Pattern.compile(File.pathSeparator, Pattern.LITERAL).split(classPath)) {
File file = new File(element);
if (file.isDirectory()) {
classFileLocators.add(new ForFolder(file));
classFileLocators.add(ForFolder.of(file, classFileVersion));
} else if (file.isFile()) {
classFileLocators.add(of(file));
classFileLocators.add(of(file, classFileVersion));
}
}
return new Compound(classFileLocators);
Expand Down Expand Up @@ -1095,12 +1096,13 @@ public static ClassFileLocator ofBootPath(File bootPath) throws IOException {
if (module == null) {
return NoOp.INSTANCE;
}
ClassFileVersion classFileVersion = ClassFileVersion.ofThisVm();
List<ClassFileLocator> classFileLocators = new ArrayList<ClassFileLocator>(module.length);
for (File aModule : module) {
if (aModule.isFile()) {
classFileLocators.add(of(aModule));
} else if (aModule.isDirectory()) { // Relevant for locally built OpenJDK.
classFileLocators.add(new ForFolder(aModule));
classFileLocators.add(ForFolder.of(aModule, classFileVersion));
}
}
return new Compound(classFileLocators);
Expand Down Expand Up @@ -1155,6 +1157,7 @@ public static ClassFileLocator ofModulePath(String modulePath) throws IOExceptio
* @throws IOException If an I/O exception occurs.
*/
public static ClassFileLocator ofModulePath(String modulePath, String baseFolder) throws IOException {
ClassFileVersion classFileVersion = ClassFileVersion.ofThisVm();
List<ClassFileLocator> classFileLocators = new ArrayList<ClassFileLocator>();
for (String element : Pattern.compile(System.getProperty("path.separator"), Pattern.LITERAL).split(modulePath)) {
File file = new File(baseFolder, element);
Expand All @@ -1163,11 +1166,11 @@ public static ClassFileLocator ofModulePath(String modulePath, String baseFolder
if (module != null) {
for (File aModule : module) {
if (aModule.isDirectory()) {
classFileLocators.add(new ForFolder(aModule));
classFileLocators.add(ForFolder.of(aModule, classFileVersion));
} else if (aModule.isFile()) {
classFileLocators.add(aModule.getName().endsWith(JMOD_FILE_EXTENSION)
? of(aModule)
: ForJarFile.of(aModule));
: ForJarFile.of(aModule, classFileVersion));
}
}
}
Expand Down

0 comments on commit f96b589

Please sign in to comment.