javac compiler message when class extends record

Vicente Romero vicente.romero at oracle.com
Thu Dec 19 13:46:54 UTC 2019


thanks Tagir, I have created [1] to track this,

Vicente

[1] https://bugs.openjdk.java.net/browse/JDK-8236266

On 12/18/19 11:45 PM, Tagir Valeev wrote:
> Hello!
>
> Consider the following code:
>
> class Test extends Record {}
>
> When I compile it (build 14-ea+27-1339) I see the following message:
>
> Test.java:1: error: records cannot directly extend Record
> class Test extends Record {}
> ^
> Note: Test.java uses preview language features.
> Note: Recompile with -Xlint:preview for details.
> 1 error
>
> I think it's somewhat confusing as it's not a record at all. For
> comparison, here's what we have if we change Record to Enum:
>
> Test.java:1: error: classes cannot directly extend java.lang.Enum
> class Test extends Enum {}
> ^
>
> I expect a similar message like "classes cannot directly extend
> java.lang.Record" in the first case. WDYT?
>
> With best regards,
> Tagir Valeev.



More information about the amber-dev mailing list