From 262fa8a4b5f0e5859a4f059e0bb16a94e7bbe781 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 22 Jan 2007 23:04:16 +0000 Subject: re PR java/29812 (env->klass value is not updated during the native calls) PR java/29812: * testsuite/libjava.jni/pr29812.java: New file. * testsuite/libjava.jni/pr29812_injar.java: New file. * testsuite/libjava.jni/pr29812_injar.jar: New file. * testsuite/libjava.jni/pr29812.out: New file. * testsuite/libjava.jni/pr29812_injar.c: New file. * testsuite/libjava.jni/pr29812_injar.h: New file. * testsuite/libjava.jni/pr29812.jar: New file. * testsuite/libjava.jni/pr29812.c: New file. * testsuite/libjava.jni/pr29812.h: New file. * testsuite/libjava.jni/jni.exp (gcj_jni_get_cxxflags_invocation): New proc. (gcj_jni_invocation_test_one): Use it. (gcj_jni_pr29812): New proc. (gcj_jni_run): Use it. * java/lang/natRuntime.cc (_load): Push a new system frame before calling JNI_OnLoad. * include/jvm.h (_Jv_JNI_PopSystemFrame): Declare. (_Jv_GetJNIEnvNewFrameWithLoader): Likewise. * jni.cc (struct _Jv_JNI_LocalFrame) : Now unsigned char. : Now bool. : New field. (_Jv_JNI_EnsureLocalCapacity): Updated. (_Jv_JNI_NewLocalRef): Likewise. (_Jv_JNI_NewLocalRef): Likewise. (_Jv_JNI_PopLocalFrame): Likewise. (_Jv_JNI_FindClass): Likewise. (_Jv_GetJNIEnvNewFrame): Likewise. (_Jv_JNI_AttachCurrentThread): Likewise. (_Jv_GetJNIEnvNewFrameWithLoader): New function. (_Jv_GetJNIEnvNewFrame): Use it. * include/jni_md.h (_CLASSPATH_JNIENV_CONTENTS): Removed 'klass'. From-SVN: r121064 --- libjava/java/lang/natRuntime.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libjava/java') diff --git a/libjava/java/lang/natRuntime.cc b/libjava/java/lang/natRuntime.cc index ecaf7d3..64c8fbb 100644 --- a/libjava/java/lang/natRuntime.cc +++ b/libjava/java/lang/natRuntime.cc @@ -207,7 +207,14 @@ java::lang::Runtime::_load (jstring path, jboolean do_search) // FIXME: what? return; } + + // Push a new frame so that JNI_OnLoad will get the right class + // loader if it calls FindClass. + ::java::lang::ClassLoader *loader + = _Jv_StackTrace::GetFirstNonSystemClassLoader(); + JNIEnv *env = _Jv_GetJNIEnvNewFrameWithLoader (loader); jint vers = ((jint (JNICALL *) (JavaVM *, void *)) onload) (vm, NULL); + _Jv_JNI_PopSystemFrame (env); if (vers != JNI_VERSION_1_1 && vers != JNI_VERSION_1_2 && vers != JNI_VERSION_1_4) { -- cgit v1.1