langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java
author akulyakh
Thu, 21 May 2015 11:41:04 -0700
changeset 30730 d3ce7619db2c
parent 24896 986d876a9121
child 30846 2b3f379840f0
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:
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) 2013, 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: 22443
diff changeset
    28
 * @bug 8028576 8042451
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    29
 * @summary Test population of reference info for exception parameters
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    30
 * @author Werner Dietl
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 24896
diff changeset
    31
 * @modules jdk.compiler/com.sun.tools.classfile
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    32
 * @compile -g Driver.java ReferenceInfoUtil.java ExceptionParameters.java
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    33
 * @run main Driver ExceptionParameters
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    34
 */
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    35
public class ExceptionParameters {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    36
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    37
    @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    38
    public String exception() {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    39
        return "void exception() { try { new Object(); } catch(@TA Exception e) { } }";
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
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    42
    @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    43
    public String finalException() {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    44
        return "void finalException() { try { new Object(); } catch(final @TA Exception e) { } }";
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    45
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    46
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    47
    @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    48
    @TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    49
    @TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    50
    public String multipleExceptions1() {
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    51
        return "void multipleExceptions() { " +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    52
            "try { new Object(); } catch(@TA Exception e) { }" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    53
            "try { new Object(); } catch(@TB Exception e) { }" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    54
            "try { new Object(); } catch(@TC Exception e) { }" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    55
            " }";
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    56
    }
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    57
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    58
    @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    59
    @TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    60
    @TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    61
    public String multipleExceptions2() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    62
        return "void multipleExceptions() { " +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    63
            "  try { new Object(); " +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    64
            "    try { new Object(); " +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    65
            "      try { new Object(); } catch(@TA Exception e) { }" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    66
            "    } catch(@TB Exception e) { }" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    67
            "  } catch(@TC Exception e) { }" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    68
            "}";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    69
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    70
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    71
    @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    72
    @TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    73
    @TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    74
    public String multipleExceptions3() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    75
        return "void multipleExceptions() { " +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    76
            "  try { new Object(); " +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    77
            "  } catch(@TA Exception e1) { "+
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    78
            "    try { new Object(); " +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    79
            "    } catch(@TB Exception e2) {" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    80
            "      try { new Object(); } catch(@TC Exception e3) { }" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    81
            "    }" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    82
            "  }" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    83
            "}";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    84
    }
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    85
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    86
    @TADescription(annotation = "RTAs", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    87
    public String exceptionRepeatableAnnoation() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    88
        return "void exception() { try { new Object(); } catch(@RTA @RTA Exception e) { } }";
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    89
    }
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    90
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    91
    @TADescription(annotation = "RTAs", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    92
    @TADescription(annotation = "RTBs", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    93
    @TADescription(annotation = "RTCs", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    94
    public String multipleExceptionsRepeatableAnnotation1() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    95
        return "void multipleExceptions() { " +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    96
                "try { new Object(); } catch(@RTA @RTA Exception e) { }" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    97
                "try { new Object(); } catch(@RTB @RTB Exception e) { }" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    98
                "try { new Object(); } catch(@RTC @RTC Exception e) { }" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
    99
                " }";
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   100
    }
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   101
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   102
    @TADescription(annotation = "RTAs", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   103
    @TADescription(annotation = "RTBs", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   104
    @TADescription(annotation = "RTCs", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   105
    public String multipleExceptionsRepeatableAnnotation2() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   106
        return "void multipleExceptions() { " +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   107
                "  try { new Object(); " +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   108
                "    try { new Object(); " +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   109
                "      try { new Object(); } catch(@RTA @RTA Exception e) { }" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   110
                "    } catch(@RTB @RTB Exception e) { }" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   111
                "  } catch(@RTC @RTC Exception e) { }" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   112
                "}";
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   113
    }
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   114
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   115
    @TADescription(annotation = "RTAs", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   116
    @TADescription(annotation = "RTBs", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   117
    @TADescription(annotation = "RTCs", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   118
    public String multipleExceptionsRepeatableAnnotation3() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   119
        return "void multipleExceptions() { " +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   120
                "  try { new Object(); " +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   121
                "  } catch(@RTA @RTA Exception e1) { "+
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   122
                "    try { new Object(); " +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   123
                "    } catch(@RTB @RTB Exception e2) {" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   124
                "      try { new Object(); } catch(@RTC @RTC Exception e3) { }" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   125
                "    }" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   126
                "  }" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   127
                "}";
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22443
diff changeset
   128
    }
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   129
}