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

SwitchBootstraps.ResolvedEnumLabels.resolvedEnum should be final

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • 23, 24
    • 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.

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

              Created:
              Updated:
              Resolved: