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

Print this page


   1 /*
   2  * @test /nodynamiccopyright/
   3  * @bug 8006775
   4  * @summary A cast cannot consist of only an annotation.
   5  * @author Werner Dietl
   6  * @compile/fail/ref=BadCast.out -XDrawDiagnostics BadCast.java
   7  */


   8 class BadCast {
   9   static void main() {
  10     Object o = (@A) "";
  11   }
  12 }
  13 

  14 @interface A { }
   1 /*
   2  * @test /nodynamiccopyright/
   3  * @bug 8006775
   4  * @summary A cast cannot consist of only an annotation.
   5  * @author Werner Dietl
   6  * @compile/fail/ref=BadCast.out -XDrawDiagnostics BadCast.java
   7  */
   8 import java.lang.annotation.*;
   9 
  10 class BadCast {
  11   static void main() {
  12     Object o = (@A) "";
  13   }
  14 }
  15 
  16 @Target(ElementType.TYPE_USE)
  17 @interface A { }