langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodThrows.java
author mchung
Wed, 27 May 2015 13:25:18 -0700
changeset 30846 2b3f379840f0
parent 30730 d3ce7619db2c
permissions -rw-r--r--
8074432: Move jdeps and javap to jdk.jdeps module Reviewed-by: jjg, alanb, erikj
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     1
/*
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 24896
diff changeset
     2
 * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     4
 *
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     8
 *
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    13
 * accompanied this code).
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    14
 *
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    18
 *
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    21
 * questions.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    22
 */
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    23
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    24
import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    25
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    26
/*
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    27
 * @test
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    28
 * @bug 8042451
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    29
 * @summary Test population of reference info for method exception clauses
30846
2b3f379840f0 8074432: Move jdeps and javap to jdk.jdeps module
mchung
parents: 30730
diff changeset
    30
 * @modules jdk.jdeps/com.sun.tools.classfile
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    31
 * @compile -g Driver.java ReferenceInfoUtil.java MethodThrows.java
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    32
 * @run main Driver MethodThrows
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    33
 */
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    34
public class MethodThrows {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    35
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    36
    @TADescription(annotation = "TA", type = THROWS, typeIndex = 0)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    37
    @TADescription(annotation = "TB", type = THROWS, typeIndex = 2)
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    38
    public String regularMethod() {
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    39
        return "class %TEST_CLASS_NAME% { void test() throws @TA RuntimeException, IllegalArgumentException, @TB Exception { } }";
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    40
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    41
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    42
    @TADescription(annotation = "TA", type = THROWS, typeIndex = 0)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    43
    @TADescription(annotation = "TB", type = THROWS, typeIndex = 2)
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    44
    public String abstractMethod() {
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    45
        return "abstract class %TEST_CLASS_NAME% { abstract void test() throws @TA RuntimeException, IllegalArgumentException, @TB Exception; }";
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    46
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    47
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    48
    @TADescription(annotation = "TA", type = THROWS, typeIndex = 0)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    49
    @TADescription(annotation = "TB", type = THROWS, typeIndex = 2)
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    50
    public String interfaceMethod() {
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    51
        return "interface %TEST_CLASS_NAME% { void test() throws @TA RuntimeException, IllegalArgumentException, @TB Exception; }";
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    52
    }
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    53
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    54
    @TADescription(annotation = "TA", type = THROWS, typeIndex = 0,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    55
                   genericLocation = {})
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    56
    @TADescription(annotation = "TB", type = THROWS, typeIndex = 0,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    57
                   genericLocation = {1, 0})
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    58
    @TADescription(annotation = "TC", type = THROWS, typeIndex = 0,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    59
                   genericLocation = {1, 0, 1, 0})
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    60
    @TADescription(annotation = "TD", type = THROWS, typeIndex = 1,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    61
                   genericLocation = {})
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    62
    @TADescription(annotation = "TE", type = THROWS, typeIndex = 1,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    63
                   genericLocation = {1, 0})
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    64
    @TADescription(annotation = "TF", type = THROWS, typeIndex = 1,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    65
                   genericLocation = {1, 0, 1, 0})
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    66
    public String NestedTypes() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    67
        return "class Outer { class Middle { class Inner1 extends Exception {}" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    68
                "  class Inner2 extends Exception{} } }" +
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 17578
diff changeset
    69
                "class %TEST_CLASS_NAME% { void test() throws @TA Outer.@TB Middle.@TC Inner1, @TD Outer.@TE Middle.@TF Inner2 { } }";
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    70
    }
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    71
}