On Fri, 16 Aug 2024 08:53:38 GMT, Shaojin Wen <[email protected]> wrote:
> The current implementation of ofDescriptor puts return type and parameter
> types together in an ArrayList, and then splits them into return type and
> array of parameter types. This ArrayList creation is unnecessary, considering
> most descriptors only have few parameter types.
>
> By splitting return type and parameter types separately and scanning the
> descriptor first to get the number of parameters, we can just allocate an
> exact, trusted array for the resulting MethodTypeDesc without copy.
src/java.base/share/classes/jdk/internal/constant/ConstantUtils.java line 297:
> 295: String objectDesc = "Ljava/lang/Object;";
> 296: if (len == objectDesc.length() &&
> descriptor.regionMatches(start, objectDesc, 0, len)) {
> 297: return ReferenceClassDescImpl.CD_Object;
Is there a reason we cannot use `ConstantDescs.CD_Object` and have to redefine
it in `ReferenceClassDescImpl`? I see no dependency in initialization order,
and the field in RCDI can be removed.
src/java.base/share/classes/jdk/internal/constant/MethodTypeDescImpl.java line
129:
> 127: var returnType = resolveClassDesc(descriptor, rightBracket + 1,
> retTypeLength);
> 128: if (length == 3 && returnType == CD_void) {
> 129: return (MethodTypeDescImpl)
> java.lang.constant.ConstantDescs.MTD_void;
Please import instead of fully qualify ConstantDescs for this field.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20611#discussion_r1722374908
PR Review Comment: https://git.openjdk.org/jdk/pull/20611#discussion_r1722375904