File tree Expand file tree Collapse file tree
tests/java/modules/Common/src/main/java/me/dexrn/jos/common/test Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package me .dexrn .jos .common .test ;
2+
3+ import java .io .InvalidObjectException ;
4+ import java .io .ObjectInputStream ;
5+ import java .io .Serial ;
6+ import java .io .Serializable ;
7+
8+ public class JOSProxyClass implements Serializable {
9+ private int myFunnyInt = 69420 ;
10+
11+ @ Serial
12+ private void readObject (ObjectInputStream stream ) throws InvalidObjectException {
13+ throw new InvalidObjectException ("Proxy required." );
14+ }
15+
16+
17+ @ Serial
18+ private Object writeReplace () {
19+ return new SerializationProxy (this );
20+ }
21+
22+ public static class SerializationProxy implements Serializable {
23+ @ Serial
24+ private static final long serialVersionUID = 0L ;
25+
26+ private final int myProxiedFunnyInt ;
27+
28+ public SerializationProxy (JOSProxyClass josProxyClass ) {
29+ this .myProxiedFunnyInt = josProxyClass .myFunnyInt ;
30+ }
31+
32+
33+ @ Serial
34+ private Object readResolve () {
35+ JOSProxyClass jos = new JOSProxyClass ();
36+ jos .myFunnyInt = this .myProxiedFunnyInt ;
37+ return jos ;
38+ }
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments