test/tools/javac/annotations/typeAnnotations/newlocations/Receivers.java

Wed, 27 Apr 2016 01:34:52 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:34:52 +0800
changeset 0
959103a6100f
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/langtools/
changeset: 2573:53ca196be1ae
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 */
aoqi@0 23
aoqi@0 24 import java.lang.annotation.*;
aoqi@0 25
aoqi@0 26 /*
aoqi@0 27 * @test
aoqi@0 28 * @bug 6843077 8006775
aoqi@0 29 * @summary new type annotation location: receivers
aoqi@0 30 * @author Mahmood Ali, Werner Dietl
aoqi@0 31 * @compile Receivers.java
aoqi@0 32 */
aoqi@0 33 class DefaultUnmodified {
aoqi@0 34 void plain(@A DefaultUnmodified this) { }
aoqi@0 35 <T> void generic(@A DefaultUnmodified this) { }
aoqi@0 36 void withException(@A DefaultUnmodified this) throws Exception { }
aoqi@0 37 String nonVoid(@A DefaultUnmodified this) { return null; }
aoqi@0 38 <T extends Runnable> void accept(@A DefaultUnmodified this, T r) throws Exception { }
aoqi@0 39 }
aoqi@0 40
aoqi@0 41 class PublicModified {
aoqi@0 42 public final void plain(@A PublicModified this) { }
aoqi@0 43 public final <T> void generic(@A PublicModified this) { }
aoqi@0 44 public final void withException(@A PublicModified this) throws Exception { }
aoqi@0 45 public final String nonVoid(@A PublicModified this) { return null; }
aoqi@0 46 public final <T extends Runnable> void accept(@A PublicModified this, T r) throws Exception { }
aoqi@0 47 }
aoqi@0 48
aoqi@0 49 class WithValue {
aoqi@0 50 void plain(@B("m") WithValue this) { }
aoqi@0 51 <T> void generic(@B("m") WithValue this) { }
aoqi@0 52 void withException(@B("m") WithValue this) throws Exception { }
aoqi@0 53 String nonVoid(@B("m") WithValue this) { return null; }
aoqi@0 54 <T extends Runnable> void accept(@B("m") WithValue this, T r) throws Exception { }
aoqi@0 55 }
aoqi@0 56
aoqi@0 57 class WithBody {
aoqi@0 58 Object f;
aoqi@0 59
aoqi@0 60 void field(@A WithBody this) {
aoqi@0 61 this.f = null;
aoqi@0 62 }
aoqi@0 63 void meth(@A WithBody this) {
aoqi@0 64 this.toString();
aoqi@0 65 }
aoqi@0 66 }
aoqi@0 67
aoqi@0 68 class Generic1<X> {
aoqi@0 69 void test1(Generic1<X> this) {}
aoqi@0 70 void test2(@A Generic1<X> this) {}
aoqi@0 71 void test3(Generic1<@A X> this) {}
aoqi@0 72 void test4(@A Generic1<@A X> this) {}
aoqi@0 73 }
aoqi@0 74
aoqi@0 75 class Generic2<@A X> {
aoqi@0 76 void test1(Generic2<X> this) {}
aoqi@0 77 void test2(@A Generic2<X> this) {}
aoqi@0 78 void test3(Generic2<@A X> this) {}
aoqi@0 79 void test4(@A Generic2<@A X> this) {}
aoqi@0 80 }
aoqi@0 81
aoqi@0 82 class Generic3<X extends @A Object> {
aoqi@0 83 void test1(Generic3<X> this) {}
aoqi@0 84 void test2(@A Generic3<X> this) {}
aoqi@0 85 void test3(Generic3<@A X> this) {}
aoqi@0 86 void test4(@A Generic3<@A X> this) {}
aoqi@0 87 }
aoqi@0 88
aoqi@0 89 class Generic4<X extends @A Object> {
aoqi@0 90 <Y> void test1(Generic4<X> this) {}
aoqi@0 91 <Y> void test2(@A Generic4<X> this) {}
aoqi@0 92 <Y> void test3(Generic4<@A X> this) {}
aoqi@0 93 <Y> void test4(@A Generic4<@A X> this) {}
aoqi@0 94 }
aoqi@0 95
aoqi@0 96 class Outer {
aoqi@0 97 class Inner {
aoqi@0 98 void none(Outer.Inner this) {}
aoqi@0 99 void outer(@A Outer.Inner this) {}
aoqi@0 100 void inner(Outer. @B("i") Inner this) {}
aoqi@0 101 void both(@A Outer.@B("i") Inner this) {}
aoqi@0 102
aoqi@0 103 void innerOnlyNone(Inner this) {}
aoqi@0 104 void innerOnly(@A Inner this) {}
aoqi@0 105 }
aoqi@0 106 }
aoqi@0 107
aoqi@0 108 class GenericOuter<S, T> {
aoqi@0 109 class GenericInner<U, V> {
aoqi@0 110 void none(GenericOuter<S, T>.GenericInner<U, V> this) {}
aoqi@0 111 void outer(@A GenericOuter<S, T>.GenericInner<U, V> this) {}
aoqi@0 112 void inner(GenericOuter<S, T>. @B("i") GenericInner<U, V> this) {}
aoqi@0 113 void both(@A GenericOuter<S, T>.@B("i") GenericInner<U, V> this) {}
aoqi@0 114
aoqi@0 115 void innerOnlyNone(GenericInner<U, V> this) {}
aoqi@0 116 void innerOnly(@A GenericInner<U, V> this) {}
aoqi@0 117 }
aoqi@0 118 }
aoqi@0 119
aoqi@0 120 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
aoqi@0 121 @interface A {}
aoqi@0 122 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
aoqi@0 123 @interface B { String value(); }

mercurial