src/share/classes/org/openjdk/jigsaw/cli/Librarian.java
Print this page
@@ -153,28 +153,25 @@
{
noDry();
while (hasArg()) {
File module = new File(takeArg());
File destination = null;
- try (FileInputStream fis = new FileInputStream(module);
- DataInputStream dis = new DataInputStream(fis);
- ModuleFile.Reader reader = new ModuleFile.Reader(dis)) {
+ try (FileInputStream fis = new FileInputStream(module)) {
+ ModuleFile.Reader reader = new ModuleFile.Reader(fis);
- ModuleInfo mi = jms.parseModuleInfo(reader.readStart());
+ ModuleInfo mi = jms.parseModuleInfo(reader.getModuleInfoBytes());
destination = new File(mi.id().name());
Path path = destination.toPath();
Files.deleteIfExists(path);
Files.createDirectory(path);
- reader.readRest(destination, false);
- }
- catch (IOException x) {
+ reader.extractTo(destination, false);
+ } catch (IOException | ModuleFileParserException x) {
// Try to cleanup if an exception is thrown
if (destination != null && destination.exists())
try {
FilePaths.deleteTree(destination.toPath());
- }
- catch (IOException y) {
+ } catch (IOException y) {
throw (Command.Exception)
new Command.Exception(y).initCause(x);
}
throw new Command.Exception(x);
}
@@ -203,14 +200,12 @@
if (mfs.isEmpty())
throw new Command.Exception("%s: no module-name specified",
command);
try {
lib.installFromManifests(mfs, strip);
- } catch (ConfigurationException x) {
+ } catch (ConfigurationException | IOException x) {
throw new Command.Exception(x);
- } catch (IOException x) {
- throw new Command.Exception(x);
}
return;
}
// Install one or more module file(s)
@@ -222,16 +217,13 @@
while (hasArg())
fs.add(new File(takeArg()));
finishArgs();
try {
lib.install(fs, verifySignature, strip);
- } catch (ConfigurationException x) {
+ } catch (ConfigurationException | IOException |
+ SignatureException | ModuleFileParserException 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
@@ -267,11 +259,12 @@
res.spaceRequired());
}
if (dry)
return;
lib.install(res, verifySignature, strip);
- } catch (ConfigurationException | IOException | SignatureException x) {
+ } catch (ConfigurationException | IOException | SignatureException |
+ ModuleFileParserException x) {
throw new Command.Exception(x);
}
}
}