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

[lworld] javac allows inline type array as varargs arg

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • repo-valhalla
    • repo-valhalla
    • tools

      Found when fixing JDK-8224110:

      public class VarArgsArray {

        inline class MyInt {
          int value;
          public MyInt() { this(0); }
          public MyInt(int v) { this.value = v; }
        }

        public VarArgsArray() throws Throwable {
          MyInt[] a = new MyInt[0];
          this.getClass().getDeclaredMethod("test", MyInt[].class).invoke(this, a); // <--- Warns, but in the case of known inline type, should be error
        }

        public void test(MyInt[] a) {
          System.out.println(a);
        }

        public static void main(String[] args) throws Throwable {
          new VarArgsArray();
        }
      }

            sadayapalam Srikanth Adayapalam (Inactive)
            dsimms David Simms
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: