Skip to content

Commit

Permalink
Merge pull request #6460 from ctabin/fix-multirelease-jar-lookup
Browse files Browse the repository at this point in the history
FISH-7959: Fixes MultiRelease JAR lookup for specific version classes
  • Loading branch information
breakponchito authored Nov 1, 2023
2 parents 3d835af + cc1f872 commit 544a5eb
Showing 1 changed file with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2016-2020] [Payara Foundation and/or its affiliates]
// Portions Copyright [2016-2023] [Payara Foundation and/or its affiliates]

package com.sun.enterprise.loader;

Expand Down Expand Up @@ -614,22 +614,36 @@ private byte[] loadClassData0(final URLEntry res, final String entryName) {
try {
if (res.isJar) { // It is a jarfile..
JarFile zip = res.zip;
JarEntry entry = zip.getJarEntry(entryName);
JarFile jar = new JarFile(res.file, false, JarFile.OPEN_READ,
Runtime.Version.parse(System.getProperty("java.version")));
JarEntry entry = jar.getJarEntry(entryName);
if (entry != null) {
InputStream classStream = zip.getInputStream(entry);
byte[] classData = getClassData(classStream);
byte[] classData = getClassData(zip.getInputStream(entry));
res.setProtectionDomain(ASURLClassLoader.this, entry.getCertificates());
return classData;
}
} else { // Its a directory....
File classFile = new File (res.file, entryName.replace('/', File.separatorChar));
String entryPath = entryName.replace('/', File.separatorChar);
File classFile = new File (res.file, entryPath);
if (classFile.exists()) {
try (InputStream classStream = new FileInputStream(classFile)) {
byte[] classData = getClassData(classStream);
res.setProtectionDomain(ASURLClassLoader.this, null);
return classData;
}
}

File multiVersionDir = new File(res.file, "META-INF/versions/");
if (multiVersionDir.exists()) {
File multiVersionClassFile = new File(multiVersionDir, entryPath);
if (multiVersionClassFile.exists()) {
try (InputStream classStream = new FileInputStream(multiVersionClassFile)) {
byte[] classData = getClassData(classStream);
res.setProtectionDomain(ASURLClassLoader.this, null);
return classData;
}
}
}
}
} catch (IOException ioe) {
_logger.log(Level.INFO, CULoggerInfo.exceptionInASURLClassLoader, ioe);
Expand Down

0 comments on commit 544a5eb

Please sign in to comment.