RFR: 8262368: wrong verifier message for bogus return type [v2]

David Holmes david.holmes at oracle.com
Wed Mar 3 03:56:40 UTC 2021


Hi Coleen,

On 3/03/2021 12:50 pm, Coleen Phillimore wrote:
> On Tue, 2 Mar 2021 05:38:31 GMT, David Holmes <dholmes at openjdk.org> wrote:
> 
>>> Harold Seigel has updated the pull request incrementally with one additional commit since the last revision:
>>>
>>>    changed error message text
>>
>> You fixed the wrong one.
>>
>> Cheers,
>> David
> 
> Let's use javac to help us with the error message:
> $ more X.java
> class X {
> void foo() { return obj; }
> int bar() { return; }
> }
> $ javac X.java
> X.java:2: error: incompatible types: unexpected return value
> void foo() { return obj; } <===  This is line 3152
>                      ^
> X.java:3: error: incompatible types: missing return value
> int bar() { return; }       <=== This is line 1678
>              ^
> 2 errors

Thank you! I see now where I was reading things in an inverted sense:

1675: case Bytecodes::_return :
1676:      if (return_type != VerificationType::bogus_type()) {
1677:        verify_error(ErrorContext::bad_code(bci),
1678:                     "Method expects a return value");
1679:        return;
1680:      }

Here we have a plain "return" but the method's return-type is not-void, 
so it is an error to have the plain "return" because the "Method expects 
a return value". So the actual initial bug report was in fact wrong.

As Harold discovered the true problem is with the other piece of code.

Sorry for the confusion Harold!

Thanks,
David

> -------------
> 
> PR: https://git.openjdk.java.net/jdk/pull/2757
> 


More information about the hotspot-runtime-dev mailing list