RFR: 8366028: MethodType::fromMethodDescriptorString should not throw UnsupportedOperationException for invalid descriptors [v2]

ExE Boss duke at openjdk.org
Mon Aug 25 17:16:43 UTC 2025


On Mon, 25 Aug 2025 14:54:14 GMT, Chen Liang <liach at openjdk.org> wrote:

>> A previous cleanup #14642 accidentally omitted the fact that an `Array.newInstance` call in `BytecodeDescriptor::parseSig` is intended to propagate `IllegalArgumentException` to `MethodType::fromMethodDescriptorString`. This bug is discovered in a recent cleanup for `BytecodeDescriptor` in #24978.
>> 
>> Instead of restoring the original `newInstance` call, this patch catches the `UnsupportedOperationException` thrown by `Class::arrayType` to because the cause IAE thrown by `newInstance` has no message at all. The existing reporting system in `BytecodeDescriptor::parseMethod` includes the whole malformed descriptor string in the error message, which can be triggered by returning `null` in `parseSig`.
>
> Chen Liang has updated the pull request incrementally with one additional commit since the last revision:
> 
>   A case for malformed return type

test/jdk/java/lang/invoke/MethodTypeTest.java line 233:

> 231:                 "(java/lang/Object)V",
> 232:                 "()java/lang/Object",
> 233:         };

And maybe also add a test case for an array type with too many dimensions in the return type:
Suggestion:

                "()java/lang/Object",
                "()" + "[".repeat(256) + "Ljava/lang/Object;",
        };

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26909#discussion_r2298665463


More information about the core-libs-dev mailing list