1 /*
2  * Copyright (c) 2013, 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 package typeannos;
25 
26 import java.lang.annotation.*;
27 
28 /*
29  * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
30  */
31 class DefaultUnmodified {
plain(@cvrA DefaultUnmodified this)32     void plain(@RcvrA DefaultUnmodified this) { }
generic(@cvrA DefaultUnmodified this)33     <T> void generic(@RcvrA DefaultUnmodified this) { }
withException(@cvrA DefaultUnmodified this)34     void withException(@RcvrA DefaultUnmodified this) throws Exception { }
nonVoid(@cvrA @cvrBR) DefaultUnmodified this)35     String nonVoid(@RcvrA @RcvrB("m") DefaultUnmodified this) { return null; }
accept(@cvrA DefaultUnmodified this, T r)36     <T extends Runnable> void accept(@RcvrA DefaultUnmodified this, T r) throws Exception { }
37 }
38 
39 class PublicModified {
plain(@cvrA PublicModified this)40     public final void plain(@RcvrA PublicModified this) { }
generic(@cvrA PublicModified this)41     public final <T> void generic(@RcvrA PublicModified this) { }
withException(@cvrA PublicModified this)42     public final void withException(@RcvrA PublicModified this) throws Exception { }
nonVoid(@cvrA PublicModified this)43     public final String nonVoid(@RcvrA PublicModified this) { return null; }
accept(@cvrA PublicModified this, T r)44     public final <T extends Runnable> void accept(@RcvrA PublicModified this, T r) throws Exception { }
45 }
46 
47 class WithValue {
plain(@cvrBR) WithValue this)48     void plain(@RcvrB("m") WithValue this) { }
generic(@cvrBR) WithValue this)49     <T> void generic(@RcvrB("m") WithValue this) { }
withException(@cvrBR) WithValue this)50     void withException(@RcvrB("m") WithValue this) throws Exception { }
nonVoid(@cvrBR) WithValue this)51     String nonVoid(@RcvrB("m") WithValue this) { return null; }
accept(@cvrBR) WithValue this, T r)52     <T extends Runnable> void accept(@RcvrB("m") WithValue this, T r) throws Exception { }
53 }
54 
55 class WithFinal {
plain(final @RcvrB(R) WithFinal this)56     void plain(final @RcvrB("m") WithFinal this) { }
generic(final @RcvrB(R) WithFinal this)57     <T> void generic(final @RcvrB("m") WithFinal this) { }
withException(final @RcvrB(R) WithFinal this)58     void withException(final @RcvrB("m") WithFinal this) throws Exception { }
nonVoid(final @RcvrB(R) WithFinal this)59     String nonVoid(final @RcvrB("m") WithFinal this) { return null; }
accept(final @RcvrB(R) WithFinal this, T r)60     <T extends Runnable> void accept(final @RcvrB("m") WithFinal this, T r) throws Exception { }
61 }
62 
63 class WithBody {
64     Object f;
65 
field(@cvrA WithBody this)66     void field(@RcvrA WithBody this) {
67         this.f = null;
68     }
meth(@cvrA WithBody this)69     void meth(@RcvrA WithBody this) {
70         this.toString();
71     }
72 }
73 
74 class Generic1<X> {
test1(Generic1<X> this)75     void test1(Generic1<X> this) {}
test2(@cvrA Generic1<X> this)76     void test2(@RcvrA Generic1<X> this) {}
test3(Generic1<@RcvrA X> this)77     void test3(Generic1<@RcvrA X> this) {}
test4(@cvrA Generic1<@RcvrA X> this)78     void test4(@RcvrA Generic1<@RcvrA X> this) {}
79 }
80 
81 class Generic2<@RcvrA X> {
test1(Generic2<X> this)82     void test1(Generic2<X> this) {}
test2(@cvrA Generic2<X> this)83     void test2(@RcvrA Generic2<X> this) {}
test3(Generic2<@RcvrA X> this)84     void test3(Generic2<@RcvrA X> this) {}
test4(@cvrA Generic2<@RcvrA X> this)85     void test4(@RcvrA Generic2<@RcvrA X> this) {}
86 }
87 
88 class Generic3<X extends @RcvrA Object> {
test1(Generic3<X> this)89     void test1(Generic3<X> this) {}
test2(@cvrA Generic3<X> this)90     void test2(@RcvrA Generic3<X> this) {}
test3(Generic3<@RcvrA X> this)91     void test3(Generic3<@RcvrA X> this) {}
test4(@cvrA Generic3<@RcvrA X> this)92     void test4(@RcvrA Generic3<@RcvrA X> this) {}
93 }
94 
95 class Generic4<X extends @RcvrA Object> {
test1(Generic4<X> this)96     <Y> void test1(Generic4<X> this) {}
test2(@cvrA Generic4<X> this)97     <Y> void test2(@RcvrA Generic4<X> this) {}
test3(Generic4<@RcvrA X> this)98     <Y> void test3(Generic4<@RcvrA X> this) {}
test4(@cvrA Generic4<@RcvrA X> this)99     <Y> void test4(@RcvrA Generic4<@RcvrA X> this) {}
100 }
101 
102 class Outer {
103     class Inner {
none(Outer.Inner this)104         void none(Outer.Inner this) {}
outer(@cvrA Outer.Inner this)105         void outer(@RcvrA Outer.Inner this) {}
inner(Outer. @cvrBR) Inner this)106         void inner(Outer. @RcvrB("i") Inner this) {}
both(@cvrA Outer.@cvrBR) Inner this)107         void both(@RcvrA Outer.@RcvrB("i") Inner this) {}
108 
innerOnlyNone(Inner this)109         void innerOnlyNone(Inner this) {}
innerOnly(@cvrA Inner this)110         void innerOnly(@RcvrA Inner this) {}
111     }
112 }
113 
114 class GenericOuter<S, T> {
115     class GenericInner<U, V> {
none(GenericOuter<S, T>.GenericInner<U, V> this)116         void none(GenericOuter<S, T>.GenericInner<U, V> this) {}
outer(@cvrA GenericOuter<S, T>.GenericInner<U, V> this)117         void outer(@RcvrA GenericOuter<S, T>.GenericInner<U, V> this) {}
inner(GenericOuter<S, T>. @RcvrB(R) GenericInner<U, V> this)118         void inner(GenericOuter<S, T>. @RcvrB("i") GenericInner<U, V> this) {}
both(@cvrA GenericOuter<S, T>.@RcvrB(R) GenericInner<U, V> this)119         void both(@RcvrA GenericOuter<S, T>.@RcvrB("i") GenericInner<U, V> this) {}
120 
innerOnlyNone(GenericInner<U, V> this)121         void innerOnlyNone(GenericInner<U, V> this) {}
innerOnly(@cvrA GenericInner<U, V> this)122         void innerOnly(@RcvrA GenericInner<U, V> this) {}
123     }
124 }
125 
126 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
127 @Documented
128 @interface RcvrA {}
129 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
130 @Documented
value()131 @interface RcvrB { String value(); }
132