Annotation is missing from javap output and getType for InstanceOfTree

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P4
    • tbd
    • Affects Version/s: 21
    • Component/s: tools

      import java.lang.annotation.ElementType;
      import java.lang.annotation.Retention;
      import java.lang.annotation.RetentionPolicy;
      import java.lang.annotation.Target;

      public class Annot {
          public void doSomething(final Object x) {
              if (x instanceof @TA Float) {
              }
              if (x instanceof @TA Boolean b) {
              }
          }

          @Target(ElementType.TYPE_USE)
          @Retention(RetentionPolicy.RUNTIME)
          @interface TA {}
      }

      1. javap -v InstanceOfPatternVariable.class prints one use of @TA.

            RuntimeVisibleTypeAnnotations:
              0: #19(): INSTANCEOF, offset=1
                InstanceOfPatternVariable$TA

      Check if that is a javac or a javap issue (most probably the second).

      2.1st InstanceOfTree, getType() returns `@TA Float` while 2nd: InstanceOfTree, getType() only returns `Boolean`, without the type annotation attached.
      For the second InstanceOfTree, getPattern() seems to return a BindingPatternTree that contains a VariableTree which has `@TA Boolean` type.

      https://mail.openjdk.org/pipermail/compiler-dev/2023-November/024915.html

            Assignee:
            Unassigned
            Reporter:
            Angelos Bimpoudis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: