test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass.java

Print this page


   1 /*
   2  * @test /nodynamiccopyright/
   3  * @bug 8006733 8006775
   4  * @ignore 8013409: test failures for type annotations
   5  * @summary A static outer class cannot be annotated.
   6  * @author Werner Dietl
   7  * @compile/fail/ref=CantAnnotateStaticClass.out -XDrawDiagnostics CantAnnotateStaticClass.java
   8  */
   9 
  10 import java.util.List;
  11 import java.lang.annotation.*;
  12 
  13 class CantAnnotateStaticClass {
  14     @Target(ElementType.TYPE_USE)
  15     @interface A {}
  16 
  17     static class Outer {
  18         class Inner {}
  19     }
  20 
  21     // 8 errors:
  22     @A Outer.Inner f1;
  23     @A Outer.Inner f1r() { return null; }
  24     void f1p(@A Outer.Inner p) { }
   1 /*
   2  * @test /nodynamiccopyright/
   3  * @bug 8006733 8006775 8013409

   4  * @summary A static outer class cannot be annotated.
   5  * @author Werner Dietl
   6  * @compile/fail/ref=CantAnnotateStaticClass.out -XDrawDiagnostics CantAnnotateStaticClass.java
   7  */
   8 
   9 import java.util.List;
  10 import java.lang.annotation.*;
  11 
  12 class CantAnnotateStaticClass {
  13     @Target(ElementType.TYPE_USE)
  14     @interface A {}
  15 
  16     static class Outer {
  17         class Inner {}
  18     }
  19 
  20     // 8 errors:
  21     @A Outer.Inner f1;
  22     @A Outer.Inner f1r() { return null; }
  23     void f1p(@A Outer.Inner p) { }