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

changeset 0
959103a6100f
child 2525
2eb010b6cb22
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/annotations/typeAnnotations/newlocations/Receivers.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,123 @@
     1.4 +/*
     1.5 + * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + */
    1.26 +
    1.27 +import java.lang.annotation.*;
    1.28 +
    1.29 +/*
    1.30 + * @test
    1.31 + * @bug 6843077 8006775
    1.32 + * @summary new type annotation location: receivers
    1.33 + * @author Mahmood Ali, Werner Dietl
    1.34 + * @compile Receivers.java
    1.35 + */
    1.36 +class DefaultUnmodified {
    1.37 +  void plain(@A DefaultUnmodified this) { }
    1.38 +  <T> void generic(@A DefaultUnmodified this) { }
    1.39 +  void withException(@A DefaultUnmodified this) throws Exception { }
    1.40 +  String nonVoid(@A DefaultUnmodified this) { return null; }
    1.41 +  <T extends Runnable> void accept(@A DefaultUnmodified this, T r) throws Exception { }
    1.42 +}
    1.43 +
    1.44 +class PublicModified {
    1.45 +  public final void plain(@A PublicModified this) { }
    1.46 +  public final <T> void generic(@A PublicModified this) { }
    1.47 +  public final void withException(@A PublicModified this) throws Exception { }
    1.48 +  public final String nonVoid(@A PublicModified this) { return null; }
    1.49 +  public final <T extends Runnable> void accept(@A PublicModified this, T r) throws Exception { }
    1.50 +}
    1.51 +
    1.52 +class WithValue {
    1.53 +  void plain(@B("m") WithValue this) { }
    1.54 +  <T> void generic(@B("m") WithValue this) { }
    1.55 +  void withException(@B("m") WithValue this) throws Exception { }
    1.56 +  String nonVoid(@B("m") WithValue this) { return null; }
    1.57 +  <T extends Runnable> void accept(@B("m") WithValue this, T r) throws Exception { }
    1.58 +}
    1.59 +
    1.60 +class WithBody {
    1.61 +  Object f;
    1.62 +
    1.63 +  void field(@A WithBody this) {
    1.64 +    this.f = null;
    1.65 +  }
    1.66 +  void meth(@A WithBody this) {
    1.67 +    this.toString();
    1.68 +  }
    1.69 +}
    1.70 +
    1.71 +class Generic1<X> {
    1.72 +  void test1(Generic1<X> this) {}
    1.73 +  void test2(@A Generic1<X> this) {}
    1.74 +  void test3(Generic1<@A X> this) {}
    1.75 +  void test4(@A Generic1<@A X> this) {}
    1.76 +}
    1.77 +
    1.78 +class Generic2<@A X> {
    1.79 +  void test1(Generic2<X> this) {}
    1.80 +  void test2(@A Generic2<X> this) {}
    1.81 +  void test3(Generic2<@A X> this) {}
    1.82 +  void test4(@A Generic2<@A X> this) {}
    1.83 +}
    1.84 +
    1.85 +class Generic3<X extends @A Object> {
    1.86 +  void test1(Generic3<X> this) {}
    1.87 +  void test2(@A Generic3<X> this) {}
    1.88 +  void test3(Generic3<@A X> this) {}
    1.89 +  void test4(@A Generic3<@A X> this) {}
    1.90 +}
    1.91 +
    1.92 +class Generic4<X extends @A Object> {
    1.93 +  <Y> void test1(Generic4<X> this) {}
    1.94 +  <Y> void test2(@A Generic4<X> this) {}
    1.95 +  <Y> void test3(Generic4<@A X> this) {}
    1.96 +  <Y> void test4(@A Generic4<@A X> this) {}
    1.97 +}
    1.98 +
    1.99 +class Outer {
   1.100 +  class Inner {
   1.101 +    void none(Outer.Inner this) {}
   1.102 +    void outer(@A Outer.Inner this) {}
   1.103 +    void inner(Outer. @B("i") Inner this) {}
   1.104 +    void both(@A Outer.@B("i") Inner this) {}
   1.105 +
   1.106 +    void innerOnlyNone(Inner this) {}
   1.107 +    void innerOnly(@A Inner this) {}
   1.108 +  }
   1.109 +}
   1.110 +
   1.111 +class GenericOuter<S, T> {
   1.112 +  class GenericInner<U, V> {
   1.113 +    void none(GenericOuter<S, T>.GenericInner<U, V> this) {}
   1.114 +    void outer(@A GenericOuter<S, T>.GenericInner<U, V> this) {}
   1.115 +    void inner(GenericOuter<S, T>. @B("i") GenericInner<U, V> this) {}
   1.116 +    void both(@A GenericOuter<S, T>.@B("i") GenericInner<U, V> this) {}
   1.117 +
   1.118 +    void innerOnlyNone(GenericInner<U, V> this) {}
   1.119 +    void innerOnly(@A GenericInner<U, V> this) {}
   1.120 +  }
   1.121 +}
   1.122 +
   1.123 +@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
   1.124 +@interface A {}
   1.125 +@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
   1.126 +@interface B { String value(); }

mercurial