You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] extensions method with long/double argument causes JNI error when run in Eclipse #3463
Describe the bug
An extension method with a long or double parameter, which is called with an int, causes an JNI error during runtime when loading the class.
Definition of the extension method with a long argument:
publicstatic <T> voidhello(Stringthat, longn) {
// nothing here
}
Calling it with an int:
publicvoidsomeMethod() {
"".hello(1);
}
This compiles, but when run in Eclipse, produces the JNI error below.
Calling with a long instead (eg. changing the 1 to a 1l) fixes the problem.
When launching the class in Eclipse, it will fail like this:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
prob/lems/JNIProblem.someMethod()V @3: invokestatic
Reason:
Type integer (current frame, stack[1]) is not assignable to long_2nd
Current Frame:
bci: @3
flags: { }
locals: { 'prob/lems/JNIProblem' }
stack: { 'java/lang/String', integer }
Bytecode:
0x0000000: 120f 08b8 0011 120f 1400 17b8 0011 b1
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:650)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:632)
With javac/java it works just fine:
$ make jni_problem
javac -cp lombok-1.18.28.jar prob/lems/JNIProblem.java
java -cp lombok-1.18.28.jar:. 'prob.lems.JNIProblem'
works in javac but not with Eclipse
Expected behavior
No JNI error :)
Version info:
Lombok version: 1.18.28
Eclipse: 2022-03 (4.23.0)
Workaround
Define both versions of the extension method (int and long), and let one call the other.
When I tried this, it still wouldn't work. Turns out, Eclipse does not recompile my calling class, when the extension method class changes.
Thanks for the detailed bug report. IIRC we already have some special handling for casts but it seems to be incomplete or incompatible with recent eclipse versions.
Activity
JNI problem with long/double arguments in extension method
JNI problem with long/double arguments in extension method
JNI problem with long/double arguments in extension method
Rawi01 commentedon Aug 2, 2023
Thanks for the detailed bug report. IIRC we already have some special handling for casts but it seems to be incomplete or incompatible with recent eclipse versions.
[fixes projectlombok#3463] Support argument widening for extension me…
[#3463] Add line to changelog
marc-guenther commentedon Sep 27, 2023
I can confirm that this fixes the problem. Thanks a lot! Always nice to fix a bug by removing "magic" from the code :)