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

    Details

    • Type: Bug
    • Status: In Progress
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 9, 12
    • Fix Version/s: tbd
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
      jar

      Description

      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

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated: