Duplicate :
|
|
Relates :
|
|
Relates :
|
Please see the minimized test: ------------------------------------------- import java.dyn.*; public class TestGeneric { public static <T> T foo(T param){ return null; } public static void main(String argv[]) throws Exception { MethodHandle handle = MethodHandles.lookup().findStatic (TestGeneric.class, "foo", MethodType.methodType(Object.class, Object.class)); try { String mh1 = (String) handle.invokeGeneric(""); } catch (Throwable thr) { thr.printStackTrace(); } try { Byte mh2 = (Byte) handle.invokeGeneric((Byte) 0); } catch (Throwable thr) { thr.printStackTrace(); } } } ------------------------------------------- Its output is: java.lang.RuntimeException: NYI at sun.dyn.InvokeGeneric.addReturnConversion(InvokeGeneric.java:147) at sun.dyn.InvokeGeneric.dispatchWithConversion(InvokeGeneric.java:129) at sun.dyn.FilterGeneric$F3.invoke_F2(FilterGeneric.java:573) at TestGeneric.main(TestGeneric.java:11) java.lang.RuntimeException: NYI at sun.dyn.InvokeGeneric.addReturnConversion(InvokeGeneric.java:147) at sun.dyn.InvokeGeneric.dispatchWithConversion(InvokeGeneric.java:129) at sun.dyn.FilterGeneric$F3.invoke_F2(FilterGeneric.java:573) at TestGeneric.main(TestGeneric.java:16)
|