mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
8135131: Enable thin server mode in Sjavac
State tracknig and incremental compilation disabled unless --state-dir is provided. Reviewed-by: jlahoda
This commit is contained in:
parent
2a12715485
commit
6238d40db4
25 changed files with 304 additions and 182 deletions
|
@ -322,6 +322,13 @@ public class Log extends AbstractLog {
|
|||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a Context.Factory to create a Log.
|
||||
*/
|
||||
public static void preRegister(Context context, PrintWriter w) {
|
||||
context.put(Log.class, (Context.Factory<Log>) (c -> new Log(c, w)));
|
||||
}
|
||||
|
||||
/** The number of errors encountered so far.
|
||||
*/
|
||||
public int nerrors = 0;
|
||||
|
|
|
@ -91,7 +91,7 @@ public class SjavacClient implements Sjavac {
|
|||
String serverConf = (tmpServerConf!=null)? tmpServerConf : "";
|
||||
String tmpId = Util.extractStringOption("id", serverConf);
|
||||
id = (tmpId!=null) ? tmpId : "id"+(((new java.util.Random()).nextLong())&Long.MAX_VALUE);
|
||||
String defaultPortfile = options.getStateDir()
|
||||
String defaultPortfile = options.getDestDir()
|
||||
.resolve("javac_server")
|
||||
.toAbsolutePath()
|
||||
.toString();
|
||||
|
|
|
@ -36,7 +36,11 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.sun.tools.javac.file.JavacFileManager;
|
||||
import com.sun.tools.javac.main.Main;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import com.sun.tools.sjavac.JavacState;
|
||||
import com.sun.tools.sjavac.Log;
|
||||
import com.sun.tools.sjavac.Module;
|
||||
|
@ -44,10 +48,13 @@ import com.sun.tools.sjavac.ProblemException;
|
|||
import com.sun.tools.sjavac.Source;
|
||||
import com.sun.tools.sjavac.Transformer;
|
||||
import com.sun.tools.sjavac.Util;
|
||||
import com.sun.tools.sjavac.options.Option;
|
||||
import com.sun.tools.sjavac.options.Options;
|
||||
import com.sun.tools.sjavac.options.SourceLocation;
|
||||
import com.sun.tools.sjavac.server.Sjavac;
|
||||
|
||||
import javax.tools.JavaFileManager;
|
||||
|
||||
/**
|
||||
* The sjavac implementation that interacts with javac and performs the actual
|
||||
* compilation.
|
||||
|
@ -77,7 +84,8 @@ public class SjavacImpl implements Sjavac {
|
|||
if (!createIfMissing(options.getDestDir()))
|
||||
return RC_FATAL;
|
||||
|
||||
if (!createIfMissing(options.getStateDir()))
|
||||
Path stateDir = options.getStateDir();
|
||||
if (stateDir != null && !createIfMissing(options.getStateDir()))
|
||||
return RC_FATAL;
|
||||
|
||||
Path gensrc = options.getGenSrcDir();
|
||||
|
@ -88,6 +96,30 @@ public class SjavacImpl implements Sjavac {
|
|||
if (hdrdir != null && !createIfMissing(hdrdir))
|
||||
return RC_FATAL;
|
||||
|
||||
if (stateDir == null) {
|
||||
// Prepare context. Direct logging to our byte array stream.
|
||||
Context context = new Context();
|
||||
PrintWriter writer = new PrintWriter(err);
|
||||
com.sun.tools.javac.util.Log.preRegister(context, writer);
|
||||
JavacFileManager.preRegister(context);
|
||||
|
||||
// Prepare arguments
|
||||
String[] passThroughArgs = Stream.of(args)
|
||||
.filter(arg -> !arg.startsWith(Option.SERVER.arg))
|
||||
.toArray(String[]::new);
|
||||
|
||||
// Compile
|
||||
com.sun.tools.javac.main.Main compiler = new com.sun.tools.javac.main.Main("javac", writer);
|
||||
Main.Result result = compiler.compile(passThroughArgs, context);
|
||||
|
||||
// Clean up
|
||||
JavaFileManager fileManager = context.get(JavaFileManager.class);
|
||||
if (fileManager instanceof JavacFileManager) {
|
||||
((JavacFileManager) fileManager).close();
|
||||
}
|
||||
return result.exitCode;
|
||||
|
||||
} else {
|
||||
// Load the prev build state database.
|
||||
JavacState javac_state = JavacState.load(options, out, err);
|
||||
|
||||
|
@ -248,6 +280,7 @@ public class SjavacImpl implements Sjavac {
|
|||
return RC_FATAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
|
@ -266,8 +299,8 @@ public class SjavacImpl implements Sjavac {
|
|||
err = "No server configuration provided.";
|
||||
} else if (!options.getImplicitPolicy().equals("none")) {
|
||||
err = "The only allowed setting for sjavac is -implicit:none";
|
||||
} else if (options.getSources().isEmpty()) {
|
||||
err = "You have to specify -src.";
|
||||
} else if (options.getSources().isEmpty() && options.getStateDir() != null) {
|
||||
err = "You have to specify -src when using --state-dir.";
|
||||
} else if (options.getTranslationRules().size() > 1
|
||||
&& options.getGenSrcDir() == null) {
|
||||
err = "You have translators but no gensrc dir (-s) specified!";
|
||||
|
|
|
@ -97,7 +97,7 @@ public class Options {
|
|||
|
||||
/** Get the path for the state directory, defaults to destDir. */
|
||||
public Path getStateDir() {
|
||||
return stateDir != null ? stateDir : destDir;
|
||||
return stateDir;
|
||||
}
|
||||
|
||||
/** Get all source locations for files to be compiled */
|
||||
|
|
|
@ -89,7 +89,7 @@ public class ApiExtraction {
|
|||
new ToolBox().new JavacTask().sources(testSrc).run();
|
||||
|
||||
// Extract PubApi
|
||||
Options options = Options.parseArgs("-d", "bin", "-cp", ".");
|
||||
Options options = Options.parseArgs("-d", "bin", "--state-dir=bin", "-cp", ".");
|
||||
PubApiExtractor pubApiExtr = new PubApiExtractor(options);
|
||||
PubApi actualApi = pubApiExtr.getPubApi("TestClass");
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ public class ClasspathDependencies extends SjavacBase {
|
|||
headline("Create a test dependency, Dep.class, and put it in the classpath dir");
|
||||
String depCode = "package dep; public class Dep { public void m1() {} }";
|
||||
toolbox.writeFile(srcDep.resolve("dep/Dep.java"), depCode);
|
||||
int rc = compile(server, "-d", classesDep, srcDep);
|
||||
int rc = compile(server, "-d", classesDep, "--state-dir=" + classesDep, srcDep);
|
||||
check(rc == 0, "Compilation failed unexpectedly");
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
@ -73,7 +73,7 @@ public class ClasspathDependencies extends SjavacBase {
|
|||
"package pkg;" +
|
||||
"import dep.Dep;" +
|
||||
"public class C { Dep dep; public void m() { new Dep().m1(); } }");
|
||||
rc = compile(server, "-d", classes, src, "-cp", classesDep);
|
||||
rc = compile(server, "-d", classes, "--state-dir=" + classes, src, "-cp", classesDep);
|
||||
check(rc == 0, "Compilation failed unexpectedly");
|
||||
FileTime modTime1 = Files.getLastModifiedTime(classes.resolve("pkg/C.class"));
|
||||
|
||||
|
@ -82,12 +82,12 @@ public class ClasspathDependencies extends SjavacBase {
|
|||
Thread.sleep(2000);
|
||||
depCode = depCode.replaceAll("}$", "private void m2() {} }");
|
||||
toolbox.writeFile(srcDep.resolve("dep/Dep.java"), depCode);
|
||||
rc = compile(server, "-d", classesDep, srcDep);
|
||||
rc = compile(server, "-d", classesDep, "--state-dir=" + classesDep, srcDep);
|
||||
check(rc == 0, "Compilation failed unexpectedly");
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
headline("Make sure that this does not trigger recompilation of C.java");
|
||||
rc = compile(server, "-d", classes, src, "-cp", classesDep);
|
||||
rc = compile(server, "-d", classes, "--state-dir=" + classes, src, "-cp", classesDep);
|
||||
check(rc == 0, "Compilation failed unexpectedly");
|
||||
FileTime modTime2 = Files.getLastModifiedTime(classes.resolve("pkg/C.class"));
|
||||
check(modTime1.equals(modTime2), "Recompilation erroneously triggered");
|
||||
|
@ -97,12 +97,12 @@ public class ClasspathDependencies extends SjavacBase {
|
|||
Thread.sleep(2000);
|
||||
depCode = depCode.replace("m1()", "m1(String... arg)");
|
||||
toolbox.writeFile(srcDep.resolve("dep/Dep.java"), depCode);
|
||||
rc = compile(server, "-d", classesDep, srcDep);
|
||||
rc = compile(server, "-d", classesDep, "--state-dir=" + classesDep, srcDep);
|
||||
check(rc == 0, "Compilation failed unexpectedly");
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
headline("Make sure that recompilation of C.java is triggered");
|
||||
rc = compile(server, "-d", classes, src, "-cp", classesDep);
|
||||
rc = compile(server, "-d", classes, "--state-dir=" + classes, src, "-cp", classesDep);
|
||||
check(rc == 0, "Compilation failed unexpectedly");
|
||||
FileTime modTime3 = Files.getLastModifiedTime(classes.resolve("pkg/C.class"));
|
||||
check(modTime2.compareTo(modTime3) < 0, "Recompilation not triggered");
|
||||
|
|
|
@ -63,6 +63,7 @@ public class CompileCircularSources extends SJavacTester {
|
|||
compile(GENSRC.toString(),
|
||||
"-d", BIN.toString(),
|
||||
"-h", HEADERS.toString(),
|
||||
"--state-dir=" + BIN,
|
||||
"-j", "3",
|
||||
SERVER_ARG,
|
||||
"--log=debug");
|
||||
|
|
|
@ -62,6 +62,7 @@ public class CompileExcludingDependency extends SJavacTester {
|
|||
"-x", "alfa/omega",
|
||||
"-sourcepath", GENSRC.toString(),
|
||||
"-d", BIN.toString(),
|
||||
"--state-dir=" + BIN,
|
||||
SERVER_ARG);
|
||||
|
||||
Map<String,Long> new_bin_state = collectState(BIN);
|
||||
|
|
|
@ -52,7 +52,8 @@ public class CompileWithAtFile extends SJavacTester {
|
|||
"-if */alfa/omega/A.java\n" +
|
||||
"-if */beta/B.java\n" +
|
||||
GENSRC + "\n" +
|
||||
"-d " + BIN + "\n");
|
||||
"-d " + BIN + "\n" +
|
||||
"--state-dir=" + BIN + "\n");
|
||||
tb.writeFile(GENSRC.resolve("alfa/omega/A.java"),
|
||||
"package alfa.omega; import beta.B; public class A { B b; }");
|
||||
tb.writeFile(GENSRC.resolve("beta/B.java"),
|
||||
|
|
|
@ -70,6 +70,7 @@ public class CompileWithInvisibleSources extends SJavacTester {
|
|||
"-sourcepath", GENSRC2.toString(),
|
||||
"-sourcepath", GENSRC3.toString(),
|
||||
"-d", BIN.toString(),
|
||||
"--state-dir=" + BIN,
|
||||
"-h", HEADERS.toString(),
|
||||
"-j", "1",
|
||||
SERVER_ARG);
|
||||
|
@ -86,6 +87,7 @@ public class CompileWithInvisibleSources extends SJavacTester {
|
|||
"-sourcepath", GENSRC2.toString(),
|
||||
"-sourcepath", GENSRC3.toString(),
|
||||
"-d", BIN.toString(),
|
||||
"--state-dir=" + BIN,
|
||||
"-h", HEADERS.toString(),
|
||||
"-j", "1",
|
||||
SERVER_ARG);
|
||||
|
|
|
@ -68,6 +68,7 @@ public class CompileWithOverrideSources extends SJavacTester {
|
|||
GENSRC.toString(),
|
||||
GENSRC2.toString(),
|
||||
"-d", BIN.toString(),
|
||||
"--state-dir=" + BIN,
|
||||
"-h", HEADERS.toString(),
|
||||
"-j", "1",
|
||||
SERVER_ARG);
|
||||
|
@ -83,6 +84,7 @@ public class CompileWithOverrideSources extends SJavacTester {
|
|||
compileExpectFailure(GENSRC.toString(),
|
||||
GENSRC2.toString(),
|
||||
"-d", BIN.toString(),
|
||||
"--state-dir=" + BIN,
|
||||
"-h", HEADERS.toString(),
|
||||
"-j", "1",
|
||||
SERVER_ARG);
|
||||
|
|
|
@ -61,6 +61,7 @@ public class ExclPattern {
|
|||
"-x", "pkg/excl-dir/*",
|
||||
"-src", "srcdir",
|
||||
"-d", "dest",
|
||||
"--state-dir=dest",
|
||||
"-j", "1",
|
||||
"-copy", ".txt",
|
||||
"--server:portfile=testserver,background=false",
|
||||
|
|
|
@ -56,11 +56,20 @@ public class IgnoreSymbolFile {
|
|||
new File("classes").mkdirs();
|
||||
|
||||
String server = "--server:portfile=testserver,background=false";
|
||||
int rc1 = compile(server, "-d", "classes", "-Werror", "src");
|
||||
int rc1 = compile(server,
|
||||
"-d", "classes",
|
||||
"--state-dir=classes",
|
||||
"-Werror",
|
||||
"src");
|
||||
if (rc1 == 0)
|
||||
error("compilation succeeded unexpectedly");
|
||||
|
||||
int rc2 = compile(server, "-d", "classes", "-Werror", "-XDignore.symbol.file=true", "src");
|
||||
int rc2 = compile(server,
|
||||
"-d", "classes",
|
||||
"--state-dir=classes",
|
||||
"-Werror",
|
||||
"-XDignore.symbol.file=true",
|
||||
"src");
|
||||
if (rc2 != 0)
|
||||
error("compilation failed unexpectedly: rc=" + rc2);
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public class IncCompInheritance extends SjavacBase {
|
|||
|
||||
// Initial compile (should succeed)
|
||||
String server = "--server:portfile=testserver,background=false";
|
||||
int rc1 = compile(server, "-d", classes, src);
|
||||
int rc1 = compile(server, "-d", classes, "--state-dir=" + classes, src);
|
||||
if (rc1 != 0)
|
||||
throw new AssertionError("Compilation failed unexpectedly");
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class IncCompInheritance extends SjavacBase {
|
|||
// Incremental compile (C should now be recompiled even though it
|
||||
// depends on A only through inheritance via B).
|
||||
// Since A.m is removed, this should fail.
|
||||
int rc2 = compile(server, "-d", classes, src);
|
||||
int rc2 = compile(server, "-d", classes, "--state-dir=" + classes, src);
|
||||
if (rc2 == 0)
|
||||
throw new AssertionError("Compilation succeeded unexpectedly");
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ public class IncCompileChangeNative extends SJavacTester {
|
|||
|
||||
compile(GENSRC.toString(),
|
||||
"-d", BIN.toString(),
|
||||
"--state-dir=" + BIN,
|
||||
"-h", HEADERS.toString(),
|
||||
"-j", "1",
|
||||
SERVER_ARG,
|
||||
|
@ -105,6 +106,7 @@ public class IncCompileChangeNative extends SJavacTester {
|
|||
|
||||
compile(GENSRC.toString(),
|
||||
"-d", BIN.toString(),
|
||||
"--state-dir=" + BIN,
|
||||
"-h", HEADERS.toString(),
|
||||
"-j", "1",
|
||||
SERVER_ARG,
|
||||
|
|
|
@ -71,6 +71,7 @@ public class IncCompileDropClasses extends SJavacTester {
|
|||
removeFrom(GENSRC, "alfa/omega/AA.java");
|
||||
compile(GENSRC.toString(),
|
||||
"-d", BIN.toString(),
|
||||
"--state-dir=" + BIN,
|
||||
"-h", HEADERS.toString(),
|
||||
"-j", "1",
|
||||
SERVER_ARG,
|
||||
|
|
|
@ -60,6 +60,7 @@ public class IncCompileFullyQualifiedRef extends SJavacTester {
|
|||
|
||||
compile(GENSRC.toString(),
|
||||
"-d", BIN.toString(),
|
||||
"--state-dir=" + BIN,
|
||||
"-j", "1",
|
||||
SERVER_ARG,
|
||||
"--log=debug");
|
||||
|
@ -74,6 +75,7 @@ public class IncCompileFullyQualifiedRef extends SJavacTester {
|
|||
|
||||
compile(GENSRC.toString(),
|
||||
"-d", BIN.toString(),
|
||||
"--state-dir=" + BIN,
|
||||
"-j", "1",
|
||||
SERVER_ARG,
|
||||
"--log=debug");
|
||||
|
|
|
@ -69,6 +69,7 @@ public class IncCompileNoChanges extends SJavacTester {
|
|||
System.out.println("Testing that no change in sources implies no change in binaries");
|
||||
compile(GENSRC.toString(),
|
||||
"-d", BIN.toString(),
|
||||
"--state-dir=" + BIN,
|
||||
"-h", HEADERS.toString(),
|
||||
"-j", "1",
|
||||
SERVER_ARG,
|
||||
|
|
|
@ -76,6 +76,7 @@ public class IncCompileUpdateNative extends SJavacTester {
|
|||
|
||||
compile(GENSRC.toString(),
|
||||
"-d", BIN.toString(),
|
||||
"--state-dir=" + BIN,
|
||||
"-h", HEADERS.toString(),
|
||||
"-j", "1",
|
||||
SERVER_ARG,
|
||||
|
|
|
@ -78,6 +78,7 @@ public class IncCompileWithChanges extends SJavacTester {
|
|||
|
||||
compile(GENSRC.toString(),
|
||||
"-d", BIN.toString(),
|
||||
"--state-dir=" + BIN,
|
||||
"-h", HEADERS.toString(),
|
||||
"-j", "1",
|
||||
SERVER_ARG,
|
||||
|
|
63
langtools/test/tools/sjavac/NoState.java
Normal file
63
langtools/test/tools/sjavac/NoState.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Test --no-state option
|
||||
* @bug 8135131
|
||||
* @library /tools/lib
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.file
|
||||
* jdk.compiler/com.sun.tools.javac.main
|
||||
* jdk.compiler/com.sun.tools.sjavac
|
||||
* @build Wrapper ToolBox
|
||||
* @run main Wrapper NoState
|
||||
*/
|
||||
|
||||
import com.sun.tools.javac.util.Assert;
|
||||
|
||||
import java.util.*;
|
||||
import java.nio.file.*;
|
||||
|
||||
public class NoState extends SJavacTester {
|
||||
public static void main(String... args) throws Exception {
|
||||
new NoState().run();
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
clean(TEST_ROOT);
|
||||
ToolBox tb = new ToolBox();
|
||||
tb.writeFile(GENSRC.resolve("pkg/A.java"), "package pkg; class A {}");
|
||||
Files.createDirectory(BIN);
|
||||
compile("-d", BIN.toString(),
|
||||
"--server:portfile=testserver,background=false",
|
||||
GENSRC + "/pkg/A.java");
|
||||
|
||||
// Make sure file was compiled
|
||||
Assert.check(Files.exists(BIN.resolve("pkg/A.class")));
|
||||
|
||||
// Make sure we have no other files (such as a javac_state file) in the bin directory
|
||||
Assert.check(Files.list(BIN).count() == 1);
|
||||
Assert.check(Files.list(BIN.resolve("pkg")).count() == 1);
|
||||
}
|
||||
}
|
|
@ -59,7 +59,6 @@ import com.sun.tools.sjavac.options.SourceLocation;
|
|||
public class OptionDecoding {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
testPaths();
|
||||
testDupPaths();
|
||||
testSourceLocations();
|
||||
|
@ -67,30 +66,28 @@ public class OptionDecoding {
|
|||
testServerConf();
|
||||
testSearchPaths();
|
||||
testTranslationRules();
|
||||
|
||||
}
|
||||
|
||||
// Test decoding of output paths
|
||||
static void testPaths() throws IOException {
|
||||
|
||||
final String H = "headers";
|
||||
final String G = "gensrc";
|
||||
final String D = "dest";
|
||||
final String stateDir = "stateDir";
|
||||
final String CMP = "srcRefList.txt";
|
||||
|
||||
Options options = Options.parseArgs("-h", H, "-s", G, "-d", D,
|
||||
Options options = Options.parseArgs("-h", H, "-s", G, "-d", D, "--state-dir=" + stateDir,
|
||||
"--compare-found-sources", CMP);
|
||||
|
||||
assertEquals(Paths.get(H).toAbsolutePath(), options.getHeaderDir());
|
||||
assertEquals(Paths.get(G).toAbsolutePath(), options.getGenSrcDir());
|
||||
assertEquals(Paths.get(D).toAbsolutePath(), options.getDestDir());
|
||||
assertEquals(Paths.get(stateDir).toAbsolutePath(), options.getStateDir());
|
||||
assertEquals(Paths.get(CMP), options.getSourceReferenceList());
|
||||
|
||||
}
|
||||
|
||||
// Providing duplicate header / dest / gensrc paths should produce an error.
|
||||
static void testDupPaths() throws IOException {
|
||||
|
||||
try {
|
||||
Options.parseArgs("-h", "dir1", "-h", "dir2");
|
||||
throw new RuntimeException("Duplicate header directories should fail.");
|
||||
|
@ -111,12 +108,10 @@ public class OptionDecoding {
|
|||
} catch (IllegalArgumentException iae) {
|
||||
// Expected
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Test source locations and -x, -i, -xf, -if filters
|
||||
static void testSourceLocations() throws IOException {
|
||||
|
||||
Path a1 = Paths.get("root/pkg1/ClassA1.java");
|
||||
Path a2 = Paths.get("root/pkg1/ClassA2.java");
|
||||
Path b1 = Paths.get("root/pkg1/pkg2/ClassB1.java");
|
||||
|
@ -185,12 +180,10 @@ public class OptionDecoding {
|
|||
|
||||
checkFilesFound(foundFiles.keySet(), a1, a2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Test basic options
|
||||
static void testSimpleOptions() {
|
||||
|
||||
Options options = Options.parseArgs("-j", "17", "--log=debug");
|
||||
assertEquals(17, options.getNumCores());
|
||||
assertEquals("debug", options.getLogLevel());
|
||||
|
@ -239,7 +232,6 @@ public class OptionDecoding {
|
|||
|
||||
// Test -tr option
|
||||
static void testTranslationRules() {
|
||||
|
||||
Class<?> cls = com.sun.tools.sjavac.CompileJavaPackages.class;
|
||||
|
||||
Options options = Options.parseArgs(
|
||||
|
@ -250,6 +242,5 @@ public class OptionDecoding {
|
|||
assertEquals(cls, options.getTranslationRules().get(".exa").getClass());
|
||||
assertEquals(cls, options.getTranslationRules().get(".exb").getClass());
|
||||
assertEquals(CopyFile.class, options.getTranslationRules().get(".html").getClass());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,21 +46,22 @@ class ParallelCompilations extends SJavacTester {
|
|||
|
||||
public void run() throws Exception {
|
||||
ToolBox tb = new ToolBox();
|
||||
final String SERVER_ARG = "--server:"
|
||||
+ "portfile=testportfile,"
|
||||
+ "background=false";
|
||||
|
||||
// Generate 10 files
|
||||
for (int i = 0; i < 10; i++) {
|
||||
String fileName = "Test" + i;
|
||||
String content = "package foo"+ i + ";\n" +
|
||||
"public class "+ fileName + "{\n" +
|
||||
"public class Test" + i + "{\n" +
|
||||
" public static void main(String[] args) {}\n" +
|
||||
"\n}";
|
||||
Path srcDir = Paths.get("src");
|
||||
tb.writeJavaFiles(srcDir,content);
|
||||
tb.writeJavaFiles(srcDir, content);
|
||||
}
|
||||
//Method will throw an exception if compilation fails
|
||||
compile("src", "-d", "classes", "-j", "10", SERVER_ARG, "--log=debug");
|
||||
// Method will throw an exception if compilation fails
|
||||
compile("src",
|
||||
"-d", BIN.toString(),
|
||||
"--state-dir=" + BIN,
|
||||
"-j", "10",
|
||||
SERVER_ARG,
|
||||
"--log=debug");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ public class PermittedArtifact extends SJavacTester {
|
|||
"--permit-artifact=" + BIN + "/alfa/omega/AA.class",
|
||||
"-src", GENSRC.toString(),
|
||||
"-d", BIN.toString(),
|
||||
"--state-dir=" + BIN,
|
||||
SERVER_ARG);
|
||||
|
||||
Map<String,Long> new_bin_state = collectState(BIN);
|
||||
|
|
|
@ -87,6 +87,7 @@ public class SJavacTester {
|
|||
|
||||
compile(GENSRC.toString(),
|
||||
"-d", BIN.toString(),
|
||||
"--state-dir=" + BIN,
|
||||
"-h", HEADERS.toString(),
|
||||
"-j", "1",
|
||||
SERVER_ARG,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue