JDK-8058304 : Non-serializable fields in serializable classes
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-09-12
  • Updated: 2015-06-04
  • Resolved: 2014-09-12
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.
8u40Fixed 9 b32Fixed
There are various non-transient fields containing MethdHandles or Switchpoints that break serialization for persistent code caching. These fields are usually not initialized when storing persistent script classes. They should be defined as transient.

Also, the new Parser.ParseState class is stored in a RecompilableScriptFunctionData field and should be serializable.
Added noreg-hard label. Serialization of classes in question is used by our persistent code caching feature, which serializes compiled classes directly after compilation. The fields in question however are only initialized while running the compiled code. Therefore, a test for this bug would require writing an alternative code store which stores compiled classes only after running them, and use it to actually run some complex scripts through it. This is currently impossible to do in Nashorn since the code store class is final.