|
Blocks :
|
|
|
Relates :
|
|
|
Relates :
|
package jdk.nashorn.test.models;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
public class NullProvider {
public static Boolean getBoolean() { return null; }
public static void main(String[] args) throws Throwable {
MethodHandle mh = MethodHandles.lookup().findStatic(NullProvider.class, "getBoolean", MethodType.methodType(Boolean.class));
mh = MethodHandles.explicitCastArguments(mh, MethodType.methodType(boolean.class));
System.out.println(mh.invoke());
}
}
throws:
Exception in thread "main" java.lang.NullPointerException
at sun.invoke.util.ValueConversions.unboxBoolean(ValueConversions.java:95)
at jdk.nashorn.test.models.NullProvider.main(NullProvider.java:13)
Expected result would be printing "false", as per documentation for explicitCastArgument that says "If T0 is a reference and T1 a primitive, and if the reference is null at runtime, a zero value is introduced."
This happens with 9 builds (e.g. just reproduced it with 9 b34). 8 builds (e.g. recent 8u40 early access release builds) seem to behave okay.
|