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