1 /*
   2  * Copyright (c) 2009, 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  * @summary Test population of reference info for method receivers
  29  * @compile -g Driver.java ReferenceInfoUtil.java MethodReceivers.java
  30  * @run main Driver MethodReceivers
  31  */
  32 public class MethodReceivers {
  33 
  34     @TADescription(annotation = "TA", type = METHOD_RECEIVER)
  35     public String regularMethod() {
  36         return "class Test { void test(@TA Test this) { } }";
  37     }
  38 
  39     @TADescription(annotation = "TA", type = METHOD_RECEIVER)
  40     public String abstractMethod() {
  41         return "abstract class Test { abstract void test(@TA Test this); }";
  42     }
  43 
  44     @TADescription(annotation = "TA", type = METHOD_RECEIVER)
  45     public String interfaceMethod() {
  46         return "interface Test { void test(@TA Test this); }";
  47     }
  48 
  49     @TADescription(annotation = "TA", type = METHOD_RECEIVER)
  50     public String regularWithThrows() {
  51         return "class Test { void test(@TA Test this) throws Exception { } }";
  52     }
  53 
  54     @TADescriptions({
  55         @TADescription(annotation = "TA", type = METHOD_RECEIVER,
  56                 genericLocation = {}),
  57         @TADescription(annotation = "TB", type = METHOD_RECEIVER,
  58                 genericLocation = {1, 0})
  59     })
  60     @TestClass("TestOuter$TestInner")
  61     public String nestedtypes1() {
  62         return "class TestOuter { class TestInner { void test(@TA TestOuter. @TB TestInner this) { } } }";
  63     }
  64 
  65     @TADescription(annotation = "TA", type = METHOD_RECEIVER,
  66             genericLocation = {})
  67     @TestClass("TestOuter$TestInner")
  68     public String nestedtypes2() {
  69         return "class TestOuter { class TestInner { void test(@TA TestOuter.TestInner this) { } } }";
  70     }
  71 
  72     @TADescription(annotation = "TB", type = METHOD_RECEIVER,
  73             genericLocation = {1, 0})
  74     @TestClass("TestOuter$TestInner")
  75     public String nestedtypes3() {
  76         return "class TestOuter { class TestInner { void test(TestOuter. @TB TestInner this) { } } }";
  77     }
  78 
  79 }