1 /* 2 * Copyright (c) 2009, 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 8042451 29 * @summary Test population of reference info for method receivers 30 * @modules jdk.jdeps/com.sun.tools.classfile 31 * @compile -g Driver.java ReferenceInfoUtil.java MethodReceivers.java 32 * @run main Driver MethodReceivers 33 */ 34 public class MethodReceivers { 35 36 @TADescription(annotation = "TA", type = METHOD_RECEIVER) 37 public String regularMethod() { 38 return "class %TEST_CLASS_NAME% { void test(@TA %TEST_CLASS_NAME% this) { } }"; 39 } 40 41 @TADescription(annotation = "TA", type = METHOD_RECEIVER) 42 public String abstractMethod() { 43 return "abstract class %TEST_CLASS_NAME% { abstract void test(@TA %TEST_CLASS_NAME% this); }"; 44 } 45 46 @TADescription(annotation = "TA", type = METHOD_RECEIVER) 47 public String interfaceMethod() { 48 return "interface %TEST_CLASS_NAME% { void test(@TA %TEST_CLASS_NAME% this); }"; 49 } 50 51 @TADescription(annotation = "TA", type = METHOD_RECEIVER) 52 public String regularWithThrows() { 53 return "class %TEST_CLASS_NAME% { void test(@TA %TEST_CLASS_NAME% this) throws Exception { } }"; 54 } 55 56 @TADescription(annotation = "TA", type = METHOD_RECEIVER, 57 genericLocation = {}) 58 @TADescription(annotation = "TB", type = METHOD_RECEIVER, 59 genericLocation = {1, 0}) 60 @TestClass("%TEST_CLASS_NAME%$TestInner") 61 public String nestedtypes1() { 62 return "class %TEST_CLASS_NAME% { class TestInner { void test(@TA %TEST_CLASS_NAME%. @TB TestInner this) { } } }"; 63 } 64 65 @TADescription(annotation = "TA", type = METHOD_RECEIVER, 66 genericLocation = {}) 67 @TestClass("%TEST_CLASS_NAME%$TestInner") 68 public String nestedtypes2() { 69 return "class %TEST_CLASS_NAME% { class TestInner { void test(@TA %TEST_CLASS_NAME%.TestInner this) { } } }"; 70 } 71 72 @TADescription(annotation = "TB", type = METHOD_RECEIVER, 73 genericLocation = {1, 0}) 74 @TestClass("%TEST_CLASS_NAME%$TestInner") 75 public String nestedtypes3() { 76 return "class %TEST_CLASS_NAME% { class TestInner { void test(%TEST_CLASS_NAME%. @TB TestInner this) { } } }"; 77 } 78 79 @TADescription(annotation = "RTAs", type = METHOD_RECEIVER) 80 public String regularMethodRepeatableAnnotation() { 81 return "class %TEST_CLASS_NAME% { void test(@RTA @RTA %TEST_CLASS_NAME% this) { } }"; 82 } 83 84 @TADescription(annotation = "RTAs", type = METHOD_RECEIVER) 85 public String abstractMethodRepeatablaAnnotation() { 86 return "abstract class %TEST_CLASS_NAME% { abstract void test(@RTA @RTA %TEST_CLASS_NAME% this); }"; 87 } 88 89 @TADescription(annotation = "RTAs", type = METHOD_RECEIVER) 90 public String interfaceMethodRepeatableAnnotation() { 91 return "interface %TEST_CLASS_NAME% { void test(@RTA @RTA %TEST_CLASS_NAME% this); }"; 92 } 93 94 @TADescription(annotation = "RTAs", type = METHOD_RECEIVER) 95 public String regularWithThrowsRepeatableAnnotation() { 96 return "class %TEST_CLASS_NAME% { void test(@RTA @RTA %TEST_CLASS_NAME% this) throws Exception { } }"; 97 } 98 99 @TADescription(annotation = "RTAs", type = METHOD_RECEIVER, 100 genericLocation = {}) 101 @TADescription(annotation = "RTBs", type = METHOD_RECEIVER, 102 genericLocation = {1, 0}) 103 @TestClass("%TEST_CLASS_NAME%$TestInner") 104 public String nestedtypesRepeatableAnnotation1() { 105 return "class %TEST_CLASS_NAME% { class TestInner { void test(@RTA @RTA %TEST_CLASS_NAME%. @RTB @RTB TestInner this) { } } }"; 106 } 107 108 @TADescription(annotation = "RTAs", type = METHOD_RECEIVER, 109 genericLocation = {}) 110 @TestClass("%TEST_CLASS_NAME%$TestInner") 111 public String nestedtypesRepeatableAnnotation2() { 112 return "class %TEST_CLASS_NAME% { class TestInner { void test(@RTA @RTA %TEST_CLASS_NAME%.TestInner this) { } } }"; 113 } 114 115 @TADescription(annotation = "RTBs", type = METHOD_RECEIVER, 116 genericLocation = {1, 0}) 117 @TestClass("%TEST_CLASS_NAME%$TestInner") 118 public String nestedtypesRepeatableAnnotation3() { 119 return "class %TEST_CLASS_NAME% { class TestInner { void test(%TEST_CLASS_NAME%. @RTB @RTB TestInner this) { } } }"; 120 } 121 }