How can I trigger a @Serial warning?

Cay Horstmann cay.horstmann at
Thu Sep 9 05:43:36 UTC 2021

I am trying to give an example of the utility of the @Serial annotation. 
But the JDK 17 javac doesn't seem to do anything with it. I tried:

@Serial private void readObject( stream, int 
shouldNotHaveThisParam) throws IOException, ClassNotFoundException
@Serial private static final String serialVersionUID = "Fred";
@Serial public String getName() { ... }

Is there some flag that I need to use? I tried -Xlint:serial, but it 
didn't make a difference.




Cay S. Horstmann | | mailto:cay at

More information about the core-libs-dev mailing list