1 /*
2 * Copyright (c) 2013, 2017, 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 {
56 WithFinal afield;
plain(final @RcvrB(R) WithFinal afield)57 void plain(final @RcvrB("m") WithFinal afield) { }
generic(final @RcvrB(R) WithFinal afield)58 <T> void generic(final @RcvrB("m") WithFinal afield) { }
withException(final @RcvrB(R) WithFinal afield)59 void withException(final @RcvrB("m") WithFinal afield) throws Exception { }
nonVoid(final @RcvrB(R) WithFinal afield)60 String nonVoid(final @RcvrB("m") WithFinal afield) { return null; }
accept(final @RcvrB(R) WithFinal afield, T r)61 <T extends Runnable> void accept(final @RcvrB("m") WithFinal afield, T r) throws Exception { }
62 }
63
64 class WithBody {
65 Object f;
66
field(@cvrA WithBody this)67 void field(@RcvrA WithBody this) {
68 this.f = null;
69 }
meth(@cvrA WithBody this)70 void meth(@RcvrA WithBody this) {
71 this.toString();
72 }
73 }
74
75 class Generic1<X> {
test1(Generic1<X> this)76 void test1(Generic1<X> this) {}
test2(@cvrA Generic1<X> this)77 void test2(@RcvrA Generic1<X> this) {}
test3(Generic1<@RcvrA X> this)78 void test3(Generic1<@RcvrA X> this) {}
test4(@cvrA Generic1<@RcvrA X> this)79 void test4(@RcvrA Generic1<@RcvrA X> this) {}
80 }
81
82 class Generic2<@RcvrA X> {
test1(Generic2<X> this)83 void test1(Generic2<X> this) {}
test2(@cvrA Generic2<X> this)84 void test2(@RcvrA Generic2<X> this) {}
test3(Generic2<@RcvrA X> this)85 void test3(Generic2<@RcvrA X> this) {}
test4(@cvrA Generic2<@RcvrA X> this)86 void test4(@RcvrA Generic2<@RcvrA X> this) {}
87 }
88
89 class Generic3<X extends @RcvrA Object> {
test1(Generic3<X> this)90 void test1(Generic3<X> this) {}
test2(@cvrA Generic3<X> this)91 void test2(@RcvrA Generic3<X> this) {}
test3(Generic3<@RcvrA X> this)92 void test3(Generic3<@RcvrA X> this) {}
test4(@cvrA Generic3<@RcvrA X> this)93 void test4(@RcvrA Generic3<@RcvrA X> this) {}
94 }
95
96 class Generic4<X extends @RcvrA Object> {
test1(Generic4<X> this)97 <Y> void test1(Generic4<X> this) {}
test2(@cvrA Generic4<X> this)98 <Y> void test2(@RcvrA Generic4<X> this) {}
test3(Generic4<@RcvrA X> this)99 <Y> void test3(Generic4<@RcvrA X> this) {}
test4(@cvrA Generic4<@RcvrA X> this)100 <Y> void test4(@RcvrA Generic4<@RcvrA X> this) {}
101 }
102
103 class Outer {
104 class Inner {
none(Outer.Inner this)105 void none(Outer.Inner this) {}
outer(@cvrA Outer.Inner this)106 void outer(@RcvrA Outer.Inner this) {}
inner(Outer. @cvrBR) Inner this)107 void inner(Outer. @RcvrB("i") Inner this) {}
both(@cvrA Outer.@cvrBR) Inner this)108 void both(@RcvrA Outer.@RcvrB("i") Inner this) {}
109
innerOnlyNone(Inner this)110 void innerOnlyNone(Inner this) {}
innerOnly(@cvrA Inner this)111 void innerOnly(@RcvrA Inner this) {}
112 }
113 }
114
115 class GenericOuter<S, T> {
116 class GenericInner<U, V> {
none(GenericOuter<S, T>.GenericInner<U, V> this)117 void none(GenericOuter<S, T>.GenericInner<U, V> this) {}
outer(@cvrA GenericOuter<S, T>.GenericInner<U, V> this)118 void outer(@RcvrA GenericOuter<S, T>.GenericInner<U, V> this) {}
inner(GenericOuter<S, T>. @RcvrB(R) GenericInner<U, V> this)119 void inner(GenericOuter<S, T>. @RcvrB("i") GenericInner<U, V> this) {}
both(@cvrA GenericOuter<S, T>.@RcvrB(R) GenericInner<U, V> this)120 void both(@RcvrA GenericOuter<S, T>.@RcvrB("i") GenericInner<U, V> this) {}
121
innerOnlyNone(GenericInner<U, V> this)122 void innerOnlyNone(GenericInner<U, V> this) {}
innerOnly(@cvrA GenericInner<U, V> this)123 void innerOnly(@RcvrA GenericInner<U, V> this) {}
124 }
125 }
126
127 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
128 @Documented
129 @interface RcvrA {}
130 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
131 @Documented
value()132 @interface RcvrB { String value(); }
133