test/langtools/tools/javac/MethodParameters/ClassReaderTest/ClassReaderTest.java
changeset 48344 89f6aa26fd6c
equal deleted inserted replaced
48343:d4329843abf4 48344:89f6aa26fd6c
       
     1 /*
       
     2  * Copyright 2017 Google Inc. 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 
       
    24 /*
       
    25  * @test
       
    26  * @bug 8007720 8177486
       
    27  * @summary class reading of named parameters
       
    28  * @library /tools/javac/lib
       
    29  * @modules java.compiler
       
    30  *          jdk.compiler
       
    31  * @compile -parameters ClassReaderTest.java MethodParameterProcessor.java
       
    32  * @compile/process/ref=ClassReaderTest.out -proc:only -processor MethodParameterProcessor ClassReaderTest ClassReaderTest$I ClassReaderTest$E
       
    33  */
       
    34 
       
    35 import static java.lang.annotation.RetentionPolicy.CLASS;
       
    36 import static java.lang.annotation.RetentionPolicy.RUNTIME;
       
    37 
       
    38 import java.lang.annotation.Retention;
       
    39 
       
    40 public class ClassReaderTest {
       
    41 
       
    42     @Retention(RUNTIME)
       
    43     @interface RuntimeAnnoOne {
       
    44         int value() default 0;
       
    45     }
       
    46 
       
    47     @Retention(RUNTIME)
       
    48     @interface RuntimeAnnoTwo {
       
    49         int value() default 0;
       
    50     }
       
    51 
       
    52     @Retention(CLASS)
       
    53     @interface ClassAnno {
       
    54         int value() default 0;
       
    55     }
       
    56 
       
    57     @MethodParameterProcessor.ParameterNames
       
    58     void f(
       
    59             @RuntimeAnnoOne(1) @RuntimeAnnoTwo(2) @ClassAnno(3) int a,
       
    60             @RuntimeAnnoOne(4) @RuntimeAnnoTwo(5) @ClassAnno(6) String b) {}
       
    61 
       
    62     class I {
       
    63         @MethodParameterProcessor.ParameterNames
       
    64         I(@ClassAnno(7) int d, @RuntimeAnnoOne(8) String e, Object o) {}
       
    65     }
       
    66 
       
    67     enum E {
       
    68         ONE(42, "");
       
    69 
       
    70         @MethodParameterProcessor.ParameterNames
       
    71         E(int x, @RuntimeAnnoOne(9) String s) {}
       
    72     }
       
    73 }