jdk-24/test/langtools/tools/javac/T6356530/SerializableAbstractClassTest.java

31 lines
954 B
Java

/*
* @test /nodynamiccopyright/
* @bug 6356530 8191637
* @summary -Xlint:serial does not flag abstract classes with persisent fields
* @compile/fail/ref=SerializableAbstractClassTest.out -XDrawDiagnostics -Werror -Xlint:serial SerializableAbstractClassTest.java
*/
abstract class SerializableAbstractClassTest implements java.io.Serializable {
// no serialVersionUID; error
abstract void m2();
static abstract class AWithUID implements java.io.Serializable {
private static final long serialVersionUID = 0;
void m(){}
}
interface I extends java.io.Serializable {
// no need for serialVersionUID
}
interface IDefault extends java.io.Serializable {
// no need for serialVersionUID
default int m() { return 1; }
}
interface IUID extends java.io.Serializable {
// no need for serialVersionUID, but not wrong
static final long serialVersionUID = 0;
}
}