Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7032850

MethodHandle.invokeGeneric throws unspecified RuntimeException if parameterized method is called

XMLWordPrintable

    • b144
    • generic
    • generic
    • Verified

      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)

            jrose John Rose
            dmiltsov Dmitry Miltsov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: