[8] Review request for 8004970, 8004971, and 8006817: implement serialization in lambda metafactory and metafactory fix

Gregg Wonderly gregg at wonderly.org
Tue Feb 12 11:43:07 PST 2013

The context class loader is a powerful and flexible way to allow calling code, 
to "switch out" the class loading mechanism at appropriate spots so that 
modularization inside of an application can result in the right isolation for 
the application.   I don't think that the context class loader "mechanisms" are 
always the best though, and it would be really nice to have lamda support for 
specifying a class loader to use as the context class loader, only during a 
particular call. Currently, people do things like

ClassLoader old = Thread.currentThread().getContextClassLoader();
try {
     Thread.currentThread().setContextClassLoader( someOtherLoader );
} finally {
     Thread.currentThread().setContextClassLoader( old );

to make the switch in and back out.  It would be nice if there was a way to wrap 
this kind of logic into a lambda expression.

Gregg Wonderly

On 2/12/2013 1:10 PM, Peter Levart wrote:
> Hi Robert,
> Just a minor note on ClassLoaders.
> In SerializedLambda.readResolve(), the capturingClass is resolved from
> it's name using the current thread's context ClassLoader. I don't know
> if this is the right thing to do. ObjectInputStream has it's own
> (pluggable) mechanism for resolving classes, which by default uses the
> so called "latest user defined loader" (see
> ObjectInputStream.resolveClass()). It would be better if
> SerializedLambda kept a reference to j.l.Class object representing
> capturingClass and leave to the serialization infrastructure do the
> resolving. But there is a SerializedLambda constructor that only takes a
> String, hm...
> I guess other classes that are resolved inside the capturingClass'
> $deserializeLambda$ method are using the caprutingClass' class loader,
> which is ok.
> Regards, Peter
> On 02/12/2013 04:23 PM, Robert Field wrote:
>> Please review the fixes for CRs:
>>          http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8004970
>>          http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8004971
>>          http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8006817
>> Webrev:
>>          http://cr.openjdk.java.net/~rfield/8004970
>> Thank,
>> Robert

More information about the lambda-dev mailing list