8136930: Simplify use of module-system options by custom launchers
8160489: Multiple -Xpatch lines ignored by javac 8156998: javac should support new option -XinheritRuntimeEnvironment Reviewed-by: jlahoda, ksrini
This commit is contained in:
parent
3b80559162
commit
978417c4c7
langtools
make/tools/crules
src
jdk.compiler/share/classes/com/sun/tools
javac
api
code
comp
file
jvm
main
processing
resources
util
javah
sjavac/options
jdk.javadoc/share/classes
com/sun/tools/javadoc
jdk/javadoc/internal/tool
jdk.jdeps/share/classes/com/sun/tools
javap
jdeps
test
ProblemList.txtTEST.ROOT
jdk/javadoc
doclet/testModules
tool
tools
all
javac
6410653
T6358024.javaT6358166.javaT6403466.javaT6406771.javaT8003967
T8010737
api
classfiles/attributes/Module
diags
Example.javaexamples.not-yet.txt
examples
AddmodsAllModulePathInvalid
CantFindModule
IllegalArgumentForOption
InvalidArgForXPatch
InvalidDefaultInterface
InvalidStaticInterface
XaddexportsMalformedEntry.javaXaddexportsTooMany.javaXaddreadsMalformedEntry.javaXaddreadsTooMany.javafatalErrors
file
modules
AddLimitMods.javaAddReadsTest.javaAnnotationProcessing.javaAnnotationProcessorsInModulesTest.javaAutomaticModules.javaDoclintOtherModules.javaDuplicateClassTest.javaEdgeCases.javaEnvVarTest.javaGraphsTest.javaHelloWorldTest.javaInheritRuntimeEnvironmentTest.javaMOptionTest.javaMissingJarInModulePathTest.javaModuleFinderTest.javaModuleInfoTest.javaModulePathTest.javaModuleSourcePathTest.javaModuleTestBase.javaModulesAndClassPathTest.javaMultiModuleModeTest.javaNPEEmptyFileTest.javaOutputDirTest.javaPackageConflictTest.javaPackageMultipleModules.javaPatchModulesTest.javaPluginsInModulesTest.javaProvidesTest.javaQueryBeforeEnter.javaRequiresPublicTest.java
@ -107,6 +107,8 @@ public class MutableFieldsAnalyzer extends AbstractCodingRulesAnalyzer {
|
||||
"layerClass", "bootMethod", "defineModulesWithOneLoaderMethod", "configurationMethod");
|
||||
ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$ServiceLoaderHelper",
|
||||
"loadMethod");
|
||||
ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$VMHelper",
|
||||
"vmClass", "getRuntimeArgumentsMethod");
|
||||
ignoreFields("com.sun.tools.javac.util.ModuleHelper",
|
||||
"addExportsMethod", "getUnnamedModuleMethod", "getModuleMethod");
|
||||
}
|
||||
|
@ -179,10 +179,10 @@ public final class JavacTool implements JavaCompiler {
|
||||
args.init("javac", options, classes, compilationUnits);
|
||||
|
||||
// init multi-release jar handling
|
||||
if (fileManager.isSupportedOption(Option.MULTIRELEASE.text) == 1) {
|
||||
if (fileManager.isSupportedOption(Option.MULTIRELEASE.primaryName) == 1) {
|
||||
Target target = Target.instance(context);
|
||||
List<String> list = List.of(target.multiReleaseValue());
|
||||
fileManager.handleOption(Option.MULTIRELEASE.text, list.iterator());
|
||||
fileManager.handleOption(Option.MULTIRELEASE.primaryName, list.iterator());
|
||||
}
|
||||
|
||||
return new JavacTaskImpl(context);
|
||||
@ -212,8 +212,9 @@ public final class JavacTool implements JavaCompiler {
|
||||
public int isSupportedOption(String option) {
|
||||
Set<Option> recognizedOptions = Option.getJavacToolOptions();
|
||||
for (Option o : recognizedOptions) {
|
||||
if (o.matches(option))
|
||||
if (o.matches(option)) {
|
||||
return o.hasArg() ? 1 : 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ import com.sun.tools.javac.file.JRTIndex;
|
||||
import com.sun.tools.javac.file.JavacFileManager;
|
||||
import com.sun.tools.javac.jvm.ClassReader;
|
||||
import com.sun.tools.javac.jvm.Profile;
|
||||
import com.sun.tools.javac.main.Option;
|
||||
import com.sun.tools.javac.platform.PlatformDescription;
|
||||
import com.sun.tools.javac.util.*;
|
||||
|
||||
@ -59,8 +60,6 @@ import static javax.tools.StandardLocation.*;
|
||||
import static com.sun.tools.javac.code.Flags.*;
|
||||
import static com.sun.tools.javac.code.Kinds.Kind.*;
|
||||
|
||||
import static com.sun.tools.javac.main.Option.*;
|
||||
|
||||
import com.sun.tools.javac.util.Dependencies.CompletionCause;
|
||||
|
||||
/**
|
||||
@ -200,10 +199,10 @@ public class ClassFinder {
|
||||
annotate = Annotate.instance(context);
|
||||
|
||||
Options options = Options.instance(context);
|
||||
verbose = options.isSet(VERBOSE);
|
||||
verbose = options.isSet(Option.VERBOSE);
|
||||
cacheCompletionFailure = options.isUnset("dev");
|
||||
preferSource = "source".equals(options.get("-Xprefer"));
|
||||
userPathsFirst = options.isSet(XXUSERPATHSFIRST);
|
||||
userPathsFirst = options.isSet(Option.XXUSERPATHSFIRST);
|
||||
allowSigFiles = context.get(PlatformDescription.class) != null;
|
||||
|
||||
completionFailureName =
|
||||
@ -211,7 +210,7 @@ public class ClassFinder {
|
||||
? names.fromString(options.get("failcomplete"))
|
||||
: null;
|
||||
|
||||
moduleOverride = options.isSet(XMODULE) ? names.fromString(options.get(XMODULE))
|
||||
moduleOverride = options.isSet(Option.XMODULE) ? names.fromString(options.get(Option.XMODULE))
|
||||
: null;
|
||||
|
||||
// Temporary, until more info is available from the module system.
|
||||
|
@ -182,10 +182,10 @@ public class Modules extends JCTree.Visitor {
|
||||
java_se = names.fromString("java.se");
|
||||
java_ = names.fromString("java.");
|
||||
|
||||
addExportsOpt = options.get(Option.XADDEXPORTS);
|
||||
addReadsOpt = options.get(Option.XADDREADS);
|
||||
addModsOpt = options.get(Option.ADDMODS);
|
||||
limitModsOpt = options.get(Option.LIMITMODS);
|
||||
addExportsOpt = options.get(Option.ADD_EXPORTS);
|
||||
addReadsOpt = options.get(Option.ADD_READS);
|
||||
addModsOpt = options.get(Option.ADD_MODULES);
|
||||
limitModsOpt = options.get(Option.LIMIT_MODULES);
|
||||
}
|
||||
|
||||
int depth = -1;
|
||||
|
@ -232,7 +232,7 @@ public abstract class BaseFileManager implements JavaFileManager {
|
||||
OptionHelper helper = new GrumpyHelper(log) {
|
||||
@Override
|
||||
public String get(Option option) {
|
||||
return options.get(option.getText());
|
||||
return options.get(option);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -251,23 +251,15 @@ public abstract class BaseFileManager implements JavaFileManager {
|
||||
}
|
||||
};
|
||||
|
||||
for (Option o: javacFileManagerOptions) {
|
||||
if (o.matches(current)) {
|
||||
if (o.hasArg()) {
|
||||
if (remaining.hasNext()) {
|
||||
if (!o.process(helper, current, remaining.next()))
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (!o.process(helper, current))
|
||||
return true;
|
||||
}
|
||||
// operand missing, or process returned true
|
||||
throw new IllegalArgumentException(current);
|
||||
}
|
||||
Option o = Option.lookup(current, javacFileManagerOptions);
|
||||
if (o == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
if (!o.handleOption(helper, current, remaining))
|
||||
throw new IllegalArgumentException(current);
|
||||
|
||||
return true;
|
||||
}
|
||||
// where
|
||||
private static final Set<Option> javacFileManagerOptions =
|
||||
@ -275,11 +267,8 @@ public abstract class BaseFileManager implements JavaFileManager {
|
||||
|
||||
@Override @DefinedBy(Api.COMPILER)
|
||||
public int isSupportedOption(String option) {
|
||||
for (Option o : javacFileManagerOptions) {
|
||||
if (o.matches(option))
|
||||
return o.hasArg() ? 1 : 0;
|
||||
}
|
||||
return -1;
|
||||
Option o = Option.lookup(option, javacFileManagerOptions);
|
||||
return (o == null) ? -1 : o.hasArg() ? 1 : 0;
|
||||
}
|
||||
|
||||
protected String multiReleaseValue;
|
||||
@ -316,7 +305,7 @@ public abstract class BaseFileManager implements JavaFileManager {
|
||||
try {
|
||||
ok = ok & handleOption(e.getKey(), e.getValue());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
log.error(Errors.IllegalArgumentForOption(e.getKey().getText(), ex.getMessage()));
|
||||
log.error(Errors.IllegalArgumentForOption(e.getKey().getPrimaryName(), ex.getMessage()));
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ import com.sun.tools.javac.util.StringUtils;
|
||||
|
||||
import static javax.tools.StandardLocation.PLATFORM_CLASS_PATH;
|
||||
|
||||
import static com.sun.tools.javac.main.Option.BOOTCLASSPATH;
|
||||
import static com.sun.tools.javac.main.Option.BOOT_CLASS_PATH;
|
||||
import static com.sun.tools.javac.main.Option.DJAVA_ENDORSED_DIRS;
|
||||
import static com.sun.tools.javac.main.Option.DJAVA_EXT_DIRS;
|
||||
import static com.sun.tools.javac.main.Option.ENDORSEDDIRS;
|
||||
@ -580,8 +580,7 @@ public class Locations {
|
||||
private class ClassPathLocationHandler extends SimpleLocationHandler {
|
||||
|
||||
ClassPathLocationHandler() {
|
||||
super(StandardLocation.CLASS_PATH,
|
||||
Option.CLASSPATH, Option.CP);
|
||||
super(StandardLocation.CLASS_PATH, Option.CLASS_PATH);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -649,7 +648,7 @@ public class Locations {
|
||||
|
||||
BootClassPathLocationHandler() {
|
||||
super(StandardLocation.PLATFORM_CLASS_PATH,
|
||||
Option.BOOTCLASSPATH, Option.XBOOTCLASSPATH,
|
||||
Option.BOOT_CLASS_PATH, Option.XBOOTCLASSPATH,
|
||||
Option.XBOOTCLASSPATH_PREPEND,
|
||||
Option.XBOOTCLASSPATH_APPEND,
|
||||
Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
|
||||
@ -669,7 +668,7 @@ public class Locations {
|
||||
|
||||
option = canonicalize(option);
|
||||
optionValues.put(option, value);
|
||||
if (option == BOOTCLASSPATH) {
|
||||
if (option == BOOT_CLASS_PATH) {
|
||||
optionValues.remove(XBOOTCLASSPATH_PREPEND);
|
||||
optionValues.remove(XBOOTCLASSPATH_APPEND);
|
||||
}
|
||||
@ -682,7 +681,7 @@ public class Locations {
|
||||
private Option canonicalize(Option option) {
|
||||
switch (option) {
|
||||
case XBOOTCLASSPATH:
|
||||
return Option.BOOTCLASSPATH;
|
||||
return Option.BOOT_CLASS_PATH;
|
||||
case DJAVA_ENDORSED_DIRS:
|
||||
return Option.ENDORSEDDIRS;
|
||||
case DJAVA_EXT_DIRS:
|
||||
@ -713,7 +712,7 @@ public class Locations {
|
||||
SearchPath computePath() throws IOException {
|
||||
SearchPath path = new SearchPath();
|
||||
|
||||
String bootclasspathOpt = optionValues.get(BOOTCLASSPATH);
|
||||
String bootclasspathOpt = optionValues.get(BOOT_CLASS_PATH);
|
||||
String endorseddirsOpt = optionValues.get(ENDORSEDDIRS);
|
||||
String extdirsOpt = optionValues.get(EXTDIRS);
|
||||
String xbootclasspathPrependOpt = optionValues.get(XBOOTCLASSPATH_PREPEND);
|
||||
@ -1141,7 +1140,7 @@ public class Locations {
|
||||
|
||||
ModuleSourcePathLocationHandler() {
|
||||
super(StandardLocation.MODULE_SOURCE_PATH,
|
||||
Option.MODULESOURCEPATH);
|
||||
Option.MODULE_SOURCE_PATH);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1473,16 +1472,16 @@ public class Locations {
|
||||
BasicLocationHandler[] handlers = {
|
||||
new BootClassPathLocationHandler(),
|
||||
new ClassPathLocationHandler(),
|
||||
new SimpleLocationHandler(StandardLocation.SOURCE_PATH, Option.SOURCEPATH),
|
||||
new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_PATH, Option.PROCESSORPATH),
|
||||
new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_MODULE_PATH, Option.PROCESSORMODULEPATH),
|
||||
new SimpleLocationHandler(StandardLocation.SOURCE_PATH, Option.SOURCE_PATH),
|
||||
new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_PATH, Option.PROCESSOR_PATH),
|
||||
new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_MODULE_PATH, Option.PROCESSOR_MODULE_PATH),
|
||||
new OutputLocationHandler(StandardLocation.CLASS_OUTPUT, Option.D),
|
||||
new OutputLocationHandler(StandardLocation.SOURCE_OUTPUT, Option.S),
|
||||
new OutputLocationHandler(StandardLocation.NATIVE_HEADER_OUTPUT, Option.H),
|
||||
new ModuleSourcePathLocationHandler(),
|
||||
// TODO: should UPGRADE_MODULE_PATH be merged with SYSTEM_MODULES?
|
||||
new ModulePathLocationHandler(StandardLocation.UPGRADE_MODULE_PATH, Option.UPGRADEMODULEPATH),
|
||||
new ModulePathLocationHandler(StandardLocation.MODULE_PATH, Option.MODULEPATH, Option.MP),
|
||||
new ModulePathLocationHandler(StandardLocation.UPGRADE_MODULE_PATH, Option.UPGRADE_MODULE_PATH),
|
||||
new ModulePathLocationHandler(StandardLocation.MODULE_PATH, Option.MODULE_PATH),
|
||||
new SystemModulesLocationHandler(),
|
||||
};
|
||||
|
||||
@ -1498,29 +1497,42 @@ public class Locations {
|
||||
|
||||
boolean handleOption(Option option, String value) {
|
||||
switch (option) {
|
||||
case XPATCH:
|
||||
Map<String, SearchPath> map = new LinkedHashMap<>();
|
||||
int eq = value.indexOf('=');
|
||||
if (eq > 0) {
|
||||
String mName = value.substring(0, eq);
|
||||
SearchPath mPatchPath = new SearchPath()
|
||||
.addFiles(value.substring(eq + 1));
|
||||
boolean ok = true;
|
||||
for (Path p: mPatchPath) {
|
||||
Path mi = p.resolve("module-info.class");
|
||||
if (Files.exists(mi)) {
|
||||
log.error(Errors.LocnModuleInfoNotAllowedOnPatchPath(mi));
|
||||
ok = false;
|
||||
case PATCH_MODULE:
|
||||
if (value == null) {
|
||||
patchMap = null;
|
||||
} else {
|
||||
// Allow an extended syntax for --patch-module consisting of a series
|
||||
// of values separated by NULL characters. This is to facilitate
|
||||
// supporting deferred file manager options on the command line.
|
||||
// See Option.PATCH_MODULE for the code that composes these multiple
|
||||
// values.
|
||||
for (String v : value.split("\0")) {
|
||||
int eq = v.indexOf('=');
|
||||
if (eq > 0) {
|
||||
String mName = v.substring(0, eq);
|
||||
SearchPath mPatchPath = new SearchPath()
|
||||
.addFiles(v.substring(eq + 1));
|
||||
boolean ok = true;
|
||||
for (Path p : mPatchPath) {
|
||||
Path mi = p.resolve("module-info.class");
|
||||
if (Files.exists(mi)) {
|
||||
log.error(Errors.LocnModuleInfoNotAllowedOnPatchPath(mi));
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
if (patchMap == null) {
|
||||
patchMap = new LinkedHashMap<>();
|
||||
}
|
||||
patchMap.put(mName, mPatchPath);
|
||||
}
|
||||
} else {
|
||||
// Should not be able to get here;
|
||||
// this should be caught and handled in Option.PATCH_MODULE
|
||||
log.error(Errors.LocnInvalidArgForXpatch(value));
|
||||
}
|
||||
}
|
||||
if (ok && !mPatchPath.isEmpty()) {
|
||||
map.computeIfAbsent(mName, (_x) -> new SearchPath())
|
||||
.addAll(mPatchPath);
|
||||
}
|
||||
} else {
|
||||
log.error(Errors.LocnInvalidArgForXpatch(value));
|
||||
}
|
||||
patchMap = map;
|
||||
return true;
|
||||
default:
|
||||
LocationHandler h = handlersForOption.get(option);
|
||||
|
@ -55,6 +55,7 @@ import com.sun.tools.javac.file.BaseFileManager;
|
||||
import com.sun.tools.javac.file.PathFileObject;
|
||||
import com.sun.tools.javac.jvm.ClassFile.NameAndType;
|
||||
import com.sun.tools.javac.jvm.ClassFile.Version;
|
||||
import com.sun.tools.javac.main.Option;
|
||||
import com.sun.tools.javac.util.*;
|
||||
import com.sun.tools.javac.util.DefinedBy.Api;
|
||||
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
|
||||
@ -67,7 +68,7 @@ import static com.sun.tools.javac.code.TypeTag.TYPEVAR;
|
||||
import static com.sun.tools.javac.jvm.ClassFile.*;
|
||||
import static com.sun.tools.javac.jvm.ClassFile.Version.*;
|
||||
|
||||
import static com.sun.tools.javac.main.Option.*;
|
||||
import static com.sun.tools.javac.main.Option.PARAMETERS;
|
||||
|
||||
/** This class provides operations to read a classfile into an internal
|
||||
* representation. The internal representation is anchored in a
|
||||
@ -236,7 +237,7 @@ public class ClassReader {
|
||||
log = Log.instance(context);
|
||||
|
||||
Options options = Options.instance(context);
|
||||
verbose = options.isSet(VERBOSE);
|
||||
verbose = options.isSet(Option.VERBOSE);
|
||||
|
||||
Source source = Source.instance(context);
|
||||
allowSimplifiedVarargs = source.allowSimplifiedVarargs();
|
||||
|
@ -63,6 +63,7 @@ import com.sun.tools.javac.platform.PlatformUtils;
|
||||
import com.sun.tools.javac.resources.CompilerProperties.Errors;
|
||||
import com.sun.tools.javac.resources.CompilerProperties.Warnings;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import com.sun.tools.javac.util.JCDiagnostic;
|
||||
import com.sun.tools.javac.util.List;
|
||||
import com.sun.tools.javac.util.ListBuffer;
|
||||
import com.sun.tools.javac.util.Log;
|
||||
@ -143,7 +144,7 @@ public class Arguments {
|
||||
|
||||
@Override
|
||||
public boolean handleFileManagerOption(Option option, String value) {
|
||||
options.put(option.getText(), value);
|
||||
options.put(option, value);
|
||||
deferredFileManagerOptions.put(option, value);
|
||||
return true;
|
||||
}
|
||||
@ -163,6 +164,11 @@ public class Arguments {
|
||||
Arguments.this.error(key, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(JCDiagnostic.Error error) {
|
||||
Arguments.this.error(error);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFile(Path p) {
|
||||
files.add(p);
|
||||
@ -193,12 +199,15 @@ public class Arguments {
|
||||
fileObjects = null;
|
||||
classNames = new LinkedHashSet<>();
|
||||
processArgs(List.from(args), Option.getJavaCompilerOptions(), cmdLineHelper, true, false);
|
||||
if (errors) {
|
||||
log.printLines(PrefixKind.JAVAC, "msg.usage", ownName);
|
||||
}
|
||||
}
|
||||
|
||||
private final OptionHelper apiHelper = new GrumpyHelper(null) {
|
||||
@Override
|
||||
public String get(Option option) {
|
||||
return options.get(option.getText());
|
||||
return options.get(option);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -297,8 +306,8 @@ public class Arguments {
|
||||
String platformString = options.get(Option.RELEASE);
|
||||
|
||||
checkOptionAllowed(platformString == null,
|
||||
option -> error("err.release.bootclasspath.conflict", option.getText()),
|
||||
Option.BOOTCLASSPATH, Option.XBOOTCLASSPATH, Option.XBOOTCLASSPATH_APPEND,
|
||||
option -> error("err.release.bootclasspath.conflict", option.getPrimaryName()),
|
||||
Option.BOOT_CLASS_PATH, Option.XBOOTCLASSPATH, Option.XBOOTCLASSPATH_APPEND,
|
||||
Option.XBOOTCLASSPATH_PREPEND,
|
||||
Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
|
||||
Option.EXTDIRS, Option.DJAVA_EXT_DIRS,
|
||||
@ -360,39 +369,29 @@ public class Arguments {
|
||||
}
|
||||
|
||||
Option option = null;
|
||||
|
||||
// first, check the provided set of javac options
|
||||
if (arg.startsWith("-")) {
|
||||
for (Option o : allowableOpts) {
|
||||
if (o.matches(arg)) {
|
||||
option = o;
|
||||
break;
|
||||
}
|
||||
}
|
||||
option = Option.lookup(arg, allowableOpts);
|
||||
} else if (allowOperands && Option.SOURCEFILE.matches(arg)) {
|
||||
option = Option.SOURCEFILE;
|
||||
}
|
||||
|
||||
if (option == null) {
|
||||
if (fm != null && fm.handleOption(arg, argIter)) {
|
||||
continue;
|
||||
if (option != null) {
|
||||
if (!option.handleOption(helper, arg, argIter)) {
|
||||
return false;
|
||||
}
|
||||
error("err.invalid.flag", arg);
|
||||
return false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (option.hasArg()) {
|
||||
if (!argIter.hasNext()) {
|
||||
error("err.req.arg", arg);
|
||||
return false;
|
||||
}
|
||||
String operand = argIter.next();
|
||||
if (option.process(helper, arg, operand)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (option.process(helper, arg)) {
|
||||
return false;
|
||||
}
|
||||
// check file manager option
|
||||
if (fm != null && fm.handleOption(arg, argIter)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// none of the above
|
||||
error("err.invalid.flag", arg);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -407,13 +406,13 @@ public class Arguments {
|
||||
*/
|
||||
public boolean validate() {
|
||||
JavaFileManager fm = getFileManager();
|
||||
if (options.isSet(Option.M)) {
|
||||
if (options.isSet(Option.MODULE)) {
|
||||
if (!fm.hasLocation(StandardLocation.CLASS_OUTPUT)) {
|
||||
log.error(Errors.OutputDirMustBeSpecifiedWithDashMOption);
|
||||
} else if (!fm.hasLocation(StandardLocation.MODULE_SOURCE_PATH)) {
|
||||
log.error(Errors.ModulesourcepathMustBeSpecifiedWithDashMOption);
|
||||
} else {
|
||||
java.util.List<String> modules = Arrays.asList(options.get(Option.M).split(","));
|
||||
java.util.List<String> modules = Arrays.asList(options.get(Option.MODULE).split(","));
|
||||
try {
|
||||
for (String module : modules) {
|
||||
Location sourceLoc = fm.getModuleLocation(StandardLocation.MODULE_SOURCE_PATH, module);
|
||||
@ -449,17 +448,20 @@ public class Arguments {
|
||||
|| options.isSet(Option.X)
|
||||
|| options.isSet(Option.VERSION)
|
||||
|| options.isSet(Option.FULLVERSION)
|
||||
|| options.isSet(Option.M))
|
||||
|| options.isSet(Option.MODULE))
|
||||
return true;
|
||||
|
||||
if (emptyAllowed)
|
||||
return true;
|
||||
|
||||
if (JavaCompiler.explicitAnnotationProcessingRequested(options)) {
|
||||
error("err.no.source.files.classes");
|
||||
} else {
|
||||
error("err.no.source.files");
|
||||
if (!errors) {
|
||||
if (JavaCompiler.explicitAnnotationProcessingRequested(options)) {
|
||||
error("err.no.source.files.classes");
|
||||
} else {
|
||||
error("err.no.source.files");
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -542,12 +544,12 @@ public class Arguments {
|
||||
|
||||
// This check is only effective in command line mode,
|
||||
// where the file manager options are added to options
|
||||
if (options.get(Option.BOOTCLASSPATH) != null) {
|
||||
if (options.get(Option.BOOT_CLASS_PATH) != null) {
|
||||
error("err.profile.bootclasspath.conflict");
|
||||
}
|
||||
}
|
||||
|
||||
if (options.isSet(Option.SOURCEPATH) && options.isSet(Option.MODULESOURCEPATH)) {
|
||||
if (options.isSet(Option.SOURCE_PATH) && options.isSet(Option.MODULE_SOURCE_PATH)) {
|
||||
error("err.sourcepath.modulesourcepath.conflict");
|
||||
}
|
||||
|
||||
@ -578,17 +580,17 @@ public class Arguments {
|
||||
|
||||
final Target t = target;
|
||||
checkOptionAllowed(t.compareTo(Target.JDK1_8) <= 0,
|
||||
option -> error("err.option.not.allowed.with.target", option.getText(), t.name),
|
||||
Option.BOOTCLASSPATH,
|
||||
option -> error("err.option.not.allowed.with.target", option.getPrimaryName(), t.name),
|
||||
Option.BOOT_CLASS_PATH,
|
||||
Option.XBOOTCLASSPATH_PREPEND, Option.XBOOTCLASSPATH, Option.XBOOTCLASSPATH_APPEND,
|
||||
Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
|
||||
Option.EXTDIRS, Option.DJAVA_EXT_DIRS);
|
||||
|
||||
checkOptionAllowed(t.compareTo(Target.JDK1_9) >= 0,
|
||||
option -> error("err.option.not.allowed.with.target", option.getText(), t.name),
|
||||
Option.MODULESOURCEPATH, Option.UPGRADEMODULEPATH,
|
||||
Option.SYSTEM, Option.MODULEPATH, Option.ADDMODS, Option.LIMITMODS,
|
||||
Option.XPATCH);
|
||||
option -> error("err.option.not.allowed.with.target", option.getPrimaryName(), t.name),
|
||||
Option.MODULE_SOURCE_PATH, Option.UPGRADE_MODULE_PATH,
|
||||
Option.SYSTEM, Option.MODULE_PATH, Option.ADD_MODULES, Option.LIMIT_MODULES,
|
||||
Option.PATCH_MODULE);
|
||||
|
||||
if (fm.hasLocation(StandardLocation.MODULE_SOURCE_PATH)) {
|
||||
if (!options.isSet(Option.PROC, "only")
|
||||
@ -608,7 +610,7 @@ public class Arguments {
|
||||
if (obsoleteOptionFound)
|
||||
log.warning(LintCategory.OPTIONS, "option.obsolete.suppression");
|
||||
|
||||
String addExports = options.get(Option.XADDEXPORTS);
|
||||
String addExports = options.get(Option.ADD_EXPORTS);
|
||||
if (addExports != null) {
|
||||
// Each entry must be of the form module/package=target-list where target-list is a
|
||||
// comma-separated list of module or ALL-UNNAMED.
|
||||
@ -636,7 +638,7 @@ public class Arguments {
|
||||
});
|
||||
}
|
||||
|
||||
String addReads = options.get(Option.XADDREADS);
|
||||
String addReads = options.get(Option.ADD_READS);
|
||||
if (addReads != null) {
|
||||
// Each entry must be of the form module=source-list where source-list is a
|
||||
// comma separated list of module or ALL-UNNAMED.
|
||||
@ -724,7 +726,7 @@ public class Arguments {
|
||||
for (String s: xdoclintCustom.split("\\s+")) {
|
||||
if (s.isEmpty())
|
||||
continue;
|
||||
doclintOpts.add(s.replace(Option.XDOCLINT_CUSTOM.text, DocLint.XMSGS_CUSTOM_PREFIX));
|
||||
doclintOpts.add(DocLint.XMSGS_CUSTOM_PREFIX + s);
|
||||
}
|
||||
}
|
||||
|
||||
@ -735,14 +737,13 @@ public class Arguments {
|
||||
|
||||
if (checkPackages != null) {
|
||||
for (String s : checkPackages.split("\\s+")) {
|
||||
doclintOpts.add(s.replace(Option.XDOCLINT_PACKAGE.text, DocLint.XCHECK_PACKAGE));
|
||||
doclintOpts.add(DocLint.XCHECK_PACKAGE + s);
|
||||
}
|
||||
}
|
||||
|
||||
// standard doclet normally generates H1, H2,
|
||||
// so for now, allow user comments to assume that
|
||||
doclintOpts.add(DocLint.XIMPLICIT_HEADERS + "2");
|
||||
|
||||
return List.from(doclintOpts.toArray(new String[doclintOpts.size()]));
|
||||
}
|
||||
|
||||
@ -771,6 +772,22 @@ public class Arguments {
|
||||
}
|
||||
}
|
||||
|
||||
void error(JCDiagnostic.Error error) {
|
||||
errors = true;
|
||||
switch (errorMode) {
|
||||
case ILLEGAL_ARGUMENT: {
|
||||
String msg = log.localize(error);
|
||||
throw new PropagatedException(new IllegalArgumentException(msg));
|
||||
}
|
||||
case ILLEGAL_STATE: {
|
||||
String msg = log.localize(error);
|
||||
throw new PropagatedException(new IllegalStateException(msg));
|
||||
}
|
||||
case LOG:
|
||||
report(error);
|
||||
}
|
||||
}
|
||||
|
||||
void error(String key, Object... args) {
|
||||
errors = true;
|
||||
switch (errorMode) {
|
||||
@ -784,7 +801,6 @@ public class Arguments {
|
||||
}
|
||||
case LOG:
|
||||
report(key, args);
|
||||
log.printLines(PrefixKind.JAVAC, "msg.usage", ownName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -797,6 +813,11 @@ public class Arguments {
|
||||
log.printRawLines(ownName + ": " + log.localize(PrefixKind.JAVAC, key, args));
|
||||
}
|
||||
|
||||
private void report(JCDiagnostic.Error error) {
|
||||
// Would be good to have support for -XDrawDiagnostics here
|
||||
log.printRawLines(ownName + ": " + log.localize(error));
|
||||
}
|
||||
|
||||
private JavaFileManager getFileManager() {
|
||||
if (fileManager == null)
|
||||
fileManager = context.get(JavaFileManager.class);
|
||||
|
@ -892,8 +892,8 @@ public class JavaCompiler {
|
||||
|
||||
// forcibly set the equivalent of -Xlint:-options, so that no further
|
||||
// warnings about command line options are generated from this point on
|
||||
options.put(XLINT_CUSTOM.text + "-" + LintCategory.OPTIONS.option, "true");
|
||||
options.remove(XLINT_CUSTOM.text + LintCategory.OPTIONS.option);
|
||||
options.put(XLINT_CUSTOM.primaryName + "-" + LintCategory.OPTIONS.option, "true");
|
||||
options.remove(XLINT_CUSTOM.primaryName + LintCategory.OPTIONS.option);
|
||||
|
||||
start_msec = now();
|
||||
|
||||
@ -1258,8 +1258,8 @@ public class JavaCompiler {
|
||||
static boolean explicitAnnotationProcessingRequested(Options options) {
|
||||
return
|
||||
options.isSet(PROCESSOR) ||
|
||||
options.isSet(PROCESSORPATH) ||
|
||||
options.isSet(PROCESSORMODULEPATH) ||
|
||||
options.isSet(PROCESSOR_PATH) ||
|
||||
options.isSet(PROCESSOR_MODULE_PATH) ||
|
||||
options.isSet(PROC, "only") ||
|
||||
options.isSet(XPRINT);
|
||||
}
|
||||
|
@ -176,12 +176,13 @@ public class Main {
|
||||
log = Log.instance(context);
|
||||
|
||||
if (argv.length == 0) {
|
||||
Option.HELP.process(new OptionHelper.GrumpyHelper(log) {
|
||||
OptionHelper h = new OptionHelper.GrumpyHelper(log) {
|
||||
@Override
|
||||
public String getOwnName() { return ownName; }
|
||||
@Override
|
||||
public void put(String name, String value) { }
|
||||
}, "-help");
|
||||
};
|
||||
Option.HELP.process(h, "-help");
|
||||
return Result.CMDERR;
|
||||
}
|
||||
|
||||
@ -266,10 +267,10 @@ public class Main {
|
||||
}
|
||||
|
||||
// init multi-release jar handling
|
||||
if (fileManager.isSupportedOption(Option.MULTIRELEASE.text) == 1) {
|
||||
if (fileManager.isSupportedOption(Option.MULTIRELEASE.primaryName) == 1) {
|
||||
Target target = Target.instance(context);
|
||||
List<String> list = List.of(target.multiReleaseValue());
|
||||
fileManager.handleOption(Option.MULTIRELEASE.text, list.iterator());
|
||||
fileManager.handleOption(Option.MULTIRELEASE.primaryName, list.iterator());
|
||||
}
|
||||
|
||||
// init JavaCompiler
|
||||
|
@ -30,9 +30,14 @@ import java.io.PrintWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.Collator;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
@ -51,6 +56,9 @@ import com.sun.tools.javac.jvm.Profile;
|
||||
import com.sun.tools.javac.jvm.Target;
|
||||
import com.sun.tools.javac.platform.PlatformProvider;
|
||||
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
|
||||
import com.sun.tools.javac.resources.CompilerProperties.Errors;
|
||||
import com.sun.tools.javac.util.Assert;
|
||||
import com.sun.tools.javac.util.JDK9Wrappers;
|
||||
import com.sun.tools.javac.util.Log;
|
||||
import com.sun.tools.javac.util.Log.PrefixKind;
|
||||
import com.sun.tools.javac.util.Log.WriterKind;
|
||||
@ -62,10 +70,13 @@ import static com.sun.tools.javac.main.Option.OptionGroup.*;
|
||||
import static com.sun.tools.javac.main.Option.OptionKind.*;
|
||||
|
||||
/**
|
||||
* Options for javac. The specific Option to handle a command-line option
|
||||
* is identified by searching the members of this enum in order, looking for
|
||||
* the first {@link #matches match}. The action for an Option is performed
|
||||
* by calling {@link #process process}, and by providing a suitable
|
||||
* Options for javac.
|
||||
* The specific Option to handle a command-line option can be found by calling
|
||||
* {@link #lookup}, which search some or all of the members of this enum in order,
|
||||
* looking for the first {@link #matches match}.
|
||||
* The action for an Option is performed {@link #handleOption}, which determines
|
||||
* whether an argument is needed and where to find it;
|
||||
* {@code handleOption} then calls {@link #process process} providing a suitable
|
||||
* {@link OptionHelper} to provide access the compiler state.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
@ -89,17 +100,12 @@ public enum Option {
|
||||
|
||||
XLINT("-Xlint", "opt.Xlint", EXTENDED, BASIC),
|
||||
|
||||
XLINT_CUSTOM("-Xlint:", EXTENDED, BASIC, ANYOF, getXLintChoices()) {
|
||||
private static final String LINT_KEY_FORMAT = " %-19s %s";
|
||||
XLINT_CUSTOM("-Xlint:", "opt.arg.Xlint", "opt.Xlint.custom", EXTENDED, BASIC, ANYOF, getXLintChoices()) {
|
||||
private final String LINT_KEY_FORMAT = LARGE_INDENT + " %-" +
|
||||
(DEFAULT_SYNOPSIS_WIDTH + SMALL_INDENT.length() - LARGE_INDENT.length() - 2) + "s %s";
|
||||
@Override
|
||||
void help(Log log, OptionKind kind) {
|
||||
if (this.kind != kind)
|
||||
return;
|
||||
|
||||
log.printRawLines(WriterKind.STDOUT,
|
||||
String.format(HELP_LINE_FORMAT,
|
||||
log.localize(PrefixKind.JAVAC, "opt.Xlint.subopts"),
|
||||
log.localize(PrefixKind.JAVAC, "opt.Xlint.suboptlist")));
|
||||
protected void help(Log log) {
|
||||
super.help(log);
|
||||
log.printRawLines(WriterKind.STDOUT,
|
||||
String.format(LINT_KEY_FORMAT,
|
||||
"all",
|
||||
@ -125,14 +131,14 @@ public enum Option {
|
||||
@Override
|
||||
public boolean matches(String option) {
|
||||
return DocLint.isValidOption(
|
||||
option.replace(XDOCLINT_CUSTOM.text, DocLint.XMSGS_CUSTOM_PREFIX));
|
||||
option.replace(XDOCLINT_CUSTOM.primaryName, DocLint.XMSGS_CUSTOM_PREFIX));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(OptionHelper helper, String option) {
|
||||
String prev = helper.get(XDOCLINT_CUSTOM);
|
||||
String next = (prev == null) ? option : (prev + " " + option);
|
||||
helper.put(XDOCLINT_CUSTOM.text, next);
|
||||
helper.put(XDOCLINT_CUSTOM.primaryName, next);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
@ -141,14 +147,14 @@ public enum Option {
|
||||
@Override
|
||||
public boolean matches(String option) {
|
||||
return DocLint.isValidOption(
|
||||
option.replace(XDOCLINT_PACKAGE.text, DocLint.XCHECK_PACKAGE));
|
||||
option.replace(XDOCLINT_PACKAGE.primaryName, DocLint.XCHECK_PACKAGE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(OptionHelper helper, String option) {
|
||||
String prev = helper.get(XDOCLINT_PACKAGE);
|
||||
String next = (prev == null) ? option : (prev + " " + option);
|
||||
helper.put(XDOCLINT_PACKAGE.text, next);
|
||||
helper.put(XDOCLINT_PACKAGE.primaryName, next);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
@ -173,35 +179,55 @@ public enum Option {
|
||||
}
|
||||
},
|
||||
|
||||
CLASSPATH("-classpath", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER),
|
||||
CLASS_PATH("--class-path -classpath -cp", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER),
|
||||
|
||||
CP("-cp", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER) {
|
||||
SOURCE_PATH("--source-path -sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER),
|
||||
|
||||
MODULE_SOURCE_PATH("--module-source-path -modulesourcepath", "opt.arg.mspath", "opt.modulesourcepath", STANDARD, FILEMANAGER),
|
||||
|
||||
MODULE_PATH("--module-path -p -modulepath -mp", "opt.arg.path", "opt.modulepath", STANDARD, FILEMANAGER),
|
||||
|
||||
UPGRADE_MODULE_PATH("--upgrade-module-path -upgrademodulepath", "opt.arg.path", "opt.upgrademodulepath", STANDARD, FILEMANAGER),
|
||||
|
||||
SYSTEM("--system -system", "opt.arg.jdk", "opt.system", STANDARD, FILEMANAGER),
|
||||
|
||||
PATCH_MODULE("--patch-module -Xpatch:", "opt.arg.patch", "opt.patch", EXTENDED, FILEMANAGER) {
|
||||
// The deferred filemanager diagnostics mechanism assumes a single value per option,
|
||||
// but --patch-module can be used multiple times, once per module. Therefore we compose
|
||||
// a value for the option containing the last value specified for each module, and separate
|
||||
// the the module=path pairs by an invalid path character, NULL.
|
||||
// The standard file manager code knows to split apart the NULL-separated components.
|
||||
@Override
|
||||
public boolean process(OptionHelper helper, String option, String arg) {
|
||||
return super.process(helper, "-classpath", arg);
|
||||
if (!arg.contains("=")) { // could be more strict regeex, e.g. "(?i)[a-z0-9_.]+=.*"
|
||||
helper.error(Errors.LocnInvalidArgForXpatch(arg));
|
||||
}
|
||||
|
||||
String previous = helper.get(this);
|
||||
if (previous == null) {
|
||||
return super.process(helper, option, arg);
|
||||
}
|
||||
|
||||
Map<String,String> map = new LinkedHashMap<>();
|
||||
for (String s : previous.split("\0")) {
|
||||
int sep = s.indexOf('=');
|
||||
map.put(s.substring(0, sep), s.substring(sep + 1));
|
||||
}
|
||||
|
||||
int sep = arg.indexOf('=');
|
||||
map.put(arg.substring(0, sep), arg.substring(sep + 1));
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
map.forEach((m, p) -> {
|
||||
if (sb.length() > 0)
|
||||
sb.append('\0');
|
||||
sb.append(m).append('=').append(p);
|
||||
});
|
||||
return super.process(helper, option, sb.toString());
|
||||
}
|
||||
},
|
||||
|
||||
SOURCEPATH("-sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER),
|
||||
|
||||
MODULESOURCEPATH("-modulesourcepath", "opt.arg.mspath", "opt.modulesourcepath", STANDARD, FILEMANAGER),
|
||||
|
||||
MODULEPATH("-modulepath", "opt.arg.path", "opt.modulepath", STANDARD, FILEMANAGER),
|
||||
|
||||
MP("-mp", "opt.arg.path", "opt.modulepath", STANDARD, FILEMANAGER) {
|
||||
@Override
|
||||
public boolean process(OptionHelper helper, String option, String arg) {
|
||||
return super.process(helper, "-modulepath", arg);
|
||||
}
|
||||
},
|
||||
|
||||
UPGRADEMODULEPATH("-upgrademodulepath", "opt.arg.path", "opt.upgrademodulepath", STANDARD, FILEMANAGER),
|
||||
|
||||
SYSTEM("-system", "opt.arg.jdk", "opt.system", STANDARD, FILEMANAGER),
|
||||
|
||||
XPATCH("-Xpatch:", "opt.arg.patch", "opt.patch", EXTENDED, FILEMANAGER),
|
||||
|
||||
BOOTCLASSPATH("-bootclasspath", "opt.arg.path", "opt.bootclasspath", STANDARD, FILEMANAGER) {
|
||||
BOOT_CLASS_PATH("--boot-class-path -bootclasspath", "opt.arg.path", "opt.bootclasspath", STANDARD, FILEMANAGER) {
|
||||
@Override
|
||||
public boolean process(OptionHelper helper, String option, String arg) {
|
||||
helper.remove("-Xbootclasspath/p:");
|
||||
@ -228,7 +254,7 @@ public enum Option {
|
||||
DJAVA_EXT_DIRS("-Djava.ext.dirs=", "opt.arg.dirs", "opt.extdirs", EXTENDED, FILEMANAGER) {
|
||||
@Override
|
||||
public boolean process(OptionHelper helper, String option, String arg) {
|
||||
return super.process(helper, "-extdirs", arg);
|
||||
return EXTDIRS.process(helper, "-extdirs", arg);
|
||||
}
|
||||
},
|
||||
|
||||
@ -237,7 +263,7 @@ public enum Option {
|
||||
DJAVA_ENDORSED_DIRS("-Djava.endorsed.dirs=", "opt.arg.dirs", "opt.endorseddirs", EXTENDED, FILEMANAGER) {
|
||||
@Override
|
||||
public boolean process(OptionHelper helper, String option, String arg) {
|
||||
return super.process(helper, "-endorseddirs", arg);
|
||||
return ENDORSEDDIRS.process(helper, "-endorseddirs", arg);
|
||||
}
|
||||
},
|
||||
|
||||
@ -245,9 +271,9 @@ public enum Option {
|
||||
|
||||
PROCESSOR("-processor", "opt.arg.class.list", "opt.processor", STANDARD, BASIC),
|
||||
|
||||
PROCESSORPATH("-processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER),
|
||||
PROCESSOR_PATH("--processor-path -processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER),
|
||||
|
||||
PROCESSORMODULEPATH("-processormodulepath", "opt.arg.path", "opt.processormodulepath", STANDARD, FILEMANAGER),
|
||||
PROCESSOR_MODULE_PATH("--processor-module-path -processormodulepath", "opt.arg.path", "opt.processormodulepath", STANDARD, FILEMANAGER),
|
||||
|
||||
PARAMETERS("-parameters","opt.parameters", STANDARD, BASIC),
|
||||
|
||||
@ -285,12 +311,9 @@ public enum Option {
|
||||
}
|
||||
},
|
||||
|
||||
RELEASE("-release", "opt.arg.release", "opt.release", STANDARD, BASIC) {
|
||||
RELEASE("--release -release", "opt.arg.release", "opt.release", STANDARD, BASIC) {
|
||||
@Override
|
||||
void help(Log log, OptionKind kind) {
|
||||
if (this.kind != kind)
|
||||
return;
|
||||
|
||||
protected void help(Log log) {
|
||||
Iterable<PlatformProvider> providers =
|
||||
ServiceLoader.load(PlatformProvider.class, Arguments.class.getClassLoader());
|
||||
Set<String> platforms = StreamSupport.stream(providers.spliterator(), false)
|
||||
@ -307,10 +330,7 @@ public enum Option {
|
||||
delim = ", ";
|
||||
}
|
||||
|
||||
log.printRawLines(WriterKind.STDOUT,
|
||||
String.format(HELP_LINE_FORMAT,
|
||||
super.helpSynopsis(log),
|
||||
log.localize(PrefixKind.JAVAC, descrKey, targets.toString())));
|
||||
super.help(log, log.localize(PrefixKind.JAVAC, descrKey, targets.toString()));
|
||||
}
|
||||
},
|
||||
|
||||
@ -346,21 +366,20 @@ public enum Option {
|
||||
}
|
||||
},
|
||||
|
||||
HELP("-help", "opt.help", STANDARD, INFO) {
|
||||
// Note: -h is already taken for "native header output directory".
|
||||
HELP("--help -help", "opt.help", STANDARD, INFO) {
|
||||
@Override
|
||||
public boolean process(OptionHelper helper, String option) {
|
||||
Log log = helper.getLog();
|
||||
String ownName = helper.getOwnName();
|
||||
log.printLines(WriterKind.STDOUT, PrefixKind.JAVAC, "msg.usage.header", ownName);
|
||||
for (Option o: getJavaCompilerOptions()) {
|
||||
o.help(log, OptionKind.STANDARD);
|
||||
}
|
||||
showHelp(log, OptionKind.STANDARD);
|
||||
log.printNewline(WriterKind.STDOUT);
|
||||
return super.process(helper, option);
|
||||
}
|
||||
},
|
||||
|
||||
A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC, true) {
|
||||
A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC, ArgKind.ADJACENT) {
|
||||
@Override
|
||||
public boolean matches(String arg) {
|
||||
return arg.startsWith("-A");
|
||||
@ -385,7 +404,8 @@ public enum Option {
|
||||
helper.error("err.invalid.A.key", option);
|
||||
return true;
|
||||
}
|
||||
return process(helper, option, option);
|
||||
helper.put(option, option);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
@ -393,9 +413,7 @@ public enum Option {
|
||||
@Override
|
||||
public boolean process(OptionHelper helper, String option) {
|
||||
Log log = helper.getLog();
|
||||
for (Option o: getJavaCompilerOptions()) {
|
||||
o.help(log, OptionKind.EXTENDED);
|
||||
}
|
||||
showHelp(log, OptionKind.EXTENDED);
|
||||
log.printNewline(WriterKind.STDOUT);
|
||||
log.printLines(WriterKind.STDOUT, PrefixKind.JAVAC, "msg.usage.nonstandard.footer");
|
||||
return super.process(helper, option);
|
||||
@ -404,7 +422,7 @@ public enum Option {
|
||||
|
||||
// This option exists only for the purpose of documenting itself.
|
||||
// It's actually implemented by the launcher.
|
||||
J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO, true) {
|
||||
J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO, ArgKind.ADJACENT) {
|
||||
@Override
|
||||
public boolean process(OptionHelper helper, String option) {
|
||||
throw new AssertionError
|
||||
@ -484,7 +502,7 @@ public enum Option {
|
||||
public boolean process(OptionHelper helper, String option) {
|
||||
String p = option.substring(option.indexOf(':') + 1).trim();
|
||||
String prev = helper.get(PLUGIN);
|
||||
helper.put(PLUGIN.text, (prev == null) ? p : prev + '\0' + p);
|
||||
helper.put(PLUGIN.primaryName, (prev == null) ? p : prev + '\0' + p);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
@ -517,7 +535,7 @@ public enum Option {
|
||||
}
|
||||
},
|
||||
|
||||
DIAGS("-diags:", null, HIDDEN, BASIC, true) {
|
||||
DIAGS("-diags:", null, HIDDEN, BASIC) {
|
||||
@Override
|
||||
public boolean process(OptionHelper helper, String option) {
|
||||
return HiddenGroup.DIAGS.process(helper, option);
|
||||
@ -531,11 +549,11 @@ public enum Option {
|
||||
XD("-XD", null, HIDDEN, BASIC) {
|
||||
@Override
|
||||
public boolean matches(String s) {
|
||||
return s.startsWith(text);
|
||||
return s.startsWith(primaryName);
|
||||
}
|
||||
@Override
|
||||
public boolean process(OptionHelper helper, String option) {
|
||||
return process(helper, option, option.substring(text.length()));
|
||||
return process(helper, option, option.substring(primaryName.length()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -548,47 +566,45 @@ public enum Option {
|
||||
}
|
||||
},
|
||||
|
||||
XADDEXPORTS("-XaddExports:", "opt.arg.addExports", "opt.addExports", EXTENDED, BASIC) {
|
||||
ADD_EXPORTS("--add-exports -XaddExports:", "opt.arg.addExports", "opt.addExports", EXTENDED, BASIC) {
|
||||
@Override
|
||||
public boolean process(OptionHelper helper, String option) {
|
||||
String p = option.substring(option.indexOf(':') + 1).trim();
|
||||
String prev = helper.get(XADDEXPORTS);
|
||||
helper.put(XADDEXPORTS.text, (prev == null) ? p : prev + '\0' + p);
|
||||
public boolean process(OptionHelper helper, String option, String arg) {
|
||||
String prev = helper.get(ADD_EXPORTS);
|
||||
helper.put(ADD_EXPORTS.primaryName, (prev == null) ? arg : prev + '\0' + arg);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
XADDREADS("-XaddReads:", "opt.arg.addReads", "opt.addReads", EXTENDED, BASIC) {
|
||||
ADD_READS("--add-reads -XaddReads:", "opt.arg.addReads", "opt.addReads", EXTENDED, BASIC) {
|
||||
@Override
|
||||
public boolean process(OptionHelper helper, String option) {
|
||||
String p = option.substring(option.indexOf(':') + 1).trim();
|
||||
String prev = helper.get(XADDREADS);
|
||||
helper.put(XADDREADS.text, (prev == null) ? p : prev + '\0' + p);
|
||||
public boolean process(OptionHelper helper, String option, String arg) {
|
||||
String prev = helper.get(ADD_READS);
|
||||
helper.put(ADD_READS.primaryName, (prev == null) ? arg : prev + '\0' + arg);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
XMODULE("-Xmodule:", "opt.arg.module", "opt.module", EXTENDED, BASIC) {
|
||||
@Override
|
||||
public boolean process(OptionHelper helper, String option) {
|
||||
public boolean process(OptionHelper helper, String option, String arg) {
|
||||
String prev = helper.get(XMODULE);
|
||||
if (prev != null) {
|
||||
helper.error("err.option.too.many", XMODULE.text);
|
||||
helper.error("err.option.too.many", XMODULE.primaryName);
|
||||
}
|
||||
String p = option.substring(option.indexOf(':') + 1);
|
||||
helper.put(XMODULE.text, p);
|
||||
helper.put(XMODULE.primaryName, arg);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
M("-m", "opt.arg.m", "opt.m", STANDARD, BASIC),
|
||||
MODULE("--module -m", "opt.arg.m", "opt.m", STANDARD, BASIC),
|
||||
|
||||
ADDMODS("-addmods", "opt.arg.addmods", "opt.addmods", STANDARD, BASIC),
|
||||
LIMITMODS("-limitmods", "opt.arg.limitmods", "opt.limitmods", STANDARD, BASIC),
|
||||
ADD_MODULES("--add-modules -addmods", "opt.arg.addmods", "opt.addmods", STANDARD, BASIC),
|
||||
|
||||
LIMIT_MODULES("--limit-modules -limitmods", "opt.arg.limitmods", "opt.limitmods", STANDARD, BASIC),
|
||||
|
||||
// This option exists only for the purpose of documenting itself.
|
||||
// It's actually implemented by the CommandLine class.
|
||||
AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO, true) {
|
||||
AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO, ArgKind.ADJACENT) {
|
||||
@Override
|
||||
public boolean process(OptionHelper helper, String option) {
|
||||
throw new AssertionError("the @ flag should be caught by CommandLine.");
|
||||
@ -629,9 +645,78 @@ public enum Option {
|
||||
}
|
||||
},
|
||||
|
||||
MULTIRELEASE("-multi-release", "opt.arg.multi-release", "opt.multi-release", HIDDEN, FILEMANAGER);
|
||||
MULTIRELEASE("--multi-release -multi-release", "opt.arg.multi-release", "opt.multi-release", HIDDEN, FILEMANAGER),
|
||||
|
||||
/** The kind of an Option. This is used by the -help and -X options. */
|
||||
INHERIT_RUNTIME_ENVIRONMENT("--inherit-runtime-environment", "opt.inherit_runtime_environment",
|
||||
EXTENDED, BASIC) {
|
||||
@Override
|
||||
public boolean process(OptionHelper helper, String option) {
|
||||
try {
|
||||
Class.forName(JDK9Wrappers.VMHelper.VM_CLASSNAME);
|
||||
String[] runtimeArgs = JDK9Wrappers.VMHelper.getRuntimeArguments();
|
||||
for (String arg : runtimeArgs) {
|
||||
// Handle any supported runtime options; ignore all others.
|
||||
// The runtime arguments always use the single token form, e.g. "--name=value".
|
||||
for (Option o : getSupportedRuntimeOptions()) {
|
||||
if (o.matches(arg)) {
|
||||
o.handleOption(helper, arg, Collections.emptyIterator());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException | SecurityException e) {
|
||||
helper.error("err.cannot.access.runtime.env");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Option[] getSupportedRuntimeOptions() {
|
||||
Option[] supportedRuntimeOptions = {
|
||||
ADD_EXPORTS,
|
||||
ADD_MODULES,
|
||||
LIMIT_MODULES,
|
||||
MODULE_PATH,
|
||||
UPGRADE_MODULE_PATH,
|
||||
PATCH_MODULE
|
||||
};
|
||||
return supportedRuntimeOptions;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The kind of argument, if any, accepted by this option. The kind is augmented
|
||||
* by characters in the name of the option.
|
||||
*/
|
||||
public enum ArgKind {
|
||||
/** This option does not take any argument. */
|
||||
NONE,
|
||||
|
||||
// Not currently supported
|
||||
// /**
|
||||
// * This option takes an optional argument, which may be provided directly after an '='
|
||||
// * separator, or in the following argument position if that word does not itself appear
|
||||
// * to be the name of an option.
|
||||
// */
|
||||
// OPTIONAL,
|
||||
|
||||
/**
|
||||
* This option takes an argument.
|
||||
* If the name of option ends with ':' or '=', the argument must be provided directly
|
||||
* after that separator.
|
||||
* Otherwise, if may appear after an '=' or in the following argument position.
|
||||
*/
|
||||
REQUIRED,
|
||||
|
||||
/**
|
||||
* This option takes an argument immediately after the option name, with no separator
|
||||
* character.
|
||||
*/
|
||||
ADJACENT
|
||||
}
|
||||
|
||||
/**
|
||||
* The kind of an Option. This is used by the -help and -X options.
|
||||
*/
|
||||
public enum OptionKind {
|
||||
/** A standard option, documented by -help. */
|
||||
STANDARD,
|
||||
@ -641,8 +726,10 @@ public enum Option {
|
||||
HIDDEN,
|
||||
}
|
||||
|
||||
/** The group for an Option. This determines the situations in which the
|
||||
* option is applicable. */
|
||||
/**
|
||||
* The group for an Option. This determines the situations in which the
|
||||
* option is applicable.
|
||||
*/
|
||||
enum OptionGroup {
|
||||
/** A basic option, available for use on the command line or via the
|
||||
* Compiler API. */
|
||||
@ -656,7 +743,9 @@ public enum Option {
|
||||
OPERAND
|
||||
}
|
||||
|
||||
/** The kind of choice for "choice" options. */
|
||||
/**
|
||||
* The kind of choice for "choice" options.
|
||||
*/
|
||||
enum ChoiceKind {
|
||||
/** The expected value is exactly one of the set of choices. */
|
||||
ONEOF,
|
||||
@ -684,65 +773,113 @@ public enum Option {
|
||||
}
|
||||
}
|
||||
|
||||
public final String text;
|
||||
|
||||
final OptionKind kind;
|
||||
|
||||
final OptionGroup group;
|
||||
|
||||
/** Documentation key for arguments.
|
||||
/**
|
||||
* The "primary name" for this option.
|
||||
* This is the name that is used to put values in the {@link Options} table.
|
||||
*/
|
||||
final String argsNameKey;
|
||||
public final String primaryName;
|
||||
|
||||
/**
|
||||
* The set of names (primary name and aliases) for this option.
|
||||
* Note that some names may end in a separator, to indicate that an argument must immediately
|
||||
* follow the separator (and cannot appear in the following argument position.
|
||||
*/
|
||||
public final String[] names;
|
||||
|
||||
/** Documentation key for arguments. */
|
||||
protected final String argsNameKey;
|
||||
|
||||
/** Documentation key for description.
|
||||
*/
|
||||
final String descrKey;
|
||||
protected final String descrKey;
|
||||
|
||||
/** Suffix option (-foo=bar or -foo:bar)
|
||||
/** The kind of this option. */
|
||||
private final OptionKind kind;
|
||||
|
||||
/** The group for this option. */
|
||||
private final OptionGroup group;
|
||||
|
||||
/** The kind of argument for this option. */
|
||||
private final ArgKind argKind;
|
||||
|
||||
/** The kind of choices for this option, if any. */
|
||||
private final ChoiceKind choiceKind;
|
||||
|
||||
/** The choices for this option, if any, and whether or not the choices are hidden. */
|
||||
private final Map<String,Boolean> choices;
|
||||
|
||||
/**
|
||||
* Looks up the first option matching the given argument in the full set of options.
|
||||
* @param arg the argument to be matches
|
||||
* @return the first option that matches, or null if none.
|
||||
*/
|
||||
final boolean hasSuffix;
|
||||
public static Option lookup(String arg) {
|
||||
return lookup(arg, EnumSet.allOf(Option.class));
|
||||
}
|
||||
|
||||
/** The kind of choices for this option, if any.
|
||||
/**
|
||||
* Looks up the first option matching the given argument within a set of options.
|
||||
* @param arg the argument to be matches
|
||||
* @return the first option that matches, or null if none.
|
||||
*/
|
||||
final ChoiceKind choiceKind;
|
||||
public static Option lookup(String arg, Set<Option> options) {
|
||||
for (Option option: options) {
|
||||
if (option.matches(arg))
|
||||
return option;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** The choices for this option, if any, and whether or not the choices
|
||||
* are hidden
|
||||
/**
|
||||
* Writes the "command line help" for given kind of option to the log.
|
||||
* @param log the log
|
||||
* @param kind the kind of options to select
|
||||
*/
|
||||
final Map<String,Boolean> choices;
|
||||
private static void showHelp(Log log, OptionKind kind) {
|
||||
Comparator<Option> comp = new Comparator<Option>() {
|
||||
final Collator collator = Collator.getInstance(Locale.US);
|
||||
{ collator.setStrength(Collator.PRIMARY); }
|
||||
|
||||
@Override
|
||||
public int compare(Option o1, Option o2) {
|
||||
return collator.compare(o1.primaryName, o2.primaryName);
|
||||
}
|
||||
};
|
||||
|
||||
Option(String text, String descrKey,
|
||||
OptionKind kind, OptionGroup group) {
|
||||
this(text, null, descrKey, kind, group, null, null, false);
|
||||
getJavaCompilerOptions()
|
||||
.stream()
|
||||
.filter(o -> o.kind == kind)
|
||||
.sorted(comp)
|
||||
.forEach(o -> {
|
||||
o.help(log);
|
||||
});
|
||||
}
|
||||
|
||||
Option(String text, String descrKey,
|
||||
OptionKind kind, OptionGroup group,
|
||||
boolean doHasSuffix) {
|
||||
this(text, null, descrKey, kind, group, null, null, doHasSuffix);
|
||||
OptionKind kind, OptionGroup group) {
|
||||
this(text, null, descrKey, kind, group, null, null, ArgKind.NONE);
|
||||
}
|
||||
|
||||
Option(String text, String argsNameKey, String descrKey,
|
||||
OptionKind kind, OptionGroup group) {
|
||||
this(text, argsNameKey, descrKey, kind, group, null, null, false);
|
||||
this(text, argsNameKey, descrKey, kind, group, null, null, ArgKind.REQUIRED);
|
||||
}
|
||||
|
||||
Option(String text, String argsNameKey, String descrKey,
|
||||
OptionKind kind, OptionGroup group, boolean doHasSuffix) {
|
||||
this(text, argsNameKey, descrKey, kind, group, null, null, doHasSuffix);
|
||||
OptionKind kind, OptionGroup group, ArgKind ak) {
|
||||
this(text, argsNameKey, descrKey, kind, group, null, null, ak);
|
||||
}
|
||||
|
||||
Option(String text, OptionKind kind, OptionGroup group,
|
||||
Option(String text, String argsNameKey, String descrKey, OptionKind kind, OptionGroup group,
|
||||
ChoiceKind choiceKind, Map<String,Boolean> choices) {
|
||||
this(text, null, null, kind, group, choiceKind, choices, false);
|
||||
this(text, argsNameKey, descrKey, kind, group, choiceKind, choices, ArgKind.REQUIRED);
|
||||
}
|
||||
|
||||
Option(String text, String descrKey,
|
||||
OptionKind kind, OptionGroup group,
|
||||
ChoiceKind choiceKind, String... choices) {
|
||||
this(text, null, descrKey, kind, group, choiceKind,
|
||||
createChoices(choices), false);
|
||||
createChoices(choices), ArgKind.REQUIRED);
|
||||
}
|
||||
// where
|
||||
private static Map<String,Boolean> createChoices(String... choices) {
|
||||
@ -755,39 +892,60 @@ public enum Option {
|
||||
private Option(String text, String argsNameKey, String descrKey,
|
||||
OptionKind kind, OptionGroup group,
|
||||
ChoiceKind choiceKind, Map<String,Boolean> choices,
|
||||
boolean doHasSuffix) {
|
||||
this.text = text;
|
||||
ArgKind argKind) {
|
||||
this.names = text.trim().split("\\s+");
|
||||
Assert.check(names.length >= 1);
|
||||
this.primaryName = names[0];
|
||||
this.argsNameKey = argsNameKey;
|
||||
this.descrKey = descrKey;
|
||||
this.kind = kind;
|
||||
this.group = group;
|
||||
this.choiceKind = choiceKind;
|
||||
this.choices = choices;
|
||||
char lastChar = text.charAt(text.length()-1);
|
||||
this.hasSuffix = doHasSuffix || lastChar == ':' || lastChar == '=';
|
||||
this.argKind = argKind;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
public String getPrimaryName() {
|
||||
return primaryName;
|
||||
}
|
||||
|
||||
public OptionKind getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
public ArgKind getArgKind() {
|
||||
return argKind;
|
||||
}
|
||||
|
||||
public boolean hasArg() {
|
||||
return argsNameKey != null && !hasSuffix;
|
||||
return (argKind != ArgKind.NONE);
|
||||
}
|
||||
|
||||
public boolean matches(String option) {
|
||||
if (!hasSuffix)
|
||||
return option.equals(text);
|
||||
for (String name: names) {
|
||||
if (matches(option, name))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!option.startsWith(text))
|
||||
private boolean matches(String option, String name) {
|
||||
if (name.startsWith("--")) {
|
||||
return option.equals(name)
|
||||
|| hasArg() && option.startsWith(name + "=");
|
||||
}
|
||||
|
||||
boolean hasSuffix = (argKind == ArgKind.ADJACENT)
|
||||
|| name.endsWith(":") || name.endsWith("=");
|
||||
|
||||
if (!hasSuffix)
|
||||
return option.equals(name);
|
||||
|
||||
if (!option.startsWith(name))
|
||||
return false;
|
||||
|
||||
if (choices != null) {
|
||||
String arg = option.substring(text.length());
|
||||
String arg = option.substring(name.length());
|
||||
if (choiceKind == ChoiceKind.ONEOF)
|
||||
return choices.keySet().contains(arg);
|
||||
else {
|
||||
@ -801,55 +959,161 @@ public enum Option {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles an option.
|
||||
* If an argument for the option is required, depending on spec of the option, it will be found
|
||||
* as part of the current arg (following ':' or '=') or in the following argument.
|
||||
* This is the recommended way to handle an option directly, instead of calling the underlying
|
||||
* {@link #process process} methods.
|
||||
* @param helper a helper to provide access to the environment
|
||||
* @param arg the arg string that identified this option
|
||||
* @param rest the remaining strings to be analysed
|
||||
* @return true if the operation was successful, and false otherwise
|
||||
* @implNote The return value is the opposite of that used by {@link #process}.
|
||||
*/
|
||||
public boolean handleOption(OptionHelper helper, String arg, Iterator<String> rest) {
|
||||
if (hasArg()) {
|
||||
String operand;
|
||||
int sep = findSeparator(arg);
|
||||
if (getArgKind() == Option.ArgKind.ADJACENT) {
|
||||
operand = arg.substring(primaryName.length());
|
||||
} else if (sep > 0) {
|
||||
operand = arg.substring(sep + 1);
|
||||
} else {
|
||||
if (!rest.hasNext()) {
|
||||
helper.error("err.req.arg", arg);
|
||||
return false;
|
||||
}
|
||||
operand = rest.next();
|
||||
}
|
||||
return !process(helper, arg, operand);
|
||||
} else {
|
||||
return !process(helper, arg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes an option that either does not need an argument,
|
||||
* or which contains an argument within it, following a separator.
|
||||
* @param helper a helper to provide access to the environment
|
||||
* @param option the option to be processed
|
||||
* @return true if an error occurred
|
||||
*/
|
||||
public boolean process(OptionHelper helper, String option) {
|
||||
if (argKind == ArgKind.NONE) {
|
||||
return process(helper, primaryName, option);
|
||||
} else {
|
||||
int sep = findSeparator(option);
|
||||
return process(helper, primaryName, option.substring(sep + 1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes an option by updating the environment via a helper object.
|
||||
* @param helper a helper to provide access to the environment
|
||||
* @param option the option to be processed
|
||||
* @param arg the value to associate with the option, or a default value
|
||||
* to be used if the option does not otherwise take an argument.
|
||||
* @return true if an error occurred
|
||||
*/
|
||||
public boolean process(OptionHelper helper, String option, String arg) {
|
||||
if (choices != null) {
|
||||
if (choiceKind == ChoiceKind.ONEOF) {
|
||||
// some clients like to see just one of option+choice set
|
||||
for (String s: choices.keySet())
|
||||
helper.remove(option + s);
|
||||
String opt = option + arg;
|
||||
helper.remove(primaryName + s);
|
||||
String opt = primaryName + arg;
|
||||
helper.put(opt, opt);
|
||||
// some clients like to see option (without trailing ":")
|
||||
// set to arg
|
||||
String nm = option.substring(0, option.length() - 1);
|
||||
String nm = primaryName.substring(0, primaryName.length() - 1);
|
||||
helper.put(nm, arg);
|
||||
} else {
|
||||
// set option+word for each word in arg
|
||||
for (String a: arg.split(",+")) {
|
||||
String opt = option + a;
|
||||
String opt = primaryName + a;
|
||||
helper.put(opt, opt);
|
||||
}
|
||||
}
|
||||
}
|
||||
helper.put(option, arg);
|
||||
helper.put(primaryName, arg);
|
||||
if (group == OptionGroup.FILEMANAGER)
|
||||
helper.handleFileManagerOption(this, arg);
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean process(OptionHelper helper, String option) {
|
||||
if (hasSuffix)
|
||||
return process(helper, text, option.substring(text.length()));
|
||||
else
|
||||
return process(helper, option, option);
|
||||
/**
|
||||
* Scans a word to find the first separator character, either colon or equals.
|
||||
* @param word the word to be scanned
|
||||
* @return the position of the first':' or '=' character in the word,
|
||||
* or -1 if none found
|
||||
*/
|
||||
private static int findSeparator(String word) {
|
||||
for (int i = 0; i < word.length(); i++) {
|
||||
switch (word.charAt(i)) {
|
||||
case ':': case '=':
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static final String HELP_LINE_FORMAT = " %-26s %s";
|
||||
/** The indent for the option synopsis. */
|
||||
private static final String SMALL_INDENT = " ";
|
||||
/** The automatic indent for the description. */
|
||||
private static final String LARGE_INDENT = " ";
|
||||
/** The space allowed for the synopsis, if the description is to be shown on the same line. */
|
||||
private static final int DEFAULT_SYNOPSIS_WIDTH = 28;
|
||||
/** The nominal maximum line length, when seeing if text will fit on a line. */
|
||||
private static final int DEFAULT_MAX_LINE_LENGTH = 80;
|
||||
/** The format for a single-line help entry. */
|
||||
private static final String COMPACT_FORMAT = SMALL_INDENT + "%-" + DEFAULT_SYNOPSIS_WIDTH + "s %s";
|
||||
|
||||
void help(Log log, OptionKind kind) {
|
||||
if (this.kind != kind)
|
||||
/**
|
||||
* Writes help text for this option to the log.
|
||||
* @param log the log
|
||||
*/
|
||||
protected void help(Log log) {
|
||||
help(log, log.localize(PrefixKind.JAVAC, descrKey));
|
||||
}
|
||||
|
||||
protected void help(Log log, String descr) {
|
||||
String synopses = Arrays.stream(names)
|
||||
.map(s -> helpSynopsis(s, log))
|
||||
.collect(Collectors.joining(", "));
|
||||
|
||||
// If option synopses and description fit on a single line of reasonable length,
|
||||
// display using COMPACT_FORMAT
|
||||
if (synopses.length() < DEFAULT_SYNOPSIS_WIDTH
|
||||
&& !descr.contains("\n")
|
||||
&& (SMALL_INDENT.length() + DEFAULT_SYNOPSIS_WIDTH + 1 + descr.length() <= DEFAULT_MAX_LINE_LENGTH)) {
|
||||
log.printRawLines(WriterKind.STDOUT, String.format(COMPACT_FORMAT, synopses, descr));
|
||||
return;
|
||||
}
|
||||
|
||||
log.printRawLines(WriterKind.STDOUT,
|
||||
String.format(HELP_LINE_FORMAT,
|
||||
helpSynopsis(log),
|
||||
log.localize(PrefixKind.JAVAC, descrKey)));
|
||||
// If option synopses fit on a single line of reasonable length, show that;
|
||||
// otherwise, show 1 per line
|
||||
if (synopses.length() <= DEFAULT_MAX_LINE_LENGTH) {
|
||||
log.printRawLines(WriterKind.STDOUT, SMALL_INDENT + synopses);
|
||||
} else {
|
||||
for (String name: names) {
|
||||
log.printRawLines(WriterKind.STDOUT, SMALL_INDENT + helpSynopsis(name, log));
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, show the description
|
||||
log.printRawLines(WriterKind.STDOUT, LARGE_INDENT + descr.replace("\n", "\n" + LARGE_INDENT));
|
||||
}
|
||||
|
||||
private String helpSynopsis(Log log) {
|
||||
/**
|
||||
* Composes the initial synopsis of one of the forms for this option.
|
||||
* @param name the name of this form of the option
|
||||
* @param log the log used to localize the description of the arguments
|
||||
* @return the synopsis
|
||||
*/
|
||||
private String helpSynopsis(String name, Log log) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(text);
|
||||
sb.append(name);
|
||||
if (argsNameKey == null) {
|
||||
if (choices != null) {
|
||||
String sep = "{";
|
||||
@ -863,10 +1127,9 @@ public enum Option {
|
||||
sb.append("}");
|
||||
}
|
||||
} else {
|
||||
if (!hasSuffix)
|
||||
if (!name.matches(".*[=:]$") && argKind != ArgKind.ADJACENT)
|
||||
sb.append(" ");
|
||||
sb.append(log.localize(PrefixKind.JAVAC, argsNameKey));
|
||||
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
@ -915,24 +1178,35 @@ public enum Option {
|
||||
return choices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the set of options supported by the command line tool.
|
||||
* @return the set of options.
|
||||
*/
|
||||
static Set<Option> getJavaCompilerOptions() {
|
||||
return EnumSet.allOf(Option.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the set of options supported by the built-in file manager.
|
||||
* @return the set of options.
|
||||
*/
|
||||
public static Set<Option> getJavacFileManagerOptions() {
|
||||
return getOptions(EnumSet.of(FILEMANAGER));
|
||||
return getOptions(FILEMANAGER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the set of options supported by this implementation of
|
||||
* the JavaCompiler API, via {@link JavaCompiler#getTask}.
|
||||
* @return the set of options.
|
||||
*/
|
||||
public static Set<Option> getJavacToolOptions() {
|
||||
return getOptions(EnumSet.of(BASIC));
|
||||
return getOptions(BASIC);
|
||||
}
|
||||
|
||||
static Set<Option> getOptions(Set<OptionGroup> desired) {
|
||||
Set<Option> options = EnumSet.noneOf(Option.class);
|
||||
for (Option option : Option.values())
|
||||
if (desired.contains(option.group))
|
||||
options.add(option);
|
||||
return Collections.unmodifiableSet(options);
|
||||
private static Set<Option> getOptions(OptionGroup group) {
|
||||
return Arrays.stream(Option.values())
|
||||
.filter(o -> o.group == group)
|
||||
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Option.class)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ package com.sun.tools.javac.main;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import com.sun.tools.javac.util.JCDiagnostic;
|
||||
import com.sun.tools.javac.util.Log;
|
||||
import com.sun.tools.javac.util.Log.PrefixKind;
|
||||
|
||||
@ -63,6 +64,9 @@ public abstract class OptionHelper {
|
||||
/** Report an error. */
|
||||
abstract void error(String key, Object... args);
|
||||
|
||||
/** Report an error. */
|
||||
abstract void error(JCDiagnostic.Error error);
|
||||
|
||||
/** Record a file to be compiled. */
|
||||
abstract void addFile(Path p);
|
||||
|
||||
@ -112,6 +116,11 @@ public abstract class OptionHelper {
|
||||
throw new IllegalArgumentException(log.localize(PrefixKind.JAVAC, key, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
void error(JCDiagnostic.Error error) {
|
||||
throw new IllegalArgumentException(log.localize(error));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFile(Path p) {
|
||||
throw new IllegalArgumentException(p.toString());
|
||||
|
@ -62,6 +62,7 @@ import com.sun.tools.javac.comp.Env;
|
||||
import com.sun.tools.javac.comp.Modules;
|
||||
import com.sun.tools.javac.file.JavacFileManager;
|
||||
import com.sun.tools.javac.main.JavaCompiler;
|
||||
import com.sun.tools.javac.main.Option;
|
||||
import com.sun.tools.javac.model.JavacElements;
|
||||
import com.sun.tools.javac.model.JavacTypes;
|
||||
import com.sun.tools.javac.platform.PlatformDescription;
|
||||
@ -89,7 +90,6 @@ import com.sun.tools.javac.util.Options;
|
||||
|
||||
import static com.sun.tools.javac.code.Lint.LintCategory.PROCESSING;
|
||||
import static com.sun.tools.javac.code.Kinds.Kind.*;
|
||||
import static com.sun.tools.javac.main.Option.*;
|
||||
import static com.sun.tools.javac.comp.CompileStates.CompileState;
|
||||
import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*;
|
||||
|
||||
@ -196,17 +196,17 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
|
||||
source = Source.instance(context);
|
||||
diags = JCDiagnostic.Factory.instance(context);
|
||||
options = Options.instance(context);
|
||||
printProcessorInfo = options.isSet(XPRINTPROCESSORINFO);
|
||||
printRounds = options.isSet(XPRINTROUNDS);
|
||||
verbose = options.isSet(VERBOSE);
|
||||
printProcessorInfo = options.isSet(Option.XPRINTPROCESSORINFO);
|
||||
printRounds = options.isSet(Option.XPRINTROUNDS);
|
||||
verbose = options.isSet(Option.VERBOSE);
|
||||
lint = Lint.instance(context).isEnabled(PROCESSING);
|
||||
compiler = JavaCompiler.instance(context);
|
||||
if (options.isSet(PROC, "only") || options.isSet(XPRINT)) {
|
||||
if (options.isSet(Option.PROC, "only") || options.isSet(Option.XPRINT)) {
|
||||
compiler.shouldStopPolicyIfNoError = CompileState.PROCESS;
|
||||
}
|
||||
fatalErrors = options.isSet("fatalEnterError");
|
||||
showResolveErrors = options.isSet("showResolveErrors");
|
||||
werror = options.isSet(WERROR);
|
||||
werror = options.isSet(Option.WERROR);
|
||||
fileManager = context.get(JavaFileManager.class);
|
||||
platformAnnotations = initPlatformAnnotations();
|
||||
|
||||
@ -279,7 +279,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
|
||||
private void initProcessorIterator(Iterable<? extends Processor> processors) {
|
||||
Iterator<? extends Processor> processorIterator;
|
||||
|
||||
if (options.isSet(XPRINT)) {
|
||||
if (options.isSet(Option.XPRINT)) {
|
||||
try {
|
||||
processorIterator = List.of(new PrintingProcessor()).iterator();
|
||||
} catch (Throwable t) {
|
||||
@ -297,7 +297,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
|
||||
* path for the named class. Otherwise, use a service
|
||||
* provider mechanism to create the processor iterator.
|
||||
*/
|
||||
String processorNames = options.get(PROCESSOR);
|
||||
String processorNames = options.get(Option.PROCESSOR);
|
||||
if (fileManager.hasLocation(ANNOTATION_PROCESSOR_MODULE_PATH)) {
|
||||
processorIterator = (processorNames == null) ?
|
||||
new ServiceIterator(serviceLoader, log) :
|
||||
@ -363,7 +363,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
|
||||
? standardFileManager.getLocationAsPaths(ANNOTATION_PROCESSOR_PATH)
|
||||
: standardFileManager.getLocationAsPaths(CLASS_PATH);
|
||||
|
||||
if (needClassLoader(options.get(PROCESSOR), workingPath) )
|
||||
if (needClassLoader(options.get(Option.PROCESSOR), workingPath) )
|
||||
handleException(key, e);
|
||||
|
||||
} else {
|
||||
|
@ -1222,7 +1222,7 @@ compiler.err.locn.module-info.not.allowed.on.patch.path=\
|
||||
|
||||
# 0: string
|
||||
compiler.err.locn.invalid.arg.for.xpatch=\
|
||||
invalid argument for -Xpatch option: {0}
|
||||
invalid argument for --patch-module option: {0}
|
||||
|
||||
#####
|
||||
|
||||
|
@ -165,12 +165,12 @@ javac.opt.Xlint.all=\
|
||||
javac.opt.Xlint.none=\
|
||||
Disable all warnings
|
||||
#L10N: do not localize: -Xlint
|
||||
javac.opt.Xlint.subopts=\
|
||||
-Xlint:key,...
|
||||
javac.opt.Xlint.suboptlist=\n\
|
||||
\ Warnings to enable or disable, separated by comma.\n\
|
||||
\ Precede a key by '-' to disable the specified warning.\n\
|
||||
\ Supported keys are:
|
||||
javac.opt.arg.Xlint=\
|
||||
<key>(,<key>)*
|
||||
javac.opt.Xlint.custom=\
|
||||
Warnings to enable or disable, separated by comma.\n\
|
||||
Precede a key by '-' to disable the specified warning.\n\
|
||||
Supported keys are:
|
||||
javac.opt.Xlint.desc.auxiliaryclass=\
|
||||
Warn about an auxiliary class that is hidden in a source file, and is used from other files.
|
||||
|
||||
@ -239,20 +239,19 @@ javac.opt.Xdoclint.subopts = \
|
||||
|
||||
# L10N: do not localize: accessibility html missing reference syntax
|
||||
# L10N: do not localize: public protected package private
|
||||
javac.opt.Xdoclint.custom=\n\
|
||||
\ Enable or disable specific checks for problems in javadoc comments,\n\
|
||||
\ where <group> is one of accessibility, html, missing, reference, or syntax,\n\
|
||||
\ and <access> is one of public, protected, package, or private.
|
||||
javac.opt.Xdoclint.custom=\
|
||||
Enable or disable specific checks for problems in javadoc comments,\n\
|
||||
where <group> is one of accessibility, html, missing, reference, or syntax,\n\
|
||||
and <access> is one of public, protected, package, or private.
|
||||
|
||||
javac.opt.Xdoclint.package.args = \
|
||||
([-]<packages>)
|
||||
[-]<packages>(,[-]<package>)*
|
||||
|
||||
javac.opt.Xdoclint.package.desc=\n\
|
||||
\ Enable or disable checks in specific packages. <packages> is a comma separated\n\
|
||||
\ list of package specifiers. Package specifier is either a qualified name of a package\n\
|
||||
\ or a package name prefix followed by '.*', which expands to all sub-packages of\n\
|
||||
\ the given package. Prefix the package specifier with '-' to disable checks for\n\
|
||||
\ the specified packages.
|
||||
javac.opt.Xdoclint.package.desc=\
|
||||
Enable or disable checks in specific packages. Each <package> is either the\n\
|
||||
qualified name of a package or a package name prefix followed by '.*', which\n\
|
||||
expands to all sub-packages of the given package. Each <package> can be prefixed\n\
|
||||
with '-' to disable checks for the specified package or packages.
|
||||
|
||||
javac.opt.Xstdout=\
|
||||
Redirect standard output
|
||||
@ -274,34 +273,36 @@ javac.opt.AT=\
|
||||
Read options and filenames from file
|
||||
javac.opt.diags=\
|
||||
Select a diagnostic mode
|
||||
javac.opt.addExports=\n\
|
||||
\ Specify a package to be considered as exported from its defining module\n\
|
||||
\ to additional modules, or to all unnamed modules if <other-module> is ALL-UNNAMED.
|
||||
javac.opt.addExports=\
|
||||
Specify a package to be considered as exported from its defining module\n\
|
||||
to additional modules, or to all unnamed modules if <other-module> is ALL-UNNAMED.
|
||||
javac.opt.arg.addExports=\
|
||||
<module>/<package>=<other-module>(,<other-module>)*
|
||||
javac.opt.addReads=\n\
|
||||
\ Specify additional modules to be considered as required by a given module.\n\
|
||||
\ <other-module> may be ALL-UNNAMED to require the unnamed module.
|
||||
javac.opt.addReads=\
|
||||
Specify additional modules to be considered as required by a given module.\n\
|
||||
<other-module> may be ALL-UNNAMED to require the unnamed module.
|
||||
javac.opt.arg.addReads=\
|
||||
<module>=<other-module>(,<other-module>)*
|
||||
javac.opt.patch=\n\
|
||||
\ Override or augment a module with classes and resources\n\
|
||||
\ in JAR files or directories
|
||||
javac.opt.patch=\
|
||||
Override or augment a module with classes and resources\n\
|
||||
in JAR files or directories
|
||||
javac.opt.arg.patch=\
|
||||
<module>=<file>(:<file>)*
|
||||
javac.opt.module=\
|
||||
Specify a module to which the classes being compiled belong.
|
||||
javac.opt.arg.module=\
|
||||
<module-name>
|
||||
javac.opt.addmods=\n\
|
||||
\ Root modules to resolve in addition to the initial modules, or all modules\n\
|
||||
\ on the module path if <module> is ALL-MODULE-PATH.
|
||||
<module>
|
||||
javac.opt.addmods=\
|
||||
Root modules to resolve in addition to the initial modules, or all modules\n\
|
||||
on the module path if <module> is ALL-MODULE-PATH.
|
||||
javac.opt.arg.addmods=\
|
||||
<module>(,<module>)*
|
||||
javac.opt.limitmods=\
|
||||
Limit the universe of observable modules
|
||||
javac.opt.arg.limitmods=\
|
||||
<module>(,<module>)*
|
||||
javac.opt.inherit_runtime_environment=\
|
||||
Inherit module system configuration options from the runtime environment.
|
||||
|
||||
## errors
|
||||
|
||||
@ -334,7 +335,7 @@ javac.err.invalid.source=\
|
||||
javac.err.error.writing.file=\
|
||||
error writing {0}; {1}
|
||||
javac.err.sourcepath.modulesourcepath.conflict=\
|
||||
cannot specify both -sourcepath and -modulesourcepath
|
||||
cannot specify both --source-path and --module-source-path
|
||||
javac.warn.source.target.conflict=\
|
||||
source release {0} requires target release {1}
|
||||
javac.warn.target.default.source.conflict=\
|
||||
@ -347,6 +348,8 @@ javac.err.file.not.directory=\
|
||||
not a directory: {0}
|
||||
javac.err.file.not.file=\
|
||||
not a file: {0}
|
||||
javac.err.cannot.access.runtime.env=\
|
||||
cannot access runtime environment
|
||||
|
||||
## messages
|
||||
|
||||
@ -356,7 +359,7 @@ where possible options include:
|
||||
|
||||
javac.msg.usage=\
|
||||
Usage: {0} <options> <source files>\n\
|
||||
use -help for a list of possible options
|
||||
use --help for a list of possible options
|
||||
|
||||
javac.msg.usage.nonstandard.footer=\
|
||||
These options are non-standard and subject to change without notice.
|
||||
|
@ -252,4 +252,40 @@ public class JDK9Wrappers {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper class for new method in jdk.internal.misc.VM.
|
||||
*/
|
||||
public static final class VMHelper {
|
||||
public static final String VM_CLASSNAME = "jdk.internal.misc.VM";
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static String[] getRuntimeArguments() {
|
||||
try {
|
||||
init();
|
||||
Object result = getRuntimeArgumentsMethod.invoke(null);
|
||||
return (String[])result;
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
|
||||
| SecurityException ex) {
|
||||
throw new Abort(ex);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------
|
||||
|
||||
private static Class<?> vmClass = null;
|
||||
private static Method getRuntimeArgumentsMethod = null;
|
||||
|
||||
private static void init() {
|
||||
if (vmClass == null) {
|
||||
try {
|
||||
vmClass = Class.forName(VM_CLASSNAME, false, null);
|
||||
getRuntimeArgumentsMethod = vmClass.getDeclaredMethod("getRuntimeArguments");
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
|
||||
throw new Abort(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -748,6 +748,14 @@ public class Log extends AbstractLog {
|
||||
return localize(PrefixKind.COMPILER_MISC, key, args);
|
||||
}
|
||||
|
||||
public String localize(JCDiagnostic.DiagnosticInfo diagInfo) {
|
||||
if (useRawMessages) {
|
||||
return diagInfo.key();
|
||||
} else {
|
||||
return messages.getLocalizedString(diagInfo.key(), diagInfo.args);
|
||||
}
|
||||
}
|
||||
|
||||
/** Find a localized string in the resource bundle.
|
||||
* @param key The key for the localized string.
|
||||
* @param args Fields to substitute into the string.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2016, 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
|
||||
@ -71,7 +71,7 @@ public class Options {
|
||||
* Get the value for an option.
|
||||
*/
|
||||
public String get(Option option) {
|
||||
return values.get(option.text);
|
||||
return values.get(option.primaryName);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,14 +101,14 @@ public class Options {
|
||||
* Check if the value for an option has been set.
|
||||
*/
|
||||
public boolean isSet(Option option) {
|
||||
return (values.get(option.text) != null);
|
||||
return (values.get(option.primaryName) != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the value for a choice option has been set to a specific value.
|
||||
*/
|
||||
public boolean isSet(Option option, String value) {
|
||||
return (values.get(option.text + value) != null);
|
||||
return (values.get(option.primaryName + value) != null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,14 +122,14 @@ public class Options {
|
||||
* Check if the value for an option has not been set.
|
||||
*/
|
||||
public boolean isUnset(Option option) {
|
||||
return (values.get(option.text) == null);
|
||||
return (values.get(option.primaryName) == null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the value for a choice option has not been set to a specific value.
|
||||
*/
|
||||
public boolean isUnset(Option option, String value) {
|
||||
return (values.get(option.text + value) == null);
|
||||
return (values.get(option.primaryName + value) == null);
|
||||
}
|
||||
|
||||
public void put(String name, String value) {
|
||||
@ -137,7 +137,7 @@ public class Options {
|
||||
}
|
||||
|
||||
public void put(Option option, String value) {
|
||||
values.put(option.text, value);
|
||||
values.put(option.primaryName, value);
|
||||
}
|
||||
|
||||
public void putAll(Options options) {
|
||||
|
@ -526,19 +526,27 @@ public class JavahTask implements NativeHeaderTool.NativeHeaderTask {
|
||||
|
||||
private void showHelp() {
|
||||
log.println(getMessage("main.usage", progname));
|
||||
|
||||
for (Option o: recognizedOptions) {
|
||||
if (o.isHidden())
|
||||
continue;
|
||||
String name = o.aliases[0].substring(1); // there must always be at least one name
|
||||
log.println(getMessage("main.opt." + name));
|
||||
}
|
||||
String[] fmOptions = { "-classpath", "-cp", "-bootclasspath" };
|
||||
|
||||
String[] fmOptions = {
|
||||
"--module-path", "--system",
|
||||
"--class-path", "-classpath", "-cp",
|
||||
"-bootclasspath"
|
||||
};
|
||||
|
||||
for (String o: fmOptions) {
|
||||
if (fileManager.isSupportedOption(o) == -1)
|
||||
continue;
|
||||
String name = o.substring(1);
|
||||
String name = o.replaceAll("^-+", "").replaceAll("-+", "_");
|
||||
log.println(getMessage("main.opt." + name));
|
||||
}
|
||||
|
||||
log.println(getMessage("main.usage.foot"));
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2016, 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
|
||||
@ -91,7 +91,6 @@ public class Util {
|
||||
log.println(s);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Help for loading localized messages.
|
||||
*/
|
||||
@ -116,18 +115,6 @@ public class Util {
|
||||
return null; /* dead code */
|
||||
}
|
||||
|
||||
/*
|
||||
* Usage message.
|
||||
*/
|
||||
public void usage() throws Exit {
|
||||
log.println(getText("usage"));
|
||||
}
|
||||
|
||||
public void version() throws Exit {
|
||||
log.println(getText("javah.version",
|
||||
System.getProperty("java.version"), null));
|
||||
}
|
||||
|
||||
/*
|
||||
* Failure modes.
|
||||
*/
|
||||
|
@ -69,58 +69,61 @@ tracing.not.supported=\
|
||||
Warning: Tracing is no longer supported. Instead, use\
|
||||
-verbose:jni option of the virtual machine.
|
||||
|
||||
#
|
||||
# Usage message.
|
||||
#
|
||||
usage=\
|
||||
Usage: javah [options] <classes>\n\
|
||||
\n\
|
||||
where [options] include:\n\
|
||||
\n\t\
|
||||
-help Print this help message and exit\n\t\
|
||||
-classpath <path> Path from which to load classes\n\t\
|
||||
-cp <path> Path from which to load classes\n\t\
|
||||
-modulepath <path> Path from which to load application modules\n\t\
|
||||
-system <path> JDK directory from which to load system modules\n\t\
|
||||
-d <dir> Output directory\n\t\
|
||||
-o <file> Output file (only one of -d or -o may be used)\n\t\
|
||||
-jni Generate JNI-style header file (default)\n\t\
|
||||
-version Print version information\n\t\
|
||||
-verbose Enable verbose output\n\t\
|
||||
-force Always write output files\n\
|
||||
\n\
|
||||
<classes> are specified with their fully qualified names, optionally\n\
|
||||
prefixed by a module name followed by '/'. Examples:\n\
|
||||
java.lang.Object\n\
|
||||
java.base/java.io.File\n\
|
||||
|
||||
main.usage=\
|
||||
Usage: \n\
|
||||
\ javah [options] <classes>\n\
|
||||
where [options] include:
|
||||
|
||||
main.opt.o=\
|
||||
\ -o <file> Output file (only one of -d or -o may be used)
|
||||
\ -o <file> Output file (only one of -d or -o may be used)
|
||||
|
||||
main.opt.d=\
|
||||
\ -d <dir> Output directory
|
||||
\ -d <dir> Output directory
|
||||
|
||||
main.opt.v=\
|
||||
\ -v -verbose Enable verbose output
|
||||
\ -v -verbose Enable verbose output
|
||||
|
||||
main.opt.h=\
|
||||
\ -h --help -? Print this message
|
||||
\ -h --help -? Print this message
|
||||
|
||||
main.opt.version=\
|
||||
\ -version Print version information
|
||||
\ -version Print version information
|
||||
|
||||
main.opt.jni=\
|
||||
\ -jni Generate JNI-style header file (default)
|
||||
\ -jni Generate JNI-style header file (default)
|
||||
|
||||
main.opt.force=\
|
||||
\ -force Always write output files
|
||||
\ -force Always write output files
|
||||
|
||||
main.opt.module_path=\
|
||||
\ --module-path <path> Path from which to load application modules
|
||||
|
||||
main.opt.upgrade_module_path=\
|
||||
\ --upgrade_module-path <path> Path from which to load application modules
|
||||
|
||||
main.opt.classpath=\
|
||||
\ -classpath <path> Path from which to load classes
|
||||
\ -classpath <path> Path from which to load classes
|
||||
|
||||
main.opt.class_path=\
|
||||
\ --class-path <path> Path from which to load classes
|
||||
|
||||
main.opt.cp=\
|
||||
\ -cp <path> Path from which to load classes
|
||||
\ -cp <path> Path from which to load classes
|
||||
|
||||
main.opt.bootclasspath=\
|
||||
\ -bootclasspath <path> Path from which to load bootstrap classes
|
||||
main.usage.foot=\
|
||||
<classes> are specified with their fully qualified names\n\
|
||||
(for example, java.lang.Object).
|
||||
\ -bootclasspath <path> Path from which to load bootstrap classes
|
||||
|
||||
main.opt.system=\
|
||||
\ --system <jdk> Specify where to find system modules
|
||||
|
||||
main.usage.foot=\n\
|
||||
GNU-style options may use '=' instead whitespace to separate the name of an option\n\
|
||||
from its value.\n\
|
||||
\n\
|
||||
Each class must be specified by its fully qualified names, optionally\n\
|
||||
prefixed by a module name followed by '/'. Examples:\n\
|
||||
\ java.lang.Object\n\
|
||||
\ java.base/java.io.File\n\
|
||||
|
||||
#
|
||||
# Version string.
|
||||
|
@ -63,7 +63,7 @@ public enum Option {
|
||||
helper.sourceRoots(paths);
|
||||
}
|
||||
},
|
||||
SOURCEPATH("-sourcepath", "Specify search path for sources.") {
|
||||
SOURCE_PATH("--source-path", "Specify search path for sources.") {
|
||||
@Override
|
||||
protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
|
||||
List<Path> paths = getFileListArg(iter, helper);
|
||||
@ -71,7 +71,13 @@ public enum Option {
|
||||
helper.sourcepath(paths);
|
||||
}
|
||||
},
|
||||
MODULEPATH("-modulepath", "Specify search path for modules.") {
|
||||
SOURCEPATH("-sourcepath", "An alias for -sourcepath") {
|
||||
@Override
|
||||
protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
|
||||
SOURCE_PATH.processMatching(iter, helper);
|
||||
}
|
||||
},
|
||||
MODULE_PATH("--module-path", "Specify search path for modules.") {
|
||||
@Override
|
||||
protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
|
||||
List<Path> paths = getFileListArg(iter, helper);
|
||||
@ -79,7 +85,19 @@ public enum Option {
|
||||
helper.modulepath(paths);
|
||||
}
|
||||
},
|
||||
CLASSPATH("-classpath", "Specify search path for classes.") {
|
||||
MODULEPATH("-modulepath", "An alias for -modulepath") {
|
||||
@Override
|
||||
protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
|
||||
MODULE_PATH.processMatching(iter, helper);
|
||||
}
|
||||
},
|
||||
P("-p", "An alias for -modulepath") {
|
||||
@Override
|
||||
protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
|
||||
MODULE_PATH.processMatching(iter, helper);
|
||||
}
|
||||
},
|
||||
CLASS_PATH("--class-path", "Specify search path for classes.") {
|
||||
@Override
|
||||
protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
|
||||
List<Path> paths = getFileListArg(iter, helper);
|
||||
@ -87,10 +105,16 @@ public enum Option {
|
||||
helper.classpath(paths);
|
||||
}
|
||||
},
|
||||
CLASSPATH("-classpath", "An alias for -classpath.") {
|
||||
@Override
|
||||
protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
|
||||
CLASS_PATH.processMatching(iter, helper);
|
||||
}
|
||||
},
|
||||
CP("-cp", "An alias for -classpath") {
|
||||
@Override
|
||||
protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
|
||||
CLASSPATH.processMatching(iter, helper);
|
||||
CLASS_PATH.processMatching(iter, helper);
|
||||
}
|
||||
},
|
||||
X("-x", "Exclude files matching the given pattern") {
|
||||
|
@ -251,9 +251,9 @@ public class Options {
|
||||
|
||||
// Source roots
|
||||
args.addSourceLocations(Option.SRC, sources);
|
||||
args.addSourceLocations(Option.SOURCEPATH, sourceSearchPaths);
|
||||
args.addSourceLocations(Option.CLASSPATH, classSearchPaths);
|
||||
args.addSourceLocations(Option.MODULEPATH, moduleSearchPaths);
|
||||
args.addSourceLocations(Option.SOURCE_PATH, sourceSearchPaths);
|
||||
args.addSourceLocations(Option.CLASS_PATH, classSearchPaths);
|
||||
args.addSourceLocations(Option.MODULE_PATH, moduleSearchPaths);
|
||||
|
||||
// Boolean options
|
||||
if (permitSourcesInDefaultPackage)
|
||||
|
@ -45,6 +45,8 @@ import com.sun.tools.javac.file.JavacFileManager;
|
||||
import com.sun.tools.javac.main.CommandLine;
|
||||
import com.sun.tools.javac.main.Option;
|
||||
import com.sun.tools.javac.file.BaseFileManager;
|
||||
import com.sun.tools.javac.main.OptionHelper;
|
||||
import com.sun.tools.javac.main.OptionHelper.GrumpyHelper;
|
||||
import com.sun.tools.javac.platform.PlatformDescription;
|
||||
import com.sun.tools.javac.platform.PlatformUtils;
|
||||
import com.sun.tools.javac.util.ClientCodeException;
|
||||
@ -173,7 +175,7 @@ public class Start extends ToolOption.Helper {
|
||||
}
|
||||
|
||||
void usage(boolean exit) {
|
||||
usage("main.usage", "-help", null, exit);
|
||||
usage("main.usage", "-help", "main.usage.foot", exit);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -365,14 +367,14 @@ public class Start extends ToolOption.Helper {
|
||||
((BaseFileManager) fileManager).handleOptions(fileManagerOpts);
|
||||
}
|
||||
|
||||
String platformString = compOpts.get("-release");
|
||||
String platformString = compOpts.get("--release");
|
||||
|
||||
if (platformString != null) {
|
||||
if (compOpts.isSet("-source")) {
|
||||
usageError("main.release.bootclasspath.conflict", "-source");
|
||||
}
|
||||
if (fileManagerOpts.containsKey(Option.BOOTCLASSPATH)) {
|
||||
usageError("main.release.bootclasspath.conflict", Option.BOOTCLASSPATH.getText());
|
||||
if (fileManagerOpts.containsKey(Option.BOOT_CLASS_PATH)) {
|
||||
usageError("main.release.bootclasspath.conflict", Option.BOOT_CLASS_PATH.getPrimaryName());
|
||||
}
|
||||
|
||||
PlatformDescription platformDescription =
|
||||
@ -555,4 +557,19 @@ public class Start extends ToolOption.Helper {
|
||||
}
|
||||
options.append(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
OptionHelper getOptionHelper() {
|
||||
return new GrumpyHelper(null) {
|
||||
@Override
|
||||
public String get(com.sun.tools.javac.main.Option option) {
|
||||
return compOpts.get(option);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(String name, String value) {
|
||||
compOpts.put(name, value);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import java.util.StringTokenizer;
|
||||
|
||||
import com.sun.tools.javac.code.Flags;
|
||||
import com.sun.tools.javac.main.Option;
|
||||
import com.sun.tools.javac.main.OptionHelper;
|
||||
import com.sun.tools.javac.util.ListBuffer;
|
||||
import com.sun.tools.javac.util.Options;
|
||||
|
||||
@ -50,21 +51,28 @@ public enum ToolOption {
|
||||
BOOTCLASSPATH("-bootclasspath", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.BOOTCLASSPATH, arg);
|
||||
helper.setFileManagerOpt(Option.BOOT_CLASS_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
CLASSPATH("-classpath", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.CLASSPATH, arg);
|
||||
helper.setFileManagerOpt(Option.CLASS_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
CP("-cp", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.CP, arg);
|
||||
helper.setFileManagerOpt(Option.CLASS_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_PATH("--class-path", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.CLASS_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
@ -78,28 +86,49 @@ public enum ToolOption {
|
||||
SOURCEPATH("-sourcepath", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.SOURCEPATH, arg);
|
||||
helper.setFileManagerOpt(Option.SOURCE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
SOURCE_PATH("--source-path", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.SOURCE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
SYSCLASSPATH("-sysclasspath", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.BOOTCLASSPATH, arg);
|
||||
helper.setFileManagerOpt(Option.BOOT_CLASS_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
MODULESOURCEPATH("-modulesourcepath", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.MODULESOURCEPATH, arg);
|
||||
helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
MODULE_SOURCE_PATH("--module-source-path", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
UPGRADEMODULEPATH("-upgrademodulepath", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.UPGRADEMODULEPATH, arg);
|
||||
helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
UPGRADE_MODULE_PATH("--upgrade-module-path", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
@ -110,10 +139,31 @@ public enum ToolOption {
|
||||
}
|
||||
},
|
||||
|
||||
SYSTEM_("--system", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.SYSTEM, arg);
|
||||
}
|
||||
},
|
||||
|
||||
MODULEPATH("-modulepath", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.MODULEPATH, arg);
|
||||
helper.setFileManagerOpt(Option.MODULE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
MODULE_PATH("--module-path", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.MODULE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
P("-p", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.MODULE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
@ -124,6 +174,13 @@ public enum ToolOption {
|
||||
}
|
||||
},
|
||||
|
||||
ADD_MODULES("--add-modules", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.ADD_MODULES.process(helper.getOptionHelper(), opt, arg);
|
||||
}
|
||||
},
|
||||
|
||||
LIMITMODS("-limitmods", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
@ -131,6 +188,13 @@ public enum ToolOption {
|
||||
}
|
||||
},
|
||||
|
||||
LIMIT_MODULES("--limit-modules", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.LIMIT_MODULES.process(helper.getOptionHelper(), opt, arg);
|
||||
}
|
||||
},
|
||||
|
||||
ENCODING("-encoding", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
@ -139,13 +203,20 @@ public enum ToolOption {
|
||||
}
|
||||
},
|
||||
|
||||
RELEASE("-release", true) {
|
||||
RELEASE("--release", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setCompilerOpt(opt, arg);
|
||||
}
|
||||
},
|
||||
|
||||
RELEASE_OLD("-release", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setCompilerOpt("--release", arg);
|
||||
}
|
||||
},
|
||||
|
||||
SOURCE("-source", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
@ -167,6 +238,55 @@ public enum ToolOption {
|
||||
}
|
||||
},
|
||||
|
||||
XADDREADS("-XaddReads:", false) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.ADD_READS.process(helper.getOptionHelper(), arg);
|
||||
}
|
||||
},
|
||||
|
||||
ADD_READS("--add-reads", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.ADD_READS.process(helper.getOptionHelper(), opt, arg);
|
||||
}
|
||||
},
|
||||
|
||||
ADDEXPORTS("-XaddExports:", false) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.ADD_EXPORTS.process(helper.getOptionHelper(), arg);
|
||||
}
|
||||
},
|
||||
|
||||
ADD_EXPORTS("--add-exports", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.ADD_EXPORTS.process(helper.getOptionHelper(), opt, arg);
|
||||
}
|
||||
},
|
||||
|
||||
XMODULE("-Xmodule:", false) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.XMODULE.process(helper.getOptionHelper(), arg);
|
||||
}
|
||||
},
|
||||
|
||||
XPATCH("-Xpatch:", false) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.XMODULE.process(helper.getOptionHelper(), arg);
|
||||
}
|
||||
},
|
||||
|
||||
PATCH_MODULE("--patch-module", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.PATCH_MODULE.process(helper.getOptionHelper(), opt, arg);
|
||||
}
|
||||
},
|
||||
|
||||
// ----- doclet options -----
|
||||
|
||||
DOCLET("-doclet", true), // handled in setDocletInvoker
|
||||
@ -362,6 +482,7 @@ public enum ToolOption {
|
||||
abstract void Xusage();
|
||||
|
||||
abstract void usageError(String msg, Object... args);
|
||||
abstract OptionHelper getOptionHelper();
|
||||
|
||||
void addToList(ListBuffer<String> list, String str){
|
||||
StringTokenizer st = new StringTokenizer(str, ":");
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 1997, 2016, 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
|
||||
@ -37,15 +37,28 @@ main.usage=Usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\
|
||||
\ -help Display command line options and exit\n\
|
||||
\ -doclet <class> Generate output via alternate doclet\n\
|
||||
\ -docletpath <path> Specify where to find doclet class files\n\
|
||||
\ -sourcepath <pathlist> Specify where to find source files\n\
|
||||
\ -classpath <pathlist> Specify where to find user class files\n\
|
||||
\ -cp <pathlist> Specify where to find user class files\n\
|
||||
\ --module-source-path <path> Specify where to find input source files for multiple modules\n\
|
||||
\ --upgrade-module-path <path> Override location of upgradeable modules\n\
|
||||
\ --module-path <path>, -p <path> Specify where to find application modules\n\
|
||||
\ --add-modules <module>(,<module>)*\n\
|
||||
\ Root modules to resolve in addition to the initial modules,\n\
|
||||
\ or all modules on the module path if <module> is ALL-MODULE-PATH.\n\
|
||||
\ --limit-modules <module>(,<module>)*\n\
|
||||
\ Limit the universe of observable modules\n\
|
||||
\ --source-path <path> Specify where to find source files\n\
|
||||
\ -sourcepath <path> Specify where to find source files\n\
|
||||
\ --class-path <path> Specify where to find user class files\n\
|
||||
\ -classpath <path> Specify where to find user class files\n\
|
||||
\ -cp <path> Specify where to find user class files\n\
|
||||
\ -exclude <pkglist> Specify a list of packages to exclude\n\
|
||||
\ -subpackages <subpkglist> Specify subpackages to recursively load\n\
|
||||
\ -breakiterator Compute first sentence with BreakIterator\n\
|
||||
\ -bootclasspath <pathlist> Override location of class files loaded\n\
|
||||
\ by the bootstrap class loader\n\
|
||||
\ -bootclasspath <path> Override location of platform class files\n\
|
||||
\ used for non-modular releases\n\
|
||||
\ --system <jdk> Override location of system modules used\n\
|
||||
\ for modular releases.\n\
|
||||
\ -source <release> Provide source compatibility with specified release\n\
|
||||
\ --release <release> Provide source compatibility with specified release\n\
|
||||
\ -extdirs <dirlist> Override location of installed extensions\n\
|
||||
\ -verbose Output messages about what Javadoc is doing\n\
|
||||
\ -locale <name> Locale to be used, e.g. en_US or en_US_WIN\n\
|
||||
@ -54,9 +67,25 @@ main.usage=Usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\
|
||||
\ -J<flag> Pass <flag> directly to the runtime system\n\
|
||||
\ -X Print a synopsis of nonstandard options and exit\n
|
||||
|
||||
main.usage.foot=\n\
|
||||
GNU-style options may use '=' instead whitespace to separate the name of an option\n\
|
||||
from its value.\n
|
||||
|
||||
main.Xusage=\
|
||||
\ -Xmaxerrs <number> Set the maximum number of errors to print\n\
|
||||
\ -Xmaxwarns <number> Set the maximum number of warnings to print\n
|
||||
\ -Xmaxwarns <number> Set the maximum number of warnings to print\n\
|
||||
\ --add-exports <module>/<package>=<other-module>(,<other-module>)*\n\
|
||||
\ Specify a package to be considered as exported from its \n\
|
||||
\ defining module to additional modules, or to all unnamed \n\
|
||||
\ modules if <other-module> is ALL-UNNAMED.\n\
|
||||
\ --add-reads <module>=<other-module>(,<other-module>)*\n\
|
||||
\ Specify additional modules to be considered as required by a\n\
|
||||
\ given module. <other-module> may be ALL-UNNAMED to require\n\
|
||||
\ the unnamed module.\n\
|
||||
\ -Xmodule:<module-name> Specify a module to which the classes being compiled belong.\n\
|
||||
\ --patch-module <module>=<file>(:<file>)*\n\
|
||||
\ Override or augment a module with classes and resources\n\
|
||||
\ in JAR files or directories\n
|
||||
|
||||
main.Xusage.foot=\
|
||||
These options are non-standard and subject to change without notice.
|
||||
|
@ -172,7 +172,7 @@ public class Start extends ToolOption.Helper {
|
||||
}
|
||||
|
||||
void usage(boolean exit) {
|
||||
usage("main.usage", "-help", null, exit);
|
||||
usage("main.usage", "-help", "main.usage.foot", exit);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -355,14 +355,14 @@ public class Start extends ToolOption.Helper {
|
||||
((BaseFileManager) fileManager).handleOptions(fileManagerOpts);
|
||||
}
|
||||
|
||||
String platformString = compOpts.get("-release");
|
||||
String platformString = compOpts.get("--release");
|
||||
|
||||
if (platformString != null) {
|
||||
if (compOpts.isSet("-source")) {
|
||||
usageError("main.release.bootclasspath.conflict", "-source");
|
||||
}
|
||||
if (fileManagerOpts.containsKey(BOOTCLASSPATH)) {
|
||||
usageError("main.release.bootclasspath.conflict", BOOTCLASSPATH.getText());
|
||||
if (fileManagerOpts.containsKey(BOOT_CLASS_PATH)) {
|
||||
usageError("main.release.bootclasspath.conflict", BOOT_CLASS_PATH.getPrimaryName());
|
||||
}
|
||||
|
||||
PlatformDescription platformDescription =
|
||||
|
@ -49,21 +49,28 @@ public enum ToolOption {
|
||||
BOOTCLASSPATH("-bootclasspath", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.BOOTCLASSPATH, arg);
|
||||
helper.setFileManagerOpt(Option.BOOT_CLASS_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
CLASSPATH("-classpath", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.CLASSPATH, arg);
|
||||
helper.setFileManagerOpt(Option.CLASS_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
CP("-cp", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.CP, arg);
|
||||
helper.setFileManagerOpt(Option.CLASS_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_PATH("--class-path", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.CLASS_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
@ -77,28 +84,49 @@ public enum ToolOption {
|
||||
SOURCEPATH("-sourcepath", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.SOURCEPATH, arg);
|
||||
helper.setFileManagerOpt(Option.SOURCE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
SOURCE_PATH("--source-path", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.SOURCE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
SYSCLASSPATH("-sysclasspath", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.BOOTCLASSPATH, arg);
|
||||
helper.setFileManagerOpt(Option.BOOT_CLASS_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
MODULESOURCEPATH("-modulesourcepath", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.MODULESOURCEPATH, arg);
|
||||
helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
MODULE_SOURCE_PATH("--module-source-path", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
UPGRADEMODULEPATH("-upgrademodulepath", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.UPGRADEMODULEPATH, arg);
|
||||
helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
UPGRADE_MODULE_PATH("--upgrade-module-path", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
@ -109,24 +137,59 @@ public enum ToolOption {
|
||||
}
|
||||
},
|
||||
|
||||
SYSTEM_("--system", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.SYSTEM, arg);
|
||||
}
|
||||
},
|
||||
|
||||
MODULEPATH("-modulepath", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.MODULEPATH, arg);
|
||||
helper.setFileManagerOpt(Option.MODULE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
MODULE_PATH("--module-path", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.MODULE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
P("-p", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.MODULE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
ADDMODS("-addmods", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.ADDMODS.process(helper.getOptionHelper(), opt, arg);
|
||||
Option.ADD_MODULES.process(helper.getOptionHelper(), opt, arg);
|
||||
}
|
||||
},
|
||||
|
||||
ADD_MODULES("--add-modules", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.ADD_MODULES.process(helper.getOptionHelper(), opt, arg);
|
||||
}
|
||||
},
|
||||
|
||||
LIMITMODS("-limitmods", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.LIMITMODS.process(helper.getOptionHelper(), opt, arg);
|
||||
Option.LIMIT_MODULES.process(helper.getOptionHelper(), opt, arg);
|
||||
}
|
||||
},
|
||||
|
||||
LIMIT_MODULES("--limit-modules", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.LIMIT_MODULES.process(helper.getOptionHelper(), opt, arg);
|
||||
}
|
||||
},
|
||||
|
||||
@ -138,7 +201,14 @@ public enum ToolOption {
|
||||
}
|
||||
},
|
||||
|
||||
RELEASE("-release", true) {
|
||||
RELEASE("--release", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.RELEASE.process(helper.getOptionHelper(), opt, arg);
|
||||
}
|
||||
},
|
||||
|
||||
RELEASE_OLD("-release", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.RELEASE.process(helper.getOptionHelper(), opt, arg);
|
||||
@ -169,14 +239,28 @@ public enum ToolOption {
|
||||
XADDREADS("-XaddReads:", false) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.XADDREADS.process(helper.getOptionHelper(), arg);
|
||||
Option.ADD_READS.process(helper.getOptionHelper(), arg);
|
||||
}
|
||||
},
|
||||
|
||||
XADDEXPORTS("-XaddExports:", false) {
|
||||
ADD_READS("--add-reads", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.XADDEXPORTS.process(helper.getOptionHelper(), arg);
|
||||
Option.ADD_READS.process(helper.getOptionHelper(), opt, arg);
|
||||
}
|
||||
},
|
||||
|
||||
ADDEXPORTS("-XaddExports:", false) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.ADD_EXPORTS.process(helper.getOptionHelper(), arg);
|
||||
}
|
||||
},
|
||||
|
||||
ADD_EXPORTS("--add-exports", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.ADD_EXPORTS.process(helper.getOptionHelper(), opt, arg);
|
||||
}
|
||||
},
|
||||
|
||||
@ -194,6 +278,13 @@ public enum ToolOption {
|
||||
}
|
||||
},
|
||||
|
||||
PATCH_MODULE("--patch-module", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.PATCH_MODULE.process(helper.getOptionHelper(), opt, arg);
|
||||
}
|
||||
},
|
||||
|
||||
// ----- doclet options -----
|
||||
|
||||
DOCLET("-doclet", true), // handled in setDocletInvoker
|
||||
|
@ -37,21 +37,27 @@ main.usage=Usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\
|
||||
\ -help Display command line options and exit\n\
|
||||
\ -doclet <class> Generate output via alternate doclet\n\
|
||||
\ -docletpath <path> Specify where to find doclet class files\n\
|
||||
\ -modulesourcepath <path> Specify where to find input source files for multiple modules\n\
|
||||
\ -upgrademodulepath <path> Override location of upgradeable modules\n\
|
||||
\ -modulepath <path> Specify where to find application modules\n\
|
||||
\ -mp <path> Specify where to find application modules\n\
|
||||
\ -addmods <module>(,<module>)* Root modules to resolve in addition to the initial modules,\n\
|
||||
\ --module-source-path <path> Specify where to find input source files for multiple modules\n\
|
||||
\ --upgrade-module-path <path> Override location of upgradeable modules\n\
|
||||
\ --module-path <path>, -p <path> Specify where to find application modules\n\
|
||||
\ --add-modules <module>(,<module>)*\n\
|
||||
\ Root modules to resolve in addition to the initial modules,\n\
|
||||
\ or all modules on the module path if <module> is ALL-MODULE-PATH.\n\
|
||||
\ -limitmods <module>(,<module>)* Limit the universe of observable modules\n\
|
||||
\ -sourcepath <pathlist> Specify where to find source files\n\
|
||||
\ -classpath <pathlist> Specify where to find user class files\n\
|
||||
\ -cp <pathlist> Specify where to find user class files\n\
|
||||
\ --limit-modules <module>(,<module>)*\n\
|
||||
\ Limit the universe of observable modules\n\
|
||||
\ --source-path <path> Specify where to find source files\n\
|
||||
\ -sourcepath <path> Specify where to find source files\n\
|
||||
\ --class-path <path> Specify where to find user class files\n\
|
||||
\ -classpath <path> Specify where to find user class files\n\
|
||||
\ -cp <path> Specify where to find user class files\n\
|
||||
\ -exclude <pkglist> Specify a list of packages to exclude\n\
|
||||
\ -subpackages <subpkglist> Specify subpackages to recursively load\n\
|
||||
\ -breakiterator Compute first sentence with BreakIterator\n\
|
||||
\ -bootclasspath <pathlist> Override location of class files loaded\n\
|
||||
\ by the bootstrap class loader\n\
|
||||
\ -bootclasspath <path> Override location of platform class files\n\
|
||||
\ used for non-modular releases\n\
|
||||
\ --system <jdk> Override location of system modules used\n\
|
||||
\ for modular releases.\n\
|
||||
\ --release <release> Provide source compatibility with specified release\n\
|
||||
\ -source <release> Provide source compatibility with specified release\n\
|
||||
\ -extdirs <dirlist> Override location of installed extensions\n\
|
||||
\ -verbose Output messages about what Javadoc is doing\n\
|
||||
@ -61,19 +67,23 @@ main.usage=Usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\
|
||||
\ -J<flag> Pass <flag> directly to the runtime system\n\
|
||||
\ -X Print a synopsis of nonstandard options and exit\n
|
||||
|
||||
main.usage.foot=\n\
|
||||
GNU-style options may use '=' instead whitespace to separate the name of an option\n\
|
||||
from its value.\n
|
||||
|
||||
main.Xusage=\
|
||||
\ -Xmaxerrs <number> Set the maximum number of errors to print\n\
|
||||
\ -Xmaxwarns <number> Set the maximum number of warnings to print\n\
|
||||
\ -XaddExports:<module>/<package>=<other-module>(,<other-module>)*\n\
|
||||
\ --add-exports <module>/<package>=<other-module>(,<other-module>)*\n\
|
||||
\ Specify a package to be considered as exported from its \n\
|
||||
\ defining module to additional modules, or to all unnamed \n\
|
||||
\ modules if <other-module> is ALL-UNNAMED.\n\
|
||||
\ -XaddReads:<module>=<other-module>(,<other-module>)*\n\
|
||||
\ --add-reads <module>=<other-module>(,<other-module>)*\n\
|
||||
\ Specify additional modules to be considered as required by a\n\
|
||||
\ given module. <other-module> may be ALL-UNNAMED to require\n\
|
||||
\ the unnamed module.\n\
|
||||
\ -Xmodule:<module-name> Specify a module to which the classes being compiled belong.\n\
|
||||
\ -Xpatch:<module>=<file>(:<file>)*\n\
|
||||
\ --patch-module <module>=<file>(:<file>)*\n\
|
||||
\ Override or augment a module with classes and resources\n\
|
||||
\ in JAR files or directories\n\
|
||||
\ -Xold Invoke the legacy javadoc tool\n
|
||||
|
@ -126,24 +126,28 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||
static final Option[] recognizedOptions = {
|
||||
|
||||
new Option(false, "-help", "--help", "-?") {
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) {
|
||||
task.options.help = true;
|
||||
}
|
||||
},
|
||||
|
||||
new Option(false, "-version") {
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) {
|
||||
task.options.version = true;
|
||||
}
|
||||
},
|
||||
|
||||
new Option(false, "-fullversion") {
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) {
|
||||
task.options.fullVersion = true;
|
||||
}
|
||||
},
|
||||
|
||||
new Option(false, "-v", "-verbose", "-all") {
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) {
|
||||
task.options.verbose = true;
|
||||
task.options.showDescriptors = true;
|
||||
@ -153,12 +157,14 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||
},
|
||||
|
||||
new Option(false, "-l") {
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) {
|
||||
task.options.showLineAndLocalVariableTables = true;
|
||||
}
|
||||
},
|
||||
|
||||
new Option(false, "-public") {
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) {
|
||||
task.options.accessOptions.add(opt);
|
||||
task.options.showAccess = AccessFlags.ACC_PUBLIC;
|
||||
@ -166,6 +172,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||
},
|
||||
|
||||
new Option(false, "-protected") {
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) {
|
||||
task.options.accessOptions.add(opt);
|
||||
task.options.showAccess = AccessFlags.ACC_PROTECTED;
|
||||
@ -173,6 +180,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||
},
|
||||
|
||||
new Option(false, "-package") {
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) {
|
||||
task.options.accessOptions.add(opt);
|
||||
task.options.showAccess = 0;
|
||||
@ -180,6 +188,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||
},
|
||||
|
||||
new Option(false, "-p", "-private") {
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) {
|
||||
if (!task.options.accessOptions.contains("-p") &&
|
||||
!task.options.accessOptions.contains("-private")) {
|
||||
@ -190,24 +199,28 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||
},
|
||||
|
||||
new Option(false, "-c") {
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) {
|
||||
task.options.showDisassembled = true;
|
||||
}
|
||||
},
|
||||
|
||||
new Option(false, "-s") {
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) {
|
||||
task.options.showDescriptors = true;
|
||||
}
|
||||
},
|
||||
|
||||
new Option(false, "-sysinfo") {
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) {
|
||||
task.options.sysInfo = true;
|
||||
}
|
||||
},
|
||||
|
||||
new Option(false, "-XDdetails") {
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) {
|
||||
task.options.details = EnumSet.allOf(InstructionDetailWriter.Kind.class);
|
||||
}
|
||||
@ -221,6 +234,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||
return sep != -1 && super.matches(opt.substring(0, sep + 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) throws BadArgs {
|
||||
int sep = opt.indexOf(":");
|
||||
for (String v: opt.substring(sep + 1).split("[,: ]+")) {
|
||||
@ -258,12 +272,14 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||
},
|
||||
|
||||
new Option(false, "-constants") {
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) {
|
||||
task.options.showConstants = true;
|
||||
}
|
||||
},
|
||||
|
||||
new Option(false, "-XDinner") {
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) {
|
||||
task.options.showInnerClasses = true;
|
||||
}
|
||||
@ -276,6 +292,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||
return sep != -1 && super.matches(opt.substring(0, sep + 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) throws BadArgs {
|
||||
int sep = opt.indexOf(":");
|
||||
try {
|
||||
@ -294,6 +311,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||
return sep != -1 && super.matches(opt.substring(0, sep + 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) throws BadArgs {
|
||||
int sep = opt.indexOf(":");
|
||||
try {
|
||||
@ -305,7 +323,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||
}
|
||||
},
|
||||
|
||||
new Option(true, "-m") {
|
||||
new Option(true, "--module", "-m") {
|
||||
@Override
|
||||
void process(JavapTask task, String opt, String arg) throws BadArgs {
|
||||
task.options.moduleName = arg;
|
||||
@ -929,21 +947,26 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||
private void showHelp() {
|
||||
printLines(getMessage("main.usage", progname));
|
||||
for (Option o: recognizedOptions) {
|
||||
String name = o.aliases[0].substring(1); // there must always be at least one name
|
||||
String name = o.aliases[0].replaceAll("^-+", "").replaceAll("-+", "_"); // there must always be at least one name
|
||||
if (name.startsWith("X") || name.equals("fullversion") || name.equals("h") || name.equals("verify"))
|
||||
continue;
|
||||
printLines(getMessage("main.opt." + name));
|
||||
}
|
||||
|
||||
String[] fmOptions = {
|
||||
"-classpath", "-cp", "-bootclasspath",
|
||||
"-upgrademodulepath", "-system", "-modulepath" };
|
||||
"--module-path", "--system",
|
||||
"--class-path", "-classpath", "-cp",
|
||||
"-bootclasspath"
|
||||
};
|
||||
|
||||
for (String o: fmOptions) {
|
||||
if (fileManager.isSupportedOption(o) == -1)
|
||||
continue;
|
||||
String name = o.substring(1);
|
||||
String name = o.replaceAll("^-+", "").replaceAll("-+", "_");
|
||||
printLines(getMessage("main.opt." + name));
|
||||
}
|
||||
|
||||
printLines(getMessage("main.usage.foot"));
|
||||
}
|
||||
|
||||
private void showVersion(boolean full) {
|
||||
|
@ -41,61 +41,73 @@ where possible options include:
|
||||
|
||||
|
||||
main.opt.help=\
|
||||
\ -help --help -? Print this usage message
|
||||
\ -help --help -? Print this usage message
|
||||
|
||||
main.opt.version=\
|
||||
\ -version Version information
|
||||
\ -version Version information
|
||||
|
||||
main.opt.v=\
|
||||
\ -v -verbose Print additional information
|
||||
\ -v -verbose Print additional information
|
||||
|
||||
main.opt.l=\
|
||||
\ -l Print line number and local variable tables
|
||||
\ -l Print line number and local variable tables
|
||||
|
||||
main.opt.public=\
|
||||
\ -public Show only public classes and members
|
||||
\ -public Show only public classes and members
|
||||
|
||||
main.opt.protected=\
|
||||
\ -protected Show protected/public classes and members
|
||||
\ -protected Show protected/public classes and members
|
||||
|
||||
main.opt.package=\
|
||||
\ -package Show package/protected/public classes\n\
|
||||
\ and members (default)
|
||||
\ -package Show package/protected/public classes\n\
|
||||
\ and members (default)
|
||||
|
||||
main.opt.p=\
|
||||
\ -p -private Show all classes and members
|
||||
\ -p -private Show all classes and members
|
||||
|
||||
main.opt.c=\
|
||||
\ -c Disassemble the code
|
||||
\ -c Disassemble the code
|
||||
|
||||
main.opt.s=\
|
||||
\ -s Print internal type signatures
|
||||
\ -s Print internal type signatures
|
||||
|
||||
main.opt.class_path=\
|
||||
\ --class-path <path> Specify where to find user class files
|
||||
|
||||
main.opt.classpath=\
|
||||
\ -classpath <path> Specify where to find user class files
|
||||
\ -classpath <path> Specify where to find user class files
|
||||
|
||||
main.opt.cp=\
|
||||
\ -cp <path> Specify where to find user class files
|
||||
\ -cp <path> Specify where to find user class files
|
||||
|
||||
main.opt.bootclasspath=\
|
||||
\ -bootclasspath <path> Override location of bootstrap class files
|
||||
\ -bootclasspath <path> Override location of bootstrap class files
|
||||
|
||||
main.opt.upgrademodulepath=\
|
||||
\ -upgrademodulepath <path> Specify where to find upgradeable modules
|
||||
main.opt.upgrade_module_path=\
|
||||
\ --upgrade-module-path <path> Specify where to find upgradeable modules
|
||||
|
||||
main.opt.system=\
|
||||
\ -system <jdk> Specify where to find system modules
|
||||
\ --system <jdk> Specify where to find system modules
|
||||
|
||||
main.opt.modulepath=\
|
||||
\ -modulepath <path> Specify where to find application modules
|
||||
main.opt.module_path=\
|
||||
\ --module-path <path> Specify where to find application modules
|
||||
|
||||
main.opt.constants=\
|
||||
\ -constants Show final constants
|
||||
|
||||
\ -constants Show final constants
|
||||
|
||||
main.opt.sysinfo=\
|
||||
\ -sysinfo Show system info (path, size, date, MD5 hash)\n\
|
||||
\ of class being processed
|
||||
\ -sysinfo Show system info (path, size, date, MD5 hash)\n\
|
||||
\ of class being processed
|
||||
|
||||
main.opt.m=\
|
||||
\ -m <module-name> Specify module containing classes to be disassembled
|
||||
main.opt.module=\
|
||||
\ --module <module>, -m <module> Specify module containing classes to be disassembled
|
||||
|
||||
main.usage.foot=\n\
|
||||
GNU-style options may use '=' instead of whitespace to separate the name of an option\n\
|
||||
from its value.\n\
|
||||
\n\
|
||||
Each class to be shown may be specified by a filename, a URL, or by its fully\n\
|
||||
qualified class name. Examples:\n\
|
||||
\ path/to/MyClass.class\n\
|
||||
\ jar:file:///path/to/MyJar.jar!/mypkg/MyClass.class\n\
|
||||
\ java.lang.Object\n
|
||||
|
@ -514,7 +514,7 @@ public class JdepsConfiguration implements AutoCloseable {
|
||||
}
|
||||
|
||||
/*
|
||||
* This method is for -check option to find all target modules specified
|
||||
* This method is for --check option to find all target modules specified
|
||||
* in qualified exports.
|
||||
*
|
||||
* Include all system modules and modules found on modulepath
|
||||
|
@ -144,7 +144,7 @@ class JdepsTask {
|
||||
}
|
||||
|
||||
static Option[] recognizedOptions = {
|
||||
new Option(false, "-h", "-?", "-help") {
|
||||
new Option(false, "-h", "-?", "-help", "--help") {
|
||||
void process(JdepsTask task, String opt, String arg) {
|
||||
task.options.help = true;
|
||||
}
|
||||
@ -195,14 +195,14 @@ class JdepsTask {
|
||||
task.options.apiOnly = true;
|
||||
}
|
||||
},
|
||||
new Option(true, "-check") {
|
||||
new Option(true, "--check") {
|
||||
void process(JdepsTask task, String opt, String arg) throws BadArgs {
|
||||
Set<String> mods = Set.of(arg.split(","));
|
||||
task.options.checkModuleDeps = mods;
|
||||
task.options.addmods.addAll(mods);
|
||||
}
|
||||
},
|
||||
new Option(true, "-genmoduleinfo") {
|
||||
new Option(true, "--gen-module-info") {
|
||||
void process(JdepsTask task, String opt, String arg) throws BadArgs {
|
||||
Path p = Paths.get(arg);
|
||||
if (Files.exists(p) && (!Files.isDirectory(p) || !Files.isWritable(p))) {
|
||||
@ -222,22 +222,22 @@ class JdepsTask {
|
||||
},
|
||||
|
||||
// ---- paths option ----
|
||||
new Option(true, "-cp", "-classpath") {
|
||||
new Option(true, "-cp", "-classpath", "--class-path") {
|
||||
void process(JdepsTask task, String opt, String arg) {
|
||||
task.options.classpath = arg;
|
||||
}
|
||||
},
|
||||
new Option(true, "-mp", "-modulepath") {
|
||||
new Option(true, "--module-path") {
|
||||
void process(JdepsTask task, String opt, String arg) throws BadArgs {
|
||||
task.options.modulePath = arg;
|
||||
}
|
||||
},
|
||||
new Option(true, "-upgrademodulepath") {
|
||||
new Option(true, "--upgrade-module-path") {
|
||||
void process(JdepsTask task, String opt, String arg) throws BadArgs {
|
||||
task.options.upgradeModulePath = arg;
|
||||
}
|
||||
},
|
||||
new Option(true, "-system") {
|
||||
new Option(true, "--system") {
|
||||
void process(JdepsTask task, String opt, String arg) throws BadArgs {
|
||||
if (arg.equals("none")) {
|
||||
task.options.systemModulePath = null;
|
||||
@ -250,13 +250,13 @@ class JdepsTask {
|
||||
}
|
||||
}
|
||||
},
|
||||
new Option(true, "-addmods") {
|
||||
new Option(true, "--add-modules") {
|
||||
void process(JdepsTask task, String opt, String arg) throws BadArgs {
|
||||
Set<String> mods = Set.of(arg.split(","));
|
||||
task.options.addmods.addAll(mods);
|
||||
}
|
||||
},
|
||||
new Option(true, "-m") {
|
||||
new Option(true, "-m", "--module") {
|
||||
void process(JdepsTask task, String opt, String arg) throws BadArgs {
|
||||
task.options.rootModule = arg;
|
||||
task.options.addmods.add(arg);
|
||||
@ -314,7 +314,7 @@ class JdepsTask {
|
||||
},
|
||||
|
||||
// Another alternative to list modules in -addmods option
|
||||
new HiddenOption(true, "-include-system-modules") {
|
||||
new HiddenOption(true, "--include-system-modules") {
|
||||
void process(JdepsTask task, String opt, String arg) throws BadArgs {
|
||||
task.options.includeSystemModulePattern = Pattern.compile(arg);
|
||||
}
|
||||
@ -345,7 +345,7 @@ class JdepsTask {
|
||||
}
|
||||
},
|
||||
|
||||
new Option(false, "-ct", "-compile-time") {
|
||||
new Option(false, "--compile-time") {
|
||||
void process(JdepsTask task, String opt, String arg) {
|
||||
task.options.compileTimeView = true;
|
||||
task.options.filterSamePackage = true;
|
||||
@ -375,7 +375,7 @@ class JdepsTask {
|
||||
task.options.showLabel = true;
|
||||
}
|
||||
},
|
||||
new HiddenOption(false, "-hide-module") {
|
||||
new HiddenOption(false, "--hide-show-module") {
|
||||
void process(JdepsTask task, String opt, String arg) {
|
||||
task.options.showModule = false;
|
||||
}
|
||||
@ -464,7 +464,7 @@ class JdepsTask {
|
||||
return EXIT_CMDERR;
|
||||
}
|
||||
if (options.checkModuleDeps != null && !inputArgs.isEmpty()) {
|
||||
reportError("err.invalid.module.option", inputArgs, "-check");
|
||||
reportError("err.invalid.module.option", inputArgs, "--check");
|
||||
}
|
||||
|
||||
boolean ok = run();
|
||||
@ -501,12 +501,12 @@ class JdepsTask {
|
||||
.forEach(mn -> config.findModule(mn).orElseThrow(() ->
|
||||
new UncheckedBadArgs(new BadArgs("err.module.not.found", mn))));
|
||||
|
||||
// -genmoduleinfo
|
||||
// --gen-module-info
|
||||
if (options.genModuleInfo != null) {
|
||||
return genModuleInfo(config);
|
||||
}
|
||||
|
||||
// -check
|
||||
// --check
|
||||
if (options.checkModuleDeps != null) {
|
||||
return new ModuleAnalyzer(config, log, options.checkModuleDeps).run();
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class ModuleAnalyzer {
|
||||
String list = config.initialArchives().stream()
|
||||
.map(Archive::getPathName).collect(joining(" "));
|
||||
throw new JdepsTask.UncheckedBadArgs(new BadArgs("err.invalid.module.option",
|
||||
list, "-check"));
|
||||
list, "--check"));
|
||||
}
|
||||
|
||||
this.configuration = config;
|
||||
|
@ -1,6 +1,6 @@
|
||||
main.usage.summary=\
|
||||
Usage: {0} <options> <path ...>]\n\
|
||||
use -h, -? or -help for a list of possible options
|
||||
use -h, -?, -help, or --help for a list of possible options
|
||||
|
||||
main.usage=\
|
||||
Usage: {0} <options> <path ...>]\n\
|
||||
@ -12,7 +12,8 @@ error.prefix=Error:
|
||||
warn.prefix=Warning:
|
||||
|
||||
main.opt.h=\
|
||||
\ -h -? -help Print this usage message
|
||||
\ -h -? -help\n\
|
||||
\ --help Print this usage message
|
||||
|
||||
main.opt.version=\
|
||||
\ -version Version information
|
||||
@ -64,24 +65,26 @@ main.opt.P=\
|
||||
\ -P -profile Show profile containing a package
|
||||
|
||||
main.opt.cp=\
|
||||
\ -cp <path> -classpath <path> Specify where to find class files
|
||||
\ -cp <path>\n\
|
||||
\ -classpath <path>\n\
|
||||
\ --class-path <path> Specify where to find class files
|
||||
|
||||
main.opt.mp=\
|
||||
\ -mp <module path>...\n\
|
||||
\ -modulepath <module path>... Specify module path
|
||||
main.opt.module-path=\
|
||||
\ --module-path <module path>... Specify module path
|
||||
|
||||
main.opt.upgrademodulepath=\
|
||||
\ -upgrademodulepath <module path>... Specify upgrade module path
|
||||
main.opt.upgrade-module-path=\
|
||||
\ --upgrade-module-path <module path>... Specify upgrade module path
|
||||
|
||||
main.opt.system=\
|
||||
\ -system <java-home> Specify an alternate system module path
|
||||
\ --system <java-home> Specify an alternate system module path
|
||||
|
||||
main.opt.addmods=\
|
||||
\ -addmods <module-name>[,<module-name>...]\n\
|
||||
main.opt.add-modules=\
|
||||
\ --add-modules <module-name>[,<module-name>...]\n\
|
||||
\ Adds modules to the root set for analysis
|
||||
|
||||
main.opt.m=\
|
||||
\ -m <module-name> Specify the root module for analysis
|
||||
\ -m <module-name>\n\
|
||||
\ --module <module-name> Specify the root module for analysis
|
||||
|
||||
main.opt.R=\
|
||||
\ -R -recursive Recursively traverse all run-time dependencies.\n\
|
||||
@ -98,8 +101,8 @@ main.opt.I=\
|
||||
\ dependency summary. This option must use\n\
|
||||
\ with -requires, -package or -regex option.
|
||||
|
||||
main.opt.ct=\
|
||||
\ -ct -compile-time Compile-time view of transitive dependencies\n\
|
||||
main.opt.compile-time=\
|
||||
\ --compile-time Compile-time view of transitive dependencies\n\
|
||||
\ i.e. compile-time view of -R option.\n\
|
||||
\ Analyzes the dependences per other given options\n\
|
||||
\ If a dependence is found from a directory,\n\
|
||||
@ -113,14 +116,14 @@ main.opt.apionly=\
|
||||
\ type, method parameter types, returned type,\n\
|
||||
\ checked exception types etc.
|
||||
|
||||
main.opt.genmoduleinfo=\
|
||||
\ -genmoduleinfo <dir> Generate module-info.java under the specified\n\
|
||||
main.opt.gen-module-info=\
|
||||
\ --gen-module-info <dir> Generate module-info.java under the specified\n\
|
||||
\ directory. The specified JAR files will be\n\
|
||||
\ analyzed. This option cannot be used with\n\
|
||||
\ -dotoutput or -cp.
|
||||
|
||||
main.opt.check=\
|
||||
\ -check <module-name>[,<module-name>...\n\
|
||||
\ --check <module-name>[,<module-name>...\n\
|
||||
\ Analyze the dependence of the specified modules\n\
|
||||
\ It prints the module descriptor, the resulting\n\
|
||||
\ module dependences after analysis and the\n\
|
||||
@ -151,7 +154,7 @@ err.unknown.option=unknown option: {0}
|
||||
err.missing.arg=no value given for {0}
|
||||
err.invalid.arg.for.option=invalid argument for option: {0}
|
||||
err.option.after.class=option must be specified before classes: {0}
|
||||
err.genmoduleinfo.not.jarfile={0} not valid for -genmoduleinfo option (must be non-modular JAR file)
|
||||
err.genmoduleinfo.not.jarfile={0} not valid for --gen-module-info option (must be non-modular JAR file)
|
||||
err.profiles.msg=No profile information
|
||||
err.exception.message={0}
|
||||
err.invalid.path=invalid path: {0}
|
||||
|
@ -86,6 +86,11 @@ tools/javap/output/RepeatingTypeAnnotations.java
|
||||
tools/sjavac/IncCompileFullyQualifiedRef.java 8152055 generic-all Requires dependency code to deal with in-method dependencies.
|
||||
tools/sjavac/IncCompileWithChanges.java 8152055 generic-all Requires dependency code to deal with in-method dependencies.
|
||||
|
||||
tools/sjavac/ApiExtraction.java 8158002 generic-all Requires investigation
|
||||
tools/sjavac/IgnoreSymbolFile.java 8158002 generic-all Requires investigation
|
||||
tools/sjavac/ClasspathDependencies.java 8158002 generic-all Requires investigation
|
||||
|
||||
|
||||
###########################################################################
|
||||
#
|
||||
# jdeps
|
||||
|
@ -14,8 +14,8 @@ keys=intermittent randomness
|
||||
# Group definitions
|
||||
groups=TEST.groups
|
||||
|
||||
# Tests using jtreg 4.2 b02 features
|
||||
requiredVersion=4.2 b02
|
||||
# Tests using jtreg 4.2 b03 features
|
||||
requiredVersion=4.2 b03
|
||||
|
||||
# Use new form of -Xpatch
|
||||
useNewXpatch=true
|
||||
# Use new module options
|
||||
useNewOptions=true
|
||||
|
@ -42,8 +42,8 @@ public class TestModules extends JavadocTester {
|
||||
@Test
|
||||
void test1() {
|
||||
javadoc("-d", "out", "-use",
|
||||
"-modulesourcepath", testSrc,
|
||||
"-addmods", "module1,module2",
|
||||
"--module-source-path", testSrc,
|
||||
"--add-modules", "module1,module2",
|
||||
"testpkgmdl1", "testpkgmdl2");
|
||||
checkExit(Exit.OK);
|
||||
testDescription(true);
|
||||
@ -57,8 +57,8 @@ public class TestModules extends JavadocTester {
|
||||
@Test
|
||||
void test2() {
|
||||
javadoc("-d", "out-html5", "-html5", "-use",
|
||||
"-modulesourcepath", testSrc,
|
||||
"-addmods", "module1,module2",
|
||||
"--module-source-path", testSrc,
|
||||
"--add-modules", "module1,module2",
|
||||
"testpkgmdl1", "testpkgmdl2");
|
||||
checkExit(Exit.OK);
|
||||
testHtml5Description(true);
|
||||
@ -72,8 +72,8 @@ public class TestModules extends JavadocTester {
|
||||
@Test
|
||||
void test3() {
|
||||
javadoc("-d", "out-nocomment", "-nocomment", "-use",
|
||||
"-modulesourcepath", testSrc,
|
||||
"-addmods", "module1,module2",
|
||||
"--module-source-path", testSrc,
|
||||
"--add-modules", "module1,module2",
|
||||
"testpkgmdl1", "testpkgmdl2");
|
||||
checkExit(Exit.OK);
|
||||
testDescription(false);
|
||||
@ -84,8 +84,8 @@ public class TestModules extends JavadocTester {
|
||||
@Test
|
||||
void test4() {
|
||||
javadoc("-d", "out-html5-nocomment", "-nocomment", "-html5", "-use",
|
||||
"-modulesourcepath", testSrc,
|
||||
"-addmods", "module1,module2",
|
||||
"--module-source-path", testSrc,
|
||||
"--add-modules", "module1,module2",
|
||||
"testpkgmdl1", "testpkgmdl2");
|
||||
checkExit(Exit.OK);
|
||||
testHtml5Description(false);
|
||||
@ -108,8 +108,8 @@ public class TestModules extends JavadocTester {
|
||||
javadoc("-d", "out-mdltags", "-author", "-version",
|
||||
"-tag", "regular:a:Regular Tag:",
|
||||
"-tag", "moduletag:s:Module Tag:",
|
||||
"-modulesourcepath", testSrc,
|
||||
"-addmods", "moduletags,module2",
|
||||
"--module-source-path", testSrc,
|
||||
"--add-modules", "moduletags,module2",
|
||||
"testpkgmdltags", "testpkgmdl2");
|
||||
checkExit(Exit.OK);
|
||||
testModuleTags();
|
||||
|
@ -47,8 +47,6 @@ public class TestStdDoclet {
|
||||
*/
|
||||
void run() throws Exception {
|
||||
File javaHome = new File(System.getProperty("java.home"));
|
||||
if (javaHome.getName().equals("jre"))
|
||||
javaHome = javaHome.getParentFile();
|
||||
File javadoc = new File(new File(javaHome, "bin"), "javadoc");
|
||||
File testSrc = new File(System.getProperty("test.src"));
|
||||
|
||||
@ -57,11 +55,6 @@ public class TestStdDoclet {
|
||||
String thisClassName = TestStdDoclet.class.getName();
|
||||
List<String> cmdArgs = new ArrayList<>();
|
||||
cmdArgs.add(javadoc.getPath());
|
||||
int i = 0;
|
||||
String prop;
|
||||
while ((prop = System.getProperty("jdk.launcher.patch." + (i++))) != null) {
|
||||
cmdArgs.add("-J-Xpatch:" + prop);
|
||||
}
|
||||
cmdArgs.addAll(Arrays.asList(
|
||||
"-classpath", ".", // insulates us from ambient classpath
|
||||
"-Xdoclint:none",
|
||||
|
@ -68,11 +68,6 @@ public class TestUserDoclet implements Doclet {
|
||||
String thisClassName = TestUserDoclet.class.getName();
|
||||
List<String> cmdArgs = new ArrayList<>();
|
||||
cmdArgs.add(javadoc.getPath());
|
||||
int i = 0;
|
||||
String prop;
|
||||
while ((prop = System.getProperty("jdk.launcher.patch." + (i++))) != null) {
|
||||
cmdArgs.add("-J-Xpatch:" + prop);
|
||||
}
|
||||
cmdArgs.addAll(Arrays.asList(
|
||||
"-doclet", thisClassName,
|
||||
"-docletpath", testClasses.getPath(),
|
||||
|
@ -148,7 +148,7 @@ public class CheckResourceKeys {
|
||||
if (codeKeys.contains(rk))
|
||||
continue;
|
||||
|
||||
error("Resource key not found in code: " + rk);
|
||||
error("Resource key not found in code: '" + rk + '"');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
@ -53,16 +54,16 @@ public class ReleaseOption {
|
||||
List<String> options = new ArrayList<>();
|
||||
options.addAll(Arrays.asList(args));
|
||||
options.add("-XDrawDiagnostics");
|
||||
options.add(System.getProperty("test.src", ".") + java.io.File.separatorChar + "ReleaseOptionSource.java");
|
||||
options.add(new File(System.getProperty("test.src", "."), "ReleaseOptionSource.java").getPath());
|
||||
StringWriter out = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(out);
|
||||
int actualResult = Main.execute(options.toArray(new String[0]), pw);
|
||||
System.err.println("actual result=" + actualResult);
|
||||
System.err.println("actual output=" + out.toString());
|
||||
if (actualResult != expectedResult)
|
||||
throw new Error();
|
||||
throw new Error("Exit code not as expected");
|
||||
if (!validate.test(out.toString())) {
|
||||
throw new Error("Not an expected error output: " + out.toString());
|
||||
throw new Error("Output not as expected");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,11 +111,11 @@ public class RunCodingRules {
|
||||
Path crulesTarget = targetDir.resolve("crules");
|
||||
Files.createDirectories(crulesTarget);
|
||||
List<String> crulesOptions = Arrays.asList(
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
|
||||
"-d", crulesTarget.toString());
|
||||
javaCompiler.getTask(null, fm, noErrors, crulesOptions, null,
|
||||
fm.getJavaFileObjectsFromFiles(crulesFiles)).call();
|
||||
@ -178,7 +178,7 @@ public class RunCodingRules {
|
||||
|
||||
List<String> options = Arrays.asList(
|
||||
"-d", sourceTarget.toString(),
|
||||
"-modulesourcepath", mainSrcDir + FS + "*" + FS + "share" + FS + "classes" + PS
|
||||
"--module-source-path", mainSrcDir + FS + "*" + FS + "share" + FS + "classes" + PS
|
||||
+ genSrcTarget + FS + "*" + FS + "share" + FS + "classes",
|
||||
"-XDaccessInternalAPI",
|
||||
"-processorpath", processorPath,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2016, 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
|
||||
@ -49,9 +49,8 @@ public class T6410653 {
|
||||
compiler.run(null, null, out, "-d", source, source);
|
||||
System.err.println(">>>" + out + "<<<");
|
||||
useRawMessages.setBoolean(null, false);
|
||||
if (!out.toString().equals(String.format("%s%n%s%n",
|
||||
"javac: javac.err.file.not.directory",
|
||||
"javac.msg.usage"))) {
|
||||
if (!out.toString().equals(String.format("%s%n",
|
||||
"javac: javac.err.file.not.directory"))) {
|
||||
throw new AssertionError(out);
|
||||
}
|
||||
System.out.println("Test PASSED. Running javac again to see localized output:");
|
||||
|
@ -70,9 +70,9 @@ public class T6358024 extends AbstractProcessor {
|
||||
JavacTool tool = JavacTool.create();
|
||||
List<String> flags = new ArrayList<String>();
|
||||
flags.addAll(Arrays.asList(
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"));
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"));
|
||||
for (Option opt: opts) {
|
||||
flags.add(opt.name);
|
||||
for (Object arg : opt.args)
|
||||
|
@ -56,10 +56,10 @@ public class T6358166 extends AbstractProcessor {
|
||||
JavaFileObject f = fm.getJavaFileObject(testSrc + File.separatorChar + self + ".java");
|
||||
|
||||
List<String> addExports = Arrays.asList(
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED");
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED");
|
||||
|
||||
test(fm, f, addExports, "-verbose", "-d", ".");
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2016, 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
|
||||
@ -58,10 +58,10 @@ public class T6403466 extends AbstractProcessor {
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
|
||||
|
||||
Iterable<String> options = Arrays.asList(
|
||||
"-XaddExports:"
|
||||
+ "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED,"
|
||||
"--add-exports",
|
||||
"jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED,"
|
||||
+ "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
|
||||
"-processorpath", testClassDir,
|
||||
"--processor-path", testClassDir,
|
||||
"-processor", self,
|
||||
"-s", ".",
|
||||
"-d", ".");
|
||||
|
@ -50,8 +50,8 @@ public class T6406771 extends AbstractProcessor {
|
||||
JavaFileObject f = fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, self+".java"))).iterator().next();
|
||||
|
||||
List<String> opts = Arrays.asList(
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
||||
"-XDaccessInternalAPI",
|
||||
"-d", ".",
|
||||
"-processorpath", testClasses,
|
||||
|
@ -116,6 +116,8 @@ public class DetectMutableStaticFields {
|
||||
"moduleFinderClass", "ofMethod");
|
||||
ignore("com/sun/tools/javac/util/JDK9Wrappers$ServiceLoaderHelper",
|
||||
"loadMethod");
|
||||
ignore("com/sun/tools/javac/util/JDK9Wrappers$VMHelper",
|
||||
"vmClass", "getRuntimeArgumentsMethod");
|
||||
}
|
||||
|
||||
private final List<String> errors = new ArrayList<>();
|
||||
|
@ -143,11 +143,11 @@ public class ParameterNamesAreNotCopiedToAnonymousInitTest {
|
||||
Arrays.asList(new File(System.getProperty("test.src"),
|
||||
this.getClass().getName() + ".java")));
|
||||
java.util.List<String> options = Arrays.asList(
|
||||
"-XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
|
||||
"-d", System.getProperty("user.dir")
|
||||
);
|
||||
JavacTask task = (JavacTask) c.getTask(null, fm, null, options, null, fos);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, 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
|
||||
@ -49,7 +49,7 @@ public class T6358786 {
|
||||
String srcdir = System.getProperty("test.src");
|
||||
File file = new File(srcdir, args[0]);
|
||||
List<String> options = Arrays.asList(
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"
|
||||
);
|
||||
JavacTaskImpl task = (JavacTaskImpl)tool.getTask(null, fm, null, options, null, fm.getJavaFileObjectsFromFiles(Arrays.asList(file)));
|
||||
Elements elements = task.getElements();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2016, 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
|
||||
@ -54,7 +54,7 @@ public class T6412669 extends AbstractProcessor {
|
||||
String[] opts = {
|
||||
"-proc:only",
|
||||
"-processor", T6412669.class.getName(),
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"
|
||||
};
|
||||
StringWriter sw = new StringWriter();
|
||||
JavacTask task = tool.getTask(sw, fm, null, Arrays.asList(opts), null, files);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2016, 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
|
||||
@ -133,7 +133,7 @@ public class TestClientCodeWrapper extends JavacTestingAbstractProcessor {
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
|
||||
List<String> javacOptions = Arrays.asList(
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
||||
"-extdirs", extDirs.getPath(), // for use by filemanager handleOption
|
||||
"-processor", TestClientCodeWrapper.class.getName()
|
||||
);
|
||||
|
@ -74,10 +74,10 @@ public class TestJavacTaskScanner extends ToolTester {
|
||||
fm.getJavaFileObjects(new File[] {file});
|
||||
StandardJavaFileManager fm = getLocalFileManager(tool, null, null);
|
||||
java.util.List<String> options = Arrays.asList(
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED");
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED");
|
||||
task = (JavacTaskImpl)tool.getTask(null, fm, null, options, null, compilationUnits);
|
||||
task.getContext().put(ScannerFactory.scannerFactoryKey,
|
||||
new MyScanner.Factory(task.getContext(), this));
|
||||
|
@ -79,8 +79,7 @@ public class TestTrees extends AbstractProcessor {
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
|
||||
|
||||
Iterable<String> opts = Arrays.asList(
|
||||
"-XaddExports:"
|
||||
+ "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
||||
"-d", ".",
|
||||
"-XDcompilePolicy=simple");
|
||||
|
||||
@ -91,8 +90,7 @@ public class TestTrees extends AbstractProcessor {
|
||||
throw new AssertionError("compilation failed");
|
||||
|
||||
opts = Arrays.asList(
|
||||
"-XaddExports:"
|
||||
+ "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
||||
"-XDaccessInternalAPI",
|
||||
"-d", ".",
|
||||
"-processorpath", testClassDir,
|
||||
|
@ -35,6 +35,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -127,8 +128,9 @@ public class ModuleTestBase {
|
||||
tr.checkContains(actualProvides, moduleDescriptor.provides, "Lists of provides don't match");
|
||||
}
|
||||
|
||||
protected void compile(Path base) throws IOException {
|
||||
protected void compile(Path base, String... options) throws IOException {
|
||||
new JavacTask(tb)
|
||||
.options(options)
|
||||
.files(findJavaFiles(base))
|
||||
.run(Task.Expect.SUCCESS)
|
||||
.writeAll();
|
||||
|
@ -223,7 +223,7 @@ class Example implements Comparable<Example> {
|
||||
// source for import statements or a magic comment
|
||||
for (File pf: procFiles) {
|
||||
if (pf.getName().equals("CreateBadClassFile.java")) {
|
||||
pOpts.add("-XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED");
|
||||
pOpts.add("--add-exports=jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED");
|
||||
}
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ class Example implements Comparable<Example> {
|
||||
}
|
||||
|
||||
if (moduleSourcePathDir != null) {
|
||||
opts.add("-modulesourcepath");
|
||||
opts.add("--module-source-path");
|
||||
opts.add(moduleSourcePathDir.getPath());
|
||||
files = moduleSourcePathFiles;
|
||||
}
|
||||
|
@ -122,6 +122,7 @@ compiler.err.locn.bad.module-info # bad class file
|
||||
compiler.err.locn.cant.read.file # bad class file
|
||||
compiler.misc.module.info.invalid.super.class # bad class file
|
||||
compiler.err.locn.cant.read.directory # file system issue
|
||||
compiler.err.locn.invalid.arg.for.xpatch # command line option error
|
||||
compiler.misc.unnamed.module # fragment uninteresting in and of itself
|
||||
compiler.misc.kindname.module # fragment uninteresting in and of itself
|
||||
compiler.misc.locn.module_path # fragment uninteresting in and of itself
|
||||
|
@ -22,5 +22,5 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.addmods.all.module.path.invalid
|
||||
// options: -addmods ALL-MODULE-PATH
|
||||
// options: --add-modules ALL-MODULE-PATH
|
||||
module m {}
|
||||
|
@ -24,7 +24,7 @@
|
||||
// key: compiler.err.cant.find.module
|
||||
// key: compiler.err.doesnt.exist
|
||||
|
||||
// options: -XaddExports:undef/undef=ALL-UNNAMED
|
||||
// options: --add-exports undef/undef=ALL-UNNAMED
|
||||
|
||||
import undef.Any;
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.illegal.argument.for.option
|
||||
// options: -modulepath doesNotExist
|
||||
// options: --module-path doesNotExist
|
||||
// run: simple
|
||||
|
||||
class X {}
|
||||
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
// key: compiler.err.locn.invalid.arg.for.xpatch
|
||||
// options: -Xpatch:blah
|
||||
|
||||
class InvalidArgForXpatch {}
|
@ -25,7 +25,7 @@
|
||||
// key: compiler.misc.bad.class.file.header
|
||||
// key: compiler.err.cant.access
|
||||
// options: -processor CreateBadClassFile
|
||||
// run: exec -XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED
|
||||
// run: exec --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED
|
||||
|
||||
/* The annotation processor will create an invalid classfile with version 51.0
|
||||
* and a non-abstract method in an interface. Loading the classfile will produce
|
||||
|
@ -25,7 +25,7 @@
|
||||
// key: compiler.misc.bad.class.file.header
|
||||
// key: compiler.err.cant.access
|
||||
// options: -processor CreateBadClassFile
|
||||
// run: exec -XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED
|
||||
// run: exec --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED
|
||||
|
||||
/* The annotation processor will create an invalid classfile with version 51.0
|
||||
* and a static method in an interface. Loading the classfile will produce
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.xaddexports.malformed.entry
|
||||
// options: -XaddExports:jdk.compiler/com.sun.tools.javac.util
|
||||
// options: --add-exports jdk.compiler/com.sun.tools.javac.util
|
||||
|
||||
public class XaddexportsMalformedEntry {
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.xaddexports.too.many
|
||||
// options: -XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED -XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
|
||||
// options: --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
|
||||
|
||||
public class XaddexportsTooMany {
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.xaddreads.malformed.entry
|
||||
// options: -XaddReads:jdk.compiler
|
||||
// options: --add-reads jdk.compiler
|
||||
|
||||
public class XaddreadsMalformedEntry {
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.xaddreads.too.many
|
||||
// options: -XaddReads:jdk.compiler=ALL-UNNAMED -XaddReads:jdk.compiler=ALL-UNNAMED
|
||||
// options: --add-reads jdk.compiler=ALL-UNNAMED --add-reads jdk.compiler=ALL-UNNAMED
|
||||
|
||||
public class XaddreadsTooMany {
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class NoJavaLangTest {
|
||||
.run();
|
||||
|
||||
// ideally we'd have a better message for this case
|
||||
String[] mpOpts = { "-system", "none", "-modulepath", "modules" };
|
||||
String[] mpOpts = { "--system", "none", "--module-path", "modules" };
|
||||
test(mpOpts, compilerErrorMessage);
|
||||
}
|
||||
|
||||
|
@ -60,9 +60,9 @@ public class T7018098 extends JavacTestingAbstractProcessor {
|
||||
_assert(!testDir.exists());
|
||||
|
||||
compile(
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
|
||||
"-XDaccessInternalAPI",
|
||||
"-proc:only",
|
||||
"-processor", myName,
|
||||
@ -73,9 +73,9 @@ public class T7018098 extends JavacTestingAbstractProcessor {
|
||||
_assert(testDir.exists());
|
||||
|
||||
compile(
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
|
||||
"--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
|
||||
"-XDaccessInternalAPI",
|
||||
"-proc:only",
|
||||
"-processor", myName,
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @summary Test -addmods and -limitmods; also test the "enabled" modules.
|
||||
* @summary Test --add-modules and --limit-modules; also test the "enabled" modules.
|
||||
* @library /tools/lib
|
||||
* @modules
|
||||
* jdk.compiler/com.sun.tools.javac.api
|
||||
@ -103,14 +103,14 @@ public class AddLimitMods extends ModuleTestBase {
|
||||
Files.createDirectories(modulePath);
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulesourcepath", moduleSrc.toString())
|
||||
.options("--module-source-path", moduleSrc.toString())
|
||||
.outdir(modulePath)
|
||||
.files(findJavaFiles(m3))
|
||||
.run()
|
||||
.writeAll();
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulesourcepath", moduleSrc.toString())
|
||||
.options("--module-source-path", moduleSrc.toString())
|
||||
.outdir(modulePath)
|
||||
.files(findJavaFiles(m2))
|
||||
.run()
|
||||
@ -118,57 +118,57 @@ public class AddLimitMods extends ModuleTestBase {
|
||||
|
||||
//real test
|
||||
new JavacTask(tb)
|
||||
.options("-modulepath", modulePath.toString(),
|
||||
.options("--module-path", modulePath.toString(),
|
||||
"-Xshouldstop:ifNoError=FLOW",
|
||||
"-limitmods", "java.base")
|
||||
"--limit-modules", "java.base")
|
||||
.outdir(modulePath)
|
||||
.files(findJavaFiles(m1))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll();
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulepath", modulePath.toString(),
|
||||
.options("--module-path", modulePath.toString(),
|
||||
"-Xshouldstop:ifNoError=FLOW",
|
||||
"-limitmods", "java.base",
|
||||
"-addmods", "m2")
|
||||
"--limit-modules", "java.base",
|
||||
"--add-modules", "m2")
|
||||
.outdir(modulePath)
|
||||
.files(findJavaFiles(m1))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll();
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulepath", modulePath.toString(),
|
||||
.options("--module-path", modulePath.toString(),
|
||||
"-Xshouldstop:ifNoError=FLOW",
|
||||
"-limitmods", "java.base",
|
||||
"-addmods", "m2,m3")
|
||||
"--limit-modules", "java.base",
|
||||
"--add-modules", "m2,m3")
|
||||
.outdir(modulePath)
|
||||
.files(findJavaFiles(m1))
|
||||
.run()
|
||||
.writeAll();
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulepath", modulePath.toString(),
|
||||
.options("--module-path", modulePath.toString(),
|
||||
"-Xshouldstop:ifNoError=FLOW",
|
||||
"-limitmods", "m2")
|
||||
"--limit-modules", "m2")
|
||||
.outdir(modulePath)
|
||||
.files(findJavaFiles(m1))
|
||||
.run()
|
||||
.writeAll();
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulepath", modulePath.toString(),
|
||||
.options("--module-path", modulePath.toString(),
|
||||
"-Xshouldstop:ifNoError=FLOW",
|
||||
"-limitmods", "m3")
|
||||
"--limit-modules", "m3")
|
||||
.outdir(modulePath)
|
||||
.files(findJavaFiles(m1))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll();
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulepath", modulePath.toString(),
|
||||
.options("--module-path", modulePath.toString(),
|
||||
"-Xshouldstop:ifNoError=FLOW",
|
||||
"-limitmods", "m3",
|
||||
"-addmods", "m2")
|
||||
"--limit-modules", "m3",
|
||||
"--add-modules", "m2")
|
||||
.outdir(modulePath)
|
||||
.files(findJavaFiles(m1))
|
||||
.run()
|
||||
@ -219,11 +219,11 @@ public class AddLimitMods extends ModuleTestBase {
|
||||
"Test.java:2:18: compiler.err.doesnt.exist: javax.annotation\n"
|
||||
+ "Test.java:5:19: compiler.err.doesnt.exist: javax.xml.bind\n"
|
||||
+ "2 errors\n"),
|
||||
new SimpleEntry<String[], String>(new String[] {"-addmods", "java.annotations.common,java.xml.bind"},
|
||||
new SimpleEntry<String[], String>(new String[] {"--add-modules", "java.annotations.common,java.xml.bind"},
|
||||
null),
|
||||
new SimpleEntry<String[], String>(new String[] {"-limitmods", "java.xml.ws,jdk.compiler"},
|
||||
new SimpleEntry<String[], String>(new String[] {"--limit-modules", "java.xml.ws,jdk.compiler"},
|
||||
null),
|
||||
new SimpleEntry<String[], String>(new String[] {"-addmods", "ALL-SYSTEM"},
|
||||
new SimpleEntry<String[], String>(new String[] {"--add-modules", "ALL-SYSTEM"},
|
||||
null)
|
||||
);
|
||||
|
||||
@ -244,7 +244,7 @@ public class AddLimitMods extends ModuleTestBase {
|
||||
Files.createDirectories(modulePath);
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulesourcepath", moduleSrc.toString())
|
||||
.options("--module-source-path", moduleSrc.toString())
|
||||
.outdir(modulePath)
|
||||
.files(findJavaFiles(moduleSrc))
|
||||
.run()
|
||||
@ -258,15 +258,15 @@ public class AddLimitMods extends ModuleTestBase {
|
||||
Files.createDirectories(cpOut);
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulepath", modulePath.toString())
|
||||
.options("--module-path", modulePath.toString())
|
||||
.outdir(cpOut)
|
||||
.files(findJavaFiles(cpSrc))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll();
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulepath", modulePath.toString(),
|
||||
"-addmods", "ALL-MODULE-PATH")
|
||||
.options("--module-path", modulePath.toString(),
|
||||
"--add-modules", "ALL-MODULE-PATH")
|
||||
.outdir(cpOut)
|
||||
.files(findJavaFiles(cpSrc))
|
||||
.run()
|
||||
@ -278,9 +278,9 @@ public class AddLimitMods extends ModuleTestBase {
|
||||
"1 error");
|
||||
|
||||
actual = new JavacTask(tb)
|
||||
.options("-modulesourcepath", moduleSrc.toString(),
|
||||
.options("--module-source-path", moduleSrc.toString(),
|
||||
"-XDrawDiagnostics",
|
||||
"-addmods", "ALL-MODULE-PATH")
|
||||
"--add-modules", "ALL-MODULE-PATH")
|
||||
.outdir(modulePath)
|
||||
.files(findJavaFiles(moduleSrc))
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -294,7 +294,7 @@ public class AddLimitMods extends ModuleTestBase {
|
||||
actual = new JavacTask(tb)
|
||||
.options("-Xmodule:java.base",
|
||||
"-XDrawDiagnostics",
|
||||
"-addmods", "ALL-MODULE-PATH")
|
||||
"--add-modules", "ALL-MODULE-PATH")
|
||||
.outdir(cpOut)
|
||||
.files(findJavaFiles(cpSrc))
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -308,14 +308,14 @@ public class AddLimitMods extends ModuleTestBase {
|
||||
actual = new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-source", "8", "-target", "8",
|
||||
"-XDrawDiagnostics",
|
||||
"-addmods", "ALL-MODULE-PATH")
|
||||
"--add-modules", "ALL-MODULE-PATH")
|
||||
.outdir(cpOut)
|
||||
.files(findJavaFiles(cpSrc))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
.getOutputLines(Task.OutputKind.DIRECT);
|
||||
|
||||
if (!actual.contains("javac: option -addmods not allowed with target 1.8")) {
|
||||
if (!actual.contains("javac: option --add-modules not allowed with target 1.8")) {
|
||||
throw new IllegalStateException("incorrect errors; actual=" + actual);
|
||||
}
|
||||
|
||||
@ -323,7 +323,7 @@ public class AddLimitMods extends ModuleTestBase {
|
||||
|
||||
actual = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-addmods", "ALL-MODULE-PATH")
|
||||
"--add-modules", "ALL-MODULE-PATH")
|
||||
.outdir(cpOut)
|
||||
.files(findJavaFiles(cpSrc))
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -386,7 +386,7 @@ public class AddLimitMods extends ModuleTestBase {
|
||||
"package api; public class Api { public void test() { } }");
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulesourcepath", moduleSrc.toString())
|
||||
.options("--module-source-path", moduleSrc.toString())
|
||||
.outdir(modulePath)
|
||||
.files(findJavaFiles(moduleSrc))
|
||||
.run()
|
||||
@ -428,7 +428,7 @@ public class AddLimitMods extends ModuleTestBase {
|
||||
tb.writeJavaFiles(m2Runtime, moduleInfo, testClassNamed.toString());
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulepath", modulePath.toString())
|
||||
.options("--module-path", modulePath.toString())
|
||||
.outdir(out)
|
||||
.files(findJavaFiles(m2Runtime))
|
||||
.run()
|
||||
@ -441,9 +441,9 @@ public class AddLimitMods extends ModuleTestBase {
|
||||
output = new JavaTask(tb)
|
||||
.vmOptions(augmentOptions(options,
|
||||
Collections.emptyList(),
|
||||
"-modulepath", modulePath.toString() + File.pathSeparator + out.getParent().toString(),
|
||||
"-classpath", classpathOut.toString(),
|
||||
"-XaddReads:m2=ALL-UNNAMED,automatic",
|
||||
"--module-path", modulePath.toString() + File.pathSeparator + out.getParent().toString(),
|
||||
"--class-path", classpathOut.toString(),
|
||||
"--add-reads", "m2=ALL-UNNAMED,automatic",
|
||||
"-m", "m2/test.Test"))
|
||||
.run()
|
||||
.writeAll()
|
||||
@ -463,7 +463,7 @@ public class AddLimitMods extends ModuleTestBase {
|
||||
"public class Test {}\n");
|
||||
|
||||
List<String> auxOptions = success ? Arrays.asList(
|
||||
"-processorpath", System.getProperty("test.class.path"),
|
||||
"--processor-path", System.getProperty("test.class.path"),
|
||||
"-processor", CheckVisibleModule.class.getName(),
|
||||
"-Aoutput=" + output,
|
||||
"-XDaccessInternalAPI=true"
|
||||
@ -471,8 +471,8 @@ public class AddLimitMods extends ModuleTestBase {
|
||||
new JavacTask(tb)
|
||||
.options(augmentOptions(options,
|
||||
auxOptions,
|
||||
"-modulepath", modulePath.toString(),
|
||||
"-classpath", classpathOut.toString(),
|
||||
"--module-path", modulePath.toString(),
|
||||
"--class-path", classpathOut.toString(),
|
||||
"-Xshouldstop:ifNoError=FLOW"))
|
||||
.outdir(modulePath)
|
||||
.files(findJavaFiles(m2))
|
||||
@ -578,14 +578,14 @@ public class AddLimitMods extends ModuleTestBase {
|
||||
};
|
||||
|
||||
private static final String[][] OPTIONS_VARIANTS = {
|
||||
{"-addmods", "automatic"},
|
||||
{"-addmods", "m1,automatic"},
|
||||
{"-addmods", "jdk.compiler,automatic"},
|
||||
{"-addmods", "m1,jdk.compiler,automatic"},
|
||||
{"-addmods", "ALL-SYSTEM,automatic"},
|
||||
{"-limitmods", "java.base", "-addmods", "automatic"},
|
||||
{"-limitmods", "java.base", "-addmods", "ALL-SYSTEM,automatic"},
|
||||
{"-limitmods", "m2", "-addmods", "automatic"},
|
||||
{"-limitmods", "jdk.compiler", "-addmods", "automatic"},
|
||||
{"--add-modules", "automatic"},
|
||||
{"--add-modules", "m1,automatic"},
|
||||
{"--add-modules", "jdk.compiler,automatic"},
|
||||
{"--add-modules", "m1,jdk.compiler,automatic"},
|
||||
{"--add-modules", "ALL-SYSTEM,automatic"},
|
||||
{"--limit-modules", "java.base", "--add-modules", "automatic"},
|
||||
{"--limit-modules", "java.base", "--add-modules", "ALL-SYSTEM,automatic"},
|
||||
{"--limit-modules", "m2", "--add-modules", "automatic"},
|
||||
{"--limit-modules", "jdk.compiler", "--add-modules", "automatic"},
|
||||
};
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Test the -XaddReads option
|
||||
* @summary Test the --add-reads option
|
||||
* @library /tools/lib
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.main
|
||||
@ -73,7 +73,7 @@ public class AddReadsTest extends ModuleTestBase {
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", src.toString())
|
||||
"--module-source-path", src.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -85,8 +85,8 @@ public class AddReadsTest extends ModuleTestBase {
|
||||
|
||||
//test add dependencies:
|
||||
new JavacTask(tb)
|
||||
.options("-XaddReads:m2=m1",
|
||||
"-modulesourcepath", src.toString(),
|
||||
.options("--add-reads", "m2=m1",
|
||||
"--module-source-path", src.toString(),
|
||||
"-processor", VerifyRequires.class.getName())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
@ -104,8 +104,8 @@ public class AddReadsTest extends ModuleTestBase {
|
||||
|
||||
//cyclic dependencies OK when created through addReads:
|
||||
new JavacTask(tb)
|
||||
.options("-XaddReads:m2=m1,m1=m2",
|
||||
"-modulesourcepath", src.toString())
|
||||
.options("--add-reads", "m2=m1,m1=m2",
|
||||
"--module-source-path", src.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
.run()
|
||||
@ -115,8 +115,8 @@ public class AddReadsTest extends ModuleTestBase {
|
||||
"module m2 { requires m1; }");
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-XaddReads:m1=m2",
|
||||
"-modulesourcepath", src.toString())
|
||||
.options("--add-reads", "m1=m2",
|
||||
"--module-source-path", src.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
.run()
|
||||
@ -165,8 +165,8 @@ public class AddReadsTest extends ModuleTestBase {
|
||||
"package impl; public class Impl { api.Api api; }");
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-classpath", jar.toString(),
|
||||
"-XaddReads:m1=ALL-UNNAMED",
|
||||
.options("--class-path", jar.toString(),
|
||||
"--add-reads", "m1=ALL-UNNAMED",
|
||||
"-XDrawDiagnostics")
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(moduleSrc))
|
||||
@ -191,9 +191,9 @@ public class AddReadsTest extends ModuleTestBase {
|
||||
"package impl; public class Impl { { api.Api.test(); } }");
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-classpath", jar.toString(),
|
||||
"-modulesourcepath", moduleSrc.toString(),
|
||||
"-XaddReads:m1=ALL-UNNAMED",
|
||||
.options("--class-path", jar.toString(),
|
||||
"--module-source-path", moduleSrc.toString(),
|
||||
"--add-reads", "m1=ALL-UNNAMED",
|
||||
"-XDrawDiagnostics")
|
||||
.outdir(classes)
|
||||
.files(m1.resolve("impl").resolve("Impl.java"))
|
||||
@ -213,8 +213,8 @@ public class AddReadsTest extends ModuleTestBase {
|
||||
"package impl; public class Impl { api.Api a; }");
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-classpath", jar.toString(),
|
||||
"-XaddReads:java.base=ALL-UNNAMED",
|
||||
.options("--class-path", jar.toString(),
|
||||
"--add-reads", "java.base=ALL-UNNAMED",
|
||||
"-Xmodule:java.base")
|
||||
.outdir(classes)
|
||||
.files(src.resolve("impl").resolve("Impl.java"))
|
||||
@ -233,7 +233,7 @@ public class AddReadsTest extends ModuleTestBase {
|
||||
"package impl; public class Impl { javax.swing.JButton b; }");
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-XaddReads:java.base=java.desktop",
|
||||
.options("--add-reads", "java.base=java.desktop",
|
||||
"-Xmodule:java.base")
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
@ -285,7 +285,7 @@ public class AddReadsTest extends ModuleTestBase {
|
||||
tb.createDirectories(classes);
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulesourcepath", src.toString())
|
||||
.options("--module-source-path", src.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
.run()
|
||||
@ -300,9 +300,9 @@ public class AddReadsTest extends ModuleTestBase {
|
||||
"package impl; public class Impl { }");
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-XaddReads:m1=ALL-UNNAMED",
|
||||
.options("--add-reads", "m1=ALL-UNNAMED",
|
||||
"-Xmodule:m1",
|
||||
"-modulepath", classes.toString())
|
||||
"--module-path", classes.toString())
|
||||
.outdir(unnamedClasses)
|
||||
.files(findJavaFiles(unnamedSrc))
|
||||
.run()
|
||||
|
@ -81,7 +81,7 @@ public class AnnotationProcessing extends ModuleTestBase {
|
||||
"package impl; public class Impl { }");
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-modulesourcepath", moduleSrc.toString(),
|
||||
.options("--module-source-path", moduleSrc.toString(),
|
||||
"-processor", AP.class.getName(),
|
||||
"-AexpectedEnclosedElements=m1=>impl")
|
||||
.outdir(classes)
|
||||
@ -113,7 +113,7 @@ public class AnnotationProcessing extends ModuleTestBase {
|
||||
"package impl2; public class Impl2 { }");
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-modulesourcepath", moduleSrc.toString(),
|
||||
.options("--module-source-path", moduleSrc.toString(),
|
||||
"-processor", AP.class.getName(),
|
||||
"-AexpectedEnclosedElements=m1=>impl1,m2=>impl2")
|
||||
.outdir(classes)
|
||||
|
@ -136,7 +136,7 @@ public class AnnotationProcessorsInModulesTest extends ModuleTestBase {
|
||||
annotationProcessor2);
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-modulesourcepath", moduleSrc.toString())
|
||||
.options("--module-source-path", moduleSrc.toString())
|
||||
.outdir(processorCompiledModules)
|
||||
.files(findJavaFiles(moduleSrc))
|
||||
.run()
|
||||
@ -159,7 +159,7 @@ public class AnnotationProcessorsInModulesTest extends ModuleTestBase {
|
||||
public void testUseOnlyOneProcessor(Path base) throws Exception {
|
||||
initialization(base);
|
||||
String log = new JavacTask(tb)
|
||||
.options("-processormodulepath", processorCompiledModules.toString(),
|
||||
.options("--processor-module-path", processorCompiledModules.toString(),
|
||||
"-processor", "mypkg2.MyProcessor2")
|
||||
.outdir(classes)
|
||||
.sources(testClass)
|
||||
@ -175,7 +175,7 @@ public class AnnotationProcessorsInModulesTest extends ModuleTestBase {
|
||||
public void testAnnotationProcessorExecutionOrder(Path base) throws Exception {
|
||||
initialization(base);
|
||||
List<String> log = new JavacTask(tb)
|
||||
.options("-processormodulepath", processorCompiledModules.toString(),
|
||||
.options("--processor-module-path", processorCompiledModules.toString(),
|
||||
"-processor", "mypkg1.MyProcessor1,mypkg2.MyProcessor2")
|
||||
.outdir(classes)
|
||||
.sources(testClass)
|
||||
@ -188,7 +188,7 @@ public class AnnotationProcessorsInModulesTest extends ModuleTestBase {
|
||||
}
|
||||
|
||||
log = new JavacTask(tb)
|
||||
.options("-processormodulepath", processorCompiledModules.toString(),
|
||||
.options("--processor-module-path", processorCompiledModules.toString(),
|
||||
"-processor", "mypkg2.MyProcessor2,mypkg1.MyProcessor1")
|
||||
.outdir(classes)
|
||||
.sources(testClass)
|
||||
@ -205,7 +205,8 @@ public class AnnotationProcessorsInModulesTest extends ModuleTestBase {
|
||||
public void testErrorOutputIfOneProcessorNameIsIncorrect(Path base) throws Exception {
|
||||
initialization(base);
|
||||
String log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics", "-processormodulepath", processorCompiledModules.toString(),
|
||||
.options("-XDrawDiagnostics",
|
||||
"--processor-module-path", processorCompiledModules.toString(),
|
||||
"-processor", "mypkg2.MyProcessor2,noPackage.noProcessor,mypkg1.MyProcessor1")
|
||||
.outdir(classes)
|
||||
.sources(testClass)
|
||||
@ -221,8 +222,9 @@ public class AnnotationProcessorsInModulesTest extends ModuleTestBase {
|
||||
public void testOptionsExclusion(Path base) throws Exception {
|
||||
initialization(base);
|
||||
List<String> log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics", "-processormodulepath", processorCompiledModules.toString(),
|
||||
"-processorpath", processorCompiledModules.toString())
|
||||
.options("-XDrawDiagnostics",
|
||||
"--processor-module-path", processorCompiledModules.toString(),
|
||||
"--processor-path", processorCompiledModules.toString())
|
||||
.outdir(classes)
|
||||
.sources(testClass)
|
||||
.run(Task.Expect.FAIL)
|
||||
|
@ -93,7 +93,7 @@ public class AutomaticModules extends ModuleTestBase {
|
||||
"package impl; public class Impl { public void e(api.Api api) { api.actionPerformed(null); } }");
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulesourcepath", moduleSrc.toString(), "-modulepath", modulePath.toString())
|
||||
.options("--module-source-path", moduleSrc.toString(), "--module-path", modulePath.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(moduleSrc))
|
||||
.run()
|
||||
@ -151,7 +151,7 @@ public class AutomaticModules extends ModuleTestBase {
|
||||
"package impl; public class Impl { public void e(api.Api api) { api.run(\"\"); } }");
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulesourcepath", moduleSrc.toString(), "-modulepath", modulePath.toString(), "-classpath", baseJar.toString())
|
||||
.options("--module-source-path", moduleSrc.toString(), "--module-path", modulePath.toString(), "--class-path", baseJar.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(moduleSrc))
|
||||
.run()
|
||||
@ -197,7 +197,7 @@ public class AutomaticModules extends ModuleTestBase {
|
||||
"package dep; public class Dep { api.Api api; }");
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulepath", modulePath.toString())
|
||||
.options("--module-path", modulePath.toString())
|
||||
.outdir(depClasses)
|
||||
.files(findJavaFiles(depSrc))
|
||||
.run()
|
||||
@ -221,7 +221,7 @@ public class AutomaticModules extends ModuleTestBase {
|
||||
"package test; public class Test { }");
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulepath", modulePath.toString())
|
||||
.options("--module-path", modulePath.toString())
|
||||
.outdir(testClasses)
|
||||
.files(findJavaFiles(testSrc))
|
||||
.run()
|
||||
@ -273,9 +273,9 @@ public class AutomaticModules extends ModuleTestBase {
|
||||
Files.createDirectories(classes);
|
||||
|
||||
List<String> log = new JavacTask(tb)
|
||||
.options("-modulesourcepath", moduleSrc.toString(),
|
||||
"-modulepath", modulePath.toString(),
|
||||
"-addmods", "automaticB",
|
||||
.options("--module-source-path", moduleSrc.toString(),
|
||||
"--module-path", modulePath.toString(),
|
||||
"--add-modules", "automaticB",
|
||||
"-XDrawDiagnostics")
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(moduleSrc))
|
||||
@ -291,8 +291,8 @@ public class AutomaticModules extends ModuleTestBase {
|
||||
}
|
||||
|
||||
log = new JavacTask(tb)
|
||||
.options("-modulesourcepath", moduleSrc.toString(),
|
||||
"-modulepath", modulePath.toString(),
|
||||
.options("--module-source-path", moduleSrc.toString(),
|
||||
"--module-path", modulePath.toString(),
|
||||
"-XDrawDiagnostics")
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(moduleSrc))
|
||||
|
@ -61,7 +61,7 @@ public class DoclintOtherModules extends ModuleTestBase {
|
||||
Files.createDirectories(classes);
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics", "-modulesourcepath", src.toString(), "-Xlint:deprecation", "-Xdoclint:-reference", "-Werror")
|
||||
.options("-XDrawDiagnostics", "--module-source-path", src.toString(), "-Xlint:deprecation", "-Xdoclint:-reference", "-Werror")
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(m1))
|
||||
.run(Task.Expect.SUCCESS)
|
||||
|
@ -60,7 +60,7 @@ public class DuplicateClassTest extends ModuleTestBase {
|
||||
Files.createDirectories(classes);
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-modulesourcepath", base.toString())
|
||||
.options("--module-source-path", base.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(base))
|
||||
.run()
|
||||
|
@ -73,7 +73,7 @@ public class EdgeCases extends ModuleTestBase {
|
||||
tb.createDirectories(classes);
|
||||
|
||||
List<String> log = new JavacTask(tb)
|
||||
.options("-XaddExports:undef/undef=ALL-UNNAMED", "-XDrawDiagnostics")
|
||||
.options("--add-exports", "undef/undef=ALL-UNNAMED", "-XDrawDiagnostics")
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -167,7 +167,7 @@ public class EdgeCases extends ModuleTestBase {
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", src.toString())
|
||||
"--module-source-path", src.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -222,16 +222,16 @@ public class EdgeCases extends ModuleTestBase {
|
||||
tb.createDirectories(classes);
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulepath", modulePath.toString(),
|
||||
"-modulesourcepath", src.toString())
|
||||
.options("--module-path", modulePath.toString(),
|
||||
"--module-source-path", src.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src_m2))
|
||||
.run()
|
||||
.writeAll();
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulepath", modulePath.toString(),
|
||||
"-modulesourcepath", src.toString())
|
||||
.options("--module-path", modulePath.toString(),
|
||||
"--module-source-path", src.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src_m3))
|
||||
.run()
|
||||
@ -250,7 +250,7 @@ public class EdgeCases extends ModuleTestBase {
|
||||
tb.createDirectories(classes);
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-sourcepath", src_m1.toString(),
|
||||
.options("--source-path", src_m1.toString(),
|
||||
"-XDrawDiagnostics")
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src_m1.resolve("test")))
|
||||
@ -261,7 +261,7 @@ public class EdgeCases extends ModuleTestBase {
|
||||
"module m1 {}");
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-sourcepath", src_m1.toString())
|
||||
.options("--source-path", src_m1.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src_m1.resolve("test")))
|
||||
.run()
|
||||
@ -286,7 +286,7 @@ public class EdgeCases extends ModuleTestBase {
|
||||
tb.createDirectories(classes);
|
||||
|
||||
List<String> log = new JavacTask(tb)
|
||||
.options("-modulesourcepath", src.toString(),
|
||||
.options("--module-source-path", src.toString(),
|
||||
"-XDrawDiagnostics")
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
|
@ -63,7 +63,7 @@ public class EnvVarTest extends ModuleTestBase {
|
||||
|
||||
tb.out.println("test that addExports can be given to javac");
|
||||
new JavacTask(tb)
|
||||
.options("-XaddExports:jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED")
|
||||
.options("--add-exports", "jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED")
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
.run(Expect.SUCCESS)
|
||||
@ -71,7 +71,7 @@ public class EnvVarTest extends ModuleTestBase {
|
||||
|
||||
tb.out.println("test that addExports can be provided with env variable");
|
||||
new JavacTask(tb, Mode.EXEC)
|
||||
.envVar("_JAVAC_OPTIONS", "-XaddExports:jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED")
|
||||
.envVar("_JAVAC_OPTIONS", "--add-exports jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED")
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
.run(Expect.SUCCESS)
|
||||
@ -80,7 +80,7 @@ public class EnvVarTest extends ModuleTestBase {
|
||||
tb.out.println("test that addExports can be provided with env variable using @file");
|
||||
Path atFile = src.resolve("at-file.txt");
|
||||
tb.writeFile(atFile,
|
||||
"-XaddExports:jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED");
|
||||
"--add-exports jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED");
|
||||
|
||||
new JavacTask(tb, Mode.EXEC)
|
||||
.envVar("_JAVAC_OPTIONS", "@" + atFile)
|
||||
|
@ -117,7 +117,7 @@ public class GraphsTest extends ModuleTestBase {
|
||||
.write(base.resolve("positiveSrc"));
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics", "-mp", modules + File.pathSeparator + jarModules)
|
||||
.options("-XDrawDiagnostics", "-p", modules + File.pathSeparator + jarModules)
|
||||
.outdir(Files.createDirectories(base.resolve("positive")))
|
||||
.files(findJavaFiles(positiveSrc))
|
||||
.run()
|
||||
@ -126,7 +126,7 @@ public class GraphsTest extends ModuleTestBase {
|
||||
Path negativeSrc = m.classes("package p; public class Negative { closedO.O o; closedN.N n; closedL.L l; }")
|
||||
.write(base.resolve("negativeSrc"));
|
||||
List<String> log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics", "-mp", modules + File.pathSeparator + jarModules)
|
||||
.options("-XDrawDiagnostics", "-p", modules + File.pathSeparator + jarModules)
|
||||
.outdir(Files.createDirectories(base.resolve("negative")))
|
||||
.files(findJavaFiles(negativeSrc))
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -144,8 +144,8 @@ public class GraphsTest extends ModuleTestBase {
|
||||
m.write(modSrc);
|
||||
List<String> out = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", modSrc.toString(),
|
||||
"-mp", jarModules.toString()
|
||||
"--module-source-path", modSrc.toString(),
|
||||
"-p", jarModules.toString()
|
||||
)
|
||||
.outdir(Files.createDirectories(base.resolve("negative")))
|
||||
.files(findJavaFiles(modSrc))
|
||||
|
@ -76,7 +76,7 @@ public class HelloWorldTest extends ModuleTestBase {
|
||||
new JavacTask(tb)
|
||||
.options("-source", "8",
|
||||
"-target", "8",
|
||||
"-bootclasspath", smallRtJar.toString())
|
||||
"--boot-class-path", smallRtJar.toString())
|
||||
.outdir(classes)
|
||||
.files(src.resolve("HelloWorld.java"))
|
||||
.run();
|
||||
@ -131,7 +131,7 @@ public class HelloWorldTest extends ModuleTestBase {
|
||||
Files.createDirectories(classes);
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulesourcepath", src.toString())
|
||||
.options("--module-source-path", src.toString())
|
||||
.outdir(classes)
|
||||
.files(src_m1.resolve("p/HelloWorld.java"))
|
||||
.run()
|
||||
|
@ -0,0 +1,421 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, 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
|
||||
* @bug 8156998
|
||||
* @summary Test --inherit-runtime-environment
|
||||
* @library /tools/lib
|
||||
* @modules
|
||||
* jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.main
|
||||
* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask toolbox.JavaTask ModuleTestBase
|
||||
* @run main InheritRuntimeEnvironmentTest
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import toolbox.ModuleBuilder;
|
||||
import toolbox.JavaTask;
|
||||
import toolbox.JavacTask;
|
||||
import toolbox.Task;
|
||||
|
||||
/**
|
||||
* Tests that javac picks up runtime options with --inherit-runtime-environment.
|
||||
* For each option, javac is first run using the option directly, as a control.
|
||||
* javac is then run again, with the same option(s) being passed to the runtime,
|
||||
* and --inherit-runtime-environment being used by javac.
|
||||
* @author jjg
|
||||
*/
|
||||
public class InheritRuntimeEnvironmentTest extends ModuleTestBase {
|
||||
public static void main(String... args) throws Exception {
|
||||
InheritRuntimeEnvironmentTest t = new InheritRuntimeEnvironmentTest();
|
||||
t.runTests();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that code being compiled can access JDK-internal API using -add-exports.
|
||||
* @param base
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testAddExports(Path base) throws Exception {
|
||||
Path src = base.resolve("src");
|
||||
tb.writeJavaFiles(src,
|
||||
"class C { com.sun.tools.javac.main.Main main; }");
|
||||
|
||||
new TestCase(base)
|
||||
.testOpts("--add-exports", "jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED")
|
||||
.files(findJavaFiles(src))
|
||||
.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that code in the unnamed module can access a module on the module path using --add-modules.
|
||||
*/
|
||||
@Test
|
||||
public void testAddModules(Path base) throws Exception {
|
||||
Path modules = base.resolve("modules");
|
||||
new ModuleBuilder(tb, "m1")
|
||||
.exports("pkg1")
|
||||
.classes("package pkg1; public class C1 { }")
|
||||
.build(modules);
|
||||
|
||||
Path src = base.resolve("src");
|
||||
tb.writeJavaFiles(src,
|
||||
"class C { pkg1.C1 c1; }");
|
||||
|
||||
new TestCase(base)
|
||||
.testOpts("--module-path", modules.toString(), "--add-modules", "m1")
|
||||
.files(findJavaFiles(src))
|
||||
.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that a module on the module path is not visible when --limit-modules is used to
|
||||
* restrict the set of observable modules.
|
||||
*/
|
||||
@Test
|
||||
public void testLimitModules(Path base) throws Exception {
|
||||
Path modules = base.resolve("modules");
|
||||
new ModuleBuilder(tb, "m1")
|
||||
.exports("pkg1")
|
||||
.classes("package pkg1; public class C1 { }")
|
||||
.build(modules);
|
||||
|
||||
Path src = base.resolve("src");
|
||||
new ModuleBuilder(tb, "m2")
|
||||
.requires("m1")
|
||||
.classes("package pkg2; public class C2 { pkg1.C1 c1; }")
|
||||
.write(src);
|
||||
|
||||
// This is the control, to verify that by default, the module being compiled will
|
||||
// be able to read modules on the module path
|
||||
new TestCase(base)
|
||||
.testOpts("--module-path", modules.toString())
|
||||
.otherOpts("--module-source-path", src.toString())
|
||||
.files(findJavaFiles(src))
|
||||
.run();
|
||||
|
||||
// This is the test, to verify that the module being compiled will not be able to read
|
||||
// modules on the module path when a --limit-modules is used
|
||||
new TestCase(base)
|
||||
.testOpts("--module-path", modules.toString(), "--limit-modules", "jdk.compiler")
|
||||
.otherOpts("-XDrawDiagnostics",
|
||||
"--module-source-path", src.toString())
|
||||
.files(findJavaFiles(src))
|
||||
.expect(Task.Expect.FAIL, "compiler.err.module.not.found")
|
||||
.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that a module being compiled can see another module on the module path
|
||||
* using --module-path.
|
||||
*/
|
||||
@Test
|
||||
public void testModulePath(Path base) throws Exception {
|
||||
Path modules = base.resolve("modules");
|
||||
new ModuleBuilder(tb, "m1")
|
||||
.exports("pkg1")
|
||||
.classes("package pkg1; public class C1 { }")
|
||||
.build(modules);
|
||||
|
||||
Path src = base.resolve("src");
|
||||
new ModuleBuilder(tb, "m2")
|
||||
.requires("m1")
|
||||
.classes("package pkg2; public class C2 { pkg1.C1 c1; }")
|
||||
.write(src);
|
||||
|
||||
new TestCase(base)
|
||||
.testOpts("--module-path", modules.toString())
|
||||
.otherOpts("--module-source-path", src.toString())
|
||||
.files(findJavaFiles(src))
|
||||
.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that a module being compiled can see classes patches into an existing module
|
||||
* with --patch-module
|
||||
*/
|
||||
@Test
|
||||
public void testPatchModule(Path base) throws Exception {
|
||||
Path patchSrc = base.resolve("patchSrc");
|
||||
tb.writeJavaFiles(patchSrc,
|
||||
"package java.util; public class Xyzzy { }");
|
||||
Path patch = base.resolve("patch");
|
||||
Files.createDirectories(patch);
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-Xmodule:java.base")
|
||||
.outdir(patch)
|
||||
.sourcepath(patchSrc)
|
||||
.files(findJavaFiles(patchSrc))
|
||||
.run()
|
||||
.writeAll();
|
||||
|
||||
Path src = base.resolve("src");
|
||||
tb.writeJavaFiles(src,
|
||||
"public class C { java.util.Xyzzy x; }");
|
||||
|
||||
new TestCase(base)
|
||||
.testOpts("--patch-module", "java.base=" + patch)
|
||||
.files(findJavaFiles(src))
|
||||
.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that options in @files are also effective.
|
||||
* The test is similar to testModulePath, except that the test options are provided in an @-file.
|
||||
*/
|
||||
@Test
|
||||
public void testAtFile(Path base) throws Exception {
|
||||
Path modules = base.resolve("modules");
|
||||
new ModuleBuilder(tb, "m1")
|
||||
.exports("pkg1")
|
||||
.classes("package pkg1; public class C1 { }")
|
||||
.build(modules);
|
||||
|
||||
Path src = base.resolve("src");
|
||||
new ModuleBuilder(tb, "m2")
|
||||
.requires("m1")
|
||||
.classes("package pkg2; public class C2 { pkg1.C1 c1; }")
|
||||
.write(src);
|
||||
|
||||
Path atFile = base.resolve("atFile");
|
||||
tb.writeFile(atFile, "--module-path " + modules);
|
||||
|
||||
new TestCase(base)
|
||||
.testOpts("@" + atFile)
|
||||
.otherOpts("--module-source-path", src.toString())
|
||||
.files(findJavaFiles(src))
|
||||
.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that --inherit-runtime-environment works in conjunction with
|
||||
* environment variables.
|
||||
* This is a variant of testAddExports.
|
||||
* The use of environment variables is sufficiently custom that it is
|
||||
* not easy to do this directly with a simple TestCase.
|
||||
*/
|
||||
@Test
|
||||
public void testEnvVars(Path base) throws Exception {
|
||||
Path src = base.resolve("src");
|
||||
tb.writeJavaFiles(src,
|
||||
"class C { com.sun.tools.javac.main.Main main; }");
|
||||
List<String> testOpts =
|
||||
Arrays.asList("--add-exports", "jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED");
|
||||
List<Path> files = Arrays.asList(findJavaFiles(src));
|
||||
|
||||
String envName = "_JAVAC_OPTIONS";
|
||||
String envValue = String.join(" ", testOpts);
|
||||
|
||||
out.println(" javac:");
|
||||
Path javacOutDir = base.resolve("out-javac");
|
||||
Files.createDirectories(javacOutDir);
|
||||
|
||||
out.println(" env: " + envName + "=" + envValue);
|
||||
out.println(" outdir: " + javacOutDir);
|
||||
out.println(" files: " + files);
|
||||
|
||||
new JavacTask(tb, Task.Mode.EXEC)
|
||||
.envVar(envName, envValue)
|
||||
.outdir(javacOutDir)
|
||||
.files(files)
|
||||
.run()
|
||||
.writeAll()
|
||||
.getOutput(Task.OutputKind.DIRECT);
|
||||
|
||||
out.println(" java:");
|
||||
Path javaOutDir = base.resolve("out-java");
|
||||
Files.createDirectories(javaOutDir);
|
||||
|
||||
Path atFile = base.resolve("atFile");
|
||||
tb.writeFile(atFile, String.join(" ", testOpts));
|
||||
|
||||
List<String> vmOpts = Arrays.asList(
|
||||
"@" + atFile,
|
||||
"--module", "jdk.compiler/com.sun.tools.javac.Main"
|
||||
);
|
||||
|
||||
List<String> classArgs = join(
|
||||
Arrays.asList("-d", javaOutDir.toString()),
|
||||
files.stream()
|
||||
.map(p -> p.toString())
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
|
||||
envValue = "--inherit-runtime-environment";
|
||||
|
||||
out.println(" env: " + envName + "=" + envValue);
|
||||
out.println(" vmOpts: " + vmOpts);
|
||||
out.println(" classArgs: " + classArgs);
|
||||
|
||||
new JavaTask(tb)
|
||||
.envVar(envName, envValue)
|
||||
.vmOptions(vmOpts)
|
||||
.classArgs(classArgs)
|
||||
.run()
|
||||
.writeAll()
|
||||
.getOutput(Task.OutputKind.STDERR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs javac with given test options, first directly, and then again, specifying the
|
||||
* options to the runtime, and using --inherit-runtime-environment.
|
||||
*/
|
||||
class TestCase {
|
||||
final Path base;
|
||||
List<String> testOpts = Collections.emptyList();
|
||||
List<String> otherOpts = Collections.emptyList();
|
||||
List<Path> files = Collections.emptyList();
|
||||
Task.Expect expect = Task.Expect.SUCCESS;
|
||||
String expectedText;
|
||||
|
||||
/**
|
||||
* Creates a test case, specifying a base directory for work files.
|
||||
*/
|
||||
TestCase(Path base) {
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the "test options" to be passed to javac or to the runtime.
|
||||
*/
|
||||
TestCase testOpts(String... testOpts) {
|
||||
this.testOpts = Arrays.asList(testOpts);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets additional options required for the compilation.
|
||||
*/
|
||||
TestCase otherOpts(String... otherOpts) {
|
||||
this.otherOpts = Arrays.asList(otherOpts);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the files to be compiled.
|
||||
*/
|
||||
TestCase files(Path... files) {
|
||||
this.files = Arrays.asList(files);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the expected output, and any expected output from javac.
|
||||
* The default is {@code Expect.SUCCESS} and no specific output expected.
|
||||
*/
|
||||
TestCase expect(Task.Expect expect, String expectedText) {
|
||||
this.expect = expect;
|
||||
this.expectedText = expectedText;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the test case.
|
||||
* First, javac is run passing the test options directly to javac.
|
||||
* Then, javac is run again, passing the test options to the runtime,
|
||||
* and using --inherit-runtime-environment.
|
||||
*/
|
||||
void run() throws IOException {
|
||||
runJavac();
|
||||
runJava();
|
||||
}
|
||||
|
||||
private void runJavac() throws IOException {
|
||||
out.println(" javac:");
|
||||
Path javacOutDir = base.resolve("out-javac");
|
||||
Files.createDirectories(javacOutDir);
|
||||
|
||||
List<String> options = join(testOpts, otherOpts);
|
||||
|
||||
out.println(" options: " + options);
|
||||
out.println(" outdir: " + javacOutDir);
|
||||
out.println(" files: " + files);
|
||||
|
||||
String log = new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options(options)
|
||||
.outdir(javacOutDir)
|
||||
.files(files)
|
||||
.run(expect)
|
||||
.writeAll()
|
||||
.getOutput(Task.OutputKind.DIRECT);
|
||||
|
||||
if (expectedText != null && !log.contains(expectedText))
|
||||
error("expected text not found");
|
||||
}
|
||||
|
||||
private void runJava() throws IOException {
|
||||
out.println(" java:");
|
||||
Path javaOutDir = base.resolve("out-java");
|
||||
Files.createDirectories(javaOutDir);
|
||||
|
||||
List<String> vmOpts = join(
|
||||
testOpts,
|
||||
Arrays.asList("--module", "jdk.compiler/com.sun.tools.javac.Main")
|
||||
);
|
||||
|
||||
List<String> classArgs = join(
|
||||
Arrays.asList("--inherit-runtime-environment",
|
||||
"-d", javaOutDir.toString()),
|
||||
otherOpts,
|
||||
files.stream()
|
||||
.map(p -> p.toString())
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
|
||||
out.println(" vmOpts: " + vmOpts);
|
||||
out.println(" classArgs: " + classArgs);
|
||||
|
||||
String log = new JavaTask(tb)
|
||||
.vmOptions(vmOpts)
|
||||
.classArgs(classArgs)
|
||||
.run(expect)
|
||||
.writeAll()
|
||||
.getOutput(Task.OutputKind.STDERR);
|
||||
|
||||
if (expectedText != null && !log.contains(expectedText))
|
||||
error("expected text not found");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Join a series of lists.
|
||||
*/
|
||||
@SafeVarargs
|
||||
private <T> List<T> join(List<T>... lists) {
|
||||
return Arrays.stream(lists)
|
||||
.flatMap(list -> list.stream())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class MOptionTest extends ModuleTestBase {
|
||||
"package test; public class Test {}");
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-m", "m1", "-modulesourcepath", src.toString(), "-d", build.toString())
|
||||
.options("-m", "m1", "--module-source-path", src.toString(), "-d", build.toString())
|
||||
.run(Task.Expect.SUCCESS)
|
||||
.writeAll();
|
||||
|
||||
@ -81,7 +81,7 @@ public class MOptionTest extends ModuleTestBase {
|
||||
Thread.sleep(2000); //timestamps
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-m", "m1", "-modulesourcepath", src.toString(), "-d", build.toString())
|
||||
.options("-m", "m1", "--module-source-path", src.toString(), "-d", build.toString())
|
||||
.run(Task.Expect.SUCCESS)
|
||||
.writeAll();
|
||||
|
||||
@ -98,7 +98,7 @@ public class MOptionTest extends ModuleTestBase {
|
||||
Files.setLastModifiedTime(testTest, FileTime.fromMillis(System.currentTimeMillis()));
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-m", "m1", "-modulesourcepath", src.toString(), "-d", build.toString())
|
||||
.options("-m", "m1", "--module-source-path", src.toString(), "-d", build.toString())
|
||||
.run(Task.Expect.SUCCESS)
|
||||
.writeAll();
|
||||
|
||||
@ -125,7 +125,7 @@ public class MOptionTest extends ModuleTestBase {
|
||||
String log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-m", "m1",
|
||||
"-modulesourcepath", src.toString())
|
||||
"--module-source-path", src.toString())
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
.getOutput(Task.OutputKind.DIRECT);
|
||||
@ -174,7 +174,7 @@ public class MOptionTest extends ModuleTestBase {
|
||||
"package p2; public class C2 {}");
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-m", "m1,m2", "-modulesourcepath", src.toString(), "-d", build.toString())
|
||||
.options("-m", "m1,m2", "--module-source-path", src.toString(), "-d", build.toString())
|
||||
.run(Task.Expect.SUCCESS)
|
||||
.writeAll();
|
||||
|
||||
@ -215,7 +215,7 @@ public class MOptionTest extends ModuleTestBase {
|
||||
Thread.sleep(2000); //timestamps
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-m", "m1,m2", "-modulesourcepath", src.toString(), "-d", build.toString())
|
||||
.options("-m", "m1,m2", "--module-source-path", src.toString(), "-d", build.toString())
|
||||
.run(Task.Expect.SUCCESS)
|
||||
.writeAll();
|
||||
|
||||
@ -241,7 +241,7 @@ public class MOptionTest extends ModuleTestBase {
|
||||
Files.setLastModifiedTime(C2Source, FileTime.fromMillis(System.currentTimeMillis()));
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-m", "m1,m2", "-modulesourcepath", src.toString(), "-d", build.toString())
|
||||
.options("-m", "m1,m2", "--module-source-path", src.toString(), "-d", build.toString())
|
||||
.run(Task.Expect.SUCCESS)
|
||||
.writeAll();
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 8154824
|
||||
* @summary Compiler should handle java.nio.file.FileSystemNotFoundException gracefully and not abort
|
||||
* @compile/fail/ref=MissingJarInModulePathTest.out -XDrawDiagnostics -Xlint:path -Werror -modulepath missing.jar MissingJarInModulePathTest.java
|
||||
* @compile/fail/ref=MissingJarInModulePathTest.out -XDrawDiagnostics -Xlint:path -Werror --module-path missing.jar MissingJarInModulePathTest.java
|
||||
*/
|
||||
|
||||
class MissingJarInModulePathTest {}
|
||||
|
@ -78,7 +78,7 @@ public class ModuleFinderTest extends ModuleTestBase {
|
||||
|
||||
|
||||
String log = new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics", "-modulepath", modules.toString())
|
||||
.options("-XDrawDiagnostics", "--module-path", modules.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src2))
|
||||
.run(Task.Expect.FAIL)
|
||||
|
@ -188,7 +188,7 @@ public class ModuleInfoTest extends ModuleTestBase {
|
||||
Files.createDirectories(classes);
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
|
||||
.options("-XDrawDiagnostics", "--module-source-path", src.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -216,7 +216,7 @@ public class ModuleInfoTest extends ModuleTestBase {
|
||||
Files.createDirectories(classes);
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
|
||||
.options("-XDrawDiagnostics", "--module-source-path", src.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -242,7 +242,7 @@ public class ModuleInfoTest extends ModuleTestBase {
|
||||
Files.createDirectories(classes);
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
|
||||
.options("-XDrawDiagnostics", "--module-source-path", src.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -289,7 +289,7 @@ public class ModuleInfoTest extends ModuleTestBase {
|
||||
Files.createDirectories(classes);
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
|
||||
.options("-XDrawDiagnostics", "--module-source-path", src.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -315,7 +315,7 @@ public class ModuleInfoTest extends ModuleTestBase {
|
||||
Files.createDirectories(classes);
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
|
||||
.options("-XDrawDiagnostics", "--module-source-path", src.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -356,7 +356,7 @@ public class ModuleInfoTest extends ModuleTestBase {
|
||||
tb.writeFile(src_m1.resolve("module-info.java"), moduleInfo);
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
|
||||
.options("-XDrawDiagnostics", "--module-source-path", src.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary tests for -modulepath
|
||||
* @summary tests for --module-path
|
||||
* @library /tools/lib
|
||||
* @modules
|
||||
* jdk.compiler/com.sun.tools.javac.api
|
||||
@ -62,13 +62,13 @@ public class ModulePathTest extends ModuleTestBase {
|
||||
|
||||
String log = new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulepath", "doesNotExist")
|
||||
"--module-path", "doesNotExist")
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
.getOutput(Task.OutputKind.DIRECT);
|
||||
|
||||
if (!log.contains("- compiler.err.illegal.argument.for.option: -modulepath, doesNotExist"))
|
||||
if (!log.contains("- compiler.err.illegal.argument.for.option: --module-path, doesNotExist"))
|
||||
throw new Exception("expected output not found");
|
||||
}
|
||||
|
||||
@ -80,13 +80,13 @@ public class ModulePathTest extends ModuleTestBase {
|
||||
|
||||
String log = new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulepath", "dummy.txt")
|
||||
"--module-path", "dummy.txt")
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
.getOutput(Task.OutputKind.DIRECT);
|
||||
|
||||
if (!log.contains("- compiler.err.illegal.argument.for.option: -modulepath, dummy.txt"))
|
||||
if (!log.contains("- compiler.err.illegal.argument.for.option: --module-path, dummy.txt"))
|
||||
throw new Exception("expected output not found");
|
||||
}
|
||||
|
||||
@ -98,13 +98,13 @@ public class ModulePathTest extends ModuleTestBase {
|
||||
|
||||
String log = new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulepath", "dummy.jimage")
|
||||
"--module-path", "dummy.jimage")
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
.getOutput(Task.OutputKind.DIRECT);
|
||||
|
||||
if (!log.contains("- compiler.err.illegal.argument.for.option: -modulepath, dummy.jimage"))
|
||||
if (!log.contains("- compiler.err.illegal.argument.for.option: --module-path, dummy.jimage"))
|
||||
throw new Exception("expected output not found");
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ public class ModulePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.outdir(classes)
|
||||
.options("-modulepath", modClasses.toString())
|
||||
.options("--module-path", modClasses.toString())
|
||||
.files(findJavaFiles(src))
|
||||
.run()
|
||||
.writeAll();
|
||||
@ -153,7 +153,7 @@ public class ModulePathTest extends ModuleTestBase {
|
||||
String log = new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.outdir(classes)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulepath", modClasses.toString())
|
||||
"--module-path", modClasses.toString())
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
@ -190,7 +190,7 @@ public class ModulePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.outdir(classes)
|
||||
.options("-modulepath", moduleJar.toString(), "-addmods", "m1")
|
||||
.options("--module-path", moduleJar.toString(), "--add-modules", "m1")
|
||||
.files(findJavaFiles(src))
|
||||
.run()
|
||||
.writeAll();
|
||||
@ -226,7 +226,7 @@ public class ModulePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.outdir(classes)
|
||||
.options("-modulepath", moduleJar.toString())
|
||||
.options("--module-path", moduleJar.toString())
|
||||
.files(findJavaFiles(src))
|
||||
.run()
|
||||
.writeAll();
|
||||
@ -240,7 +240,7 @@ public class ModulePathTest extends ModuleTestBase {
|
||||
|
||||
String log = new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulepath", "dummy.jar")
|
||||
"--module-path", "dummy.jar")
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
@ -277,7 +277,7 @@ public class ModulePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.outdir(classes)
|
||||
.options("-modulepath", jmod.toString())
|
||||
.options("--module-path", jmod.toString())
|
||||
.files(findJavaFiles(src))
|
||||
.run()
|
||||
.writeAll();
|
||||
@ -291,7 +291,7 @@ public class ModulePathTest extends ModuleTestBase {
|
||||
|
||||
String log = new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulepath", "dummy.jmod")
|
||||
"--module-path", "dummy.jmod")
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
@ -311,7 +311,7 @@ public class ModulePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulepath", modules + "/./../modules")
|
||||
"--module-path", modules + "/./../modules")
|
||||
.files(findJavaFiles(src))
|
||||
.run()
|
||||
.writeAll();
|
||||
@ -327,7 +327,7 @@ public class ModulePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulepath", modules + "/./../modules" + PATH_SEP + modules)
|
||||
"--module-path", modules + "/./../modules" + PATH_SEP + modules)
|
||||
.files(findJavaFiles(src))
|
||||
.run()
|
||||
.writeAll();
|
||||
@ -343,8 +343,8 @@ public class ModulePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulepath", modules.toString(),
|
||||
"-modulepath", modules.toString())
|
||||
"--module-path", modules.toString(),
|
||||
"--module-path", modules.toString())
|
||||
.files(findJavaFiles(src))
|
||||
.run()
|
||||
.writeAll();
|
||||
@ -370,7 +370,7 @@ public class ModulePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulepath", deepModuleDir + PATH_SEP + modules)
|
||||
"--module-path", deepModuleDir + PATH_SEP + modules)
|
||||
.files(findJavaFiles(src))
|
||||
.run()
|
||||
.writeAll();
|
||||
@ -400,7 +400,7 @@ public class ModulePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulepath", modules.toString())
|
||||
"--module-path", modules.toString())
|
||||
.files(findJavaFiles(src))
|
||||
.run()
|
||||
.writeAll();
|
||||
|
@ -62,14 +62,14 @@ public class ModuleSourcePathTest extends ModuleTestBase {
|
||||
|
||||
String log = new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-sourcepath", sp.toString().replace('/', File.separatorChar),
|
||||
"-modulesourcepath", msp.toString().replace('/', File.separatorChar),
|
||||
"--source-path", sp.toString().replace('/', File.separatorChar),
|
||||
"--module-source-path", msp.toString().replace('/', File.separatorChar),
|
||||
"dummyClass")
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
.getOutput(Task.OutputKind.DIRECT);
|
||||
|
||||
if (!log.contains("cannot specify both -sourcepath and -modulesourcepath"))
|
||||
if (!log.contains("cannot specify both --source-path and --module-source-path"))
|
||||
throw new Exception("expected diagnostic not found");
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ public class ModuleSourcePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", src.toString())
|
||||
"--module-source-path", src.toString())
|
||||
.outdir(modules)
|
||||
.files(prefixAll(findJavaFiles(src), Paths.get("./")))
|
||||
.run()
|
||||
@ -100,7 +100,7 @@ public class ModuleSourcePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", "./" + src)
|
||||
"--module-source-path", "./" + src)
|
||||
.outdir(modules)
|
||||
.files(findJavaFiles(src))
|
||||
.run()
|
||||
@ -123,7 +123,7 @@ public class ModuleSourcePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", base + "/{src1,src2/inner_dir}")
|
||||
"--module-source-path", base + "/{src1,src2/inner_dir}")
|
||||
.files(base.resolve("src1/m0/pkg0/A.java"), base.resolve("src2/inner_dir/m1/pkg1/A.java"))
|
||||
.outdir(modules)
|
||||
.run()
|
||||
@ -154,12 +154,12 @@ public class ModuleSourcePathTest extends ModuleTestBase {
|
||||
for (String sourcepath : sourcePaths) {
|
||||
String log = new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", sourcepath.replace('/', File.separatorChar))
|
||||
"--module-source-path", sourcepath.replace('/', File.separatorChar))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
.getOutput(Task.OutputKind.DIRECT);
|
||||
|
||||
if (!log.contains("- compiler.err.illegal.argument.for.option: -modulesourcepath, mismatched braces"))
|
||||
if (!log.contains("- compiler.err.illegal.argument.for.option: --module-source-path, mismatched braces"))
|
||||
throw new Exception("expected output for path [" + sourcepath + "] not found");
|
||||
}
|
||||
}
|
||||
@ -182,7 +182,7 @@ public class ModuleSourcePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath",
|
||||
"--module-source-path",
|
||||
base + "/{src/{{src1,src2,src3},{srcB,srcC}/{src1,src2/srcX{X,Y}/}},.}"
|
||||
.replace('/', File.separatorChar))
|
||||
.files(findJavaFiles(base.resolve(modulePaths[modulePaths.length - 1])))
|
||||
@ -207,7 +207,7 @@ public class ModuleSourcePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", base + "/{dummy.txt,src}")
|
||||
"--module-source-path", base + "/{dummy.txt,src}")
|
||||
.files(src.resolve("kettle$/electric/Heater.java"))
|
||||
.outdir(modules)
|
||||
.run()
|
||||
@ -227,7 +227,7 @@ public class ModuleSourcePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", base + "/{src}")
|
||||
"--module-source-path", base + "/{src}")
|
||||
.files(src.resolve("kettle$/electric/Heater.java"))
|
||||
.outdir(modules)
|
||||
.run()
|
||||
@ -246,7 +246,7 @@ public class ModuleSourcePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", base + "/{}")
|
||||
"--module-source-path", base + "/{}")
|
||||
.files(base.resolve("kettle$/electric/Heater.java"))
|
||||
.outdir(modules)
|
||||
.run()
|
||||
@ -267,7 +267,7 @@ public class ModuleSourcePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", "{" + src + "," + src + "/car}")
|
||||
"--module-source-path", "{" + src + "," + src + "/car}")
|
||||
.files(findJavaFiles(src))
|
||||
.outdir(modules)
|
||||
.run()
|
||||
@ -286,7 +286,7 @@ public class ModuleSourcePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", base + "/src/./../src")
|
||||
"--module-source-path", base + "/src/./../src")
|
||||
.files(src.resolve("kettle/electric/Heater.java"))
|
||||
.outdir(modules)
|
||||
.run()
|
||||
@ -305,7 +305,7 @@ public class ModuleSourcePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", base + "/{src,src,src}")
|
||||
"--module-source-path", base + "/{src,src,src}")
|
||||
.files(src.resolve("m1/a/A.java"))
|
||||
.outdir(modules)
|
||||
.run()
|
||||
@ -323,7 +323,7 @@ public class ModuleSourcePathTest extends ModuleTestBase {
|
||||
|
||||
String log = new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", base + "/not_exist" + PATH_SEP + base + "/{not_exist,}")
|
||||
"--module-source-path", base + "/not_exist" + PATH_SEP + base + "/{not_exist,}")
|
||||
.files(base.resolve("m1/a/A.java"))
|
||||
.outdir(modules)
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -342,7 +342,7 @@ public class ModuleSourcePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", base + "{/not_exist,/}")
|
||||
"--module-source-path", base + "{/not_exist,/}")
|
||||
.files(base.resolve("m1/a/A.java"))
|
||||
.outdir(modules)
|
||||
.run()
|
||||
@ -361,7 +361,7 @@ public class ModuleSourcePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", base + "/{,{,,,,src,,,}}")
|
||||
"--module-source-path", base + "/{,{,,,,src,,,}}")
|
||||
.files(src.resolve("m1/a/A.java"))
|
||||
.outdir(modules)
|
||||
.run()
|
||||
@ -380,7 +380,7 @@ public class ModuleSourcePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", base + "/*/classes/")
|
||||
"--module-source-path", base + "/*/classes/")
|
||||
.files(base.resolve("kettle/classes/electric/Heater.java"))
|
||||
.outdir(modules)
|
||||
.run()
|
||||
@ -403,7 +403,7 @@ public class ModuleSourcePathTest extends ModuleTestBase {
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", src + "{/*/gensrc/,/*/classes/}" + PATH_SEP
|
||||
"--module-source-path", src + "{/*/gensrc/,/*/classes/}" + PATH_SEP
|
||||
+ src + "/*/special/classes")
|
||||
.files(findJavaFiles(src))
|
||||
.outdir(modules)
|
||||
@ -432,12 +432,12 @@ public class ModuleSourcePathTest extends ModuleTestBase {
|
||||
for (String sourcepath : sourcePaths) {
|
||||
String log = new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", sourcepath.replace('/', File.separatorChar))
|
||||
"--module-source-path", sourcepath.replace('/', File.separatorChar))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
.getOutput(Task.OutputKind.DIRECT);
|
||||
|
||||
if (!log.contains("- compiler.err.illegal.argument.for.option: -modulesourcepath, illegal use of *"))
|
||||
if (!log.contains("- compiler.err.illegal.argument.for.option: --module-source-path, illegal use of *"))
|
||||
throw new Exception("expected output for path [" + sourcepath + "] not found");
|
||||
}
|
||||
}
|
||||
|
@ -21,28 +21,10 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import toolbox.JavacTask;
|
||||
import toolbox.TestRunner;
|
||||
import toolbox.ToolBox;
|
||||
|
||||
|
@ -46,7 +46,6 @@ import javax.lang.model.element.TypeElement;
|
||||
import toolbox.JarTask;
|
||||
import toolbox.JavacTask;
|
||||
import toolbox.Task;
|
||||
import toolbox.ToolBox;
|
||||
|
||||
public class ModulesAndClassPathTest extends ModuleTestBase {
|
||||
|
||||
@ -70,7 +69,7 @@ public class ModulesAndClassPathTest extends ModuleTestBase {
|
||||
"package impl; public class Impl { api.Api api; }");
|
||||
|
||||
List<String> modLog = new JavacTask(tb)
|
||||
.options("-classpath", jar.toString(),
|
||||
.options("--class-path", jar.toString(),
|
||||
"-XDrawDiagnostics")
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(moduleSrc))
|
||||
@ -86,8 +85,8 @@ public class ModulesAndClassPathTest extends ModuleTestBase {
|
||||
}
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-classpath", jar.toString(),
|
||||
"-XaddReads:m1=ALL-UNNAMED")
|
||||
.options("--class-path", jar.toString(),
|
||||
"--add-reads", "m1=ALL-UNNAMED")
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(moduleSrc))
|
||||
.run()
|
||||
@ -95,8 +94,8 @@ public class ModulesAndClassPathTest extends ModuleTestBase {
|
||||
.getOutputLines(Task.OutputKind.DIRECT);
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-classpath", jar.toString() + File.pathSeparator + System.getProperty("test.classes"),
|
||||
"-XaddReads:m1=ALL-UNNAMED",
|
||||
.options("--class-path", jar.toString() + File.pathSeparator + System.getProperty("test.classes"),
|
||||
"--add-reads", "m1=ALL-UNNAMED",
|
||||
"-processor", ProcessorImpl.class.getName())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(moduleSrc))
|
||||
@ -121,7 +120,7 @@ public class ModulesAndClassPathTest extends ModuleTestBase {
|
||||
"package impl; public class Impl { api.Api api; }");
|
||||
|
||||
List<String> modLog = new JavacTask(tb)
|
||||
.options("-classpath", jar.toString(),
|
||||
.options("--class-path", jar.toString(),
|
||||
"-sourcepath", m1.toString(),
|
||||
"-XDrawDiagnostics")
|
||||
.outdir(classes)
|
||||
@ -154,7 +153,7 @@ public class ModulesAndClassPathTest extends ModuleTestBase {
|
||||
"package impl; public class Impl { api.Api api; }");
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-classpath", jar.toString(),
|
||||
.options("--class-path", jar.toString(),
|
||||
"-XDrawDiagnostics")
|
||||
.outdir(classes)
|
||||
.files(m1.resolve("module-info.java"))
|
||||
@ -163,7 +162,7 @@ public class ModulesAndClassPathTest extends ModuleTestBase {
|
||||
.getOutputLines(Task.OutputKind.DIRECT);
|
||||
|
||||
List<String> modLog = new JavacTask(tb)
|
||||
.options("-classpath", jar.toString(),
|
||||
.options("--class-path", jar.toString(),
|
||||
"-XDrawDiagnostics")
|
||||
.outdir(classes)
|
||||
.files(m1.resolve("impl").resolve("Impl.java"))
|
||||
|
@ -60,7 +60,7 @@ public class MultiModuleModeTest extends ModuleTestBase {
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", src.toString())
|
||||
"--module-source-path", src.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -83,7 +83,7 @@ public class MultiModuleModeTest extends ModuleTestBase {
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", src.toString())
|
||||
"--module-source-path", src.toString())
|
||||
.outdir(classes)
|
||||
.files(join(findJavaFiles(src), findJavaFiles(misc)))
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -104,7 +104,7 @@ public class MultiModuleModeTest extends ModuleTestBase {
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", src.toString())
|
||||
"--module-source-path", src.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -124,7 +124,7 @@ public class MultiModuleModeTest extends ModuleTestBase {
|
||||
Files.createDirectories(modules);
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulesourcepath", src.toString())
|
||||
.options("--module-source-path", src.toString())
|
||||
.outdir(modules)
|
||||
.files(src.resolve("m2/module-info.java"))
|
||||
.run()
|
||||
@ -139,7 +139,7 @@ public class MultiModuleModeTest extends ModuleTestBase {
|
||||
Files.createDirectories(modules1);
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulesourcepath", src1.toString())
|
||||
.options("--module-source-path", src1.toString())
|
||||
.outdir(modules1)
|
||||
.files(src1.resolve("m1/module-info.java"))
|
||||
.run()
|
||||
@ -151,8 +151,8 @@ public class MultiModuleModeTest extends ModuleTestBase {
|
||||
Files.createDirectories(modules2);
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulepath", modules1.toString(),
|
||||
"-modulesourcepath", src2.toString())
|
||||
.options("--module-path", modules1.toString(),
|
||||
"--module-source-path", src2.toString())
|
||||
.outdir(modules2)
|
||||
.files(src2.resolve("m2/module-info.java"))
|
||||
.run()
|
||||
|
@ -51,7 +51,7 @@ public class NPEEmptyFileTest extends ModuleTestBase {
|
||||
Path emptyJavaFile = base.resolve("Test.java");
|
||||
tb.writeFile(emptyJavaFile, "");
|
||||
new JavacTask(tb, Task.Mode.EXEC)
|
||||
.options("-modulesourcepath", modules.toString(),
|
||||
.options("--module-source-path", modules.toString(),
|
||||
"-d", modules.toString(), emptyJavaFile.toString())
|
||||
.run()
|
||||
.writeAll();
|
||||
|
@ -63,7 +63,7 @@ public class OutputDirTest extends ModuleTestBase {
|
||||
public void testError(Path base) throws Exception {
|
||||
String log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", src.toString())
|
||||
"--module-source-path", src.toString())
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
@ -78,7 +78,7 @@ public class OutputDirTest extends ModuleTestBase {
|
||||
new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-proc:only",
|
||||
"-modulesourcepath", src.toString())
|
||||
"--module-source-path", src.toString())
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.SUCCESS)
|
||||
.writeAll();
|
||||
@ -90,7 +90,7 @@ public class OutputDirTest extends ModuleTestBase {
|
||||
new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-d", classes.toString(),
|
||||
"-modulesourcepath", src.toString())
|
||||
"--module-source-path", src.toString())
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.SUCCESS)
|
||||
.writeAll();
|
||||
@ -120,7 +120,7 @@ public class OutputDirTest extends ModuleTestBase {
|
||||
String log = new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.outdir(modClasses) // an exploded module
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", src.toString())
|
||||
"--module-source-path", src.toString())
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
@ -157,7 +157,7 @@ public class OutputDirTest extends ModuleTestBase {
|
||||
.outdir(classes) // within an exploded module
|
||||
.options("-XDrawDiagnostics",
|
||||
"-Xlint", "-Werror",
|
||||
"-modulepath", modClasses.toString())
|
||||
"--module-path", modClasses.toString())
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
|
@ -82,7 +82,7 @@ public class PackageConflictTest extends ModuleTestBase {
|
||||
Files.createDirectories(classes);
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-Werror", "-modulesourcepath", base.toString())
|
||||
.options("-Werror", "--module-source-path", base.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(base))
|
||||
.run()
|
||||
@ -107,7 +107,7 @@ public class PackageConflictTest extends ModuleTestBase {
|
||||
Files.createDirectories(classes);
|
||||
|
||||
List<String> log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics", "-modulesourcepath", base.toString())
|
||||
.options("-XDrawDiagnostics", "--module-source-path", base.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(base))
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -137,7 +137,7 @@ public class PackageConflictTest extends ModuleTestBase {
|
||||
.write(modSrc);
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics", "-mp", modules.toString())
|
||||
.options("-XDrawDiagnostics", "-p", modules.toString())
|
||||
.outdir(Files.createDirectories(base.resolve("classes")))
|
||||
.files(findJavaFiles(modSrc.resolve("M")))
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -162,7 +162,7 @@ public class PackageConflictTest extends ModuleTestBase {
|
||||
.write(modSrc);
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics", "-modulesourcepath", modSrc.toString())
|
||||
.options("-XDrawDiagnostics", "--module-source-path", modSrc.toString())
|
||||
.outdir(Files.createDirectories(base.resolve("classes")))
|
||||
.files(findJavaFiles(modSrc))
|
||||
.run(Task.Expect.SUCCESS)
|
||||
@ -189,7 +189,7 @@ public class PackageConflictTest extends ModuleTestBase {
|
||||
.write(modSrc);
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics", "-mp", modules.toString())
|
||||
.options("-XDrawDiagnostics", "-p", modules.toString())
|
||||
.outdir(Files.createDirectories(base.resolve("classes")))
|
||||
.files(findJavaFiles(modSrc.resolve("M")))
|
||||
.run(Task.Expect.SUCCESS)
|
||||
@ -220,7 +220,7 @@ public class PackageConflictTest extends ModuleTestBase {
|
||||
.write(modSrc);
|
||||
|
||||
List<String> log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics", "-mp", modules.toString())
|
||||
.options("-XDrawDiagnostics", "-p", modules.toString())
|
||||
.outdir(Files.createDirectories(base.resolve("classes")))
|
||||
.files(findJavaFiles(modSrc.resolve("K")))
|
||||
.run(Task.Expect.FAIL)
|
||||
@ -252,7 +252,7 @@ public class PackageConflictTest extends ModuleTestBase {
|
||||
.classes("package p; public class DependsOnN { boolean f = pkg.A.flagN; } ")
|
||||
.write(modSrc);
|
||||
new JavacTask(tb)
|
||||
.options("-modulesourcepath", modSrc.toString())
|
||||
.options("--module-source-path", modSrc.toString())
|
||||
.outdir(Files.createDirectories(base.resolve("classes")))
|
||||
.files(findJavaFiles(modSrc.resolve("K")))
|
||||
.run(Task.Expect.SUCCESS)
|
||||
@ -265,7 +265,7 @@ public class PackageConflictTest extends ModuleTestBase {
|
||||
|
||||
List<String> output = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", modSrc.toString())
|
||||
"--module-source-path", modSrc.toString())
|
||||
.outdir(Files.createDirectories(base.resolve("classes")))
|
||||
.files(findJavaFiles(modSrc.resolve("K")))
|
||||
.run(Task.Expect.FAIL)
|
||||
|
@ -39,7 +39,6 @@ import java.util.List;
|
||||
|
||||
import toolbox.JavacTask;
|
||||
import toolbox.Task;
|
||||
import toolbox.ToolBox;
|
||||
|
||||
public class PackageMultipleModules extends ModuleTestBase {
|
||||
|
||||
@ -64,7 +63,7 @@ public class PackageMultipleModules extends ModuleTestBase {
|
||||
Files.createDirectories(classes);
|
||||
|
||||
List<String> log = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics", "-modulesourcepath", base.toString())
|
||||
.options("-XDrawDiagnostics", "--module-source-path", base.toString())
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(base))
|
||||
.run(Task.Expect.FAIL)
|
||||
|
127
langtools/test/tools/javac/modules/PatchModulesTest.java
Normal file
127
langtools/test/tools/javac/modules/PatchModulesTest.java
Normal file
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* @bug 8160489
|
||||
* @summary tests for --patch-modules
|
||||
* @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
|
||||
* @build toolbox.ToolBox toolbox.JavacTask toolbox.ModuleBuilder ModuleTestBase
|
||||
* @run main PatchModulesTest
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
import com.sun.source.util.JavacTask;
|
||||
import com.sun.tools.javac.api.JavacTool;
|
||||
import com.sun.tools.javac.file.BaseFileManager;
|
||||
import com.sun.tools.javac.file.JavacFileManager;
|
||||
import com.sun.tools.javac.file.Locations;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
|
||||
public class PatchModulesTest extends ModuleTestBase {
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
PatchModulesTest t = new PatchModulesTest();
|
||||
t.init();
|
||||
t.runTests();
|
||||
}
|
||||
|
||||
private static String PS = File.pathSeparator;
|
||||
|
||||
void init() throws IOException {
|
||||
tb.createDirectories("a", "b", "c", "d", "e");
|
||||
tb.writeJavaFiles(Paths.get("."), "class C { }");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimple(Path base) throws Exception {
|
||||
test(asList("java.base=a"),
|
||||
"{java.base=[a]}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPair(Path base) throws Exception {
|
||||
test(asList("java.base=a", "java.compiler=b"),
|
||||
"{java.base=[a], java.compiler=[b]}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiple(Path base) throws Exception {
|
||||
test(asList("java.base=a:b"),
|
||||
"{java.base=[a, b]}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLastOneWins(Path base) throws Exception {
|
||||
test(asList("java.base=a", "java.compiler=b", "java.base=c"),
|
||||
"{java.base=[c], java.compiler=[b]}");
|
||||
}
|
||||
|
||||
void test(List<String> patches, String expect) throws Exception {
|
||||
JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler();
|
||||
StringWriter sw = new StringWriter();
|
||||
try (PrintWriter pw = new PrintWriter(sw)) {
|
||||
JavacFileManager fm = tool.getStandardFileManager(null, null, null);
|
||||
List<String> opts = patches.stream()
|
||||
.map(p -> "--patch-module=" + p.replace(":", PS))
|
||||
.collect(Collectors.toList());
|
||||
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects("C.java");
|
||||
JavacTask task = tool.getTask(pw, fm, null, opts, null, files);
|
||||
|
||||
Field locationsField = BaseFileManager.class.getDeclaredField("locations");
|
||||
locationsField.setAccessible(true);
|
||||
Object locations = locationsField.get(fm);
|
||||
|
||||
Field patchMapField = Locations.class.getDeclaredField("patchMap");
|
||||
patchMapField.setAccessible(true);
|
||||
Map<?,?> patchMap = (Map<?,?>) patchMapField.get(locations);
|
||||
String found = patchMap.toString();
|
||||
|
||||
if (!found.equals(expect)) {
|
||||
tb.out.println("Expect: " + expect);
|
||||
tb.out.println("Found: " + found);
|
||||
error("output not as expected");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public class PluginsInModulesTest extends ModuleTestBase {
|
||||
plugin1);
|
||||
|
||||
String log = new JavacTask(tb)
|
||||
.options("-modulesourcepath", moduleSrc.toString())
|
||||
.options("--module-source-path", moduleSrc.toString())
|
||||
.outdir(processorCompiledModules)
|
||||
.files(findJavaFiles(moduleSrc))
|
||||
.run()
|
||||
@ -130,7 +130,7 @@ public class PluginsInModulesTest extends ModuleTestBase {
|
||||
public void testUseOnlyOneProcessor(Path base) throws Exception {
|
||||
initialization(base);
|
||||
List<String> log = new JavacTask(tb)
|
||||
.options("-processormodulepath", processorCompiledModules.toString(),
|
||||
.options("--processor-module-path", processorCompiledModules.toString(),
|
||||
"-Xplugin:simpleplugin1")
|
||||
.outdir(classes)
|
||||
.sources(testClass)
|
||||
|
@ -77,7 +77,7 @@ public class ProvidesTest extends ModuleTestBase {
|
||||
Files.createDirectories(modules);
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulesourcepath", src.toString())
|
||||
.options("--module-source-path", src.toString())
|
||||
.outdir(modules)
|
||||
.files(findJavaFiles(src))
|
||||
.run(Task.Expect.SUCCESS)
|
||||
@ -160,7 +160,7 @@ public class ProvidesTest extends ModuleTestBase {
|
||||
|
||||
List<String> output = new JavacTask(tb)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", modules.toString())
|
||||
"--module-source-path", modules.toString())
|
||||
.outdir(Files.createDirectories(base.resolve("classes")))
|
||||
.files(findJavaFiles(modules))
|
||||
.run(Task.Expect.FAIL)
|
||||
|
@ -94,7 +94,7 @@ public class QueryBeforeEnter extends ModuleTestBase {
|
||||
Files.createDirectories(modulePath);
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulesourcepath", moduleSrc.toString())
|
||||
.options("--module-source-path", moduleSrc.toString())
|
||||
.outdir(modulePath)
|
||||
.files(findJavaFiles(moduleSrc))
|
||||
.run()
|
||||
@ -131,8 +131,8 @@ public class QueryBeforeEnter extends ModuleTestBase {
|
||||
(com.sun.source.util.JavacTask) javaCompiler.getTask(null,
|
||||
null,
|
||||
d -> { throw new IllegalStateException(d.toString()); },
|
||||
Arrays.asList("-modulepath", modulePath.toString(),
|
||||
"-classpath", cp.toString(),
|
||||
Arrays.asList("--module-path", modulePath.toString(),
|
||||
"--class-path", cp.toString(),
|
||||
"-sourcepath", src.toString()),
|
||||
null,
|
||||
fm.getJavaFileObjects(src.resolve("test").resolve("Test2.java")));
|
||||
@ -170,7 +170,7 @@ public class QueryBeforeEnter extends ModuleTestBase {
|
||||
Files.createDirectories(modulePath);
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulesourcepath", moduleSrc.toString())
|
||||
.options("--module-source-path", moduleSrc.toString())
|
||||
.outdir(modulePath)
|
||||
.files(findJavaFiles(moduleSrc))
|
||||
.run()
|
||||
@ -207,8 +207,8 @@ public class QueryBeforeEnter extends ModuleTestBase {
|
||||
(com.sun.source.util.JavacTask) javaCompiler.getTask(null,
|
||||
null,
|
||||
d -> { throw new IllegalStateException(d.toString()); },
|
||||
Arrays.asList("-modulepath", modulePath.toString(),
|
||||
"-classpath", cp.toString(),
|
||||
Arrays.asList("--module-path", modulePath.toString(),
|
||||
"--class-path", cp.toString(),
|
||||
"-sourcepath", src.toString()),
|
||||
null,
|
||||
fm.getJavaFileObjects(findJavaFiles(src)));
|
||||
@ -245,7 +245,7 @@ public class QueryBeforeEnter extends ModuleTestBase {
|
||||
Files.createDirectories(modulePath);
|
||||
|
||||
new JavacTask(tb)
|
||||
.options("-modulesourcepath", modulePathSrc.toString())
|
||||
.options("--module-source-path", modulePathSrc.toString())
|
||||
.outdir(modulePath)
|
||||
.files(findJavaFiles(modulePathSrc))
|
||||
.run()
|
||||
@ -289,9 +289,9 @@ public class QueryBeforeEnter extends ModuleTestBase {
|
||||
(com.sun.source.util.JavacTask) javaCompiler.getTask(null,
|
||||
null,
|
||||
d -> { throw new IllegalStateException(d.toString()); },
|
||||
Arrays.asList("-modulepath", modulePath.toString(),
|
||||
"-classpath", cp.toString(),
|
||||
"-modulesourcepath", moduleSrc.toString(),
|
||||
Arrays.asList("--module-path", modulePath.toString(),
|
||||
"--class-path", cp.toString(),
|
||||
"--module-source-path", moduleSrc.toString(),
|
||||
"-d", out.toString()),
|
||||
null,
|
||||
fm.getJavaFileObjects(findJavaFiles(moduleSrc)));
|
||||
@ -339,7 +339,7 @@ public class QueryBeforeEnter extends ModuleTestBase {
|
||||
(com.sun.source.util.JavacTask) javaCompiler.getTask(null,
|
||||
null,
|
||||
d -> { throw new IllegalStateException(d.toString()); },
|
||||
Arrays.asList("-processorpath", processorPath,
|
||||
Arrays.asList("--processor-path", processorPath,
|
||||
"-processor", AP.class.getName(),
|
||||
"-Xplugin:test"),
|
||||
null,
|
||||
@ -347,7 +347,7 @@ public class QueryBeforeEnter extends ModuleTestBase {
|
||||
task.call();
|
||||
}
|
||||
|
||||
Main.compile(new String[] {"-processorpath", processorPath,
|
||||
Main.compile(new String[] {"--processor-path", processorPath,
|
||||
"-Xplugin:test",
|
||||
testSource.toString()});
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public class RequiresPublicTest extends ModuleTestBase {
|
||||
String log = new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics")
|
||||
.files(findJavaFiles(src))
|
||||
.outdir(classes.toString()) // should allow Path here
|
||||
.outdir(classes)
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
.getOutput(Task.OutputKind.DIRECT);
|
||||
@ -96,7 +96,7 @@ public class RequiresPublicTest extends ModuleTestBase {
|
||||
Files.createDirectories(classes);
|
||||
|
||||
new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-modulesourcepath", src.toString())
|
||||
.options("--module-source-path", src.toString())
|
||||
.files(findJavaFiles(src))
|
||||
.outdir(classes)
|
||||
.run()
|
||||
@ -113,7 +113,7 @@ public class RequiresPublicTest extends ModuleTestBase {
|
||||
|
||||
String log = new JavacTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-XDrawDiagnostics",
|
||||
"-modulesourcepath", src.toString())
|
||||
"--module-source-path", src.toString())
|
||||
.files(findJavaFiles(src))
|
||||
.outdir(classes)
|
||||
.run(Task.Expect.FAIL)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user