< prev index next >
src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2014, 2017, 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. Oracle designates this
*** 33,44 ****
--- 33,48 ----
import java.nio.file.PathMatcher;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
+ import java.util.Locale;
import java.util.MissingResourceException;
import java.util.function.Predicate;
+ import java.util.stream.Collectors;
+ import java.util.stream.Stream;
+
import jdk.internal.jimage.BasicImageReader;
import jdk.internal.jimage.ImageHeader;
import jdk.internal.jimage.ImageLocation;
import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.tree.ClassNode;
*** 97,107 ****
log = out;
TASK_HELPER.setLog(log);
}
static class OptionsValues {
! Task task = Task.LIST;
String directory = ".";
String include = "";
boolean fullVersion;
boolean help;
boolean verbose;
--- 101,111 ----
log = out;
TASK_HELPER.setLog(log);
}
static class OptionsValues {
! Task task = null;
String directory = ".";
String include = "";
boolean fullVersion;
boolean help;
boolean verbose;
*** 170,197 ****
log.println(TASK_HELPER.getMessage("main.usage.summary", PROGNAME));
return EXIT_ABNORMAL;
}
try {
! List<String> unhandled = OPTION_HELPER.handleOptions(this, args);
!
! if(!unhandled.isEmpty()) {
try {
! options.task = Enum.valueOf(Task.class, unhandled.get(0).toUpperCase());
} catch (IllegalArgumentException ex) {
! throw TASK_HELPER.newBadArgs("err.not.a.task", unhandled.get(0));
}
! for(int i = 1; i < unhandled.size(); i++) {
! options.jimages.add(new File(unhandled.get(i)));
}
! } else if (!options.help && !options.version && !options.fullVersion) {
! throw TASK_HELPER.newBadArgs("err.invalid.task", "<unspecified>");
}
if (options.help) {
! if (unhandled.isEmpty()) {
log.println(TASK_HELPER.getMessage("main.usage", PROGNAME));
Arrays.asList(RECOGNIZED_OPTIONS).stream()
.filter(option -> !option.isHidden())
.sorted()
.forEach(option -> {
--- 174,208 ----
log.println(TASK_HELPER.getMessage("main.usage.summary", PROGNAME));
return EXIT_ABNORMAL;
}
try {
! String command;
! String[] remaining = args;
try {
! command = args[0];
! options.task = Enum.valueOf(Task.class, args[0].toUpperCase(Locale.ENGLISH));
! remaining = args.length > 1 ? Arrays.copyOfRange(args, 1, args.length)
! : new String[0];
} catch (IllegalArgumentException ex) {
! command = null;
! options.task = null;
}
! // process arguments
! List<String> unhandled = OPTION_HELPER.handleOptions(this, remaining);
! for (String f : unhandled) {
! options.jimages.add(new File(f));
}
!
! if (options.task == null && !options.help && !options.version && !options.fullVersion) {
! throw TASK_HELPER.newBadArgs("err.not.a.task",
! command != null ? command : "<unspecified>");
}
if (options.help) {
! if (options.task == null) {
log.println(TASK_HELPER.getMessage("main.usage", PROGNAME));
Arrays.asList(RECOGNIZED_OPTIONS).stream()
.filter(option -> !option.isHidden())
.sorted()
.forEach(option -> {
*** 201,219 ****
} else {
try {
log.println(TASK_HELPER.getMessage("main.usage." +
options.task.toString().toLowerCase()));
} catch (MissingResourceException ex) {
! throw TASK_HELPER.newBadArgs("err.not.a.task", unhandled.get(0));
}
}
return EXIT_OK;
}
if (options.version || options.fullVersion) {
! TASK_HELPER.showVersion(options.fullVersion);
if (unhandled.isEmpty()) {
return EXIT_OK;
}
}
--- 212,234 ----
} else {
try {
log.println(TASK_HELPER.getMessage("main.usage." +
options.task.toString().toLowerCase()));
} catch (MissingResourceException ex) {
! throw TASK_HELPER.newBadArgs("err.not.a.task", command);
}
}
return EXIT_OK;
}
if (options.version || options.fullVersion) {
! if (options.task == null && !unhandled.isEmpty()) {
! throw TASK_HELPER.newBadArgs("err.not.a.task",
! Stream.of(args).collect(Collectors.joining(" ")));
! }
+ TASK_HELPER.showVersion(options.fullVersion);
if (unhandled.isEmpty()) {
return EXIT_OK;
}
}
*** 433,443 ****
break;
case VERIFY:
iterate(this::listTitle, null, this::verify);
break;
default:
! throw TASK_HELPER.newBadArgs("err.invalid.task",
options.task.name()).showUsage(true);
}
return true;
}
}
--- 448,458 ----
break;
case VERIFY:
iterate(this::listTitle, null, this::verify);
break;
default:
! throw TASK_HELPER.newBadArgs("err.not.a.task",
options.task.name()).showUsage(true);
}
return true;
}
}
< prev index next >