Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnsatisfiedLinkError on using JNA direct calls with YourKit Java Profiler instrumentation #236

Closed
trofimander opened this issue May 28, 2013 · 4 comments

Comments

@trofimander
Copy link

Running JNA code with YourKit Java Profiler agent I get the following error

Error looking up function '$$YJP$$open': /usr/lib/java/jdk6/bin/java: undefined symbol: $$YJP$$open 
java.lang.UnsatisfiedLinkError: Error looking up function '$$YJP$$open': /usr/lib/java/jdk6/bin/java: undefined symbol: $$YJP$$open
    at com.sun.jna.Function.<init>(Function.java:179)
    at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:350)
    at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:330)
    at com.sun.jna.Native.register(Native.java:1369)
    at com.sun.jna.Native.register(Native.java:1033)
    at jtermios.linux.JTermiosImpl$Linux_C_lib_DirectMapping.<clinit>(JTermiosImpl.java:168)
    at jtermios.linux.JTermiosImpl.<clinit>(JTermiosImpl.java:67)
    at jtermios.JTermios.<clinit>(JTermios.java:288)
    at jpty.JPty.execInPTY(JPty.java:273)
    at jpty.JPty.execInPTY(JPty.java:204)
    at com.jediterm.pty.PtyProcess.<init>(Unknown Source)
    at com.jediterm.pty.PtyProcess.<init>(Unknown Source)

Read response from YourKit guys for details: http://forums.yourkit.com/viewtopic.php?f=3&t=3299#p10809
Also this suggestion can be usefull: https://groups.google.com/forum/?fromgroups#!topic/jna-users/z-n85N0emSw

@twall
Copy link
Contributor

twall commented May 29, 2013

Supply a FunctionMapper in your library options when you call Native.register(NativeLibrary) which strips the $$YJP$$ prefix from the method name. Contrary to the yourkit post, it is the profiler's fault that the native mapping is broken. Their technique of "automatically" registering the new native with the JVM breaks when the JNI code doesn't do canonical mapping between Java native method declarations and the native exported symbols (which is the case with JNA and even some parts of the JVM itself).

Even with a type mapper, I'm not certain it'd work; I don't recall offhand if the direct mapping even makes use of a supplied FunctionMapper if one exists in the options.

On May 28, 2013, at 12:47 PM, traff wrote:

Running JNA code with YourKit Java Profiler agent I get the following error

Error looking up function '$$YJP$$open': /usr/lib/java/jdk6/bin/java: undefined symbol: $$YJP$$open
java.lang.UnsatisfiedLinkError: Error looking up function '$$YJP$$open': /usr/lib/java/jdk6/bin/java: undefined symbol: $$YJP$$open
at com.sun.jna.Function.(Function.java:179)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:350)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:330)
at com.sun.jna.Native.register(Native.java:1369)
at com.sun.jna.Native.register(Native.java:1033)
at jtermios.linux.JTermiosImpl$Linux_C_lib_DirectMapping.(JTermiosImpl.java:168)
at jtermios.linux.JTermiosImpl.(JTermiosImpl.java:67)
at jtermios.JTermios.(JTermios.java:288)
at jpty.JPty.execInPTY(JPty.java:273)
at jpty.JPty.execInPTY(JPty.java:204)
at com.jediterm.pty.PtyProcess.(Unknown Source)
at com.jediterm.pty.PtyProcess.(Unknown Source)

Read response from YourKit guys for details: http://forums.yourkit.com/viewtopic.php?f=3&t=3299#p10809


Reply to this email directly or view it on GitHub.

@twall
Copy link
Contributor

twall commented May 29, 2013

I've verified that direct mapping does take into account any supplied FunctionMapper. It's up to you to add the function mapper if you know you're going to be using such a profiler.

@twall twall closed this as completed May 29, 2013
@trofimander
Copy link
Author

Thanks a lot for the quick and detailed answer! I'll try to supply FunctionMapper, althought it's not my library that uses JNA.

@twall
Copy link
Contributor

twall commented Jun 13, 2013

Addressed in 3704b23

mstyura pushed a commit to mstyura/jna that referenced this issue Sep 9, 2024
Motivation:

Now that we support cross-compiling to aarch64 we should also do so during PR builds and normal builds

Modifications:

Add workflow config for aarch64

Result:

Ensure we can always build for aarch64 as well
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants