author | akulyakh |
Thu, 21 May 2015 11:41:04 -0700 | |
changeset 30730 | d3ce7619db2c |
parent 23795 | 62509b72088e |
child 36526 | 3b41f1c69604 |
permissions | -rw-r--r-- |
23795
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
23795
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
23795
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
4 |
* |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
8 |
* |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
13 |
* accompanied this code). |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
14 |
* |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
18 |
* |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
21 |
* questions. |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
22 |
*/ |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
23 |
|
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
24 |
/* |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
25 |
* @test |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
26 |
* @bug 8038080 |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
27 |
* @summary make sure that all declaration annotations are discovered |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
28 |
* by the processing environment |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
29 |
* @library /tools/javac/lib |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
23795
diff
changeset
|
30 |
* @modules jdk.compiler/com.sun.tools.javac.util |
23795
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
31 |
* @build JavacTestingAbstractProcessor ProcessingEnvAnnoDiscovery |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
32 |
* @compile/process -processor ProcessingEnvAnnoDiscovery ProcessingEnvAnnoDiscovery.java |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
33 |
*/ |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
34 |
|
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
35 |
import java.lang.annotation.*; |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
36 |
import java.util.Set; |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
37 |
import javax.annotation.processing.*; |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
38 |
import javax.lang.model.element.*; |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
39 |
|
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
40 |
import com.sun.tools.javac.util.*; |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
41 |
|
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
42 |
@ProcessingEnvAnnoDiscovery.Anno1 |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
43 |
public class ProcessingEnvAnnoDiscovery<@ProcessingEnvAnnoDiscovery.Anno4 T> |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
44 |
extends JavacTestingAbstractProcessor { |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
45 |
private int round = 0; |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
46 |
|
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
47 |
public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) { |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
48 |
if (round++ == 0) { |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
49 |
System.out.println(annos); |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
50 |
Assert.check(annos.contains(eltUtils.getTypeElement("java.lang.annotation.Target"))); |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
51 |
Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno1"))); |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
52 |
Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno2"))); |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
53 |
Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno3"))); |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
54 |
Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno4"))); |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
55 |
Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno5"))); |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
56 |
Assert.check(annos.size() == 6, "Found extra annotations"); //Anno1-5 + @Target |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
57 |
} |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
58 |
|
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
59 |
return true; |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
60 |
} |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
61 |
|
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
62 |
@Anno2 |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
63 |
public <@Anno5 K> K m(@Anno3 long foo) { |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
64 |
return null; |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
65 |
} |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
66 |
|
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
67 |
@interface Anno1 {} |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
68 |
|
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
69 |
@interface Anno2 {} |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
70 |
|
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
71 |
@interface Anno3 {} |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
72 |
|
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
73 |
@Target(ElementType.TYPE_PARAMETER) |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
74 |
@interface Anno4 {} |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
75 |
|
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
76 |
@Target(ElementType.TYPE_PARAMETER) |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
77 |
@interface Anno5 {} |
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
78 |
|
62509b72088e
8038080: annotation processors don't visit declaration parameter annotations
jfranck
parents:
diff
changeset
|
79 |
} |