Better error message instead of "record header expected"?
Vicente Romero
vicente.romero at oracle.com
Mon Sep 19 14:28:07 UTC 2022
Hi Jaikiran,
Thanks for the report, I have filed [1] to track this issue,
Thanks,
Vicente
[1] https://bugs.openjdk.org/browse/JDK-8294020
On 9/19/22 09:44, Jaikiran Pai wrote:
> Please consider this trivial code:
>
> public record Record {
>
> }
>
> Trying to compile this results in:
>
> javac Record.java
>
> Record.java:1: error: record header expected
>
> public record Record {
> ^
>
> 1 error
>
> It isn't too clear what that error message means. It took me a while
> to realize that I had missed using the () after the record's name.
> Changing the source to:
>
> public record Record() {
>
> }
>
> is what the error was trying to convey. Could this error message be
> improved?
>
> By the way, notice that the error message was pointing to the "r"
> letter of the "record" keyword with the ^ sign. Is that right place
> for this error or should it have been after the "d" of the "Record"
> name, similar to what appears to be reported for constructors of
> classes, for example:
>
> public class Event {
> public Event {
>
> }
> }
>
> javac Event.java
>
> Event.java:2: error: <identifier> expected
> public Event {
> ^
> 1 error
>
> (not sure if mail clients will preserve the spacing - that ^ appears
> between the "t" and the "{")
>
> -Jaikiran
>
More information about the compiler-dev
mailing list