Improve error message for jimage command line tool regarding version mismatch

XMLWordPrintable

    • Type: Sub-task
    • Resolution: Unresolved
    • Priority: P4
    • None
    • Affects Version/s: None
    • Component/s: tools
    • None
    • Fix Understood

      The jimage tool is designed to be matched with the jimage files it can process, and each JDK installation has its one version of the tool.

      However, some software distributions (esp. Linux) place the jimage binary of the default JDK into the shell path (e.g. via a symbolic link in /usr/bin).

      Until now this wasn't a big deal because all versions of the tool worked with all jimage files because the version was always 1.0.

      With the work on preview mode, the jimage version will be changed, and the jimage command will no longer work with any jimage file.

      Currently, a version mismatch produces the output:
      ----
      % jimage list <jdk>/lib/modules
      Error: Unable to open <jdk>/lib/modules: The image file "<jdk>/lib/modules" is not the correct version. Major: 1. Minor: 1
      ----

      This is not actually helpful and doesn't inform the user of the actual issue or give them enough information to address it. Instead is should say something like:
      ---
      % jimage list <path>/modules
      Error: Unable to open <path>/modules: mismatched versions
        Use '<JAVA_HOME>/bin/jimage' for the JDK associated with this jimage file.
      ---
      where <path> would be the actual path in the user's filesystem.

      Additionally, the tool could look to see if the image file was placed in what appears to be a JDK installation and infer the correct tool to use. For example:
      ---
      % jimage list <path>/lib/modules
      Error: Unable to open <path>/lib/modules: mismatched versions
        Use '<JAVA_HOME>/bin/jimage' for the JDK associated with this jimage file.
        Found candidate jimage tool: <path>/bin/jimage
      ---
      which a user could then just cut & paste into their command prompt.

            Assignee:
            David Beaumont
            Reporter:
            David Beaumont
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: