On Mon, 23 Sep 2024 15:27:06 GMT, Chen Liang <li...@openjdk.org> wrote:

>> A small optimization of processMethod, by using local variables and 
>> extracting exception methods, reduces codeSize from 326 to 286
>
> src/java.base/share/classes/jdk/internal/classfile/impl/StackMapGenerator.java
>  line 432:
> 
>> 430:                     nextFrame.dirty = false;
>> 431:                 } else if (thisOffset < bcs.bci()) {
>> 432:                     throw new ClassFormatError(String.format("Bad stack 
>> map offset %d", thisOffset));
> 
> @asotona Is this CFE an outdated implementation behavior from an older 
> implementation? If yes, we can just use `generatorError("Bad stack map 
> offset");` instead.

Yes, good catch. I thought we already get rid of these :)

> src/java.base/share/classes/jdk/internal/classfile/impl/StackMapGenerator.java
>  line 444:
> 
>> 442: 
>> 443:     private static ClassFormatError classFormatError(int thisOffset) {
>> 444:         throw new ClassFormatError(String.format("Bad stack map offset 
>> %d", thisOffset));
> 
> Suggestion:
> 
>         return new ClassFormatError(String.format("Bad stack map offset %d", 
> thisOffset));
> 
> Prefer to return instead of throw in such convenience methods.

The same here - we should not throw CFE anymore.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21137#discussion_r1771677571
PR Review Comment: https://git.openjdk.org/jdk/pull/21137#discussion_r1771680222

Reply via email to