src/share/classes/org/openjdk/jigsaw/cli/Librarian.java

Print this page

        

*** 104,122 **** try { bs = lib.readClass(mid, cn); if (bs == null) throw new Command.Exception("%s: No such class in module %s", cn, mid); ! OutputStream fout = null; ! try { ! fout = (ops.equals("-") ! ? System.out ! : new FileOutputStream(ops)); fout.write(bs); - } finally { - if (fout != null) - fout.close(); } } catch (IllegalArgumentException x) { throw new Command.Exception(x.getMessage()); } catch (IOException x) { throw new Command.Exception(x); --- 104,116 ---- try { bs = lib.readClass(mid, cn); if (bs == null) throw new Command.Exception("%s: No such class in module %s", cn, mid); ! try (OutputStream fout = (ops.equals("-") ? System.out ! : new FileOutputStream(ops))) { fout.write(bs); } } catch (IllegalArgumentException x) { throw new Command.Exception(x.getMessage()); } catch (IOException x) { throw new Command.Exception(x);
*** 203,216 **** if (mfs.isEmpty()) throw new Command.Exception("%s: no module-name specified", command); try { lib.installFromManifests(mfs, strip); ! } catch (ConfigurationException x) { throw new Command.Exception(x); - } catch (IOException x) { - throw new Command.Exception(x); } return; } // Install one or more module file(s) --- 197,208 ---- if (mfs.isEmpty()) throw new Command.Exception("%s: no module-name specified", command); try { lib.installFromManifests(mfs, strip); ! } catch (ConfigurationException | IOException x) { throw new Command.Exception(x); } return; } // Install one or more module file(s)
*** 222,237 **** while (hasArg()) fs.add(new File(takeArg())); finishArgs(); try { lib.install(fs, verifySignature, strip); ! } catch (ConfigurationException x) { throw new Command.Exception(x); - } catch (IOException x) { - throw new Command.Exception(x); - } catch (SignatureException x) { - throw new Command.Exception(x); } return; } // Otherwise treat args as module-id queries --- 214,225 ---- while (hasArg()) fs.add(new File(takeArg())); finishArgs(); try { lib.install(fs, verifySignature, strip); ! } catch (ConfigurationException |IOException | SignatureException x) { throw new Command.Exception(x); } return; } // Otherwise treat args as module-id queries
*** 248,258 **** if (!hasArg()) break; s = takeArg(); } try { - boolean quiet = false; // ## Need -q Resolution res = lib.resolve(midqs); if (res.modulesNeeded().isEmpty()) { if (!quiet) out.format("Nothing to install%n"); return; --- 236,245 ----
*** 283,293 **** throws Command.Exception { noDry(); File classes = new File(takeArg()); File dst = new File(takeArg()); ! List<Manifest> mfs = new ArrayList<Manifest>(); while (hasArg()) mfs.add(Manifest.create(takeArg(), classes)); finishArgs(); try { lib.preInstall(mfs, dst); --- 270,280 ---- throws Command.Exception { noDry(); File classes = new File(takeArg()); File dst = new File(takeArg()); ! List<Manifest> mfs = new ArrayList<>(); while (hasArg()) mfs.add(Manifest.create(takeArg(), classes)); finishArgs(); try { lib.preInstall(mfs, dst);
*** 303,320 **** { if (dry && force) throw new Command.Exception("%s: specify only one of " + "-n (--dry-run) or -f (--force)", command); ! List<ModuleId> mids = new ArrayList<ModuleId>(); try { while (hasArg()) mids.add(jms.parseModuleId(takeArg())); } catch (IllegalArgumentException x) { throw new Command.Exception(x.getMessage()); } - boolean quiet = false; // ## Need -q try { if (force) lib.removeForcibly(mids); else lib.remove(mids, dry); --- 290,306 ---- { if (dry && force) throw new Command.Exception("%s: specify only one of " + "-n (--dry-run) or -f (--force)", command); ! List<ModuleId> mids = new ArrayList<>(); try { while (hasArg()) mids.add(jms.parseModuleId(takeArg())); } catch (IllegalArgumentException x) { throw new Command.Exception(x.getMessage()); } try { if (force) lib.removeForcibly(mids); else lib.remove(mids, dry);
*** 360,404 **** static class Config extends Command<SimpleLibrary> { protected void go(SimpleLibrary lib) throws Command.Exception { noDry(); ! List<ModuleId> mids = new ArrayList<ModuleId>(); try { while (hasArg()) mids.add(jms.parseModuleId(takeArg())); } catch (IllegalArgumentException x) { throw new Command.Exception(x.getMessage()); } try { lib.configure(mids); ! } catch (ConfigurationException x) { throw new Command.Exception(x); - } catch (IOException x) { - throw new Command.Exception(x); } } } static class ReIndex extends Command<SimpleLibrary> { protected void go(SimpleLibrary lib) throws Command.Exception { noDry(); ! List<ModuleId> mids = new ArrayList<ModuleId>(); try { while (hasArg()) mids.add(jms.parseModuleId(takeArg())); } catch (IllegalArgumentException x) { throw new Command.Exception(x.getMessage()); } try { lib.reIndex(mids); ! } catch (ConfigurationException x) { throw new Command.Exception(x); - } catch (IOException x) { - throw new Command.Exception(x); } } } static class Repos extends Command<SimpleLibrary> { --- 346,386 ---- static class Config extends Command<SimpleLibrary> { protected void go(SimpleLibrary lib) throws Command.Exception { noDry(); ! List<ModuleId> mids = new ArrayList<>(); try { while (hasArg()) mids.add(jms.parseModuleId(takeArg())); } catch (IllegalArgumentException x) { throw new Command.Exception(x.getMessage()); } try { lib.configure(mids); ! } catch (ConfigurationException | IOException x) { throw new Command.Exception(x); } } } static class ReIndex extends Command<SimpleLibrary> { protected void go(SimpleLibrary lib) throws Command.Exception { noDry(); ! List<ModuleId> mids = new ArrayList<>(); try { while (hasArg()) mids.add(jms.parseModuleId(takeArg())); } catch (IllegalArgumentException x) { throw new Command.Exception(x.getMessage()); } try { lib.reIndex(mids); ! } catch (ConfigurationException | IOException x) { throw new Command.Exception(x); } } } static class Repos extends Command<SimpleLibrary> {
*** 559,583 **** private void usage() { out.format("%n"); out.format("usage: jmod add-repo [-i <index>] URL%n"); out.format(" jmod config [<module-id> ...]%n"); ! out.format(" jmod create [-L <library>] [-P <parent>]" + ! " [--natlib <natlib>] [--natcmd <natcmd>] [--config <config>]%n"); out.format(" jmod del-repo URL%n"); out.format(" jmod dump-class <module-id> <class-name> <output-file>%n"); out.format(" jmod dump-config <module-id>%n"); out.format(" jmod extract <module-file> ...%n"); ! out.format(" jmod identify%n"); ! out.format(" jmod install [--noverify] [-n] <module-id-query> ...%n"); out.format(" jmod install [--noverify] <module-file> ...%n"); out.format(" jmod install <classes-dir> <module-name> ...%n"); ! out.format(" jmod list [-v] [-p] [-R] [<module-id-query>]%n"); out.format(" jmod preinstall <classes-dir> <dst-dir> <module-name> ...%n"); out.format(" jmod refresh [-f] [-n] [-v]%n"); out.format(" jmod reindex [<module-id> ...]%n"); ! out.format(" jmod remove [-f] [-n] [<module-id> ...]%n"); out.format(" jmod repos [-v]%n"); out.format("%n"); try { parser.printHelpOn(out); } catch (IOException x) { --- 541,566 ---- private void usage() { out.format("%n"); out.format("usage: jmod add-repo [-i <index>] URL%n"); out.format(" jmod config [<module-id> ...]%n"); ! out.format(" jmod create [-L <library>] [-P <parent>] "); ! out.format( "[--natlib <natlib>] [--natcmd <natcmd>] "); ! out.format( "[--config <config>]%n"); out.format(" jmod del-repo URL%n"); out.format(" jmod dump-class <module-id> <class-name> <output-file>%n"); out.format(" jmod dump-config <module-id>%n"); out.format(" jmod extract <module-file> ...%n"); ! out.format(" jmod [identify|id]%n"); ! out.format(" jmod install [--noverify] [-n] [-q] <module-id-query> ...%n"); out.format(" jmod install [--noverify] <module-file> ...%n"); out.format(" jmod install <classes-dir> <module-name> ...%n"); ! out.format(" jmod [list|ls] [-v] [-p] [-R] [<module-id-query>]%n"); out.format(" jmod preinstall <classes-dir> <dst-dir> <module-name> ...%n"); out.format(" jmod refresh [-f] [-n] [-v]%n"); out.format(" jmod reindex [<module-id> ...]%n"); ! out.format(" jmod [remove|rm] [-f] [-n] [-q] [<module-id> ...]%n"); out.format(" jmod repos [-v]%n"); out.format("%n"); try { parser.printHelpOn(out); } catch (IOException x) {
*** 641,650 **** --- 624,635 ---- .ofType(Integer.class)); parser.acceptsAll(Arrays.asList("f", "force"), "Force the requested operation"); parser.acceptsAll(Arrays.asList("n", "dry-run"), "Dry-run the requested operation"); + parser.acceptsAll(Arrays.asList("q", "quiet"), + "Suppress chattering output"); parser.acceptsAll(Arrays.asList("R", "repos"), "List contents of associated repositories"); parser.acceptsAll(Arrays.asList("noverify"), "Do not verify module signatures. " + "Treat as unsigned.");
*** 689,702 **** throw new Command.Exception(x); } } try { cmd.newInstance().run(lib, opts); ! } catch (InstantiationException x) { throw new AssertionError(x); - } catch (IllegalAccessException x) { - throw new AssertionError(x); } } private static File libPath(OptionSet opts) { if (opts.has(libPath)) { --- 674,685 ---- throw new Command.Exception(x); } } try { cmd.newInstance().run(lib, opts); ! } catch (InstantiationException | IllegalAccessException x) { throw new AssertionError(x); } } private static File libPath(OptionSet opts) { if (opts.has(libPath)) {