RFR: 8260337: Optimize ImageReader lookup, used by Class.getResource

Claes Redestad redestad at openjdk.java.net
Mon Jan 25 15:30:51 UTC 2021


This patch optimizes the code paths exercised by `String.class.getResource("String.class")` by:

- Adding an ASCII fast-path to methods verifying strings in the jimage, which can then be done allocation-free
- Avoiding the allocation of the `long[8]` attributes when verifying only for the purpose of verifying a path exists
- Using the `JNUA.create` fast-path in `SystemModuleReader` (which should be OK since we just verified the given name is a JRT path)
- Remove a redundant check in `Class::resolveName` and fitting the `StringBuilder` to size

-------------

Commit messages:
 - Remove more redundant checks
 - More cleanups, remove redundant null checks, synchronization
 - Minor cleanup, remove some code duplication
 - Fix offsets to properly find extension-less resources (ModuleReaderTest etc)
 - Merge branch 'master' into jrt_getString
 - Make ImageLocation lookup mostly allocation-free, use JNUA.create in SystemModuleReader, improve Class.resolveName
 - Invert length for non-ASCII case
 - Add working micro, cleanup and fix code
 - Improve jimage string reading

Changes: https://git.openjdk.java.net/jdk/pull/2212/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=2212&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8260337
  Stats: 387 lines in 8 files changed: 263 ins; 63 del; 61 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2212.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2212/head:pull/2212

PR: https://git.openjdk.java.net/jdk/pull/2212


More information about the core-libs-dev mailing list