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

Mon, 16 Sep 2013 14:13:44 +0200

author
jlahoda
date
Mon, 16 Sep 2013 14:13:44 +0200
changeset 2028
4ce8148ffc4f
parent 0
959103a6100f
permissions
-rw-r--r--

8021112: Spurious unchecked warning reported by javac
6480588: No way to suppress deprecation warnings when implementing deprecated interface
Summary: Fixing DeferredLintHandler configuration, so lint warnings are reported with correct @SuppressWarnings settings
Reviewed-by: jjg, vromero

     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