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.
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.