JDK-8210721 : Replace legacy serial exception field with Throwable::cause
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2018-09-13
  • Updated: 2018-11-21
  • Resolved: 2018-09-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 12
12 b12Fixed
Related Reports
Relates :  
Description
A few exception classes such as ExceptionInInitializerError, InvocationTargetException, etc were defined prior to the exception chaining facility and provides the API to get the cause of the exception.  These classes keep its legacy serial field e.g. ExceptionInInitializerError::exception to get the serialization to work on older JDK version.

During the review of JDK-8209553 [1], Peter and Joe suggest to remove this redundant field and implement the serialization using serialPersistentFields, readObject and writeObject. 

It turns out that these redundant fields were removed when the exception chaining support was initially implemented but it got reverted to fix JDK-4385429 since Throwable::setCause rejects any further change as Throwable::cause has been initialized to null.

We can redo the fix for JDK-4385429  by introducing an internal API for these exceptions to set Throwable::cause.

[1] http://mail.openjdk.java.net/pipermail/core-libs-dev/2018-August/054878.html