Adding native method in custom jdk package

David Holmes david.holmes at oracle.com
Thu Mar 23 00:22:05 UTC 2017


On 23/03/2017 4:07 AM, Christian Hagedorn wrote:
> Thanks for your quick help. That got me on the right track, it does work
> now. I added my path to the LIBJAVA_SRC_DIRS in the
> “jdk/make/lib/CoreLibraries.gmk” file.

Yes that was the missing part. But this is a build question, or at best 
a JDK question, not a hotspot question.

Regards,
David

>
>
> Best regards,
>
> Christian
>
>
>
> Von: Bob Vandette [mailto:bob.vandette at oracle.com]
> Gesendet: Mittwoch, 22. März 2017 18:23
> An: Christian Hagedorn
> Cc: hotspot-dev at openjdk.java.net
> Betreff: Re: Adding native method in custom jdk package
>
>
>
> Checkout this blog that provides a simple example of how to create and call
> a native
>
> function in a shared library.
>
>
>
> https://blogs.oracle.com/moonocean/entry/a_simple_example_of_jni
>
>
>
> Let me know if you have any questions,
>
> Bob.
>
>
>
> On Mar 22, 2017, at 12:32 PM, Christian Hagedorn <ch-hagedorn at hispeed.ch>
> wrote:
>
>
>
> Hi,
>
>
>
> I have created a class Test.java in an own package test.lang inside the jdk
> ("jdk/src/share/classes/test/lang/Test.java"). Now I wanted to add a native
> method.
>
> I found out that my header was created inside"
> build/linux./jdk/gensrc_headers/test_lang_Test.h".
>
> So I have tried to just create a new file inside a new folder
> "jdk/src/share/native/test/lang/Test.c" including "test_lang_Test.h".
>
> From there I do my JNICALL to the VM like it is done for example in
> "jdk/src/share/native/java/lang/System.c".
>
> However this still results in a UnsatisfiedLinkError. I am sure I have to do
> some more steps to link and add it to the build properly. What am I missing?
>
>
>
> Best regards,
>
> Christian
>
>
>
>
>
>


More information about the hotspot-dev mailing list