38 IMPORTDEPRECATED("import java.lang.Deprecated;\n"), |
38 IMPORTDEPRECATED("import java.lang.Deprecated;\n"), |
39 IMPORTDOCUMENTED("import java.lang.annotation.Documented;\n"), |
39 IMPORTDOCUMENTED("import java.lang.annotation.Documented;\n"), |
40 IMPORTINHERITED("import java.lang.annotation.Inherited;\n"), |
40 IMPORTINHERITED("import java.lang.annotation.Inherited;\n"), |
41 IMPORTRETENTION("import java.lang.annotation.Retention;\n" + |
41 IMPORTRETENTION("import java.lang.annotation.Retention;\n" + |
42 "\nimport java.lang.annotation.RetentionPolicy;\n"), |
42 "\nimport java.lang.annotation.RetentionPolicy;\n"), |
|
43 IMPORTSTMTS("import java.lang.annotation.*;\n"), |
43 REPEATABLE("\n@Repeatable(FooContainer.class)\n"), |
44 REPEATABLE("\n@Repeatable(FooContainer.class)\n"), |
44 CONTAINER("@interface FooContainer {\n" +" Foo[] value();\n}\n"), |
45 CONTAINER("@interface FooContainer {\n" +" Foo[] value();\n}\n"), |
45 BASE("@interface Foo {}\n"), |
46 BASE("@interface Foo {}\n"), |
|
47 BASEANNO("@Foo"), |
46 REPEATABLEANNO("\n@Foo() @Foo()"), |
48 REPEATABLEANNO("\n@Foo() @Foo()"), |
47 DEPRECATED("\n@Deprecated"), |
49 DEPRECATED("\n@Deprecated"), |
48 DOCUMENTED("\n@Documented"), |
50 DOCUMENTED("\n@Documented"), |
49 INHERITED("\n@Inherited"), |
51 INHERITED("\n@Inherited"), |
50 RETENTION("@Retention(RetentionPolicy.#VAL)\n"); |
52 RETENTION("@Retention(RetentionPolicy.#VAL)\n"), |
|
53 TARGET("\n@Target(#VAL)\n"); |
51 |
54 |
52 private String val; |
55 private String val; |
53 |
56 |
54 |
57 |
55 private ContentVars(String val) { |
58 private ContentVars(String val) { |
67 * - TargetAnnoCombo.java |
70 * - TargetAnnoCombo.java |
68 */ |
71 */ |
69 public static final String template = |
72 public static final String template = |
70 "/*PACKAGE*/\n" + |
73 "/*PACKAGE*/\n" + |
71 "//pkg test;\n\n" + |
74 "//pkg test;\n\n" + |
|
75 "/*ANNODATA*/\n" + // import statements, declaration of Foo/FooContainer |
72 "/*TYPE*/ //class\n" + |
76 "/*TYPE*/ //class\n" + |
73 "class #ClassName {\n" + |
77 "class #ClassName {\n" + |
74 " /*FIELD*/ //instance var\n" + |
78 " /*FIELD*/ //instance var\n" + |
75 " public int x = 0;\n\n" + |
79 " public int x = 0;\n\n" + |
76 " /*FIELD*/ //Enum constants\n" + |
80 " /*FIELD*/ //Enum constants\n" + |
95 "enum TestEnum {}\n\n" + |
99 "enum TestEnum {}\n\n" + |
96 "/*TYPE*/ //Interface\n" + |
100 "/*TYPE*/ //Interface\n" + |
97 "interface TestInterface {}\n\n" + |
101 "interface TestInterface {}\n\n" + |
98 "/*TYPE*/\n" + |
102 "/*TYPE*/\n" + |
99 "/*ANNOTATION_TYPE*/\n" + |
103 "/*ANNOTATION_TYPE*/\n" + |
100 "@interface TestAnnotationType{}\n"; |
104 "@interface TestAnnotationType{}\n" + |
|
105 "class TestPkg {}\n" + |
|
106 "class TestTypeAnno </*TYPE_PARAMETER*/ T extends Object> {\n" + |
|
107 " String /*TYPE_USE*/[] arr;\n" + |
|
108 "}"; |
101 |
109 |
102 // Create and compile FileObject using values for className and contents |
110 // Create and compile FileObject using values for className and contents |
103 public static boolean compileCode(String className, String contents, |
111 public static boolean compileCode(String className, String contents, |
104 DiagnosticCollector<JavaFileObject> diagnostics) { |
112 DiagnosticCollector<JavaFileObject> diagnostics) { |
105 boolean ok = false; |
113 boolean ok = false; |