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

JSR 292 Raw retypes and return type conversions are needed

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      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);
          }
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jrose John Rose
              Reporter:
              kshiroko Kirill Shirokov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: