Details
-
Bug
-
Resolution: Fixed
-
P3
-
11
-
b05
Description
The documentation talks about WrongMethodTypeException in case of mismatched type. It does not mention about reference casting error for return type. JDK fails with ClassCastException for the below code:
import java.lang.invoke.*;
public class code {
public static void main(String[] args) throws Throwable {
System.out.println("Testing ConstantBoostraps.invoke");
ConstantBootstraps.invoke(MethodHandles.lookup(), null, int.class, MethodHandles.lookup().unreflect(code.class.getDeclaredMethod("worker", int[].class)), new code(), 10, 10);
}
public Object worker(int... args) {
return 0L;
}
}
import java.lang.invoke.*;
public class code {
public static void main(String[] args) throws Throwable {
System.out.println("Testing ConstantBoostraps.invoke");
ConstantBootstraps.invoke(MethodHandles.lookup(), null, int.class, MethodHandles.lookup().unreflect(code.class.getDeclaredMethod("worker", int[].class)), new code(), 10, 10);
}
public Object worker(int... args) {
return 0L;
}
}
Attachments
Issue Links
- csr for
-
JDK-8199540 Clarify the throwing of exceptions from ConstantBootstraps.invoke
- Closed