< prev index next >

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModulesPlugin.java

Print this page
rev 52456 : imported patch asm.additional


 417         void validatePackages() {
 418             Set<String> nonExistPackages = new TreeSet<>();
 419             descriptor.exports().stream()
 420                 .map(Exports::source)
 421                 .filter(pn -> !packages.contains(pn))
 422                 .forEach(nonExistPackages::add);
 423 
 424             descriptor.opens().stream()
 425                 .map(Opens::source)
 426                 .filter(pn -> !packages.contains(pn))
 427                 .forEach(nonExistPackages::add);
 428 
 429             if (!nonExistPackages.isEmpty()) {
 430                 throw new PluginException("Packages that are exported or open in "
 431                     + descriptor.name() + " are not present: " + nonExistPackages);
 432             }
 433         }
 434 
 435         boolean hasModulePackages() throws IOException {
 436             Set<String> packages = new HashSet<>();
 437             ClassVisitor cv = new ClassVisitor(Opcodes.ASM6) {
 438                 @Override
 439                 public ModuleVisitor visitModule(String name,
 440                                                  int flags,
 441                                                  String version) {
 442                     return new ModuleVisitor(Opcodes.ASM6) {
 443                         public void visitPackage(String pn) {
 444                             packages.add(pn);
 445                         }
 446                     };
 447                 }
 448             };
 449 
 450             try (InputStream in = getInputStream()) {
 451                 // parse module-info.class
 452                 ClassReader cr = new ClassReader(in);
 453                 cr.accept(cv, 0);
 454                 return packages.size() > 0;
 455             }
 456         }
 457 
 458         /**
 459          * Returns true if module-info.class should be rewritten to add the
 460          * ModulePackages attribute.
 461          */
 462         boolean shouldRewrite() {




 417         void validatePackages() {
 418             Set<String> nonExistPackages = new TreeSet<>();
 419             descriptor.exports().stream()
 420                 .map(Exports::source)
 421                 .filter(pn -> !packages.contains(pn))
 422                 .forEach(nonExistPackages::add);
 423 
 424             descriptor.opens().stream()
 425                 .map(Opens::source)
 426                 .filter(pn -> !packages.contains(pn))
 427                 .forEach(nonExistPackages::add);
 428 
 429             if (!nonExistPackages.isEmpty()) {
 430                 throw new PluginException("Packages that are exported or open in "
 431                     + descriptor.name() + " are not present: " + nonExistPackages);
 432             }
 433         }
 434 
 435         boolean hasModulePackages() throws IOException {
 436             Set<String> packages = new HashSet<>();
 437             ClassVisitor cv = new ClassVisitor(Opcodes.ASM7) {
 438                 @Override
 439                 public ModuleVisitor visitModule(String name,
 440                                                  int flags,
 441                                                  String version) {
 442                     return new ModuleVisitor(Opcodes.ASM7) {
 443                         public void visitPackage(String pn) {
 444                             packages.add(pn);
 445                         }
 446                     };
 447                 }
 448             };
 449 
 450             try (InputStream in = getInputStream()) {
 451                 // parse module-info.class
 452                 ClassReader cr = new ClassReader(in);
 453                 cr.accept(cv, 0);
 454                 return packages.size() > 0;
 455             }
 456         }
 457 
 458         /**
 459          * Returns true if module-info.class should be rewritten to add the
 460          * ModulePackages attribute.
 461          */
 462         boolean shouldRewrite() {


< prev index next >