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