blob: b45b36c21986f641707b8ef61137b9e7f258e31e [file] [log] [blame]
Jan Lahoda315696d2013-09-16 14:13:44 +02001/**
2 * @test /nodynamiccopyright/
3 * @bug 8021112
4 * @summary Verify that \\@SuppressWarnings("unchecked") works for type annotations
Alexander Kulyakhtinb6262442015-05-21 11:41:04 -07005 * @modules jdk.compiler/com.sun.tools.javac.api
6 * jdk.compiler/com.sun.tools.javac.code
7 * jdk.compiler/com.sun.tools.javac.file
8 * jdk.compiler/com.sun.tools.javac.tree
Joel Borggrén-Franck053a9d52014-09-08 13:11:28 +02009 * @ignore 8057683 improve ordering of errors with type annotations
Jan Lahoda315696d2013-09-16 14:13:44 +020010 * @build VerifySuppressWarnings
11 * @compile/ref=TypeAnnotations.out -XDrawDiagnostics -Xlint:unchecked,deprecation,cast TypeAnnotations.java
12 * @run main VerifySuppressWarnings TypeAnnotations.java
13 */
14
15import java.lang.annotation.*;
16
17public class TypeAnnotations extends @TA Object implements @TA Runnable {
18
19 public @TA String @TA [] m(@TA String @TA [] p) throws @TA Throwable {
20 Runnable r = () -> {
21 @TA Object tested = null;
22 @TA boolean isAnnotated = tested instanceof @TA String;
23 };
24
25 @TA Object tested = null;
26 @TA boolean isAnnotated = tested instanceof @TA String;
27
28 return (@TA String @TA []) null;
29 }
30
31 {
32 Runnable r = () -> {
33 @TA Object tested = null;
34 @TA boolean isAnnotated = tested instanceof @TA String;
35 };
36
37 @TA Object tested = null;
38 @TA boolean isAnnotated = tested instanceof @TA String;
39
40 @TA String @TA [] ret = (@TA String @TA []) null;
41 }
42
43 @TA String @TA [] f = new @TA String @TA[0];
44
45 @Override public void run() { }
46
47 public static class Inner extends @TA Object implements @TA Runnable {
48 @Override public void run() { }
49 }
50}
51
52@Target({ElementType.TYPE_USE, ElementType.TYPE})
53@Deprecated
54@interface TA {
55
56}