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

Varargs array type incompatible with bridge method

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 6, 7, 8, 9
    • Fix Version/s: tbd_major
    • Component/s: specification
    • Labels:
      None

      Description

      If this test case is compiled with javac:

      interface Iface<T extends Number> {
          String m(T...t);
      }

      public class Test {
          public static void main(String[] args) {
              Iface<? super Integer> i = (Integer...a) -> "";
              String result = i.m(1);
          }
      }

      at execution time you will get:

      Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Number; cannot be cast to [Ljava.lang.Integer;
      at Test$$Lambda$1/980546781.m(Unknown Source)
      at Test.main(Test.java:8)

      This is correct according to the current spec. It should be checked if the spec can be modified to deal better with similar cases.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dlsmith Dan Smith
              Reporter:
              vromero Vicente Arturo Romero Zaldivar
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated: