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

TYPE_USE-target-annotating record component having RecordComponent type: javac "error: scoping construct cannot be annotated with type-use annotation"

    Details

      Description

      Consider the following code sample:

      import java.lang.annotation.*;
      public class Bug01 {
          @Target({ElementType.RECORD_COMPONENT, ElementType.TYPE_USE}) @interface Anno { }
          record Rec(@Anno java.lang.reflect.RecordComponent rc) {}
      }

      When compiling it with jdk14b27

      javac --enable-preview --release 14 Bug01.java

      the following error occurs:

      Bug01.java:4: error: scoping construct cannot be annotated with type-use annotation: @Bug01.Anno
          record Rec(@Anno java.lang.reflect.RecordComponent rc) {}
                                            ^
      Note: Bug01.java uses preview language features.
      Note: Recompile with -Xlint:preview for details.
      1 error


        Attachments

          Activity

            People

            • Assignee:
              vromero Vicente Arturo Romero Zaldivar
              Reporter:
              dbessono Dmitry Bessonov
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: