src/share/classes/org/openjdk/jigsaw/SimpleLibrary.java

Print this page

        

*** 27,36 **** --- 27,37 ---- import java.lang.module.*; import java.io.*; import java.net.URI; import java.nio.file.*; + import java.nio.file.attribute.BasicFileAttributes; import java.security.*; import java.security.cert.*; import java.util.*; import java.util.jar.*; import java.util.zip.*;
*** 889,899 **** File f = new File((File)o, path); if (!f.exists()) return null; return f.toURI(); } - assert false; return null; } public byte[] readLocalClass(ModuleId mid, String className) throws IOException --- 890,899 ----
*** 1007,1016 **** --- 1007,1032 ---- pf.delete(); } } } + private List<Path> listFiles(Path dir) throws IOException { + final List<Path> files = new ArrayList<>(); + java.nio.file.Files.walkFileTree(dir, new SimpleFileVisitor<Path>() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) + throws IOException + { + if (!file.endsWith("module-info.class")) + files.add(file); + + return FileVisitResult.CONTINUE; + } + }); + return files; + } + private void install(Manifest mf, File dst, boolean strip) throws IOException { if (mf.classes().size() > 1) throw new IllegalArgumentException("Multiple module-class"
*** 1074,1101 **** return true; } }}); ix.store(); } else { try (FileOutputStream fos = new FileOutputStream(new File(mdst, "classes")); JarOutputStream jos = new JarOutputStream(new BufferedOutputStream(fos))) { ! // Copy class files and build index ! final Index ix = new Index(mdst); ! Files.storeTree(src, jos, isDeflated(), new Files.Filter<File>() { ! public boolean accept(File f) throws IOException { ! if (f.isDirectory()) ! return true; ! if (f.getName().endsWith(".class")) { ! return addToIndex(ClassInfo.read(f), ix); ! } else { ! return true; } ! }}); ix.store(); copyModuleInfo(dst, mi, bs); - } if (strip) strip(mdst); } } --- 1090,1122 ---- return true; } }}); ix.store(); } else { + // Copy class/resource files and build index + Index ix = new Index(mdst); + Path srcPath = src.toPath(); + List<Path> files = listFiles(srcPath); + + if (!files.isEmpty()) { try (FileOutputStream fos = new FileOutputStream(new File(mdst, "classes")); JarOutputStream jos = new JarOutputStream(new BufferedOutputStream(fos))) { ! boolean deflate = isDeflated(); ! for (Path path : files) { ! File file = path.toFile(); ! String jp = Files.convertSeparator(srcPath.relativize(path).toString()); ! try (OutputStream out = Files.newOutputStream(jos, deflate, jp)) { ! java.nio.file.Files.copy(path, out); } ! if (file.getName().endsWith(".class")) ! addToIndex(ClassInfo.read(file), ix); ! } ! } ! } ix.store(); copyModuleInfo(dst, mi, bs); if (strip) strip(mdst); } }