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

[lworld] javac rejects assignments to components of array fields with initializers in the prologue

XMLWordPrintable

      this code:

      ```
      value class Test {
          private final int[] data = new int[10];
          Test() {
              for (int i = 0; i < data.length; i++) {
                  data[i] = i;
              }
          }
      }
      ```

      should be accepted by javac without errors or initialization warnings, if enable, but it is rejected. Basically field data has an initializer and fields with initializers can't be assigned to in the prologue. But `data[i] = i` is assigning to an array component, not to the whole array.

            vromero Vicente Arturo Romero Zaldivar
            vromero Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: