src/share/classes/org/openjdk/jigsaw/ModuleFile.java
Print this page
@@ -56,10 +56,13 @@
}
}
public final static class Reader implements Closeable {
+ // The library where this module is to be installed, or null if
+ // simply extracting ( jmod Extract, or jsign )
+ private SimpleLibrary lib;
private DataInputStream stream;
private File destination;
private boolean deflate;
private HashType hashtype;
@@ -121,10 +124,15 @@
this.stream =
new DataInputStream(new BufferedInputStream(stream));
}
}
+ public Reader(DataInputStream stream, SimpleLibrary lib) {
+ this(stream);
+ this.lib = lib;
+ }
+
private void checkHashMatch(byte[] expected, byte[] computed)
throws IOException
{
if (!MessageDigest.isEqual(expected, computed))
throw new IOException("Expected hash "
@@ -467,10 +475,23 @@
throws IOException
{
return readModuleInfo(in, csize); // signature has the same format
}
+ // Returns the path for the section type, if the library
+ // has one configured.
+ private File librarySectionPath(SectionType type) {
+ if (lib != null && type == SectionType.NATIVE_LIBS
+ && lib.natlibs() != null)
+ return lib.natlibs();
+ if (lib != null && type == SectionType.NATIVE_CMDS
+ && lib.natcmds() != null)
+ return lib.natcmds();
+
+ return null;
+ }
+
private File computeRealPath(String storedpath) throws IOException {
String convertedpath = storedpath.replace('/', File.separatorChar);
File path = new File(convertedpath);
@@ -487,10 +508,20 @@
private File computeRealPath(SectionType type,
String storedpath)
throws IOException
{
+ File lsp = librarySectionPath(type);
+ if (lsp != null) {
+ // The library has a configured path for this section
+ File realpath = new File(lsp, storedpath);
+ // Create the parent directories if necessary
+ File parent = realpath.getParentFile();
+ if (!parent.exists())
+ Files.mkdirs(parent, realpath.getName());
+ return realpath;
+ }
String dir = getSubdirOfSection(type);
return computeRealPath(dir + File.separatorChar + storedpath);
}
private static void markNativeCodeExecutable(SectionType type,