1 /* 2 * Copyright (c) 2013, 2015, 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 */ 23 24 import static com.sun.tools.classfile.TypeAnnotation.TargetType.*; 25 26 /* 27 * @test 28 * @bug 8028576 8042451 29 * @summary Test population of reference info for exception parameters 30 * @author Werner Dietl 31 * @modules jdk.jdeps/com.sun.tools.classfile 32 * @compile -g Driver.java ReferenceInfoUtil.java ExceptionParameters.java 33 * @run main Driver ExceptionParameters 34 */ 35 public class ExceptionParameters { 36 37 @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0) exception()38 public String exception() { 39 return "void exception() { try { new Object(); } catch(@TA Exception e) { } }"; 40 } 41 42 @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0) finalException()43 public String finalException() { 44 return "void finalException() { try { new Object(); } catch(final @TA Exception e) { } }"; 45 } 46 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) multipleExceptions1()50 public String multipleExceptions1() { 51 return "void multipleExceptions() { " + 52 "try { new Object(); } catch(@TA Exception e) { }" + 53 "try { new Object(); } catch(@TB Exception e) { }" + 54 "try { new Object(); } catch(@TC Exception e) { }" + 55 " }"; 56 } 57 58 @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0) 59 @TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1) 60 @TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2) multipleExceptions2()61 public String multipleExceptions2() { 62 return "void multipleExceptions() { " + 63 " try { new Object(); " + 64 " try { new Object(); " + 65 " try { new Object(); } catch(@TA Exception e) { }" + 66 " } catch(@TB Exception e) { }" + 67 " } catch(@TC Exception e) { }" + 68 "}"; 69 } 70 71 @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0) 72 @TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1) 73 @TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2) multipleExceptions3()74 public String multipleExceptions3() { 75 return "void multipleExceptions() { " + 76 " try { new Object(); " + 77 " } catch(@TA Exception e1) { "+ 78 " try { new Object(); " + 79 " } catch(@TB Exception e2) {" + 80 " try { new Object(); } catch(@TC Exception e3) { }" + 81 " }" + 82 " }" + 83 "}"; 84 } 85 86 @TADescription(annotation = "RTAs", type = EXCEPTION_PARAMETER, exceptionIndex = 0) exceptionRepeatableAnnotation()87 public String exceptionRepeatableAnnotation() { 88 return "void exception() { try { new Object(); } catch(@RTA @RTA Exception e) { } }"; 89 } 90 91 @TADescription(annotation = "RTAs", type = EXCEPTION_PARAMETER, exceptionIndex = 0) 92 @TADescription(annotation = "RTBs", type = EXCEPTION_PARAMETER, exceptionIndex = 1) 93 @TADescription(annotation = "RTCs", type = EXCEPTION_PARAMETER, exceptionIndex = 2) multipleExceptionsRepeatableAnnotation1()94 public String multipleExceptionsRepeatableAnnotation1() { 95 return "void multipleExceptions() { " + 96 "try { new Object(); } catch(@RTA @RTA Exception e) { }" + 97 "try { new Object(); } catch(@RTB @RTB Exception e) { }" + 98 "try { new Object(); } catch(@RTC @RTC Exception e) { }" + 99 " }"; 100 } 101 102 @TADescription(annotation = "RTAs", type = EXCEPTION_PARAMETER, exceptionIndex = 0) 103 @TADescription(annotation = "RTBs", type = EXCEPTION_PARAMETER, exceptionIndex = 1) 104 @TADescription(annotation = "RTCs", type = EXCEPTION_PARAMETER, exceptionIndex = 2) multipleExceptionsRepeatableAnnotation2()105 public String multipleExceptionsRepeatableAnnotation2() { 106 return "void multipleExceptions() { " + 107 " try { new Object(); " + 108 " try { new Object(); " + 109 " try { new Object(); } catch(@RTA @RTA Exception e) { }" + 110 " } catch(@RTB @RTB Exception e) { }" + 111 " } catch(@RTC @RTC Exception e) { }" + 112 "}"; 113 } 114 115 @TADescription(annotation = "RTAs", type = EXCEPTION_PARAMETER, exceptionIndex = 0) 116 @TADescription(annotation = "RTBs", type = EXCEPTION_PARAMETER, exceptionIndex = 1) 117 @TADescription(annotation = "RTCs", type = EXCEPTION_PARAMETER, exceptionIndex = 2) multipleExceptionsRepeatableAnnotation3()118 public String multipleExceptionsRepeatableAnnotation3() { 119 return "void multipleExceptions() { " + 120 " try { new Object(); " + 121 " } catch(@RTA @RTA Exception e1) { "+ 122 " try { new Object(); " + 123 " } catch(@RTB @RTB Exception e2) {" + 124 " try { new Object(); } catch(@RTC @RTC Exception e3) { }" + 125 " }" + 126 " }" + 127 "}"; 128 } 129 } 130