mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
don't try to parse annotation tables more than once; use defining classloader when loading array classes during linking
This commit is contained in:
parent
805d1d13d8
commit
664cb3cd39
@ -33,6 +33,9 @@ public class SystemClassLoader extends ClassLoader {
|
||||
|
||||
private native boolean resourceExists(String name);
|
||||
|
||||
private static native Class resolveClass(ClassLoader loader, byte[] spec)
|
||||
throws ClassNotFoundException;
|
||||
|
||||
protected URL findResource(String name) {
|
||||
if (resourceExists(name)) {
|
||||
try {
|
||||
@ -45,11 +48,18 @@ public class SystemClassLoader extends ClassLoader {
|
||||
private static Class loadClass(ClassLoader loader,
|
||||
byte[] nameBytes, int offset, int length)
|
||||
{
|
||||
String name = new String(nameBytes, offset, length, false);
|
||||
byte[] spec = new byte[length + 1];
|
||||
System.arraycopy(nameBytes, offset, spec, 0, length);
|
||||
|
||||
try {
|
||||
return loader.loadClass(name);
|
||||
Class c = resolveClass(loader, spec);
|
||||
if (c == null) {
|
||||
throw new NoClassDefFoundError();
|
||||
}
|
||||
return c;
|
||||
} catch (ClassNotFoundException e) {
|
||||
NoClassDefFoundError error = new NoClassDefFoundError(name);
|
||||
NoClassDefFoundError error = new NoClassDefFoundError
|
||||
(new String(nameBytes, offset, length, false));
|
||||
error.initCause(e);
|
||||
throw error;
|
||||
}
|
||||
@ -158,7 +168,7 @@ public class SystemClassLoader extends ClassLoader {
|
||||
private static void parseAnnotationTable(ClassLoader loader,
|
||||
Addendum addendum)
|
||||
{
|
||||
if (addendum != null && addendum.annotationTable != null) {
|
||||
if (addendum != null && addendum.annotationTable instanceof byte[]) {
|
||||
try {
|
||||
addendum.annotationTable = parseAnnotationTable
|
||||
(loader, addendum.pool, new ByteArrayInputStream
|
||||
|
@ -231,6 +231,16 @@ Avian_avian_SystemClassLoader_findClass
|
||||
return search(t, name, resolveSystemClass, true);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT int64_t JNICALL
|
||||
Avian_avian_SystemClassLoader_resolveClass
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
object loader = reinterpret_cast<object>(arguments[0]);
|
||||
object spec = reinterpret_cast<object>(arguments[1]);
|
||||
|
||||
return reinterpret_cast<int64_t>(resolveClass(t, loader, spec));
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT int64_t JNICALL
|
||||
Avian_avian_SystemClassLoader_resourceExists
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
|
Loading…
Reference in New Issue
Block a user