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

Refactor ImageReader in preparation for Valhalla support.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3 P3
    • 26
    • None
    • tools

      As part of the Valhalla work (JDK-8352750), src/java.base/share/classes/jdk/internal/jimage/ImageReader.java will need to change its behavior to allow preview classes/packages to be seen directly, without module patching.

      However, the existing implementation of this class is somewhat complex in places, and makes the process of adding overlay support for preview classes quite tricky.

      In particular, child nodes are currently created on demand and can leave a directory node with a partially filled child list, in a non-deterministic order. This greatly confuses any attempt to add logic for reading overlay resource nodes reliably from a different location in the jimage.

      Similarly, the symbolic links created in the packages/ directory namespace will need to be recalculated depending on the presence of absence of preview entries (the code for this is quite complex at the moment too).

      The good news is that with a bit of refactoring, all the "rough edges" can be removed, leaving simplified logic, especially with respect to "directory" nodes and their children, which will allow a much simpler change to support preview classes in the Valhalla repository.

      The refactoring (already prototyped) will:
      1. Simplify where child nodes can be created inside ImageReader
      2. Remove APIs which expose the underlying data of BasicImageReader (and would thus bypass the overlay behaviour when it's added).
      3. Modify internal APIs to avoid users encountering "incomplete" directory nodes at any point (this has caused issues in the past).
      4. Rework parent directory creation (this has a measurable performance improvement on JVM startup and general JRT FileSystem use).

      Since this refactoring is quite large and already separable from the work for Valhalla, it was suggested that the basic refactoring go into the mainline JDK, where it can be thoroughly tested and baked while the Valhalla work continues in parallel.

            dabeaumo David Beaumont
            dabeaumo David Beaumont
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: