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

jar tool allows the main class to be set to a class that is not in the JAR file

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 9, 12
    • tools
    • None
    • jar

      The jar tool currently allows the main class to be set to a class that does not exist in the JAR file. The bug may be limited to the case where the JAR file does not contain any classes in named packages. Here's an example where the error is caught at runtime rather than at packaging time.

      cat > module-info.java << EOF
      module m { }
      EOF
      javac module-info.java
      jar --create --file foo.jar module-info.class
      jar --update --file foo.jar --main-class p.Main

      $ java -p foo.jar -d m
      Error occurred during initialization of boot layer
      java.lang.module.FindException: Error reading module: foo.jar
      Caused by: java.lang.module.InvalidModuleDescriptorException: Package p not found in module

            lancea Lance Andersen
            alanb Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: