8264148: Update spec for exceptions retrofitted for exception chaining

Reviewed-by: rriggs, smarks
This commit is contained in:
Joe Darcy 2021-03-30 19:59:59 +00:00
parent 353807c5f1
commit 815248ab27
22 changed files with 40 additions and 76 deletions

View file

@ -1193,7 +1193,7 @@ public class ObjectStreamClass implements Serializable {
try {
writeObjectMethod.invoke(obj, new Object[]{ out });
} catch (InvocationTargetException ex) {
Throwable th = ex.getTargetException();
Throwable th = ex.getCause();
if (th instanceof IOException) {
throw (IOException) th;
} else {
@ -1223,7 +1223,7 @@ public class ObjectStreamClass implements Serializable {
try {
readObjectMethod.invoke(obj, new Object[]{ in });
} catch (InvocationTargetException ex) {
Throwable th = ex.getTargetException();
Throwable th = ex.getCause();
if (th instanceof ClassNotFoundException) {
throw (ClassNotFoundException) th;
} else if (th instanceof IOException) {
@ -1254,7 +1254,7 @@ public class ObjectStreamClass implements Serializable {
try {
readObjectNoDataMethod.invoke(obj, (Object[]) null);
} catch (InvocationTargetException ex) {
Throwable th = ex.getTargetException();
Throwable th = ex.getCause();
if (th instanceof ObjectStreamException) {
throw (ObjectStreamException) th;
} else {
@ -1283,7 +1283,7 @@ public class ObjectStreamClass implements Serializable {
try {
return writeReplaceMethod.invoke(obj, (Object[]) null);
} catch (InvocationTargetException ex) {
Throwable th = ex.getTargetException();
Throwable th = ex.getCause();
if (th instanceof ObjectStreamException) {
throw (ObjectStreamException) th;
} else {
@ -1313,7 +1313,7 @@ public class ObjectStreamClass implements Serializable {
try {
return readResolveMethod.invoke(obj, (Object[]) null);
} catch (InvocationTargetException ex) {
Throwable th = ex.getTargetException();
Throwable th = ex.getCause();
if (th instanceof ObjectStreamException) {
throw (ObjectStreamException) th;
} else {

View file

@ -33,13 +33,6 @@ package java.io;
* field. The stream is reset to it's initial state and all references
* to objects already deserialized are discarded.
*
* <p>As of release 1.4, this exception has been retrofitted to conform to
* the general purpose exception-chaining mechanism. The "exception causing
* the abort" that is provided at construction time and
* accessed via the public {@link #detail} field is now known as the
* <i>cause</i>, and may be accessed via the {@link Throwable#getCause()}
* method, as well as the aforementioned "legacy field."
*
* @since 1.1
*/
public class WriteAbortedException extends ObjectStreamException {
@ -49,12 +42,13 @@ public class WriteAbortedException extends ObjectStreamException {
/**
* Exception that was caught while writing the ObjectStream.
*
* <p>This field predates the general-purpose exception chaining facility.
* The {@link Throwable#getCause()} method is now the preferred means of
* obtaining this information.
* @deprecated This field predates the general-purpose exception
* chaining facility. The {@link Throwable#getCause()} method is
* now the preferred means of obtaining this information.
*
* @serial
*/
@Deprecated(since="17")
public Exception detail;
/**
@ -87,6 +81,7 @@ public class WriteAbortedException extends ObjectStreamException {
* which may be null.
* @since 1.4
*/
@Override
public Throwable getCause() {
return detail;
}