Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8159248

ModuleFinder.of not clear that FindException thrown if module descriptor cannot be derived for automatic module

    Details

      Description

      Specification for method :
      http://jre.us.oracle.com/java/re/jdk/9/promoted/latest/docs/api/java/lang/module/ModuleFinder.html#of-java.nio.file.Path...-

      says:

      "If the JAR file has a Main-Class attribute in its main manifest then its value is the main class."

      which could give an impression that the value is taken without any verification. However standard builder API is used so if for example empty value is discovered the following happens:

      ======================
      java.lang.module.FindException: Unable to derive module descriptor for: ..... emptymainclass.jar
      at java.lang.module.ModulePath.readJar(java.base@9-ea/ModulePath.java:513)
      at java.lang.module.ModulePath.readModule(java.base@9-ea/ModulePath.java:274)
      at java.lang.module.ModulePath.scan(java.base@9-ea/ModulePath.java:193)
      at java.lang.module.ModulePath.scanNextEntry(java.base@9-ea/ModulePath.java:145)
      at java.lang.module.ModulePath.find(java.base@9-ea/ModulePath.java:109)
      ...
      Caused by: java.lang.IllegalArgumentException: Empty main class name
      at jdk.internal.module.Checks.requireJavaIdentifier(java.base@9-ea/Checks.java:70)
      at java.lang.module.ModuleDescriptor$Builder.mainClass(java.base@9-ea/ModuleDescriptor.java:1519)
      at java.lang.module.ModulePath.deriveModuleDescriptor(java.base@9-ea/ModulePath.java:475)
      at java.lang.module.ModulePath.readJar(java.base@9-ea/ModulePath.java:509)
      ======================

      Constraints set by builder API (+FindException) deserve to be mentioned in the spec for MF.of() or assertion ""If the JAR file has a Main-Class attribute in its main manifest then its value is the main class." needs to be updated

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alanb Alan Bateman
                Reporter:
                dbessono Dmitry Bessonov
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: