Skip to content

Commit c4d04bb

Browse files
committed
Fix class loader visibility issue in JAR loading.
1 parent 05296fe commit c4d04bb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/vm/jvm/runtime/org/perl6/nqp/runtime/BootJavaInterop.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,10 @@ protected void finishClass(ClassContext cc) {
222222
//} catch (java.io.IOException e) {
223223
// e.printStackTrace();
224224
//}
225-
cc.constructed = new ByteClassLoader(bits).findClass(cc.className.replace('/','.'));
225+
cc.constructed = (cc.target == null
226+
? new ByteClassLoader(bits)
227+
: new ByteClassLoader(bits, cc.target.getClassLoader())
228+
).findClass(cc.className.replace('/','.'));
226229
try {
227230
cc.constructed.getField("constants").set(null, cc.constants.toArray(new Object[0]));
228231
} catch (ReflectiveOperationException roe) {

src/vm/jvm/runtime/org/perl6/nqp/runtime/ByteClassLoader.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ public ByteClassLoader(byte[] bytes) {
77
this.bytes = bytes;
88
}
99

10+
public ByteClassLoader(byte[] bytes, ClassLoader parent) {
11+
super(parent);
12+
this.bytes = bytes;
13+
}
14+
1015
public Class<?> findClass(String name) {
1116
return defineClass(name, this.bytes, 0, this.bytes.length);
1217
}

0 commit comments

Comments
 (0)