< prev index next >

src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java

Print this page

        

*** 378,390 **** } private void iterate(JImageAction jimageAction, ModuleAction moduleAction, ResourceAction resourceAction) throws IOException, BadArgs { ! if (options.jimages.isEmpty()) { ! throw TASK_HELPER.newBadArgs("err.no.jimage"); ! } for (File file : options.jimages) { if (!file.exists() || !file.isFile()) { throw TASK_HELPER.newBadArgs("err.not.a.jimage", file.getName()); } --- 378,388 ---- } private void iterate(JImageAction jimageAction, ModuleAction moduleAction, ResourceAction resourceAction) throws IOException, BadArgs { ! validateOptions(); for (File file : options.jimages) { if (!file.exists() || !file.isFile()) { throw TASK_HELPER.newBadArgs("err.not.a.jimage", file.getName()); }
*** 433,442 **** --- 431,459 ---- } } } } + private void validateOptions() throws BadArgs { + if (options.jimages.isEmpty()) { + throw TASK_HELPER.newBadArgs("err.no.jimage"); + } + + if (options.task == Task.EXTRACT) { + File extractTargetDir = new File(options.directory); + if (extractTargetDir.exists()) { + if (extractTargetDir.isDirectory()) { + if (extractTargetDir.listFiles().length > 0) { + throw TASK_HELPER.newBadArgs("err.not.an.empty.dir", options.directory); + } + } else { + throw TASK_HELPER.newBadArgs("err.not.a.dir", options.directory); + } + } + } + } + private boolean run() throws Exception, BadArgs { switch (options.task) { case EXTRACT: iterate(null, null, this::extract); break;
< prev index next >