So far, a subset of Lambda's appear very suitable for marshalling remotely, 
where their code can execute in a remote jvm.

A lambda, that doesn't refer to object methods in its enclosing class, results 
in the java compiller creating a static method that accepts captured object 
arguments, containing the lambda's block code.

With ASM, I can very easily read a class and strip out all but this static 
method.  A non instantiable class file with no class init.

This class can be given a temporary known name, unrelated to the original 
client code (not intended for class loading, but identity).

A named identity of this class can then be created using a message digest of 
the class bytes. 

The class byte code can be packaged and serialized remotely.

Upon deserialization, the class can be rewritten again (if not loaded 
previously) and named after its message digest, and given a new object method 
to implement the functional interface, final fields added to hold serialized 
captured arguments, and a constructor that accepts the captured arguments.

It is now a simple basic object that calls a static method with arguments.

The class file would be verified, then loaded into a ClassLoader with no 
permissions.

The class would be cached in a Map with weak values, the key being the message 
digest, so idential deserialized lambda's wouldn't need to rewrite and load 
their class bytecode.

These lambda's could be used in services to allow remote internal iteration, 
over large data collections, like distributed hash tables, to process and 
return results.

An argument captured by a lambda, could itself be a remote service, used as a 
callback.  Lambda's could be stored by services, and used like queries to 
notify remote listeners of changes in service state.

A bit like an Event notification version of Map Reduce. 

It seems reasonable that distributed lambda's should provide a subset of Java 
lambda expressions based on static compilled methods and that all object 
arguments that lambda's capture should be or implement public api or service 
api.

Thoughts?

Peter.

Reply via email to