Constructors.java revision 2823:e77eb6b8977e
1/* 2 * Copyright (c) 2012, 2013, 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/* 25 * @test 26 * @bug 8026791 8042451 27 * @summary Test population of reference info for constructor results 28 * @compile -g Driver.java ReferenceInfoUtil.java Constructors.java 29 * @run main Driver Constructors 30 */ 31 32import static com.sun.tools.classfile.TypeAnnotation.TargetType.*; 33 34public class Constructors { 35 36 @TADescription(annotation = "TA", type = METHOD_RETURN) 37 @TADescription(annotation = "TB", type = METHOD_RETURN) 38 @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0) 39 public String regularClass() { 40 return "class %TEST_CLASS_NAME% { @TA %TEST_CLASS_NAME%() {}" + 41 " @TB %TEST_CLASS_NAME%(@TC int b) {} }"; 42 } 43 44 @TADescription(annotation = "TA", type = METHOD_RETURN, genericLocation = {1, 0}) 45 @TADescription(annotation = "TB", type = METHOD_RETURN, genericLocation = {1, 0}) 46 @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0) 47 @TestClass("%TEST_CLASS_NAME%$Inner") 48 public String innerClass() { 49 return "class %TEST_CLASS_NAME% { class Inner {" + 50 " @TA Inner() {}" + 51 " @TB Inner(@TC int b) {}" + 52 " } }"; 53 } 54 55 @TADescription(annotation = "TA", type = METHOD_RECEIVER) 56 @TADescription(annotation = "TB", type = METHOD_RETURN, genericLocation = {1, 0}) 57 @TADescription(annotation = "TC", type = METHOD_RECEIVER) 58 @TADescription(annotation = "TD", type = METHOD_RETURN, genericLocation = {1, 0}) 59 @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER, paramIndex = 0) 60 @TestClass("%TEST_CLASS_NAME%$Inner") 61 public String innerClass2() { 62 return "class %TEST_CLASS_NAME% { class Inner {" + 63 " @TB Inner(@TA %TEST_CLASS_NAME% %TEST_CLASS_NAME%.this) {}" + 64 " @TD Inner(@TC %TEST_CLASS_NAME% %TEST_CLASS_NAME%.this, @TE int b) {}" + 65 " } }"; 66 } 67 68 @TADescription(annotation = "TA", type = METHOD_RECEIVER) 69 @TADescription(annotation = "TB", type = METHOD_RECEIVER, genericLocation = {1, 0}) 70 @TADescription(annotation = "TC", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0}) 71 @TADescription(annotation = "TD", type = METHOD_RECEIVER, genericLocation = {1, 0}) 72 @TADescription(annotation = "TE", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0}) 73 @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER, paramIndex = 0) 74 @TestClass("Outer$Middle$Inner") 75 public String innerClass3() { 76 return "class Outer { class Middle { class Inner {" + 77 " @TC Inner(@TA Outer. @TB Middle Middle.this) {}" + 78 " @TE Inner(@TD Middle Outer.Middle.this, @TF int b) {}" + 79 " } } }"; 80 } 81 82 @TADescription(annotation = "RTAs", type = METHOD_RETURN) 83 @TADescription(annotation = "RTBs", type = METHOD_RETURN) 84 @TADescription(annotation = "RTCs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0) 85 public String regularClassRepeatableAnnotation() { 86 return "class %TEST_CLASS_NAME% { @RTA @RTA %TEST_CLASS_NAME%() {}" + 87 " @RTB @RTB %TEST_CLASS_NAME%(@RTC @RTC int b) {} }"; 88 } 89 90 @TADescription(annotation = "RTAs", type = METHOD_RETURN, genericLocation = {1, 0}) 91 @TADescription(annotation = "RTBs", type = METHOD_RETURN, genericLocation = {1, 0}) 92 @TADescription(annotation = "RTCs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0) 93 @TestClass("%TEST_CLASS_NAME%$Inner") 94 public String innerClassRepeatableAnnotation() { 95 return "class %TEST_CLASS_NAME% { class Inner {" + 96 " @RTA @RTA Inner() {}" + 97 " @RTB @RTB Inner(@RTC @RTC int b) {}" + 98 " } }"; 99 } 100 101 @TADescription(annotation = "RTAs", type = METHOD_RECEIVER) 102 @TADescription(annotation = "RTBs", type = METHOD_RETURN, genericLocation = {1, 0}) 103 @TADescription(annotation = "RTCs", type = METHOD_RECEIVER) 104 @TADescription(annotation = "RTDs", type = METHOD_RETURN, genericLocation = {1, 0}) 105 @TADescription(annotation = "RTEs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0) 106 @TestClass("%TEST_CLASS_NAME%$Inner") 107 public String innerClassRepeatableAnnotation2() { 108 return "class %TEST_CLASS_NAME% { class Inner {" + 109 " @RTB @RTB Inner(@RTA @RTA %TEST_CLASS_NAME% %TEST_CLASS_NAME%.this) {}" + 110 " @RTD @RTD Inner(@RTC @RTC %TEST_CLASS_NAME% %TEST_CLASS_NAME%.this, @RTE @RTE int b) {}" + 111 " } }"; 112 } 113 114 @TADescription(annotation = "RTAs", type = METHOD_RECEIVER) 115 @TADescription(annotation = "RTBs", type = METHOD_RECEIVER, genericLocation = {1, 0}) 116 @TADescription(annotation = "RTCs", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0}) 117 @TADescription(annotation = "RTDs", type = METHOD_RECEIVER, genericLocation = {1, 0}) 118 @TADescription(annotation = "RTEs", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0}) 119 @TADescription(annotation = "RTFs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0) 120 @TestClass("Outer$Middle$Inner") 121 public String innerClassRepatableAnnotation3() { 122 return "class Outer { class Middle { class Inner {" + 123 " @RTC @RTC Inner(@RTA @RTA Outer. @RTB @RTB Middle Middle.this) {}" + 124 " @RTE @RTE Inner(@RTD @RTD Middle Outer.Middle.this, @RTF @RTF int b) {}" + 125 " } } }"; 126 } 127} 128