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

     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  */
    24 import java.lang.annotation.*;
    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  */
    33 class 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 }
    41 class 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 }
    49 class 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 }
    57 class WithBody {
    58   Object f;
    60   void field(@A WithBody this) {
    61     this.f = null;
    62   }
    63   void meth(@A WithBody this) {
    64     this.toString();
    65   }
    66 }
    68 class 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 }
    75 class 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 }
    82 class 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 }
    89 class 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 }
    96 class 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) {}
   103     void innerOnlyNone(Inner this) {}
   104     void innerOnly(@A Inner this) {}
   105   }
   106 }
   108 class 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) {}
   115     void innerOnlyNone(GenericInner<U, V> this) {}
   116     void innerOnly(@A GenericInner<U, V> this) {}
   117   }
   118 }
   120 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
   121 @interface A {}
   122 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
   123 @interface B { String value(); }

mercurial