Skip to content

Commit

Permalink
createPackage: processing manifest file
Browse files Browse the repository at this point in the history
  • Loading branch information
lprimak committed Nov 21, 2024
1 parent 4a79348 commit 8244abc
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -725,9 +725,14 @@ protected Class findClass(String name) throws ClassNotFoundException {
// set all spec and impl data for the package,
// so just use null. This is consistent will the
// JDK code that does the same.
definePackage(packageName, null, null, null,
null, null, null, null);
} catch(IllegalArgumentException iae) {
var manifest = classData.jarFile == null ? null : classData.jarFile.getManifest();
if (manifest == null) {
definePackage(packageName, null, null, null,
null, null, null, null);
} else {
definePackage(packageName, manifest, classData.pd.getCodeSource().getLocation());
}
} catch(IllegalArgumentException | IOException iae) {
// duplicate attempt to define same package.
// safe to ignore.
_logger.log(Level.FINE, "duplicate package " +
Expand Down Expand Up @@ -802,14 +807,14 @@ protected synchronized ClassData findClassData(String name) throws ClassNotFound
byte[] result = loadClassData0(u, entryName);
if (result != null) {
if (System.getSecurityManager() == null) {
return new ClassData(result, u.pd);
return new ClassData(result, u.pd, u.zip);
} else {
//recreate the pd to include the declared permissions
CodeSource cs = u.pd.getCodeSource();
PermissionCollection pc = this.getPermissions(cs);
ProtectionDomain pdWithPemissions =
new ProtectionDomain(u.pd.getCodeSource(), pc, u.pd.getClassLoader(), u.pd.getPrincipals());
return new ClassData(result, pdWithPemissions);
return new ClassData(result, pdWithPemissions, u.zip);
}
}
}
Expand Down Expand Up @@ -1321,10 +1326,12 @@ private static final class ClassData {

/** must be 'final' to ensure thread visibility */
private final ProtectionDomain pd;
private final JarFile jarFile;

ClassData(byte[] classBytes, ProtectionDomain pd) {
ClassData(byte[] classBytes, ProtectionDomain pd, JarFile jarFile) {
this.classBytes = classBytes;
this.pd = pd;
this.jarFile = jarFile;
}
private synchronized byte[] getClassBytes() {
return classBytes;
Expand Down

0 comments on commit 8244abc

Please sign in to comment.