Joe Darcy 6a466fe7ae 8202056: Expand serial warning to check for bad overloads of serial-related methods and ineffectual fields
8160675: Issue lint warning for non-serializable non-transient instance fields in serializable type

Reviewed-by: erikj, sspitsyn, jlahoda, vromero, rriggs, smarks
2021-10-21 21:11:01 +00:00

39 lines
1003 B
Java

/*
* @test /nodynamiccopyright/
* @bug 8202056
* @compile/ref=EnumSerial.out -XDrawDiagnostics -Xlint:serial EnumSerial.java
*/
import java.io.*;
enum EnumSerial implements Serializable {
INSTANCE;
// Verify a warning is generated in an enum class for each of the
// distinguished serial fields and methods.
private static final long serialVersionUID = 42;
private static final ObjectStreamField[] serialPersistentFields = {};
private void writeObject(ObjectOutputStream stream) throws IOException {
stream.defaultWriteObject();
}
private Object writeReplace() throws ObjectStreamException {
return null;
}
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
}
private void readObjectNoData() throws ObjectStreamException {
return;
}
private Object readResolve() throws ObjectStreamException {
return null;
}
}