[lworld] Handling of @Strict by javac needs some fixes

XMLWordPrintable

      The issues can be seen after compiling this Java source code:

      import jdk.internal.vm.annotation.NullRestricted;
      import jdk.internal.vm.annotation.Strict;

      public class NRTest {
          static value class Value {
      int i = 0;
          }

          @Strict
          @NullRestricted
          Value v = new Value();
          
          public static void main(String[] args) {
      var t = new NRTest();
          }
      }

      When disassembling the produced class file, the information related to the field v is:

        NRTest$Value v;
          descriptor: LNRTest$Value;
          flags: (0x0800) ACC_STRICT_INIT
          RuntimeVisibleAnnotations:
            0: #18()
              jdk.internal.vm.annotation.NullRestricted
          RuntimeInvisibleAnnotations:
            0: #20()
              jdk.internal.vm.annotation.Strict


      Javac correctly sets the ACC_STRICT_INIT flag in the field's access flags.
      However, javac also puts jdk.internal.vm.annotation.Strict in the set of runtime annotations of the field. This is redundant with the ACC_STRICT_INIT flag, and it is not consistent with the definition of the Strict annotation which is declared as having a SOURCE policy retention:

      @Target(ElementType.FIELD)
      @Retention(RetentionPolicy.SOURCE)
      public @interface Strict {
      }

            Assignee:
            Vicente Arturo Romero Zaldivar
            Reporter:
            Frederic Parain
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: