RFR: 8338937: Optimize the string concatenation of ClassDesc

ExE Boss duke at openjdk.org
Sun Aug 25 21:32:02 UTC 2024


On Sun, 25 Aug 2024 21:07:16 GMT, Shaojin Wen <duke at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/StringConcatHelper.java line 787:
>> 
>>> 785:     }
>>> 786: 
>>> 787:     static String concat(String prefix, String value, String suffix) {
>> 
>> `Class​::descriptorString()` can probably also make use of this method and `String​::concat​(String)`:
>> 
>> if (isArray()) {
>> 	return "[".concat(componentType.descriptorString());
>> } else if (isHidden()) {
>> 	// unchanged
>> } else {
>> 	String name = getName().replace('.', '/');
>> 	return StringConcatHelper.concat("L", name, ";");
>> }
>
> In this case, there are too many locations under the java.lang package to change, and a new PR may be more appropriate.

Well, `Class​::descriptorString()` is referenced from the `ReferenceClassDescImpl` creation code in `ConstantUtils`:
https://github.com/openjdk/jdk/blob/5671f836039ef1683e3e9ce5b7cf0fa2f1860e2d/src/java.base/share/classes/jdk/internal/constant/ConstantUtils.java#L89-L91

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20705#discussion_r1730433878


More information about the core-libs-dev mailing list