mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
8049367: Modular Run-Time Images
Co-authored-by: Alan Bateman <alan.bateman@oracle.com> Co-authored-by: Alex Buckley <alex.buckley@oracle.com> Co-authored-by: Bradford Wetmore <bradford.wetmore@oracle.com> Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com> Co-authored-by: James Laskey <james.laskey@oracle.com> Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com> Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com> Co-authored-by: Magnus Ihse Bursie <magnus.ihse.bursie@oracle.com> Co-authored-by: Mandy Chung <mandy.chung@oracle.com> Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com> Co-authored-by: Paul Sandoz <paul.sandoz@oracle.com> Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com> Reviewed-by: jlahoda, ksrini
This commit is contained in:
parent
f141ae6666
commit
8bc2b3ff3a
80 changed files with 2575 additions and 2861 deletions
|
@ -1546,31 +1546,31 @@ public class ToolBox {
|
|||
}
|
||||
|
||||
private void writeFiles(JarOutputStream jos) throws IOException {
|
||||
Path base = (baseDir == null) ? currDir : baseDir;
|
||||
for (Path path : paths) {
|
||||
Files.walkFileTree(base.resolve(path), new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
||||
try {
|
||||
Path base = (baseDir == null) ? currDir : baseDir;
|
||||
for (Path path : paths) {
|
||||
Files.walkFileTree(base.resolve(path), new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
||||
try {
|
||||
String p = base.relativize(file)
|
||||
.normalize()
|
||||
.toString()
|
||||
.replace(File.separatorChar, '/');
|
||||
JarEntry e = new JarEntry(p);
|
||||
jos.putNextEntry(e);
|
||||
jos.putNextEntry(e);
|
||||
try {
|
||||
jos.write(Files.readAllBytes(file));
|
||||
} finally {
|
||||
jos.closeEntry();
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
} catch (IOException e) {
|
||||
return FileVisitResult.CONTINUE;
|
||||
} catch (IOException e) {
|
||||
error("Exception while adding " + file + " to jar file", e);
|
||||
return FileVisitResult.TERMINATE;
|
||||
return FileVisitResult.TERMINATE;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFileObjects(JarOutputStream jos) throws IOException {
|
||||
|
@ -1587,9 +1587,9 @@ public class ToolBox {
|
|||
} catch (IOException ex) {
|
||||
error("Exception while adding " + fo.getName() + " to jar file", ex);
|
||||
}
|
||||
} finally {
|
||||
} finally {
|
||||
jos.closeEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1599,17 +1599,30 @@ public class ToolBox {
|
|||
*/
|
||||
private final Pattern jarEntry = Pattern.compile(".*!/(?:META-INF/sym/[^/]+/)?(.*)");
|
||||
|
||||
/*
|
||||
* A jrt: URL is of the form jrt:/module/package/file
|
||||
*/
|
||||
private final Pattern jrtEntry = Pattern.compile("/([^/]+)/(.*)");
|
||||
|
||||
private String guessPath(FileObject fo) {
|
||||
URI u = fo.toUri();
|
||||
switch (u.getScheme()) {
|
||||
case "jar":
|
||||
case "jar": {
|
||||
Matcher m = jarEntry.matcher(u.getSchemeSpecificPart());
|
||||
if (m.matches()) {
|
||||
return m.group(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "jrt": {
|
||||
Matcher m = jrtEntry.matcher(u.getSchemeSpecificPart());
|
||||
if (m.matches()) {
|
||||
return m.group(2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException(fo.getName());
|
||||
throw new IllegalArgumentException(fo.getName() + "--" + fo.toUri());
|
||||
}
|
||||
|
||||
private void error(String message, Throwable t) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue