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

JSR 292 method handle collector transform does not work correctly on subtypes of Object[]

XMLWordPrintable

      The asCollector transform does not respect the type argument.
      When it collects a series of arguments, it always puts it into an Object[] array.
      This causes a CCE if the ultimate target requires a more specific type, such as String[].

      Here is a customer report:

      http://mail.openjdk.java.net/pipermail/mlvm-dev/2011-February/002439.html

      Also, this reproduces the bug:

      MethodHandle asList = lookup().
          findStatic(Arrays.class, "asList", methodType(List.class, Object[].class));

      asList = asList.asType(methodType(List.class, String[].class)).
          asVarargsCollector(String[].class);

      System.out.println(asList.invokeWithArguments("a", "b", "c"));

            jrose John Rose
            jrose John Rose
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: