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

Print this page




 993     }
 994 
 995     private void reIndex(ModuleId mid)
 996         throws IOException
 997     {
 998 
 999         File md = findModuleDir(mid);
1000         if (md == null)
1001             throw new IllegalArgumentException(mid + ": No such module");
1002         File cd = new File(md, "classes");
1003         final Index ix = new Index(md);
1004 
1005         if (cd.isDirectory()) {
1006             Files.walkTree(cd, new Files.Visitor<File>() {
1007                 public void accept(File f) throws IOException {
1008                     if (f.getPath().endsWith(".class"))
1009                         addToIndex(ClassInfo.read(f), ix);
1010                 }
1011             });
1012         } else if (cd.isFile()) {
1013             FileInputStream fis = new FileInputStream(cd);
1014             ZipInputStream zis = new ZipInputStream(fis);

1015             ZipEntry ze;
1016             while ((ze = zis.getNextEntry()) != null) {
1017                 if (!ze.getName().endsWith(".class"))
1018                     continue;
1019                 addToIndex(ClassInfo.read(Files.nonClosingStream(zis),
1020                                           ze.getSize(),
1021                                           mid + ":" + ze.getName()),
1022                            ix);
1023             }
1024         }

1025 
1026         ix.store();
1027     }
1028 
1029     /**
1030      * Strip the debug attributes from the classes in a given module
1031      * directory.
1032      */
1033     private void strip(File md) throws IOException {
1034         File classes = new File(md, "classes");
1035         if (classes.isFile()) {
1036             File pf = new File(md, "classes.pack");
1037             try (JarFile jf = new JarFile(classes);
1038                 FileOutputStream out = new FileOutputStream(pf))
1039             {
1040                 Pack200.Packer packer = Pack200.newPacker();
1041                 Map<String,String> p = packer.properties();
1042                 p.put("com.sun.java.util.jar.pack.strip.debug", Pack200.Packer.TRUE);
1043                 packer.pack(jf, out);
1044             }




 993     }
 994 
 995     private void reIndex(ModuleId mid)
 996         throws IOException
 997     {
 998 
 999         File md = findModuleDir(mid);
1000         if (md == null)
1001             throw new IllegalArgumentException(mid + ": No such module");
1002         File cd = new File(md, "classes");
1003         final Index ix = new Index(md);
1004 
1005         if (cd.isDirectory()) {
1006             Files.walkTree(cd, new Files.Visitor<File>() {
1007                 public void accept(File f) throws IOException {
1008                     if (f.getPath().endsWith(".class"))
1009                         addToIndex(ClassInfo.read(f), ix);
1010                 }
1011             });
1012         } else if (cd.isFile()) {
1013             try (FileInputStream fis = new FileInputStream(cd);
1014                  ZipInputStream zis = new ZipInputStream(fis))
1015             {
1016                 ZipEntry ze;
1017                 while ((ze = zis.getNextEntry()) != null) {
1018                     if (!ze.getName().endsWith(".class"))
1019                         continue;
1020                     addToIndex(ClassInfo.read(Files.nonClosingStream(zis),
1021                                               ze.getSize(),
1022                                               mid + ":" + ze.getName()),
1023                                ix);
1024                 }
1025             }
1026         }
1027 
1028         ix.store();
1029     }
1030 
1031     /**
1032      * Strip the debug attributes from the classes in a given module
1033      * directory.
1034      */
1035     private void strip(File md) throws IOException {
1036         File classes = new File(md, "classes");
1037         if (classes.isFile()) {
1038             File pf = new File(md, "classes.pack");
1039             try (JarFile jf = new JarFile(classes);
1040                 FileOutputStream out = new FileOutputStream(pf))
1041             {
1042                 Pack200.Packer packer = Pack200.newPacker();
1043                 Map<String,String> p = packer.properties();
1044                 p.put("com.sun.java.util.jar.pack.strip.debug", Pack200.Packer.TRUE);
1045                 packer.pack(jf, out);
1046             }