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

SwitchBootstraps.ResolvedEnumLabels.resolvedEnum should be final

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 24
    • 23, 24
    • core-libs
    • None
    • b05

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: