RFR: 8355004: Apply java.io.Serial annotations in java.compiler

Sergey Bylokhov serb at openjdk.org
Sat Apr 26 02:50:18 UTC 2025


On Fri, 25 Apr 2025 22:46:07 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

> Please review the application of `@Serial` annotation ([JDK-8202385](https://bugs.openjdk.org/browse/JDK-8202385)) to types in the compiler module to enable stricter compile-time checking of serialization-related declarations. Just a few classes are covered.
> 
> This annotation can be applied to these methods in the module:
> 
> private void writeObject(java.io.ObjectOutputStream stream) throws IOException
> private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException
> private void readObjectNoData() throws ObjectStreamException
> ANY-ACCESS-MODIFIER Object writeReplace() throws ObjectStreamException
> ANY-ACCESS-MODIFIER Object readResolve() throws ObjectStreamException
> private static final ObjectStreamField[] serialPersistentFields
> private static final long serialVersionUID
> 
> Any feedback or suggestions are welcome!

src/java.compiler/share/classes/javax/annotation/processing/FilerException.java line 45:

> 43:     @Serial
> 44:     private static final long serialVersionUID = 8426423106453163293L;
> 45: 

Note that `private` will not affect the behavior of the code.

src/java.compiler/share/classes/javax/lang/model/type/MirroredTypeException.java line 46:

> 44:     @Serial
> 45:     private static final long serialVersionUID = 269L;
> 46: 

Some classes used the int literal and others used long, so I unified them.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24891#discussion_r2061126112
PR Review Comment: https://git.openjdk.org/jdk/pull/24891#discussion_r2061125658


More information about the compiler-dev mailing list