JDK-7032850 : MethodHandle.invokeGeneric throws unspecified RuntimeException if parameterized method is called
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang.invoke
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2011-03-31
  • Updated: 2012-03-22
  • Resolved: 2011-07-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b144Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
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)

Comments
EVALUATION Implement invocation corner cases, including correct type conversions and interface type enforcement. Changeset 20bf5b0970e9.
23-05-2011

EVALUATION Missing code in generic invocation path. This can be filled in now that 6939861 is integrated.
13-05-2011