Test ReleaseOptionCurrent.java writes ReleaseOption.class in the source directory
Jonathan Gibbons
jonathan.gibbons at oracle.com
Thu May 17 14:29:12 UTC 2018
David,
test.classes is for the test classes compiled by jtreg, It should not be
used for arbitrary classes that may be compiled while the test is being run.
-- Jon
On 5/17/18 6:08 AM, David Holmes wrote:
> Hi Bernard,
>
> Can't you just use System.getProperty("test.classes") to get the
> output directory?
>
> Cheers,
> David
>
> On 17/05/2018 10:39 PM, B. Blaser wrote:
>> Hi,
>>
>> Test ReleaseOptionCurrent.java writes ReleaseOption.class in the
>> source directory.
>> Next is a quick fix for this.
>> Any feedback is welcome.
>>
>> Cheers,
>> Bernard
>>
>>
>> diff -r 8e4fcfb4cfe4
>> test/langtools/tools/javac/options/release/ReleaseOptionCurrent.java
>> ---
>> a/test/langtools/tools/javac/options/release/ReleaseOptionCurrent.java
>> Thu May 17 10:32:26 2018 +0200
>> +++
>> b/test/langtools/tools/javac/options/release/ReleaseOptionCurrent.java
>> Thu May 17 14:17:52 2018 +0200
>> @@ -25,10 +25,14 @@
>> * @test
>> * @bug 8202387
>> * @summary Verify that javac can handle --release <current>
>> + * @library /tools/lib
>> * @modules jdk.compiler/com.sun.tools.javac.code
>> */
>>
>> import java.io.IOException;
>> +import java.nio.file.Files;
>> +import java.nio.file.Path;
>> +import java.nio.file.Paths;
>> import java.util.Arrays;
>> import java.util.List;
>> import javax.tools.JavaCompiler;
>> @@ -38,18 +42,29 @@
>>
>> import com.sun.tools.javac.code.Source;
>>
>> +import toolbox.ToolBox;
>> +
>> public class ReleaseOptionCurrent {
>> public static void main(String... args) throws IOException {
>> new ReleaseOptionCurrent().run();
>> }
>>
>> + private final ToolBox tb = new ToolBox();
>> +
>> void run() throws IOException {
>> String lineSep = System.getProperty("line.separator");
>> + Path classes = Paths.get("classes");
>> +
>> + if (Files.exists(classes)) {
>> + tb.cleanDirectory(classes);
>> + } else {
>> + Files.createDirectories(classes);
>> + }
>> JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
>> try (StandardJavaFileManager fm =
>> compiler.getStandardFileManager(null, null, null)) {
>> Iterable<? extends JavaFileObject> input =
>>
>> fm.getJavaFileObjects(System.getProperty("test.src") +
>> "/ReleaseOption.java");
>> - List<String> options = Arrays.asList("--release",
>> Source.DEFAULT.name);
>> + List<String> options = Arrays.asList("-d",
>> classes.toString(), "--release", Source.DEFAULT.name);
>>
>> boolean result = compiler.getTask(null, fm, null,
>> options, null, input).call();
>> if (!result) {
>>
More information about the compiler-dev
mailing list