jdk-24/test/langtools/tools/javac/warnings/Serial/SerialMethodArity.java
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

41 lines
1.3 KiB
Java

/*
* @test /nodynamiccopyright/
* @bug 8202056
* @compile/ref=SerialMethodArity.out -XDrawDiagnostics -Xlint:serial SerialMethodArity.java
*/
import java.io.*;
class SerialMethodMods implements Serializable {
private static final long serialVersionUID = 42;
private static class CustomObjectOutputStream extends ObjectOutputStream {
public CustomObjectOutputStream() throws IOException,
SecurityException {}
}
// Should have a single parameter of exact type ObjectOutputStream
private void writeObject(CustomObjectOutputStream stream) throws IOException {
stream.defaultWriteObject();
}
// Should have a single parameter of exact type ObjectInputStream
private void readObject(ObjectInputStream stream, int retries)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
}
// Should have no arguments
private void readObjectNoData(int retries) throws ObjectStreamException {}
// Should have no arguments
public Object writeReplace(int arg0, int arg1) throws ObjectStreamException {
return null;
}
// Should have no arguments
public Object readResolve(double foo, float bar) throws ObjectStreamException {
return null;
}
}