< prev index next >

src/java.base/share/classes/java/lang/reflect/UndeclaredThrowableException.java

Print this page

        

*** 60,69 **** --- 60,70 ---- * @author Peter Jones * @see InvocationHandler * @since 1.3 */ public class UndeclaredThrowableException extends RuntimeException { + @java.io.Serial static final long serialVersionUID = 330127114055056639L; /** * Constructs an {@code UndeclaredThrowableException} with the * specified {@code Throwable}.
*** 106,124 **** --- 107,127 ---- /** * Serializable fields for UndeclaredThrowableException. * * @serialField undeclaredThrowable Throwable */ + @java.io.Serial private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField("undeclaredThrowable", Throwable.class) }; /* * Reconstitutes the UndeclaredThrowableException instance from a stream * and initialize the cause properly when deserializing from an older * version. */ + @java.io.Serial private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { ObjectInputStream.GetField fields = s.readFields(); Throwable exception = (Throwable) fields.get("undeclaredThrowable", null); if (exception != null) { SharedSecrets.getJavaLangAccess().setCause(this, exception);
*** 127,136 **** --- 130,140 ---- /* * To maintain compatibility with older implementation, write a serial * "ex" field with the cause as the value. */ + @java.io.Serial private void writeObject(ObjectOutputStream out) throws IOException { ObjectOutputStream.PutField fields = out.putFields(); fields.put("undeclaredThrowable", super.getCause()); out.writeFields(); }
< prev index next >