> From: "Remi Forax" <[email protected]>
> To: "David Alayachew" <[email protected]>
> Cc: "valhalla-dev" <[email protected]>
> Sent: Wednesday, October 29, 2025 9:30:22 AM
> Subject: Re: Compiler error message not clear for Valhalla EA 2
> This is an interesting case because i'm not sure the compiler should emit an
> error here.
> Currently the error occurs because as you said the call to super() is added
> after the call to throw.
> But throwing an exception in a constructor of an identity class is valid, and
> i
> do not see a reason why this behavior should not be the same in the case of a
> value class.
or perhaps javac should behave more like when there is an explicit call to
'return'
value class V {
V ( int v ) {
return ;
}
}
java: 'return' not allowed before explicit constructor invocation
> regards,
> Rémi
regards,
Rémi
>> From: "David Alayachew" <[email protected]>
>> To: "valhalla-dev" <[email protected]>
>> Sent: Wednesday, October 29, 2025 5:30:23 AM
>> Subject: Re: Compiler error message not clear for Valhalla EA 2
>> The compiler error message goes away if I put a super(); as the first
>> statement
>> in the constructor. But still, that error message could be clearer.
>> From: "David Alayachew" <[email protected]>
>> To: "valhalla-dev" <[email protected]>
>> Sent: Wednesday, October 29, 2025 5:27:55 AM
>> Subject: Compiler error message not clear for Valhalla EA 2
>> Hello [ mailto:[email protected] | @valhalla-dev ] ,
>> While testing out the new Valhalla EA that came out a few days ago, I ran
>> into
>> the following compiler error.
>> Here is a minified example.
>> public value class abc
>> {
>> public abc()
>> {
>> throw new UnsupportedOperationException();
>> }
>> public static void someHelperMethod()
>> {}
>> }
>> And here is the compiler error message.
>> $ java --enable-preview abc.java
>> abc.java:5: error: unreachable statement
>> {
>> ^
>> 1 error
>> error: compilation failed
>> That location is the opening curly brace of the constructor.
>> Can we have a more clear error message?
>> Thank you for your time and consideration.
>> David Alayachew