< prev index next >
src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java
Print this page
rev 14867 : 8159172: Update usage of jlink/jimage/jmod to show option patterns
Reviewed-by: mchung
@@ -52,12 +52,12 @@
new Option<JImageTask>(true, (task, option, arg) -> {
task.options.directory = arg;
}, "--dir"),
new Option<JImageTask>(true, (task, option, arg) -> {
- task.options.filters = arg;
- }, "--filter"),
+ task.options.include = arg;
+ }, "--include"),
new Option<JImageTask>(false, (task, option, arg) -> {
task.options.fullVersion = true;
}, true, "--fullversion"),
@@ -79,16 +79,16 @@
= TASK_HELPER.newOptionsHelper(JImageTask.class, RECOGNIZED_OPTIONS);
private static final String PROGNAME = "jimage";
private static final FileSystem JRT_FILE_SYSTEM = Utils.jrtFileSystem();
private final OptionsValues options;
- private final List<Predicate<String>> filterPredicates;
+ private final List<Predicate<String>> includePredicates;
private PrintWriter log;
JImageTask() {
this.options = new OptionsValues();
- this.filterPredicates = new ArrayList<>();
+ this.includePredicates = new ArrayList<>();
log = null;
}
void setLog(PrintWriter out) {
log = out;
@@ -96,11 +96,11 @@
}
static class OptionsValues {
Task task = Task.LIST;
String directory = ".";
- String filters = "";
+ String include = "";
boolean fullVersion;
boolean help;
boolean verbose;
boolean version;
List<File> jimages = new LinkedList<>();
@@ -198,10 +198,12 @@
name = name.substring(1);
}
log.println(TASK_HELPER.getMessage("main.opt." + name));
}
+
+ log.println(TASK_HELPER.getMessage("main.opt.footer"));
} else {
try {
log.println(TASK_HELPER.getMessage("main.usage." +
options.task.toString().toLowerCase()));
} catch (MissingResourceException ex) {
@@ -217,11 +219,11 @@
if (unhandled.isEmpty()) {
return EXIT_OK;
}
}
- processFilter(options.filters);
+ processInclude(options.include);
return run() ? EXIT_OK : EXIT_ERROR;
} catch (BadArgs e) {
TASK_HELPER.reportError(e.key, e.args);
@@ -237,19 +239,19 @@
} finally {
log.flush();
}
}
- private void processFilter(String filters) {
- if (filters.isEmpty()) {
+ private void processInclude(String include) {
+ if (include.isEmpty()) {
return;
}
- for (String filter : filters.split(",")) {
+ for (String filter : include.split(",")) {
final PathMatcher matcher = Utils.getPathMatcher(JRT_FILE_SYSTEM, filter);
Predicate<String> predicate = (path) -> matcher.matches(JRT_FILE_SYSTEM.getPath(path));
- filterPredicates.add(predicate);
+ includePredicates.add(predicate);
}
}
private void listTitle(File file, BasicImageReader reader) {
log.println("jimage: " + file);
@@ -386,13 +388,13 @@
if (resourceAction != null) {
String[] entryNames = reader.getEntryNames();
String oldModule = "";
for (String name : entryNames) {
- boolean match = filterPredicates.isEmpty();
+ boolean match = includePredicates.isEmpty();
- for (Predicate<String> predicate : filterPredicates) {
+ for (Predicate<String> predicate : includePredicates) {
if (predicate.test(name)) {
match = true;
break;
}
}
< prev index next >