The following program
class CrashWithException {
private static <T> void test(T arg) {
Function<Class<T>,Field[]> firstFunction = Class<T>::getFields;
}
public static void main(String... args) {
test("Hello World");
}
}
Crashes at runtime:
Exception in thread "main" java.lang.BootstrapMethodError: call site initialization exception
at java.lang.invoke.CallSite.makeSite(CallSite.java:298)
at java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:295)
at CrashWithException.test(CrashWithException.java)
at CrashWithException.main(CrashWithException.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.IllegalArgumentException: not a direct method handle
at java.lang.invoke.MethodHandleInfo.<init>(MethodHandleInfo.java:52)
at java.lang.invoke.AbstractValidatingLambdaMetafactory.<init>(AbstractValidatingLambdaMetafactory.java:125)
at java.lang.invoke.InnerClassLambdaMetafactory.<init>(InnerClassLambdaMetafactory.java:126)
at java.lang.invoke.LambdaMetafactory.metaFactory(LambdaMetafactory.java:207)
at java.lang.invoke.CallSite.makeSite(CallSite.java:283)
... 8 more
class CrashWithException {
private static <T> void test(T arg) {
Function<Class<T>,Field[]> firstFunction = Class<T>::getFields;
}
public static void main(String... args) {
test("Hello World");
}
}
Crashes at runtime:
Exception in thread "main" java.lang.BootstrapMethodError: call site initialization exception
at java.lang.invoke.CallSite.makeSite(CallSite.java:298)
at java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:295)
at CrashWithException.test(CrashWithException.java)
at CrashWithException.main(CrashWithException.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.IllegalArgumentException: not a direct method handle
at java.lang.invoke.MethodHandleInfo.<init>(MethodHandleInfo.java:52)
at java.lang.invoke.AbstractValidatingLambdaMetafactory.<init>(AbstractValidatingLambdaMetafactory.java:125)
at java.lang.invoke.InnerClassLambdaMetafactory.<init>(InnerClassLambdaMetafactory.java:126)
at java.lang.invoke.LambdaMetafactory.metaFactory(LambdaMetafactory.java:207)
at java.lang.invoke.CallSite.makeSite(CallSite.java:283)
... 8 more
- is blocked by
-
JDK-8021050 MethodHandleInfo throws exception when method handle is to a method with @CallerSensitive
- Closed