JNI Native - System (java.lang.System)

mr rupplin mearvk at outlook.com
Fri Aug 3 02:53:13 UTC 2018


Hello.

Trying to run a simple JNI call and I keep getting the following:

SecureJVM : GNU Public License 2.0
Program Name >> java
Launcher Name >> openjdk
Windows >> off
Version >> 9-internal+0-adhoc.mearvk.jdk9

A new instance of Hope is born.
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.<init>(Hope.java:19)


The source looks like:

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


The C source looks like:


JNIEXPORT void JNICALL
Java_java_lang_System_setMemoryAllocationListener0(JNIEnv *env, jclass cla, jobject listener)
{
printf("setMemoryAllocationListener called:\n");

    jfieldID fid =
        (*env)->GetStaticFieldID(env,cla,"memoryAllocationListener","Ljava/lang/memory/MemoryAllocationListener;");

    printf("\t >> Lookup of MemoryAllocationListener completed");

    if (fid == 0)
        return;


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

    printf("\t >> SetStaticObjectField completed");
}


I am unable to discern the problem.  The make runs clean as does a non-native call that instantiates a MemoryAllocationListener object.

Can you guys spot the issue?

Thanks,

Max R.

Sr. Software Tech



More information about the build-dev mailing list