diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index b06211777f..4842ab8581 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -439,17 +439,20 @@ class MyClasspath : public Classpath { unsigned libraryPathOffset = sb.offset; sb.append(javaHome); #ifdef PLATFORM_WINDOWS - sb.append("/bin"); +# define LIB_DIR "/bin" #elif defined __APPLE__ - sb.append("/lib"); +# define LIB_DIR "/lib" #elif defined ARCH_x86_64 - sb.append("/lib/amd64"); +# define LIB_DIR "/lib/amd64" #elif defined ARCH_arm - sb.append("/lib/arm"); +# define LIB_DIR "/lib/arm" #else // todo: handle other architectures - sb.append("/lib/i386"); +# define LIB_DIR "/lib/i386" #endif + sb.append(LIB_DIR ":"); + sb.append(javaHome); + sb.append(LIB_DIR "/xawt"); sb.append('\0'); unsigned tzMappingsOffset = sb.offset; @@ -635,6 +638,7 @@ class MyClasspath : public Classpath { #else // not AVIAN_OPENJDK_SRC expect(t, loadLibrary(t, libraryPath, "verify", true, true)); expect(t, loadLibrary(t, libraryPath, "java", true, true)); + loadLibrary(t, libraryPath, "mawt", true, true); #endif // not AVIAN_OPENJDK_SRC { object assertionLock = resolveField diff --git a/src/jnienv.cpp b/src/jnienv.cpp index 9d73a233df..f8a0ff3987 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -396,6 +396,14 @@ Throw(Thread* t, jthrowable throwable) return 0; } +jobject JNICALL +NewLocalRef(Thread* t, jobject o) +{ + ENTER(t, Thread::ActiveState); + + return makeLocalReference(t, *o); +} + void JNICALL DeleteLocalRef(Thread* t, jobject r) { @@ -3513,6 +3521,7 @@ populateJNITables(JavaVMVTable* vmTable, JNIEnvVTable* envTable) envTable->NewDirectByteBuffer = local::NewDirectByteBuffer; envTable->GetDirectBufferAddress = local::GetDirectBufferAddress; envTable->GetDirectBufferCapacity = local::GetDirectBufferCapacity; + envTable->NewLocalRef = local::NewLocalRef; envTable->DeleteLocalRef = local::DeleteLocalRef; envTable->GetObjectClass = local::GetObjectClass; envTable->GetSuperclass = local::GetSuperclass; diff --git a/test/JNI.java b/test/JNI.java index cbb17cc925..955bfc9052 100644 --- a/test/JNI.java +++ b/test/JNI.java @@ -57,6 +57,8 @@ public class JNI { private static native int getStaticIntField(Class c, long id); + private static native Object testLocalRef(Object o); + public static int method242() { return 242; } public static final int field950 = 950; @@ -106,5 +108,9 @@ public class JNI { (JNI.class, fromReflectedField (JNI.class.getField("field950")), true) .getName().equals("field950")); + + { Object o = new Object(); + expect(testLocalRef(o) == o); + } } } diff --git a/test/jni.cpp b/test/jni.cpp index eacf9e31bc..8b8d6dc8c9 100644 --- a/test/jni.cpp +++ b/test/jni.cpp @@ -101,6 +101,12 @@ Java_JNI_getStaticIntField(JNIEnv* e, jclass, jclass c, jlong id) return e->GetStaticIntField(c, reinterpret_cast(id)); } +extern "C" JNIEXPORT jobject JNICALL +Java_JNI_testLocalRef(JNIEnv* e, jclass, jobject o) +{ + return e->NewLocalRef(o); +} + extern "C" JNIEXPORT jobject JNICALL Java_Buffers_allocateNative(JNIEnv* e, jclass, jint capacity) {