java-topology/test/langtools/tools/javac/warnings/Serial/InterfaceNonPrivateMethods.java
russell@unturf.com 0a580b313d undefect. CWE-407 — 63 sites patched across 27 ecosystems
Authors: russell@unturf.com · brackishbert@gmail.com · foxhop.net · TimeHexOn.com

Patches, unit tests, benchmarks, whitepaper, and outreach briefs.
Public domain — no copyright claimed. Use freely.
2026-03-26 17:11:57 -04:00

43 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;
}
}
}