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