-
Type:
Bug
-
Resolution: Fixed
-
Priority:
P4
-
Affects Version/s: 1.1.4, 1.1.5, 1.1.6
-
Component/s: vm-legacy
-
1.1.6
-
x86
-
windows_95, windows_nt
-
Not verified
Name: chT40241 Date: 01/29/98
When the symcjit is used, native methods defined via the RegisterNatives JNI call are not called, and instead an UnsatisfiedLinkError is thrown. The code works without the JIT.
Here is a simple test case. The Java code (JITterBug.java):
public class JITterBug {
static native void direct();
static native void indirect();
public static void main(String args[]) {
direct();
try {
indirect();
} catch(Throwable t) {
t.printStackTrace();
}
}
static {
System.loadLibrary("JITterBugC");
}
}
and the C code (JITterBugC.c):
#include "jni.h"
#include <stdio.h>
__declspec(dllexport) void __stdcall Java_JITterBug_direct(void *, jobject);
void __stdcall IndirectMethod(void *, jobject);
__declspec(dllexport) void __stdcall Java_JITterBug_direct(void *Jenv, jobject This)
{
int rc;
JNIEnv *env = (JNIEnv *) Jenv;
JNINativeMethod methods[1] = {
{ "indirect", "()V", &IndirectMethod }};
fprintf(stderr, "Entered direct() method.\n");
rc = (*env)->RegisterNatives(env, This, methods, 1);
if (rc != 0) fprintf(stderr, "RegisterNatives failed!\n");
}
void __stdcall IndirectMethod(void *env, jobject This)
{
fprintf(stderr, "Entered indirect() method.\n");
}
Without the JIT, stderr indicates that IndirectMethod was called, while with the JIT it shows an UnsatisfiedLinkError being thrown.
chuck.hickey@Eng 1998-01-30
I deleted their suggested fix, which had an error, and placed the most
recent fix in "Suggested Fix"
- duplicates
-
JDK-4098955 RegisterNative() does not work with the JIT
-
- Closed
-
-
JDK-4104204 The JIT 3.0 does not support the JNI RegisterNatives method
-
- Closed
-