author | mchung |
Wed, 27 May 2015 13:25:18 -0700 | |
changeset 30846 | 2b3f379840f0 |
parent 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
27545
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
29050
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
27545
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
4 |
* |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
8 |
* |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
13 |
* accompanied this code). |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
14 |
* |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
18 |
* |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
21 |
* questions. |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
22 |
*/ |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
23 |
|
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
24 |
/* |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
25 |
* @test SyntheticParameters |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
26 |
* @summary Test generation of annotations on inner class parameters. |
27853
746c658e8d35
8065132: Parameter annotations not updated when synthetic parameters are prepended
emc
parents:
27545
diff
changeset
|
27 |
* @library /lib/annotations/ |
30846 | 28 |
* @modules jdk.jdeps/com.sun.tools.classfile |
27545
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
29 |
* @run main SyntheticParameters |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
30 |
*/ |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
31 |
|
27853
746c658e8d35
8065132: Parameter annotations not updated when synthetic parameters are prepended
emc
parents:
27545
diff
changeset
|
32 |
import annotations.classfile.ClassfileInspector; |
746c658e8d35
8065132: Parameter annotations not updated when synthetic parameters are prepended
emc
parents:
27545
diff
changeset
|
33 |
|
27545
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
34 |
import java.io.*; |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
35 |
import java.lang.annotation.*; |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
36 |
|
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
37 |
import com.sun.tools.classfile.*; |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
38 |
|
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
39 |
public class SyntheticParameters extends ClassfileInspector { |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
40 |
|
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
41 |
private static final String Inner_class = "SyntheticParameters$Inner.class"; |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
42 |
private static final String Foo_class = "SyntheticParameters$Foo.class"; |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
43 |
private static final Expected Inner_expected = |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
44 |
new Expected("SyntheticParameters$Inner", |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
45 |
null, |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
46 |
new ExpectedMethodTypeAnnotation[] { |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
47 |
(ExpectedMethodTypeAnnotation) |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
48 |
// Assert there is an annotation on the |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
49 |
// first parameter. |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
50 |
new ExpectedMethodTypeAnnotation.Builder( |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
51 |
"<init>", |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
52 |
"A", |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
53 |
TypeAnnotation.TargetType.METHOD_FORMAL_PARAMETER, |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
54 |
false, |
29050 | 55 |
1).setParameterIndex(0).build() |
27545
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
56 |
}, |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
57 |
null); |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
58 |
private static final Expected Foo_expected = |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
59 |
new Expected("SyntheticParameters$Foo", |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
60 |
null, |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
61 |
new ExpectedMethodTypeAnnotation[] { |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
62 |
(ExpectedMethodTypeAnnotation) |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
63 |
// Assert there is no annotation on the |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
64 |
// $enum$name parameter. |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
65 |
new ExpectedMethodTypeAnnotation.Builder( |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
66 |
"<init>", |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
67 |
"A", |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
68 |
TypeAnnotation.TargetType.METHOD_FORMAL_PARAMETER, |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
69 |
false, |
29050 | 70 |
1).setParameterIndex(0).build() }, |
27545
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
71 |
null); |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
72 |
|
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
73 |
public static void main(String... args) throws Exception { |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
74 |
new SyntheticParameters().run( |
27853
746c658e8d35
8065132: Parameter annotations not updated when synthetic parameters are prepended
emc
parents:
27545
diff
changeset
|
75 |
new ClassFile[] { getClassFile(Inner_class, Inner.class), |
746c658e8d35
8065132: Parameter annotations not updated when synthetic parameters are prepended
emc
parents:
27545
diff
changeset
|
76 |
getClassFile(Foo_class, Foo.class) }, |
27545
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
77 |
new Expected[] { Inner_expected, Foo_expected }); |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
78 |
} |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
79 |
|
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
80 |
public class Inner { |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
81 |
public Inner(@A int a) {} |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
82 |
public void foo(@A int a, int b) {} |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
83 |
} |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
84 |
|
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
85 |
public static enum Foo { |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
86 |
ONE(null); |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
87 |
Foo(@A Object a) {} |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
88 |
} |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
89 |
} |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
90 |
|
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
91 |
@Target({ElementType.TYPE_USE}) |
9b19c6e31489
8029012: parameter_index for type annotation not updated after outer.this added
emc
parents:
diff
changeset
|
92 |
@interface A {} |