Thu, 31 Aug 2017 15:17:03 +0800
merge
1 /*
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
24 import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
26 /*
27 * @test
28 * @bug 8028576
29 * @summary Test population of reference info for exception parameters
30 * @author Werner Dietl
31 * @compile -g Driver.java ReferenceInfoUtil.java ExceptionParameters.java
32 * @run main Driver ExceptionParameters
33 */
34 public class ExceptionParameters {
36 @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
37 public String exception() {
38 return "void exception() { try { new Object(); } catch(@TA Exception e) { } }";
39 }
41 @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
42 public String finalException() {
43 return "void finalException() { try { new Object(); } catch(final @TA Exception e) { } }";
44 }
46 @TADescriptions({
47 @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0),
48 @TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1),
49 @TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
50 })
51 public String multipleExceptions1() {
52 return "void multipleExceptions() { " +
53 "try { new Object(); } catch(@TA Exception e) { }" +
54 "try { new Object(); } catch(@TB Exception e) { }" +
55 "try { new Object(); } catch(@TC Exception e) { }" +
56 " }";
57 }
59 @TADescriptions({
60 @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0),
61 @TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1),
62 @TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
63 })
64 public String multipleExceptions2() {
65 return "void multipleExceptions() { " +
66 " try { new Object(); " +
67 " try { new Object(); " +
68 " try { new Object(); } catch(@TA Exception e) { }" +
69 " } catch(@TB Exception e) { }" +
70 " } catch(@TC Exception e) { }" +
71 "}";
72 }
74 @TADescriptions({
75 @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0),
76 @TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1),
77 @TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2)
78 })
79 public String multipleExceptions3() {
80 return "void multipleExceptions() { " +
81 " try { new Object(); " +
82 " } catch(@TA Exception e1) { "+
83 " try { new Object(); " +
84 " } catch(@TB Exception e2) {" +
85 " try { new Object(); } catch(@TC Exception e3) { }" +
86 " }" +
87 " }" +
88 "}";
89 }
90 }