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