SwitchBootstraps.ResolvedEnumLabels.resolvedEnum should be final

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 24
    • Affects Version/s: 23, 24
    • Component/s: core-libs
    • None
    • b05

      Current definition is:

              private final MethodHandles.Lookup lookup;
              private final EnumDesc<?>[] enumDescs;
              @Stable
              private Object[] resolvedEnum;

              public ResolvedEnumLabels(MethodHandles.Lookup lookup, EnumDesc<?>[] enumDescs) {
                  this.lookup = lookup;
                  this.enumDescs = enumDescs;
                  this.resolvedEnum = new Object[enumDescs.length];
              }

      ...and `resolvedEnum` is not `final`. So technically publishing the object via data race can show `resolvedEnum` as `null`, which would break `test()` that does not expect it. Currently not a practical problem since its safety is covered by adjacent `final` fields, but should be more precise.

            Assignee:
            Aleksey Shipilev
            Reporter:
            Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: