MethodReceivers.java revision 2942:08092deced3f
1246122Shselasky/* 2213379Shselasky * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. 3213379Shselasky * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4213379Shselasky * 5213379Shselasky * This code is free software; you can redistribute it and/or modify it 6213379Shselasky * under the terms of the GNU General Public License version 2 only, as 7213379Shselasky * published by the Free Software Foundation. 8213379Shselasky * 9213379Shselasky * This code is distributed in the hope that it will be useful, but WITHOUT 10213379Shselasky * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11213379Shselasky * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12213379Shselasky * version 2 for more details (a copy is included in the LICENSE file that 13213379Shselasky * accompanied this code). 14213379Shselasky * 15213379Shselasky * You should have received a copy of the GNU General Public License version 16213379Shselasky * 2 along with this work; if not, write to the Free Software Foundation, 17213379Shselasky * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18213379Shselasky * 19213379Shselasky * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20213379Shselasky * or visit www.oracle.com if you need additional information or have any 21213379Shselasky * questions. 22213379Shselasky */ 23213379Shselasky 24213379Shselaskyimport static com.sun.tools.classfile.TypeAnnotation.TargetType.*; 25213379Shselasky 26213379Shselasky/* 27213379Shselasky * @test 28213379Shselasky * @bug 8042451 29213379Shselasky * @summary Test population of reference info for method receivers 30213379Shselasky * @modules jdk.jdeps/com.sun.tools.classfile 31213379Shselasky * @compile -g Driver.java ReferenceInfoUtil.java MethodReceivers.java 32213379Shselasky * @run main Driver MethodReceivers 33213379Shselasky */ 34213379Shselaskypublic class MethodReceivers { 35213379Shselasky 36213379Shselasky @TADescription(annotation = "TA", type = METHOD_RECEIVER) 37213379Shselasky public String regularMethod() { 38213379Shselasky return "class %TEST_CLASS_NAME% { void test(@TA %TEST_CLASS_NAME% this) { } }"; 39248554Shselasky } 40248554Shselasky 41213379Shselasky @TADescription(annotation = "TA", type = METHOD_RECEIVER) 42213379Shselasky public String abstractMethod() { 43246122Shselasky return "abstract class %TEST_CLASS_NAME% { abstract void test(@TA %TEST_CLASS_NAME% this); }"; 44246122Shselasky } 45246122Shselasky 46213379Shselasky @TADescription(annotation = "TA", type = METHOD_RECEIVER) 47213379Shselasky public String interfaceMethod() { 48213379Shselasky return "interface %TEST_CLASS_NAME% { void test(@TA %TEST_CLASS_NAME% this); }"; 49213379Shselasky } 50213379Shselasky 51213379Shselasky @TADescription(annotation = "TA", type = METHOD_RECEIVER) 52213379Shselasky public String regularWithThrows() { 53213379Shselasky return "class %TEST_CLASS_NAME% { void test(@TA %TEST_CLASS_NAME% this) throws Exception { } }"; 54213379Shselasky } 55213379Shselasky 56213379Shselasky @TADescription(annotation = "TA", type = METHOD_RECEIVER, 57213379Shselasky genericLocation = {}) 58213379Shselasky @TADescription(annotation = "TB", type = METHOD_RECEIVER, 59213379Shselasky genericLocation = {1, 0}) 60213379Shselasky @TestClass("%TEST_CLASS_NAME%$TestInner") 61213379Shselasky public String nestedtypes1() { 62213379Shselasky return "class %TEST_CLASS_NAME% { class TestInner { void test(@TA %TEST_CLASS_NAME%. @TB TestInner this) { } } }"; 63213379Shselasky } 64213379Shselasky 65213379Shselasky @TADescription(annotation = "TA", type = METHOD_RECEIVER, 66213379Shselasky genericLocation = {}) 67213379Shselasky @TestClass("%TEST_CLASS_NAME%$TestInner") 68213379Shselasky public String nestedtypes2() { 69213379Shselasky return "class %TEST_CLASS_NAME% { class TestInner { void test(@TA %TEST_CLASS_NAME%.TestInner this) { } } }"; 70213379Shselasky } 71213379Shselasky 72213379Shselasky @TADescription(annotation = "TB", type = METHOD_RECEIVER, 73213379Shselasky genericLocation = {1, 0}) 74213379Shselasky @TestClass("%TEST_CLASS_NAME%$TestInner") 75213379Shselasky public String nestedtypes3() { 76213379Shselasky return "class %TEST_CLASS_NAME% { class TestInner { void test(%TEST_CLASS_NAME%. @TB TestInner this) { } } }"; 77213379Shselasky } 78213379Shselasky 79213379Shselasky @TADescription(annotation = "RTAs", type = METHOD_RECEIVER) 80213379Shselasky public String regularMethodRepeatableAnnotation() { 81246122Shselasky return "class %TEST_CLASS_NAME% { void test(@RTA @RTA %TEST_CLASS_NAME% this) { } }"; 82246122Shselasky } 83213379Shselasky 84213379Shselasky @TADescription(annotation = "RTAs", type = METHOD_RECEIVER) 85213379Shselasky public String abstractMethodRepeatablaAnnotation() { 86213379Shselasky return "abstract class %TEST_CLASS_NAME% { abstract void test(@RTA @RTA %TEST_CLASS_NAME% this); }"; 87213379Shselasky } 88213379Shselasky 89213379Shselasky @TADescription(annotation = "RTAs", type = METHOD_RECEIVER) 90255347Shselasky public String interfaceMethodRepeatableAnnotation() { 91255347Shselasky return "interface %TEST_CLASS_NAME% { void test(@RTA @RTA %TEST_CLASS_NAME% this); }"; 92255347Shselasky } 93255347Shselasky 94255347Shselasky @TADescription(annotation = "RTAs", type = METHOD_RECEIVER) 95255347Shselasky public String regularWithThrowsRepeatableAnnotation() { 96255347Shselasky return "class %TEST_CLASS_NAME% { void test(@RTA @RTA %TEST_CLASS_NAME% this) throws Exception { } }"; 97213379Shselasky } 98239617Shselasky 99239617Shselasky @TADescription(annotation = "RTAs", type = METHOD_RECEIVER, 100251499Shselasky genericLocation = {}) 101213379Shselasky @TADescription(annotation = "RTBs", type = METHOD_RECEIVER, 102242126Shselasky genericLocation = {1, 0}) 103213379Shselasky @TestClass("%TEST_CLASS_NAME%$TestInner") 104242126Shselasky public String nestedtypesRepeatableAnnotation1() { 105242126Shselasky return "class %TEST_CLASS_NAME% { class TestInner { void test(@RTA @RTA %TEST_CLASS_NAME%. @RTB @RTB TestInner this) { } } }"; 106239617Shselasky } 107239617Shselasky 108251499Shselasky @TADescription(annotation = "RTAs", type = METHOD_RECEIVER, 109251499Shselasky genericLocation = {}) 110251499Shselasky @TestClass("%TEST_CLASS_NAME%$TestInner") 111255768Shselasky public String nestedtypesRepeatableAnnotation2() { 112255768Shselasky return "class %TEST_CLASS_NAME% { class TestInner { void test(@RTA @RTA %TEST_CLASS_NAME%.TestInner this) { } } }"; 113213379Shselasky } 114213379Shselasky 115213379Shselasky @TADescription(annotation = "RTBs", type = METHOD_RECEIVER, 116213379Shselasky genericLocation = {1, 0}) 117213379Shselasky @TestClass("%TEST_CLASS_NAME%$TestInner") 118213379Shselasky public String nestedtypesRepeatableAnnotation3() { 119213379Shselasky return "class %TEST_CLASS_NAME% { class TestInner { void test(%TEST_CLASS_NAME%. @RTB @RTB TestInner this) { } } }"; 120213379Shselasky } 121213379Shselasky} 122213379Shselasky