RFR: 8331291: java.lang.classfile.Attributes class performs a lot of static initializations [v2]

Chen Liang liach at openjdk.org
Tue Apr 30 12:31:05 UTC 2024


On Tue, 30 Apr 2024 12:13:59 GMT, Adam Sotona <asotona at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/classfile/impl/BoundAttribute.java line 996:
>> 
>>> 994:     public static AttributeMapper<?> standardAttribute(Utf8Entry name) {
>>> 995:         // critical bootstrap path, so no lambdas nor method handles here
>>> 996:         return switch (name.hashCode()) {
>> 
>> I think we can safely switch over strings, as they are compiled to hashCode switch like what you explicitly have right now. Isn't that the case?
>
> Freshly parsed Utf8Entries conversion to String is expensive and unnecessary. We should be very careful when to ask for the conversion as it significantly affects some benchmarks.

You are right, I forgot these are Utf8Entry instead of Strings.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19006#discussion_r1584719802


More information about the hotspot-compiler-dev mailing list