RFR: 8262368: wrong verifier message for bogus return type
David Holmes
dholmes at openjdk.java.net
Mon Mar 1 02:35:48 UTC 2021
On Fri, 26 Feb 2021 20:07:49 GMT, Harold Seigel <hseigel at openjdk.org> wrote:
> Please review this small change to fix some verifier error messages. If a method's descriptor has a void return signature, but contains a bytecode such as 'ireturn' or 'areturn'. then it will get a VerifyError exception with the message "Method descriptor has a void return type". Conversely, if a method's descriptor has a non-void return signature, but contains a 'return' bytecode then it will get a VerifyError exception with the message "Method descriptor has a non-void return type".
>
> A sample error message looks like:
> Error: Unable to initialize main class Hi
> Caused by: java.lang.VerifyError: Method descriptor has a void return type
> Exception Details:
> Location:
> Hi.noRet(I)V @1: ireturn
> Reason:
> Type integer (current frame, stack[0]) is not assignable to top (from method signature)
> Current Frame:
> bci: @1
> flags: { }
> locals: { integer }
> stack: { integer }
> Bytecode:
> 0000000: 08ac
>
> The fix was tested with Mach5 tiers 1 and 2 on Linux, Mac OS, and Windows, tiers 3-5 on Linux x64. and the JCK Lang and VM tests on Linux x64.
>
> Thanks, Harold
Hi Harold,
Sorry I don't like the new messages. See below.
Thanks,
David
src/hotspot/share/classfile/verifier.cpp line 1678:
> 1676: if (return_type != VerificationType::bogus_type()) {
> 1677: verify_error(ErrorContext::bad_code(bci),
> 1678: "Method descriptor has a non-void return type");
I prefer the original text. The new text makes me have to think about what the actual problem is too much.
src/hotspot/share/classfile/verifier.cpp line 3152:
> 3150: verify_error(ErrorContext::bad_type(bci,
> 3151: current_frame->stack_top_ctx(), TypeOrigin::signature(return_type)),
> 3152: "Method descriptor has a void return type");
I would prefer "Method does not expect a return value".
-------------
Changes requested by dholmes (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/2757
More information about the hotspot-runtime-dev
mailing list