8152704: jlink command line output/help message improvement
Reviewed-by: mchung
This commit is contained in:
parent
8030f17dde
commit
4c3bc4f31f
@ -46,6 +46,7 @@ import jdk.tools.jlink.internal.Archive.Entry;
|
||||
import jdk.tools.jlink.internal.Archive.Entry.EntryType;
|
||||
import jdk.tools.jlink.internal.PoolImpl.CompressedModuleData;
|
||||
import jdk.tools.jlink.plugin.ExecutableImage;
|
||||
import jdk.tools.jlink.plugin.PluginException;
|
||||
import jdk.tools.jlink.plugin.Pool;
|
||||
import jdk.tools.jlink.plugin.Pool.ModuleData;
|
||||
import jdk.tools.jlink.plugin.Pool.ModuleDataType;
|
||||
@ -183,6 +184,8 @@ public final class ImageFileCreator {
|
||||
PoolImpl resultResources;
|
||||
try {
|
||||
resultResources = pluginSupport.visitResources(allContent);
|
||||
} catch (PluginException pe) {
|
||||
throw pe;
|
||||
} catch (Exception ex) {
|
||||
throw new IOException(ex);
|
||||
}
|
||||
|
@ -92,6 +92,7 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr
|
||||
"*sun/text/resources/cldr/ext/[^\\/]+_%%.class," +
|
||||
"*sun/util/resources/cldr/ext/[^\\/]+_%%.class,";
|
||||
private Predicate<String> predicate;
|
||||
private String userParam;
|
||||
private List<Locale.LanguageRange> priorityList;
|
||||
private List<Locale> available;
|
||||
private List<String> filtered;
|
||||
@ -155,13 +156,17 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr
|
||||
|
||||
@Override
|
||||
public void configure(Map<String, String> config) {
|
||||
try {
|
||||
priorityList = Arrays.stream(config.get(NAME).split(","))
|
||||
.map(Locale.LanguageRange::new)
|
||||
.collect(Collectors.toList());
|
||||
} catch (IllegalArgumentException iae) {
|
||||
throw new PluginException(iae.getLocalizedMessage());
|
||||
}
|
||||
userParam = config.get(NAME);
|
||||
priorityList = Arrays.stream(userParam.split(","))
|
||||
.map(s -> {
|
||||
try {
|
||||
return new Locale.LanguageRange(s);
|
||||
} catch (IllegalArgumentException iae) {
|
||||
throw new PluginException(String.format(
|
||||
PluginsResourceBundle.getMessage(NAME + ".invalidtag"), s));
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -191,7 +196,8 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr
|
||||
filtered = filterLocales(available);
|
||||
|
||||
if (filtered.isEmpty()) {
|
||||
throw new PluginException(PluginsResourceBundle.getMessage(NAME + ".nomatchinglocales"));
|
||||
throw new PluginException(
|
||||
String.format(PluginsResourceBundle.getMessage(NAME + ".nomatchinglocales"), userParam));
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -20,7 +20,7 @@ Level 0: constant string sharing\n\
|
||||
Level 1: ZIP\n\
|
||||
Level 2: both.\n\
|
||||
An optional filter can be specified to list the pattern of files to be filtered.\n\
|
||||
Use ^ for negation. eg: *Exception.class,*Error.class,^/java.base/java/lang/*
|
||||
Use ^ for negation. e.g.: *Exception.class,*Error.class,^/java.base/java/lang/*
|
||||
|
||||
compact-cp.argument=<resource paths>
|
||||
|
||||
@ -32,17 +32,17 @@ copy-files.argument=<List of <file path>=<image target> to copy to the image>.
|
||||
|
||||
copy-files.description=\
|
||||
If files to copy are not absolute path, JDK home dir is used.\n\
|
||||
eg: jrt-fs.jar,LICENSE,/home/me/myfile.txt=somewehere/conf.txt
|
||||
e.g.: jrt-fs.jar,LICENSE,/home/me/myfile.txt=somewehere/conf.txt
|
||||
|
||||
exclude-files.argument=<files to exclude | files of excluded files>
|
||||
|
||||
exclude-files.description=\
|
||||
Specify files to exclude. eg: *.diz, /java.base/native/client/*
|
||||
Specify files to exclude. e.g.: *.diz, /java.base/native/client/*
|
||||
|
||||
exclude-resources.argument=<resources to exclude | file of excluded resources>
|
||||
|
||||
exclude-resources.description=\
|
||||
Specify resources to exclude. eg: *.jcov, */META-INF/*
|
||||
Specify resources to exclude. e.g.: *.jcov, */META-INF/*
|
||||
|
||||
installed-modules.description=Fast loading of module descriptors (always enabled)
|
||||
|
||||
@ -51,7 +51,7 @@ onoff.argument=<on|off>
|
||||
sort-resources.argument=<paths in priority order | file with resource paths>
|
||||
|
||||
sort-resources.description=\
|
||||
Sort resources. eg: */modules-info.class,/java-base/java/lang/*
|
||||
Sort resources. e.g.: */modules-info.class,/java-base/java/lang/*
|
||||
|
||||
strip-debug.description=\
|
||||
Strip debug information from the output image
|
||||
@ -73,13 +73,16 @@ include-locales.argument=\
|
||||
|
||||
include-locales.description=\
|
||||
BCP 47 language tags separated by a comma, allowing locale matching\n\
|
||||
defined in RFC 4647. eg: en,ja,*-IN
|
||||
defined in RFC 4647. e.g.: en,ja,*-IN
|
||||
|
||||
include-locales.missingpackages=\
|
||||
Missing locale data packages in jdk.localedata:\n\t
|
||||
|
||||
include-locales.nomatchinglocales=\
|
||||
No matching locales found. Check the specified pattern.
|
||||
No matching locales found for \"%s\". Check the specified pattern.
|
||||
|
||||
include-locales.invalidtag=\
|
||||
Invalid language tag: %s
|
||||
|
||||
main.status.ok=Functional.
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class JLink2Test {
|
||||
.addJmods(helper.getStdJmodsDir())
|
||||
.addJmods(jar.getParent())
|
||||
.addMods("bad")
|
||||
.call().assertFailure("(\n|\r|.)*Error: jdk.tools.jlink.plugin.PluginException: module-info.class not found for bad module(\n|\r|.)*");
|
||||
.call().assertFailure("(\n|\r|.)*Error: module-info.class not found for bad module(\n|\r|.)*");
|
||||
try (JarOutputStream out = new JarOutputStream(new FileOutputStream(jar.toFile()))) {
|
||||
JarEntry entry = new JarEntry("classes");
|
||||
out.putNextEntry(entry);
|
||||
@ -118,7 +118,7 @@ public class JLink2Test {
|
||||
.addJmods(jar.getParent())
|
||||
.addJars(helper.getStdJmodsDir())
|
||||
.addMods("bad")
|
||||
.call().assertFailure("(\n|\r|.)*Error: jdk.tools.jlink.plugin.PluginException: module-info.class not found for bad module(\n|\r|.)*");
|
||||
.call().assertFailure("(\n|\r|.)*Error: module-info.class not found for bad module(\n|\r|.)*");
|
||||
}
|
||||
|
||||
private static void testSameNames(Helper helper) throws Exception {
|
||||
|
@ -298,17 +298,19 @@ public class IncludeLocalesPluginTest {
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
new PluginException(
|
||||
PluginsResourceBundle.getMessage("include-locales.nomatchinglocales"))
|
||||
.toString(),
|
||||
new PluginException(String.format(
|
||||
PluginsResourceBundle.getMessage("include-locales.nomatchinglocales"), "xyz"))
|
||||
.getMessage(),
|
||||
},
|
||||
|
||||
// Error case: Invalid argument
|
||||
{"--include-locales=zh_HK",
|
||||
{"--include-locales=en,zh_HK",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"range=zh_hk",
|
||||
new PluginException(String.format(
|
||||
PluginsResourceBundle.getMessage("include-locales.invalidtag"), "zh_HK"))
|
||||
.getMessage(),
|
||||
},
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user