JDK-8004972 : Serialization testing framework
  • Type: Sub-task
  • Component: tools
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2012-12-12
  • Updated: 2013-05-01
  • Resolved: 2013-05-01
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 8
8-repo-lambdaFixed
Related Reports
Blocks :  
Cloners :  
Description
Create a tool, ideally which can be run as a java.lang.instrument agent, to enable running of lambda tests in an alternate mode where all lambdas are made serializable and their serializability verified, and tests performed using a deserialized copy.  

A sketch of the idea is below.

The lambda capture site for
a non-serializable lambda looks different from a serializable one.  A
regular capture site looks like:

indy:
  bootstrap = java.lang.invoke.LambdaMetafactory.metaFactory
  static args =
     MethodHandle[ functional interface method ]
     MethodHandle[ impl method ]
     MethodType[ instantiated method type ]
  dyn args = captured lambda args

Think of this as the "simplified" or "fast path" metafactory. A serializable capture looks like:

indy:
  bootstrap = java.lang.invoke.LambdaMetafactory.altMetaFactory
  static args =
     MethodHandle[ functional interface method ]
     MethodHandle[ impl method ]
     MethodType[ instantiated method type ]
     flags word with SERIALIZABLE bit set
     zero or more marker interfaces result should implement
  dyn args = captured lambda args

So, the approach is this: take our existing tests, grovel over the bytecode
using ASM, find the regular capture sites, and replace them with a
serializable capture site and a call to a method like:

  newLambdaObject = checkSerialization(lambdaObject, captured args...)

The implementation of this method would check to see whether all
captured args are serializable, if so, would serialize and deserialize
the object and return that, otherwise just return the input object.


Then we use the above to mangle the bytecode of our existing lambda
tests, and run both the regular and mangled versions.  The idea being
that all our existing lambda tests now are run in both nonserializable
and serializable modes, increasing test coverage of serialization
handling.



Comments
The framework is done.
01-05-2013

working on it.
12-12-2012