author | jjg |
Wed, 07 Nov 2012 17:01:19 -0800 | |
changeset 14451 | c18762e096ae |
child 15356 | cf312dc54c60 |
permissions | -rw-r--r-- |
14451
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
1 |
/* |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
2 |
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
4 |
* |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
8 |
* |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
13 |
* accompanied this code). |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
14 |
* |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
18 |
* |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
21 |
* questions. |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
22 |
*/ |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
23 |
|
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
24 |
import java.net.URI; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
25 |
import java.net.URISyntaxException; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
26 |
import java.util.Arrays; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
27 |
import javax.tools.DiagnosticCollector; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
28 |
import javax.tools.JavaCompiler; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
29 |
import javax.tools.JavaFileObject; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
30 |
import javax.tools.SimpleJavaFileObject; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
31 |
import javax.tools.ToolProvider; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
32 |
import javax.tools.JavaCompiler.CompilationTask; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
33 |
|
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
34 |
public class Helper { |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
35 |
|
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
36 |
enum ContentVars { |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
37 |
IMPORTCONTAINERSTMTS("\nimport java.lang.annotation.ContainedBy;\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
38 |
"\nimport java.lang.annotation.ContainerFor;\n"), |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
39 |
IMPORTDEPRECATED("import java.lang.Deprecated;\n"), |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
40 |
IMPORTDOCUMENTED("import java.lang.annotation.Documented;\n"), |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
41 |
IMPORTINHERITED("import java.lang.annotation.Inherited;\n"), |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
42 |
IMPORTRETENTION("import java.lang.annotation.Retention;\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
43 |
"\nimport java.lang.annotation.RetentionPolicy;\n"), |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
44 |
CONTAINEDBY("\n@ContainedBy(FooContainer.class)\n"), |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
45 |
CONTAINERFOR("@ContainerFor(Foo.class)\n"), |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
46 |
CONTAINER("@interface FooContainer {\n" +" Foo[] value();\n}\n"), |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
47 |
BASE("@interface Foo {}\n"), |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
48 |
REPEATABLEANNO("\n@Foo() @Foo()"), |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
49 |
DEPRECATED("\n@Deprecated"), |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
50 |
DOCUMENTED("\n@Documented"), |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
51 |
INHERITED("\n@Inherited"), |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
52 |
RETENTION("@Retention(RetentionPolicy.#VAL)\n"); |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
53 |
|
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
54 |
private String val; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
55 |
|
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
56 |
|
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
57 |
private ContentVars(String val) { |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
58 |
this.val = val; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
59 |
} |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
60 |
|
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
61 |
public String getVal() { |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
62 |
return val; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
63 |
} |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
64 |
} |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
65 |
|
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
66 |
/* String template where /*<TYPE>*/ /*gets replaced by repeating anno |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
67 |
* Used to generate test src for combo tests |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
68 |
* - BasicSyntaxCombo.java |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
69 |
* - TargetAnnoCombo.java |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
70 |
*/ |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
71 |
public static final String template = |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
72 |
"/*PACKAGE*/\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
73 |
"//pkg test;\n\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
74 |
"/*TYPE*/ //class\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
75 |
"class #ClassName {\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
76 |
" /*FIELD*/ //instance var\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
77 |
" public int x = 0;\n\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
78 |
" /*FIELD*/ //Enum constants\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
79 |
" TestEnum testEnum;\n\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
80 |
" /*FIELD*/ // Static field\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
81 |
" public static int num;\n\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
82 |
" /*STATIC_INI*/\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
83 |
" static { \n" + "num = 10; \n }\n\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
84 |
" /*CONSTRUCTOR*/\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
85 |
" #ClassName() {}\n\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
86 |
" /*INSTANCE_INI*/\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
87 |
" { \n x = 10; \n }" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
88 |
" /*INNER_CLASS*/\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
89 |
" class innerClass {}\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
90 |
" /*METHOD*/\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
91 |
" void bar(/*PARAMETER*/ int baz) {\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
92 |
" /*LOCAL_VARIABLE*/\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
93 |
" int y = 0;\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
94 |
" }\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
95 |
"}\n\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
96 |
"/*TYPE*/ //Enum\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
97 |
"enum TestEnum {}\n\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
98 |
"/*TYPE*/ //Interface\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
99 |
"interface TestInterface {}\n\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
100 |
"/*TYPE*/\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
101 |
"/*ANNOTATION_TYPE*/\n" + |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
102 |
"@interface TestAnnotationType{}\n"; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
103 |
|
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
104 |
// Create and compile FileObject using values for className and contents |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
105 |
public static boolean compileCode(String className, String contents, |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
106 |
DiagnosticCollector<JavaFileObject> diagnostics) { |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
107 |
boolean ok = false; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
108 |
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
109 |
if (compiler == null) { |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
110 |
throw new RuntimeException("can't get javax.tools.JavaCompiler!"); |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
111 |
} |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
112 |
|
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
113 |
JavaFileObject file = getFile(className, contents); |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
114 |
Iterable<? extends JavaFileObject> compilationUnit = Arrays.asList(file); |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
115 |
|
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
116 |
CompilationTask task = compiler.getTask(null, null, diagnostics, null, null, compilationUnit); |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
117 |
ok = task.call(); |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
118 |
return ok; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
119 |
|
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
120 |
} |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
121 |
|
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
122 |
// Compile a list of FileObjects |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
123 |
public static boolean compileCode(DiagnosticCollector<JavaFileObject> diagnostics, Iterable<? extends JavaFileObject> files) { |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
124 |
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
125 |
if (compiler == null) { |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
126 |
throw new RuntimeException("can't get javax.tools.JavaCompiler!"); |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
127 |
} |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
128 |
|
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
129 |
CompilationTask task = compiler.getTask(null, null, diagnostics, null, null, files); |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
130 |
boolean ok = task.call(); |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
131 |
return ok; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
132 |
} |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
133 |
|
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
134 |
static JavaFileObject getFile(String name, String code) { |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
135 |
JavaFileObject o = null; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
136 |
try { |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
137 |
o = new JavaStringFileObject(name, code); |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
138 |
} catch (URISyntaxException e) { |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
139 |
throw new RuntimeException(e); |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
140 |
} |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
141 |
return o; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
142 |
} |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
143 |
static class JavaStringFileObject extends SimpleJavaFileObject { |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
144 |
final String theCode; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
145 |
public JavaStringFileObject(String fileName, String theCode) throws URISyntaxException { |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
146 |
super(new URI("string:///" + fileName.replace('.','/') + ".java"), Kind.SOURCE); |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
147 |
this.theCode = theCode; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
148 |
} |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
149 |
@Override |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
150 |
public CharSequence getCharContent(boolean ignoreEncodingErrors) { |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
151 |
return theCode; |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
152 |
} |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
153 |
} |
c18762e096ae
8002157: Write combo compiler tests for repeating annotations for JDK8
jjg
parents:
diff
changeset
|
154 |
} |