Integrated: 8231622: SuppressWarning("serial") ignored on field serialVersionUID

Guoxiong Li github.com+13688759+lgxbslgx at openjdk.java.net
Mon Dec 21 17:52:57 UTC 2020


On Fri, 4 Dec 2020 16:21:28 GMT, Guoxiong Li <github.com+13688759+lgxbslgx at openjdk.org> wrote:

> Hi all,
> 
> Currently, a warning is generated when compiling the following code by using the option `-Xlint`.
> 
> import java.io.Serializable;
> class B implements Serializable {
>     @SuppressWarnings("serial")
>     private static final byte serialVersionUID = 5;
> }
> 
> output:
> B.java:4: warning: [serial] serialVersionUID must be of type long in class B
>     private static final byte serialVersionUID = 5;
>                               ^
> 1 warning
> 
> The annotation `@SuppressWarnings("serial")` on  field serialVersionUID is ignored by the compiler.
> This patch fixes it and adds some tests.
> Thank you for taking the time to review.
> 
> Best Regards.

This pull request has now been integrated.

Changeset: 01d51a10
Author:    Guoxiong Li <lgxbslgx at gmail.com>
Committer: Jonathan Gibbons <jjg at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/01d51a10
Stats:     126 lines in 2 files changed: 124 ins; 0 del; 2 mod

8231622: SuppressWarning("serial") ignored on field serialVersionUID

Reviewed-by: jjg

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

PR: https://git.openjdk.java.net/jdk/pull/1626


More information about the compiler-dev mailing list