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

44 lines
1.3 KiB
Java

/*
* @test /nodynamiccopyright/
* @bug 8202056
* @compile/ref=InterfaceNonPrivateMethods.out -XDrawDiagnostics -Xlint:serial InterfaceNonPrivateMethods.java
*/
import java.io.*;
// Holder class
class InterfaceNonPrivateMethods {
interface NonPrivateMethods extends Serializable {
public void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException;
public void readObjectNoData() throws ObjectStreamException;
public void writeObject(ObjectOutputStream stream) throws IOException;
// Ineffective default methods; serialization only looks up
// superclass chain
public default Object writeReplace() throws ObjectStreamException {
return null;
}
public default Object readResolve() throws ObjectStreamException {
return null;
}
}
interface NonPrivateMethodsDefaults extends Serializable {
default public void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException {
return;
}
default public void readObjectNoData()
throws ObjectStreamException {
return;
}
default public void writeObject(ObjectOutputStream stream)
throws IOException {
return;
}
}
}