diff --git a/openjdk.ld b/openjdk.ld index ac767806e5..3c17a160b2 100644 --- a/openjdk.ld +++ b/openjdk.ld @@ -88,6 +88,7 @@ SUNWprivate_1.1 { JVM_EnableCompiler; JVM_Exit; JVM_FillInStackTrace; + JVM_FindClassFromCaller; JVM_FindClassFromClass; JVM_FindClassFromClassLoader; JVM_FindClassFromBootLoader; diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index 82f24173a1..6247eda6ca 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -4237,6 +4237,49 @@ extern "C" AVIAN_EXPORT void JNICALL run(t, jvmResolveClass, arguments); } +uint64_t jvmFindClassFromCaller(Thread* t, uintptr_t* arguments) +{ + const char* name = reinterpret_cast(arguments[0]); + jboolean init = arguments[1]; + jobject loader = reinterpret_cast(arguments[2]); + // jclass caller = reinterpret_cast(arguments[3]); + + /* XXX The caller's protection domain should be used during + the resolveClass but there is no specification or + unit-test in OpenJDK documenting the desired effect */ + + GcClass* c = resolveClass( + t, + loader ? cast(t, *loader) : roots(t)->bootLoader(), + name, + true, + static_cast(GcClassNotFoundException::Type)); + + if (init) { + PROTECT(t, c); + + initClass(t, c); + } + + return reinterpret_cast(makeLocalReference(t, getJClass(t, c))); +} + +extern "C" AVIAN_EXPORT jclass JNICALL + EXPORT(JVM_FindClassFromCaller)(Thread* t, + const char* name, + jboolean init, + jobject loader, + jclass caller) +{ + uintptr_t arguments[] = {reinterpret_cast(name), + init, + reinterpret_cast(loader), + reinterpret_cast(caller)}; + + return reinterpret_cast( + run(t, jvmFindClassFromCaller, arguments)); +} + uint64_t jvmFindClassFromClassLoader(Thread* t, uintptr_t* arguments) { const char* name = reinterpret_cast(arguments[0]);