< prev index next >

src/java.base/share/classes/java/lang/module/ModulePath.java

Print this page

        

*** 54,63 **** --- 54,65 ---- import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; + import jdk.internal.jmod.JmodFile; + import jdk.internal.jmod.JmodFile.Section; import jdk.internal.module.ConfigurableModuleFinder; import jdk.internal.perf.PerfCounter; /**
*** 292,306 **** } // -- jmod files -- ! private Set<String> jmodPackages(ZipFile zf) { ! return zf.stream() ! .filter(e -> e.getName().startsWith("classes/") && ! e.getName().endsWith(".class")) ! .map(e -> toPackageName(e.getName().substring(8))) .filter(pkg -> pkg.length() > 0) // module-info .collect(Collectors.toSet()); } /** --- 294,308 ---- } // -- jmod files -- ! private Set<String> jmodPackages(JmodFile jf) { ! return jf.stream() ! .filter(e -> e.section() == Section.CLASSES) ! .map(JmodFile.Entry::name) ! .map(this::toPackageName) .filter(pkg -> pkg.length() > 0) // module-info .collect(Collectors.toSet()); } /**
*** 309,326 **** * * @throws IOException * @throws InvalidModuleDescriptorException */ private ModuleReference readJMod(Path file) throws IOException { ! try (ZipFile zf = new ZipFile(file.toString())) { ! ZipEntry ze = zf.getEntry("classes/" + MODULE_INFO); ! if (ze == null) { ! throw new IOException(MODULE_INFO + " is missing: " + file); ! } ModuleDescriptor md; ! try (InputStream in = zf.getInputStream(ze)) { ! md = ModuleDescriptor.read(in, () -> jmodPackages(zf)); } return ModuleReferences.newJModModule(md, file); } } --- 311,324 ---- * * @throws IOException * @throws InvalidModuleDescriptorException */ private ModuleReference readJMod(Path file) throws IOException { ! try (JmodFile jf = new JmodFile(file)) { ModuleDescriptor md; ! try (InputStream in = jf.getInputStream(Section.CLASSES, MODULE_INFO)) { ! md = ModuleDescriptor.read(in, () -> jmodPackages(jf)); } return ModuleReferences.newJModModule(md, file); } }
< prev index next >