Skip to content

Commit d7f953d

Browse files
committed
Extract P6Opaque.ByteClassLoader to its own class.
This is in preparation for CStruct support on JVM, which needs some of the same class generation infrastructure as P6Opaque.
1 parent b22f11f commit d7f953d

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.perl6.nqp.sixmodel;
2+
3+
public class ByteClassLoader extends ClassLoader {
4+
private byte[] bytes;
5+
6+
public ByteClassLoader(byte[] bytes) {
7+
this.bytes = bytes;
8+
}
9+
10+
public Class<?> findClass(String name) {
11+
return defineClass(name, this.bytes, 0, this.bytes.length);
12+
}
13+
}

src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/P6Opaque.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.objectweb.asm.Type;
1515
import org.perl6.nqp.runtime.ExceptionHandling;
1616
import org.perl6.nqp.runtime.ThreadContext;
17+
import org.perl6.nqp.sixmodel.ByteClassLoader;
1718
import org.perl6.nqp.sixmodel.REPR;
1819
import org.perl6.nqp.sixmodel.STable;
1920
import org.perl6.nqp.sixmodel.SerializationReader;
@@ -719,18 +720,6 @@ public long hint_for(ThreadContext tc, STable st, SixModelObject classHandle, St
719720
return STable.NO_HINT;
720721
}
721722

722-
private class ByteClassLoader extends ClassLoader {
723-
private byte[] bytes;
724-
725-
public ByteClassLoader(byte[] bytes) {
726-
this.bytes = bytes;
727-
}
728-
729-
public Class<?> findClass(String name) {
730-
return defineClass(name, this.bytes, 0, this.bytes.length);
731-
}
732-
}
733-
734723
@SuppressWarnings("unchecked")
735724
public void deserialize_repr_data(ThreadContext tc, STable st, SerializationReader reader) {
736725
// Instantiate REPR data.

0 commit comments

Comments
 (0)