mirror of
https://github.com/corda/corda.git
synced 2025-01-23 04:48:09 +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 native boolean resourceExists(String name);
|
||||||
|
|
||||||
|
private static native Class resolveClass(ClassLoader loader, byte[] spec)
|
||||||
|
throws ClassNotFoundException;
|
||||||
|
|
||||||
protected URL findResource(String name) {
|
protected URL findResource(String name) {
|
||||||
if (resourceExists(name)) {
|
if (resourceExists(name)) {
|
||||||
try {
|
try {
|
||||||
@ -45,11 +48,18 @@ public class SystemClassLoader extends ClassLoader {
|
|||||||
private static Class loadClass(ClassLoader loader,
|
private static Class loadClass(ClassLoader loader,
|
||||||
byte[] nameBytes, int offset, int length)
|
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 {
|
try {
|
||||||
return loader.loadClass(name);
|
Class c = resolveClass(loader, spec);
|
||||||
|
if (c == null) {
|
||||||
|
throw new NoClassDefFoundError();
|
||||||
|
}
|
||||||
|
return c;
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
NoClassDefFoundError error = new NoClassDefFoundError(name);
|
NoClassDefFoundError error = new NoClassDefFoundError
|
||||||
|
(new String(nameBytes, offset, length, false));
|
||||||
error.initCause(e);
|
error.initCause(e);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@ -158,7 +168,7 @@ public class SystemClassLoader extends ClassLoader {
|
|||||||
private static void parseAnnotationTable(ClassLoader loader,
|
private static void parseAnnotationTable(ClassLoader loader,
|
||||||
Addendum addendum)
|
Addendum addendum)
|
||||||
{
|
{
|
||||||
if (addendum != null && addendum.annotationTable != null) {
|
if (addendum != null && addendum.annotationTable instanceof byte[]) {
|
||||||
try {
|
try {
|
||||||
addendum.annotationTable = parseAnnotationTable
|
addendum.annotationTable = parseAnnotationTable
|
||||||
(loader, addendum.pool, new ByteArrayInputStream
|
(loader, addendum.pool, new ByteArrayInputStream
|
||||||
|
@ -231,6 +231,16 @@ Avian_avian_SystemClassLoader_findClass
|
|||||||
return search(t, name, resolveSystemClass, true);
|
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
|
extern "C" JNIEXPORT int64_t JNICALL
|
||||||
Avian_avian_SystemClassLoader_resourceExists
|
Avian_avian_SystemClassLoader_resourceExists
|
||||||
(Thread* t, object, uintptr_t* arguments)
|
(Thread* t, object, uintptr_t* arguments)
|
||||||
|
Loading…
Reference in New Issue
Block a user