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.Archive.Entry.EntryType;
|
||||||
import jdk.tools.jlink.internal.PoolImpl.CompressedModuleData;
|
import jdk.tools.jlink.internal.PoolImpl.CompressedModuleData;
|
||||||
import jdk.tools.jlink.plugin.ExecutableImage;
|
import jdk.tools.jlink.plugin.ExecutableImage;
|
||||||
|
import jdk.tools.jlink.plugin.PluginException;
|
||||||
import jdk.tools.jlink.plugin.Pool;
|
import jdk.tools.jlink.plugin.Pool;
|
||||||
import jdk.tools.jlink.plugin.Pool.ModuleData;
|
import jdk.tools.jlink.plugin.Pool.ModuleData;
|
||||||
import jdk.tools.jlink.plugin.Pool.ModuleDataType;
|
import jdk.tools.jlink.plugin.Pool.ModuleDataType;
|
||||||
@ -183,6 +184,8 @@ public final class ImageFileCreator {
|
|||||||
PoolImpl resultResources;
|
PoolImpl resultResources;
|
||||||
try {
|
try {
|
||||||
resultResources = pluginSupport.visitResources(allContent);
|
resultResources = pluginSupport.visitResources(allContent);
|
||||||
|
} catch (PluginException pe) {
|
||||||
|
throw pe;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new IOException(ex);
|
throw new IOException(ex);
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,7 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr
|
|||||||
"*sun/text/resources/cldr/ext/[^\\/]+_%%.class," +
|
"*sun/text/resources/cldr/ext/[^\\/]+_%%.class," +
|
||||||
"*sun/util/resources/cldr/ext/[^\\/]+_%%.class,";
|
"*sun/util/resources/cldr/ext/[^\\/]+_%%.class,";
|
||||||
private Predicate<String> predicate;
|
private Predicate<String> predicate;
|
||||||
|
private String userParam;
|
||||||
private List<Locale.LanguageRange> priorityList;
|
private List<Locale.LanguageRange> priorityList;
|
||||||
private List<Locale> available;
|
private List<Locale> available;
|
||||||
private List<String> filtered;
|
private List<String> filtered;
|
||||||
@ -155,13 +156,17 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configure(Map<String, String> config) {
|
public void configure(Map<String, String> config) {
|
||||||
try {
|
userParam = config.get(NAME);
|
||||||
priorityList = Arrays.stream(config.get(NAME).split(","))
|
priorityList = Arrays.stream(userParam.split(","))
|
||||||
.map(Locale.LanguageRange::new)
|
.map(s -> {
|
||||||
.collect(Collectors.toList());
|
try {
|
||||||
} catch (IllegalArgumentException iae) {
|
return new Locale.LanguageRange(s);
|
||||||
throw new PluginException(iae.getLocalizedMessage());
|
} catch (IllegalArgumentException iae) {
|
||||||
}
|
throw new PluginException(String.format(
|
||||||
|
PluginsResourceBundle.getMessage(NAME + ".invalidtag"), s));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -191,7 +196,8 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr
|
|||||||
filtered = filterLocales(available);
|
filtered = filterLocales(available);
|
||||||
|
|
||||||
if (filtered.isEmpty()) {
|
if (filtered.isEmpty()) {
|
||||||
throw new PluginException(PluginsResourceBundle.getMessage(NAME + ".nomatchinglocales"));
|
throw new PluginException(
|
||||||
|
String.format(PluginsResourceBundle.getMessage(NAME + ".nomatchinglocales"), userParam));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -20,7 +20,7 @@ Level 0: constant string sharing\n\
|
|||||||
Level 1: ZIP\n\
|
Level 1: ZIP\n\
|
||||||
Level 2: both.\n\
|
Level 2: both.\n\
|
||||||
An optional filter can be specified to list the pattern of files to be filtered.\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>
|
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=\
|
copy-files.description=\
|
||||||
If files to copy are not absolute path, JDK home dir is used.\n\
|
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.argument=<files to exclude | files of excluded files>
|
||||||
|
|
||||||
exclude-files.description=\
|
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.argument=<resources to exclude | file of excluded resources>
|
||||||
|
|
||||||
exclude-resources.description=\
|
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)
|
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.argument=<paths in priority order | file with resource paths>
|
||||||
|
|
||||||
sort-resources.description=\
|
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.description=\
|
||||||
Strip debug information from the output image
|
Strip debug information from the output image
|
||||||
@ -73,13 +73,16 @@ include-locales.argument=\
|
|||||||
|
|
||||||
include-locales.description=\
|
include-locales.description=\
|
||||||
BCP 47 language tags separated by a comma, allowing locale matching\n\
|
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=\
|
include-locales.missingpackages=\
|
||||||
Missing locale data packages in jdk.localedata:\n\t
|
Missing locale data packages in jdk.localedata:\n\t
|
||||||
|
|
||||||
include-locales.nomatchinglocales=\
|
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.
|
main.status.ok=Functional.
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ public class JLink2Test {
|
|||||||
.addJmods(helper.getStdJmodsDir())
|
.addJmods(helper.getStdJmodsDir())
|
||||||
.addJmods(jar.getParent())
|
.addJmods(jar.getParent())
|
||||||
.addMods("bad")
|
.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()))) {
|
try (JarOutputStream out = new JarOutputStream(new FileOutputStream(jar.toFile()))) {
|
||||||
JarEntry entry = new JarEntry("classes");
|
JarEntry entry = new JarEntry("classes");
|
||||||
out.putNextEntry(entry);
|
out.putNextEntry(entry);
|
||||||
@ -118,7 +118,7 @@ public class JLink2Test {
|
|||||||
.addJmods(jar.getParent())
|
.addJmods(jar.getParent())
|
||||||
.addJars(helper.getStdJmodsDir())
|
.addJars(helper.getStdJmodsDir())
|
||||||
.addMods("bad")
|
.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 {
|
private static void testSameNames(Helper helper) throws Exception {
|
||||||
|
@ -298,17 +298,19 @@ public class IncludeLocalesPluginTest {
|
|||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
new PluginException(
|
new PluginException(String.format(
|
||||||
PluginsResourceBundle.getMessage("include-locales.nomatchinglocales"))
|
PluginsResourceBundle.getMessage("include-locales.nomatchinglocales"), "xyz"))
|
||||||
.toString(),
|
.getMessage(),
|
||||||
},
|
},
|
||||||
|
|
||||||
// Error case: Invalid argument
|
// Error case: Invalid argument
|
||||||
{"--include-locales=zh_HK",
|
{"--include-locales=en,zh_HK",
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
"range=zh_hk",
|
new PluginException(String.format(
|
||||||
|
PluginsResourceBundle.getMessage("include-locales.invalidtag"), "zh_HK"))
|
||||||
|
.getMessage(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user