6a466fe7ae
8160675: Issue lint warning for non-serializable non-transient instance fields in serializable type Reviewed-by: erikj, sspitsyn, jlahoda, vromero, rriggs, smarks
44 lines
1.3 KiB
Java
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;
|
|
}
|
|
}
|
|
}
|
|
|