< prev index next >

src/java.base/share/classes/jdk/internal/module/ModulePath.java

Print this page

        

*** 511,521 **** while ((cn = nextLine(reader)) != null) { if (cn.length() > 0) { String pn = packageName(cn); if (!packages.contains(pn)) { String msg = "Provider class " + cn + " not in module"; ! throw new IOException(msg); } providerClasses.add(cn); } } } --- 511,521 ---- while ((cn = nextLine(reader)) != null) { if (cn.length() > 0) { String pn = packageName(cn); if (!packages.contains(pn)) { String msg = "Provider class " + cn + " not in module"; ! throw new InvalidModuleDescriptorException(msg); } providerClasses.add(cn); } } }
*** 531,541 **** if (mainClass != null) { mainClass = mainClass.replace("/", "."); String pn = packageName(mainClass); if (!packages.contains(pn)) { String msg = "Main-Class " + mainClass + " not in module"; ! throw new IOException(msg); } builder.mainClass(mainClass); } } --- 531,541 ---- if (mainClass != null) { mainClass = mainClass.replace("/", "."); String pn = packageName(mainClass); if (!packages.contains(pn)) { String msg = "Main-Class " + mainClass + " not in module"; ! throw new InvalidModuleDescriptorException(msg); } builder.mainClass(mainClass); } }
*** 607,620 **** if (entry == null) { // no module-info.class so treat it as automatic module try { ModuleDescriptor md = deriveModuleDescriptor(jf); ! attrs = new ModuleInfo.Attributes(md, null, null); ! } catch (IllegalArgumentException e) { ! throw new FindException( ! "Unable to derive module descriptor for: " + jf.getName(), e); } } else { attrs = ModuleInfo.read(jf.getInputStream(entry), --- 607,619 ---- if (entry == null) { // no module-info.class so treat it as automatic module try { ModuleDescriptor md = deriveModuleDescriptor(jf); ! attrs = new ModuleInfo.Attributes(md, null, null, null); ! } catch (RuntimeException e) { ! throw new FindException("Unable to derive module descriptor for " + jf.getName(), e); } } else { attrs = ModuleInfo.read(jf.getInputStream(entry),
*** 670,691 **** } /** * Maps the name of an entry in a JAR or ZIP file to a package name. * ! * @throws IllegalArgumentException if the name is a class file in ! * the top-level directory of the JAR/ZIP file (and it's ! * not module-info.class) */ private Optional<String> toPackageName(String name) { assert !name.endsWith("/"); int index = name.lastIndexOf("/"); if (index == -1) { if (name.endsWith(".class") && !name.equals(MODULE_INFO)) { ! throw new IllegalArgumentException(name ! + " found in top-level directory" ! + " (unnamed package not allowed in module)"); } return Optional.empty(); } String pn = name.substring(0, index).replace('/', '.'); --- 669,690 ---- } /** * Maps the name of an entry in a JAR or ZIP file to a package name. * ! * @throws InvalidModuleDescriptorException if the name is a class file in ! * the top-level directory of the JAR/ZIP file (and it's not ! * module-info.class) */ private Optional<String> toPackageName(String name) { assert !name.endsWith("/"); int index = name.lastIndexOf("/"); if (index == -1) { if (name.endsWith(".class") && !name.equals(MODULE_INFO)) { ! String msg = name + " found in top-level directory" ! + " (unnamed package not allowed in module)"; ! throw new InvalidModuleDescriptorException(msg); } return Optional.empty(); } String pn = name.substring(0, index).replace('/', '.');
*** 699,721 **** /** * Maps the relative path of an entry in an exploded module to a package * name. * ! * @throws IllegalArgumentException if the name is a class file in * the top-level directory (and it's not module-info.class) */ private Optional<String> toPackageName(Path file) { assert file.getRoot() == null; Path parent = file.getParent(); if (parent == null) { String name = file.toString(); if (name.endsWith(".class") && !name.equals(MODULE_INFO)) { ! throw new IllegalArgumentException(name ! + " found in top-level directory" ! + " (unnamed package not allowed in module)"); } return Optional.empty(); } String pn = parent.toString().replace(File.separatorChar, '.'); --- 698,720 ---- /** * Maps the relative path of an entry in an exploded module to a package * name. * ! * @throws InvalidModuleDescriptorException if the name is a class file in * the top-level directory (and it's not module-info.class) */ private Optional<String> toPackageName(Path file) { assert file.getRoot() == null; Path parent = file.getParent(); if (parent == null) { String name = file.toString(); if (name.endsWith(".class") && !name.equals(MODULE_INFO)) { ! String msg = name + " found in top-level directory" ! + " (unnamed package not allowed in module)"; ! throw new InvalidModuleDescriptorException(msg); } return Optional.empty(); } String pn = parent.toString().replace(File.separatorChar, '.');
< prev index next >