Describe the issue
Invoking a MethodHandle on a method with Long as return type returns 0 instead of null using native-image.
This can also be reproduced using Integer and Boolean as return type.
Steps to reproduce the issue
I added a reproducer, see https://github.com/dagrammy/graal-native-bug-test
git clone https://github.com/dagrammy/graal-native-bug-test.git and follow the steps in the readme https://github.com/dagrammy/graal-native-bug-test/blob/main/README.md
Describe GraalVM and your environment:
- GraalVM version: graalvm-ce-java17-22.3.0
- JDK major version: 17
- OS: macOS Ventura 13.0.1
- Architecture: arm/Apple M1
More details
Full example can be found here: https://github.com/dagrammy/graal-native-bug-test
This is a simple Pojo bean:
public class BeanLong {
private Long value = null;
public BeanLong() {
}
public Long getValue() {
return value;
}
}
The getter is invoked using a MethodHandle:
Class<?> beanClass = BeanLong.class;
Object bean = new BeanLong();
Method method = beanClass.getMethod("getValue");
MethodHandle methodHandle = MethodHandles.publicLookup().unreflect(method);
// Call to MH returns 0 in native mode instead of null
Long out = (Long) methodHandle.invoke(bean);
System.out.println(">>>>> " + out + " <<<<<");
Output in JVM:
Output in native-image:
Using MethodHandles.publicLookup().findVirtual(beanClass, "getValue", MethodType.methodType(Long.class)); instead of unreflect also shows this behaviour (s. reproducer).
Maybe issue #5209 is related?
Describe the issue
Invoking a
MethodHandleon a method withLongas return type returns0instead ofnullusing native-image.This can also be reproduced using
IntegerandBooleanas return type.Steps to reproduce the issue
I added a reproducer, see https://github.com/dagrammy/graal-native-bug-test
git clone https://github.com/dagrammy/graal-native-bug-test.gitand follow the steps in the readme https://github.com/dagrammy/graal-native-bug-test/blob/main/README.mdDescribe GraalVM and your environment:
More details
Full example can be found here: https://github.com/dagrammy/graal-native-bug-test
This is a simple Pojo bean:
The getter is invoked using a MethodHandle:
Output in JVM:
Output in native-image:
Using
MethodHandles.publicLookup().findVirtual(beanClass, "getValue", MethodType.methodType(Long.class));instead ofunreflectalso shows this behaviour (s. reproducer).Maybe issue #5209 is related?