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

Javac allows type annotations of outer type for a method's receiver type

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      It is possible to annotate the outer type of a receiver type even if the inner type is not parameterized.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the attached code and look into the class file where the outer type is treated like a owner type of a parameterized type.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      javac emitts a compiler error.
      ACTUAL -
      javac writes the type annotation into the class file.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      class Foo {
        class Bar {
          void qux(@TypeAnnotation Foo.@TypeAnnotation Bar this) { } // Foo is treated as owner type.
        }
      }

      @Target(ElementType.TYPE_USE)
      @Retention(RetentionPolicy.RUNTIME)
      @interface TypeAnnotation { }
      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            • Assignee:
              rpatil Ramanand Patil (Inactive)
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: