MethodReceivers.java revision 1520:71f35e4b93a5
189400Smike/*
241762Swes * Copyright (c) 2009 Oracle and/or its affiliates. All rights reserved.
341762Swes * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
441762Swes *
541762Swes * This code is free software; you can redistribute it and/or modify it
641762Swes * under the terms of the GNU General Public License version 2 only, as
71573Srgrimes * published by the Free Software Foundation.
81573Srgrimes *
91573Srgrimes * This code is distributed in the hope that it will be useful, but WITHOUT
101573Srgrimes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
111573Srgrimes * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
121573Srgrimes * version 2 for more details (a copy is included in the LICENSE file that
131573Srgrimes * accompanied this code).
1441762Swes *
151573Srgrimes * You should have received a copy of the GNU General Public License version
1641762Swes * 2 along with this work; if not, write to the Free Software Foundation,
171573Srgrimes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18251069Semaste *
191573Srgrimes * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
201573Srgrimes * or visit www.oracle.com if you need additional information or have any
211573Srgrimes * questions.
2241762Swes */
2341762Swes
2441762Swesimport static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
2541762Swes
2641762Swes/*
2741762Swes * @test
2841762Swes * @summary Test population of reference info for method receivers
2941762Swes * @compile -g Driver.java ReferenceInfoUtil.java MethodReceivers.java
3041762Swes * @run main Driver MethodReceivers
3141762Swes */
3241762Swespublic class MethodReceivers {
331573Srgrimes
341573Srgrimes    @TADescription(annotation = "TA", type = METHOD_RECEIVER)
3589400Smike    public String regularMethod() {
3689400Smike        return "class Test { void test(@TA Test this) { } }";
3789400Smike    }
3892986Sobrien
3992986Sobrien    @TADescription(annotation = "TA", type = METHOD_RECEIVER)
4089400Smike    public String abstractMethod() {
411573Srgrimes        return "abstract class Test { abstract void test(@TA Test this); }";
4289387Smike    }
4389387Smike
4489387Smike    @TADescription(annotation = "TA", type = METHOD_RECEIVER)
451573Srgrimes    public String interfaceMethod() {
461573Srgrimes        return "interface Test { void test(@TA Test this); }";
47103057Stjr    }
48103057Stjr
49103057Stjr    @TADescription(annotation = "TA", type = METHOD_RECEIVER)
50103057Stjr    public String regularWithThrows() {
511573Srgrimes        return "class Test { void test(@TA Test this) throws Exception { } }";
52103057Stjr    }
531573Srgrimes
5489400Smike    @TADescriptions({
5589385Smike        @TADescription(annotation = "TA", type = METHOD_RECEIVER,
561573Srgrimes                genericLocation = {}),
5789385Smike        @TADescription(annotation = "TB", type = METHOD_RECEIVER,
5889385Smike                genericLocation = {1, 0})
591573Srgrimes    })
6089385Smike    @TestClass("TestOuter$TestInner")
6189385Smike    public String nestedtypes1() {
6289385Smike        return "class TestOuter { class TestInner { void test(@TA TestOuter. @TB TestInner this) { } } }";
6341762Swes    }
6489385Smike
6589400Smike    @TADescription(annotation = "TA", type = METHOD_RECEIVER,
6689385Smike            genericLocation = {})
6789385Smike    @TestClass("TestOuter$TestInner")
6889400Smike    public String nestedtypes2() {
6989385Smike        return "class TestOuter { class TestInner { void test(@TA TestOuter.TestInner this) { } } }";
7089385Smike    }
7189385Smike
7289385Smike    @TADescription(annotation = "TB", type = METHOD_RECEIVER,
7341762Swes            genericLocation = {1, 0})
7489385Smike    @TestClass("TestOuter$TestInner")
751573Srgrimes    public String nestedtypes3() {
7689385Smike        return "class TestOuter { class TestInner { void test(TestOuter. @TB TestInner this) { } } }";
7789385Smike    }
7889385Smike
7989385Smike}
8089385Smike