|
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 */ |
|
9 |
|
10 import java.lang.annotation.*; |
|
11 |
|
12 public class TypeAnnotations extends @TA Object implements @TA Runnable { |
|
13 |
|
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 }; |
|
19 |
|
20 @TA Object tested = null; |
|
21 @TA boolean isAnnotated = tested instanceof @TA String; |
|
22 |
|
23 return (@TA String @TA []) null; |
|
24 } |
|
25 |
|
26 { |
|
27 Runnable r = () -> { |
|
28 @TA Object tested = null; |
|
29 @TA boolean isAnnotated = tested instanceof @TA String; |
|
30 }; |
|
31 |
|
32 @TA Object tested = null; |
|
33 @TA boolean isAnnotated = tested instanceof @TA String; |
|
34 |
|
35 @TA String @TA [] ret = (@TA String @TA []) null; |
|
36 } |
|
37 |
|
38 @TA String @TA [] f = new @TA String @TA[0]; |
|
39 |
|
40 @Override public void run() { } |
|
41 |
|
42 public static class Inner extends @TA Object implements @TA Runnable { |
|
43 @Override public void run() { } |
|
44 } |
|
45 } |
|
46 |
|
47 @Target({ElementType.TYPE_USE, ElementType.TYPE}) |
|
48 @Deprecated |
|
49 @interface TA { |
|
50 |
|
51 } |