test/tools/javac/warnings/suppress/TypeAnnotations.java

Wed, 08 Oct 2014 14:16:40 -0700

author
asaha
date
Wed, 08 Oct 2014 14:16:40 -0700
changeset 2586
f5e5ca7505e2
parent 0
959103a6100f
permissions
-rw-r--r--

Merge

     1 /**
     2  * @test /nodynamiccopyright/
     3  * @bug 8021112
     4  * @summary Verify that \\@SuppressWarnings("unchecked") works for type annotations
     5  * @build VerifySuppressWarnings
     6  * @compile/ref=TypeAnnotations.out -XDrawDiagnostics -Xlint:unchecked,deprecation,cast TypeAnnotations.java
     7  * @run main VerifySuppressWarnings TypeAnnotations.java
     8  */
    10 import java.lang.annotation.*;
    12 public class TypeAnnotations extends @TA Object implements @TA Runnable {
    14     public @TA String @TA [] m(@TA String @TA [] p) throws @TA Throwable {
    15         Runnable r = () -> {
    16             @TA Object tested = null;
    17             @TA boolean isAnnotated = tested instanceof @TA String;
    18         };
    20         @TA Object tested = null;
    21         @TA boolean isAnnotated = tested instanceof @TA String;
    23         return (@TA String @TA []) null;
    24     }
    26     {
    27         Runnable r = () -> {
    28             @TA Object tested = null;
    29             @TA boolean isAnnotated = tested instanceof @TA String;
    30         };
    32         @TA Object tested = null;
    33         @TA boolean isAnnotated = tested instanceof @TA String;
    35         @TA String @TA [] ret = (@TA String @TA []) null;
    36     }
    38     @TA String @TA [] f = new @TA String @TA[0];
    40     @Override public void run() { }
    42     public static class Inner extends @TA Object implements @TA Runnable {
    43         @Override public void run() { }
    44     }
    45 }
    47 @Target({ElementType.TYPE_USE, ElementType.TYPE})
    48 @Deprecated
    49 @interface TA {
    51 }

mercurial