// Modifier 'strictfp' is redundant on Java 17 and later publicstrictfpstaticvoidfunc2() { floata=0.1231231f; doubleb=0.23456d; doublec= a + b; System.out.println(c); }
publicstaticvoidmain(String[] args) { DeserializationFilter.func(); DeserializationFilter.serial(cirle); DeserializationFilter.deserial(); } // 反序列化失败 Exception in thread "main" java.lang.RuntimeException: java.io.InvalidClassException: filter status: REJECTED at JDK17/com.janwarlen.feature.DeserializationFilter.deserial(DeserializationFilter.java:38) at JDK17/com.janwarlen.Demo.main(Demo.java:26) Caused by: java.io.InvalidClassException: filter status: REJECTED at java.base/java.io.ObjectInputStream.filterCheck(ObjectInputStream.java:1414) at java.base/java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:2055) at java.base/java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1909) at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2235) at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1744) at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:514) at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:472) at JDK17/com.janwarlen.feature.DeserializationFilter.deserial(DeserializationFilter.java:32) ... 1 more