JDK-7016250 : JSR 292 Raw retypes and return type conversions are needed
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs20
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2011-02-01
  • Updated: 2012-02-01
  • Resolved: 2011-05-13
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
7Resolved
Related Reports
Duplicate :  
Relates :  
Description
When invokedynamic instruction or MethodHandles.convertArguments() needs to convert between primary types, an exception like the one below is thrown:

Exception in thread "main" java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.Byte
        at sun.dyn.util.ValueConversions.unboxByte(ValueConversions.java:61)
        at sun.dyn.util.ValueConversions.unboxByteRaw(ValueConversions.java:98)
        at sun.dyn.ToGeneric$Adapter.return_I(ToGeneric.java:393)
        at sun.dyn.ToGeneric$A1.invoke_I(ToGeneric.java:643)

A short test case for this:

import java.dyn.*;

public class R { 
    public static void main(String... args) throws Throwable {
        MethodHandle mh1 = MethodHandles.identity(int.class);
        MethodHandle mh2 = MethodHandles.convertArguments(mh1, MethodType.methodType(short.class, int.class));
        short s = (short) mh2.invokeExact(123);
    }
}

Comments
EVALUATION The root cause of the missing conversions was the lack of recursive method handle functionality in the JVM. This has been corrected with 6939861.
13-05-2011