Warnings reported with -Xcheck:jni when using Memory class
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- java
- Domain
- operating-systems
Research direction
Reproduce the report with the supplied Java snippet, OpenJDK 11.0.8, JNA 5.6.0, and -Xcheck:jni. Start by tracing Native.loadNativeDispatchLibraryFromClasspath and Memory.malloc in Native.java and Memory.java; done means determining whether the reported JNI warnings can be eliminated and covering the result with a regression test.
Written by the indexing model from the issue text.
Description
To reproduce, run the following snippet with -Xcheck:jni VM argument (I'm running with OpenJDK 11.0.8):
import com.sun.jna.Memory;
public class Test {
public static void main(String[] args) {
Memory m = new Memory(1024L);
System.out.println(m);
}
}
Observe output:
Warning: SIGINT handler expected:libjvm.so+0xc14f00 found:0x0000000000000001
Running in non-interactive shell, SIGINT handler is replaced by shell
Signal Handlers:
SIGSEGV: [libjvm.so+0xc14d00], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGBUS: [libjvm.so+0xc14d00], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGFPE: [libjvm.so+0xc14d00], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGPIPE: [libjvm.so+0xc14d00], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGXFSZ: [libjvm.so+0xc14d00], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGILL: [libjvm.so+0xc14d00], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGUSR2: [libjvm.so+0xc14b80], sa_mask[0]=00100000000000000000000000000000, sa_flags=SA_RESTART|SA_SIGINFO
SIGHUP: [libjvm.so+0xc14f00], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGINT: SIG_IGN, sa_mask[0]=00000000000000000000000000000000, sa_flags=none
SIGTERM: [libjvm.so+0xc14f00], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGQUIT: [libjvm.so+0xc14f00], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
WARNING: JNI local refs: 33, exceeds capacity: 32
at java.lang.ClassLoader$NativeLibrary.load0([email protected]/Native Method)
at java.lang.ClassLoader$NativeLibrary.load([email protected]/ClassLoader.java:2442)
at java.lang.ClassLoader$NativeLibrary.loadLibrary([email protected]/ClassLoader.java:2498)
- locked <0x00000000ff401e20> (a java.util.HashSet)
at java.lang.ClassLoader.loadLibrary0([email protected]/ClassLoader.java:2694)
at java.lang.ClassLoader.loadLibrary([email protected]/ClassLoader.java:2627)
at java.lang.Runtime.load0([email protected]/Runtime.java:768)
at java.lang.System.load([email protected]/System.java:1837)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1018)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:988)
at com.sun.jna.Native.<clinit>(Native.java:195)
at com.sun.jna.Memory.malloc(Memory.java:722)
at com.sun.jna.Memory.<init>(Memory.java:114)
at test.Test.main(Test.java:9)
WARNING in native method: JNI call made without checking exceptions when required to from CallStaticObjectMethod
at java.lang.ClassLoader$NativeLibrary.load0([email protected]/Native Method)
at java.lang.ClassLoader$NativeLibrary.load([email protected]/ClassLoader.java:2442)
at java.lang.ClassLoader$NativeLibrary.loadLibrary([email protected]/ClassLoader.java:2498)
- locked <0x00000000ff401e20> (a java.util.HashSet)
at java.lang.ClassLoader.loadLibrary0([email protected]/ClassLoader.java:2694)
at java.lang.ClassLoader.loadLibrary([email protected]/ClassLoader.java:2627)
at java.lang.Runtime.load0([email protected]/Runtime.java:768)
at java.lang.System.load([email protected]/System.java:1837)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1018)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:988)
at com.sun.jna.Native.<clinit>(Native.java:195)
at com.sun.jna.Memory.malloc(Memory.java:722)
at com.sun.jna.Memory.<init>(Memory.java:114)
at test.Test.main(Test.java:9)
allocated@0x7ffff0510730 (1024 bytes)
Seen with jna-5.6.0.jar (latest I could find from maven: https://mvnrepository.com/artifact/net.java.dev.jna/jna).
Background:
We observe those warnings in our Eclipse based product (when checking for JNI problems with -Xcheck:jni), coming from SVN plug-ins:
WARNING in native method: JNI call made without checking exceptions when required to from CallStaticObjectMethod
at java.lang.ClassLoader$NativeLibrary.load0([email protected]/Native Method)
at java.lang.ClassLoader$NativeLibrary.load([email protected]/ClassLoader.java:2442)
at java.lang.ClassLoader$NativeLibrary.loadLibrary([email protected]/ClassLoader.java:2498)
- locked <0x00000005007d6730> (a java.util.HashSet)
at java.lang.ClassLoader.loadLibrary0([email protected]/ClassLoader.java:2694)
at java.lang.ClassLoader.loadLibrary([email protected]/ClassLoader.java:2627)
at java.lang.Runtime.load0([email protected]/Runtime.java:768)
at java.lang.System.load([email protected]/System.java:1837)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:761)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:736)
at com.sun.jna.Native.<clinit>(Native.java:131)
at com.sun.jna.Pointer.<clinit>(Pointer.java:41)
at org.tmatesoft.svn.core.internal.util.jna.SVNLinuxUtil.<clinit>(SVNLinuxUtil.java:33)
- Dominant language
- Java
- Stars
- 8.9k
- Forks
- 1.7k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from java-native-access/jna
-
Difficulty 4/5 3-5 days Newbie friendliness 66/100
java-native-access/jna#1738 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
java-native-access/jna#1736 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
java-native-access/jna#1717 ·
-
Windows32Exception - The parameter is incorrectPossibly taken @marktech0813 claimed this 332 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
java-native-access/jna#1700 · 11 comments ·
-
feature request
Difficulty 4/5 3-5 days Newbie friendliness 35/100
java-native-access/jna#1698 · 1 comment ·
All issues in java-native-access/jna
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Netcracker/qubership-integration-platform#1046 ·
Maintainers usually reply within 2 days
-
`check_java_version()` fails when Java path contains spaces (Windows / Git Bash, `C:\Program Files`)Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Fix Math.ceilDiv wrong result for exact positive divisionsPossibly taken @pamod-madubashana claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
scala-native/scala-native#5094 ·
Maintainers usually reply within 1 day
-
NullPointerException in blocking command completion callback when the command succeeds (3.52.0)Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days