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

Nonrelevant error message when passing int to anonymous class constructor

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P5
    • tbd
    • 9
    • tools

    Description

      Let's consider following example:

      class Test19_2 <T> {
          private static class MyClass {}
          public static MyClass v1 = new MyClass();
          Test19_2(T t, MyClass ... mc) {}
      }

      public class Test19 {
          public static void main(String[] args) {
              new Test19_2<>(1, Test19_2.v1){};
          }
      }

      On JDK9b73 compilation fails with following errors:

      Error:(9, 21) java: incompatible types: cannot infer type arguments for Test19_2<>
          reason: formal varargs element type Test19_2.MyClass is not accessible from class Test19
      Error:(9, 39) java: Test19_2.MyClass has private access in Test19_2
      Error:(9, 24) java: incompatible types: int cannot be converted to T

      The last error message is nonrelevant.

      Attachments

        Activity

          People

            vromero Vicente Arturo Romero Zaldivar
            grakov Georgiy Rakov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: