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

Optimize ImageReader lookup, used by Class.getResource

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 17
    • Component/s: tools
    • Subcomponent:
    • Resolved In Build:
      b09

      Description

      As a proxy for a resource lookup, consider String.class.getResource("String.class"). This will drop into the jimage code reading lib/modules to produce a URL to the String.class bytes.

      A microbenchmark shows just getting to that URL is quite costly:

      Benchmark Mode Cnt Score Error Units
      ClassGetResource.stringClass avgt 5 2885.403 ± 309.787 ns/op
      ClassGetResource.stringClass:·gc.alloc.rate.norm avgt 5 1368.124 ± 0.056 B/op

      There are several inefficiencies along this path that could be addressed, including adding an ASCII fast-path to the jimage verification code that checks if the name points to a real resource.

      Optimizing the underlying jimage code can be helpful for a variety of applications, including javac.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              redestad Claes Redestad
              Reporter:
              redestad Claes Redestad
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: