System.java Development Question (original) (raw)

mr rupplin mearvk at outlook.com
Fri Aug 3 13:22:07 UTC 2018


Hello.

I'm not sure if there's a minor typo but I cannot find the error in it. Can you guys look? In System.c we have:

JNIEXPORT void JNICALL Java_java_lang_System_setMemoryAllocationListener0(JNIEnv *env, jclass cla, jobject listener) { jfieldID fid = (*env)->GetStaticFieldID(env,cla,"memoryAllocationListener","Ljava/lang/memory/MemoryAllocationListener;");

if (fid == 0)
    return;

(*env)->SetStaticObjectField(env,cla,fid,listener);

}


And in System.java we have:

public static final MemoryAllocationListener memoryAllocationListener = null;

...

public static void setMemoryAllocationListener(MemoryAllocationListener memoryAllocationListener) {
    checkMalloc();
    setMemoryAllocationListener0(memoryAllocationListener);
}

...

//SecureJVM private
private static native void setMemoryAllocationListener0(MemoryAllocationListener memoryAllocationListener);

We get the following after running a trivial Java program:

Exception in thread "main" java.lang.UnsatisfiedLinkError: java.lang.System.setMemoryAllocationListener0(Ljava/lang/memory/MemoryAllocationListener;)V at java.base/java.lang.System.setMemoryAllocationListener0(Native Method) at java.base/java.lang.System.setMemoryAllocationListener(System.java:261) at Hope.(Hope.java:19) at Hope.main(Hope.java:11)


Can we skip right to it? What is the issue here?

Thanks.

Max R.



More information about the core-libs-dev mailing list