langtools/test/tools/javac/warnings/suppress/TypeAnnotations.java
author akulyakh
Thu, 21 May 2015 11:41:04 -0700
changeset 30730 d3ce7619db2c
parent 26532 aa84b6606229
permissions -rw-r--r--
8076543: Add @modules as needed to the langtools tests Reviewed-by: jjg, shurailine

/**
 * @test /nodynamiccopyright/
 * @bug 8021112
 * @summary Verify that \\@SuppressWarnings("unchecked") works for type annotations
 * @modules jdk.compiler/com.sun.tools.javac.api
 *          jdk.compiler/com.sun.tools.javac.code
 *          jdk.compiler/com.sun.tools.javac.file
 *          jdk.compiler/com.sun.tools.javac.tree
 * @ignore  8057683 improve ordering of errors with type annotations
 * @build VerifySuppressWarnings
 * @compile/ref=TypeAnnotations.out -XDrawDiagnostics -Xlint:unchecked,deprecation,cast TypeAnnotations.java
 * @run main VerifySuppressWarnings TypeAnnotations.java
 */

import java.lang.annotation.*;

public class TypeAnnotations extends @TA Object implements @TA Runnable {

    public @TA String @TA [] m(@TA String @TA [] p) throws @TA Throwable {
        Runnable r = () -> {
            @TA Object tested = null;
            @TA boolean isAnnotated = tested instanceof @TA String;
        };

        @TA Object tested = null;
        @TA boolean isAnnotated = tested instanceof @TA String;

        return (@TA String @TA []) null;
    }

    {
        Runnable r = () -> {
            @TA Object tested = null;
            @TA boolean isAnnotated = tested instanceof @TA String;
        };

        @TA Object tested = null;
        @TA boolean isAnnotated = tested instanceof @TA String;

        @TA String @TA [] ret = (@TA String @TA []) null;
    }

    @TA String @TA [] f = new @TA String @TA[0];

    @Override public void run() { }

    public static class Inner extends @TA Object implements @TA Runnable {
        @Override public void run() { }
    }
}

@Target({ElementType.TYPE_USE, ElementType.TYPE})
@Deprecated
@interface TA {

}