[records] Is serialVersionUID warning for records redundant?
Remi Forax
forax at univ-mlv.fr
Mon Aug 3 09:23:18 UTC 2020
----- Mail original -----
> De: "Tagir Valeev" <amaembo at gmail.com>
> À: "amber-dev" <amber-dev at openjdk.java.net>
> Envoyé: Lundi 3 Août 2020 09:30:03
> Objet: [records] Is serialVersionUID warning for records redundant?
> Hello!
>
> I believe, explicit specification of serialVersionUID in records
> rarely makes sense and should be discouraged. Still javac issues a
> lint warning if it's absent:
>
>>"C:\Program Files\Java\jdk-15\bin\java.exe" --version
> openjdk 15-ea 2020-09-15
> OpenJDK Runtime Environment (build 15-ea+33-1546)
> OpenJDK 64-Bit Server VM (build 15-ea+33-1546, mixed mode, sharing)
>
>>type Test.java
> public record Test() implements java.io.Serializable {}
>
>>"C:\Program Files\Java\jdk-15\bin\javac.exe" --enable-preview --release=15
>>-Xlint:all Test.java
> Test.java:1: warning: [preview] records are a preview feature and may
> be removed in a future release.
> public record Test() implements java.io.Serializable {}
> ^
> Test.java:1: warning: [serial] serializable class Test has no
> definition of serialVersionUID
> public record Test() implements java.io.Serializable {}
> ^
> 2 warnings
>
> To my opinion, javac should be updated to skip this warning.
yep, i agree.
>
> With best regards,
> Tagir Valeev.
Rémi
More information about the amber-dev
mailing list