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

Annotation is missing from javap output and getType for InstanceOfTree

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 21
    • tools
    • None

      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

            Unassigned Unassigned
            abimpoudis Angelos Bimpoudis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: