JNI Native - System (java.lang.System)

mr rupplin mearvk at outlook.com
Fri Aug 3 12:49:59 UTC 2018


How would I subscribe to core-libs-dev?

Ok.
________________________________
From: David Holmes <david.holmes at oracle.com>
Sent: Thursday, August 2, 2018 11:55 PM
To: mr rupplin; build-dev at openjdk.java.net
Subject: Re: JNI Native - System (java.lang.System)

Hi Max,

The build-dev list is for discussing the OpenJDK build system. You
appear to running into issues customizing parts of OpenJDK for your own
use. It would be more appropriate to ask on core-libs-dev how to extend
the System class - though examination of the existing native methods in
System.java and System.c should show how it is done. There is not enough
information in your post to see where you may have a made an error or
omission.

Cheers,
David

On 3/08/2018 12:53 PM, mr rupplin wrote:
> 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