author | jlahoda |
Thu, 26 Jan 2017 14:11:38 +0100 | |
changeset 43368 | cabe410a7a5c |
permissions | -rw-r--r-- |
43368
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
1 |
/* |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
4 |
* |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
8 |
* |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
13 |
* accompanied this code). |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
14 |
* |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
18 |
* |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
21 |
* questions. |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
22 |
*/ |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
23 |
|
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
24 |
/** |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
25 |
* @test |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
26 |
* @bug 8067747 |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
27 |
* @summary Verify the correct Filer behavior w.r.t. initial inputs |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
28 |
* (should throw FilerException when overwriting initial inputs). |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
29 |
* @library /tools/lib /tools/javac/lib |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
30 |
* @modules jdk.compiler/com.sun.tools.javac.api |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
31 |
* jdk.compiler/com.sun.tools.javac.main |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
32 |
* @build toolbox.ToolBox toolbox.JavacTask toolbox.Task |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
33 |
* @build OverwriteInitialInput JavacTestingAbstractProcessor |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
34 |
* @run main OverwriteInitialInput |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
35 |
*/ |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
36 |
|
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
37 |
import java.io.IOException; |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
38 |
import java.io.OutputStream; |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
39 |
import java.io.Writer; |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
40 |
import java.nio.file.Files; |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
41 |
import java.nio.file.Path; |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
42 |
import java.nio.file.Paths; |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
43 |
import java.util.Set; |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
44 |
|
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
45 |
import javax.annotation.processing.FilerException; |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
46 |
import javax.annotation.processing.RoundEnvironment; |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
47 |
import javax.annotation.processing.SupportedOptions; |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
48 |
import javax.lang.model.element.TypeElement; |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
49 |
import javax.tools.StandardLocation; |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
50 |
|
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
51 |
import toolbox.JavacTask; |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
52 |
import toolbox.Task; |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
53 |
import toolbox.ToolBox; |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
54 |
|
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
55 |
@SupportedOptions({OverwriteInitialInput.EXPECT_EXCEPTION_OPTION, |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
56 |
OverwriteInitialInput.TEST_SOURCE |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
57 |
}) |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
58 |
public class OverwriteInitialInput extends JavacTestingAbstractProcessor { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
59 |
|
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
60 |
public static final String EXPECT_EXCEPTION_OPTION = "exception"; |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
61 |
public static final String TEST_SOURCE = "testSource"; |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
62 |
|
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
63 |
@Override |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
64 |
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
65 |
if (roundEnv.processingOver()) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
66 |
if (processingEnv.getOptions().containsKey(EXPECT_EXCEPTION_OPTION)) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
67 |
try (Writer w = processingEnv.getFiler().createSourceFile("Test").openWriter()) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
68 |
throw new AssertionError("Expected IOException not seen."); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
69 |
} catch (FilerException ex) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
70 |
//expected |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
71 |
} catch (IOException ex) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
72 |
throw new IllegalStateException(ex); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
73 |
} |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
74 |
try (OutputStream out = processingEnv.getFiler().createClassFile("Test").openOutputStream()) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
75 |
throw new AssertionError("Expected IOException not seen."); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
76 |
} catch (FilerException ex) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
77 |
//expected |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
78 |
} catch (IOException ex) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
79 |
throw new IllegalStateException(ex); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
80 |
} |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
81 |
if (processingEnv.getOptions().containsKey(TEST_SOURCE)) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
82 |
try (OutputStream out = processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT, "", "Test.java").openOutputStream()) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
83 |
throw new AssertionError("Expected IOException not seen."); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
84 |
} catch (FilerException ex) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
85 |
//expected |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
86 |
} catch (IOException ex) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
87 |
throw new IllegalStateException(ex); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
88 |
} |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
89 |
} else { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
90 |
try (OutputStream out = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", "Test2.class").openOutputStream()) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
91 |
throw new AssertionError("Expected IOException not seen."); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
92 |
} catch (FilerException ex) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
93 |
//expected |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
94 |
} catch (IOException ex) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
95 |
throw new IllegalStateException(ex); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
96 |
} |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
97 |
} |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
98 |
} else { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
99 |
try (Writer w = processingEnv.getFiler().createSourceFile("Test").openWriter()) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
100 |
w.append("public class Test {}"); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
101 |
} catch (IOException ex) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
102 |
throw new IllegalStateException(ex); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
103 |
} |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
104 |
try (OutputStream out = processingEnv.getFiler().createClassFile("Test2").openOutputStream()) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
105 |
try (ToolBox.MemoryFileManager mfm = new ToolBox.MemoryFileManager()) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
106 |
ToolBox tb = new ToolBox(); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
107 |
new JavacTask(tb) |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
108 |
.sources("public class Test2 {}") |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
109 |
.fileManager(mfm) |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
110 |
.run() |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
111 |
.writeAll(); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
112 |
|
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
113 |
out.write(mfm.getFileBytes(StandardLocation.CLASS_OUTPUT, "Test2")); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
114 |
} |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
115 |
} catch (IOException ex) { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
116 |
throw new IllegalStateException(ex); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
117 |
} |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
118 |
} |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
119 |
} |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
120 |
|
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
121 |
return false; |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
122 |
} |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
123 |
|
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
124 |
public static void main(String... args) throws IOException { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
125 |
new OverwriteInitialInput().run(); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
126 |
} |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
127 |
|
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
128 |
void run() throws IOException { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
129 |
run(Task.Mode.API); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
130 |
run(Task.Mode.CMDLINE); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
131 |
} |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
132 |
|
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
133 |
void run(Task.Mode mode) throws IOException { |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
134 |
ToolBox tb = new ToolBox(); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
135 |
Path path = Paths.get("output"); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
136 |
if (Files.isDirectory(path)) |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
137 |
tb.cleanDirectory(path); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
138 |
Files.deleteIfExists(path); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
139 |
tb.createDirectories(path); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
140 |
Path thisSource = Paths.get(System.getProperty("test.src"), "OverwriteInitialInput.java"); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
141 |
new JavacTask(tb, mode).options("-processor", "OverwriteInitialInput", |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
142 |
"-d", path.toString(), |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
143 |
"-XDaccessInternalAPI=true") |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
144 |
.files(thisSource) |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
145 |
.run() |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
146 |
.writeAll(); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
147 |
new JavacTask(tb, mode).options("-processor", "OverwriteInitialInput", |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
148 |
"-d", path.toString(), |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
149 |
"-A" + EXPECT_EXCEPTION_OPTION, |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
150 |
"-A" + TEST_SOURCE, |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
151 |
"-XDaccessInternalAPI=true") |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
152 |
.files(thisSource, path.resolve("Test.java")) |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
153 |
.run() |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
154 |
.writeAll(); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
155 |
new JavacTask(tb, mode).options("-processor", "OverwriteInitialInput", |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
156 |
"-classpath", path.toString(), |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
157 |
"-processorpath", System.getProperty("test.class.path"), |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
158 |
"-d", path.toString(), |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
159 |
"-A" + EXPECT_EXCEPTION_OPTION, |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
160 |
"-XDaccessInternalAPI=true") |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
161 |
.classes("Test", "Test2") |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
162 |
.run() |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
163 |
.writeAll(); |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
164 |
} |
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
165 |
|
cabe410a7a5c
8067747: javac throws exception during compilation when annotation processing is enabled
jlahoda
parents:
diff
changeset
|
166 |
} |