Jan Lahoda | 315696d | 2013-09-16 14:13:44 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @test /nodynamiccopyright/ |
| 3 | * @bug 8021112 |
| 4 | * @summary Verify that \\@SuppressWarnings("unchecked") works for type annotations |
Alexander Kulyakhtin | b626244 | 2015-05-21 11:41:04 -0700 | [diff] [blame] | 5 | * @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-Franck | 053a9d5 | 2014-09-08 13:11:28 +0200 | [diff] [blame] | 9 | * @ignore 8057683 improve ordering of errors with type annotations |
Jan Lahoda | 315696d | 2013-09-16 14:13:44 +0200 | [diff] [blame] | 10 | * @build VerifySuppressWarnings |
| 11 | * @compile/ref=TypeAnnotations.out -XDrawDiagnostics -Xlint:unchecked,deprecation,cast TypeAnnotations.java |
| 12 | * @run main VerifySuppressWarnings TypeAnnotations.java |
| 13 | */ |
| 14 | |
| 15 | import java.lang.annotation.*; |
| 16 | |
| 17 | public 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 | } |