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

Guoxiong Li github.com+13688759+lgxbslgx at openjdk.java.net
Fri Dec 4 16:27:24 UTC 2020


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:
A.java:10: 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.

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

Commit messages:
 - 8231622: SuppressWarning(serial) ignored on field serialVersionUID

Changes: https://git.openjdk.java.net/jdk/pull/1626/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=1626&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8231622
  Stats: 118 lines in 7 files changed: 116 ins; 0 del; 2 mod
  Patch: https://git.openjdk.java.net/jdk/pull/1626.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/1626/head:pull/1626

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


More information about the compiler-dev mailing list