RFR: 8328874: Class::forName0 should validate the class name length early [v15]
Guanqiang Han
ghan at openjdk.org
Tue Sep 9 01:05:40 UTC 2025
On Sun, 7 Sep 2025 20:09:53 GMT, Chen Liang <liach at openjdk.org> wrote:
>> Guanqiang Han has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Use a different native method for testNative, since the implementation of forName has changed.
>
> src/java.base/share/classes/java/lang/Class.java line 4162:
>
>> 4160: if (!ModifiedUtf.isValidLengthInConstantPool(name)) {
>> 4161: throw new ClassNotFoundException(
>> 4162: "Class name length exceeds limit of " + ModifiedUtf.CONSTANT_POOL_UTF8_MAX_BYTES);
>
> Suggestion:
>
> "Class name length exceeds limit of " + ModifiedUtf.CONSTANT_POOL_UTF8_MAX_BYTES + ": " + name);
@liach Thanks for the suggestion.
I think including the name is useful, but since it can be extremely long in this case, I’d prefer to log only the first part (e.g. first 256 chars + “…”) to give context without flooding the logs.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26802#discussion_r2331704563
More information about the core-libs-dev
mailing list