langtools/test/tools/javac/processing/errors/CrashOnNonExistingAnnotation/Source.java
author akulyakh
Thu, 21 May 2015 11:41:04 -0700
changeset 30730 d3ce7619db2c
parent 21704 e215a6216604
permissions -rw-r--r--
8076543: Add @modules as needed to the langtools tests Reviewed-by: jjg, shurailine
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21704
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
     1
/*
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 21704
diff changeset
     2
 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
21704
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
     4
 *
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
     8
 *
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    13
 * accompanied this code).
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    14
 *
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    18
 *
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    21
 * questions.
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    22
 */
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    23
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    24
/*
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    25
 * @test /nodynamiccopyright/
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    26
 * @bug 8027310
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    27
 * @summary Ensure no exceptions on unresolvable annotations
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 21704
diff changeset
    28
 * @modules jdk.compiler/com.sun.tools.javac.api
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 21704
diff changeset
    29
 *          jdk.compiler/com.sun.tools.javac.file
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 21704
diff changeset
    30
 *          jdk.compiler/com.sun.tools.javac.util
21704
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    31
 * @build Processor
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    32
 * @run main Processor Source.java
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    33
 */
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    34
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    35
import java.util.List;
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    36
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    37
@Anno("TYPE")
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    38
public class Source {
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    39
    @Anno("TYPE")
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    40
    class Inner {
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    41
        class InnerInner {
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    42
            public @Anno("CONSTRUCTOR") InnerInner(@Anno("TYPE_USE") Source. @Anno("TYPE_USE") Inner Inner.this,
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    43
                                                   @Anno("PARAMETER") java.lang. @Anno("TYPE_USE") Runnable p) {
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    44
                Runnable r = () -> {
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    45
                    @Anno("TYPE_USE") Object tested = null;
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    46
                    @Anno("TYPE_USE") boolean isAnnotated = tested instanceof @Anno("TYPE_USE") String;
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    47
                };
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    48
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    49
                @Anno("TYPE_USE") Object tested = (@Anno("TYPE_USE") String @Anno("TYPE_USE") []) null;
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    50
                @Anno("TYPE_USE") boolean isAnnotated = tested instanceof@Anno("TYPE_USE") String;
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    51
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    52
                tested = new java.lang. @Anno("TYPE_USE") Object();
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    53
                tested = new @Anno("TYPE_USE") Object();
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    54
            }
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    55
        }
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    56
    }
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    57
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    58
    {
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    59
        Runnable r = () -> {
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    60
            @Anno("TYPE_USE") Object tested = null;
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    61
            @Anno("TYPE_USE") boolean isAnnotated = tested instanceof @Anno("TYPE_USE") String;
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    62
        };
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    63
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    64
        @Anno("TYPE_USE") Object tested = (@Anno("TYPE_USE") String @Anno("TYPE_USE") []) null;
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    65
        @Anno("TYPE_USE") boolean isAnnotated = tested instanceof@Anno("TYPE_USE") String;
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    66
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    67
        tested = new java.lang. @Anno("TYPE_USE") Object();
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    68
        tested = new @Anno("TYPE_USE") Object();
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    69
    }
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    70
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    71
    @Anno("TYPE")
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    72
    @Anno("ANNOTATION_TYPE")
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    73
    @interface A { }
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    74
    abstract class Parameterized<@Anno("TYPE_PARAMETER") T extends @Anno("TYPE_USE") CharSequence &
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    75
                                                                   @Anno("TYPE_USE") Runnable>
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    76
        implements @Anno("TYPE_USE") List<@Anno("TYPE_USE") Runnable> { }
e215a6216604 8027310: Annotation Processor crashes with NPE
jlahoda
parents:
diff changeset
    77
}