RemoteClassLoader doesn't provide ClassFile information for Lambdas

Robert Field robert.field at oracle.com
Thu Mar 9 03:16:07 UTC 2017


Ah!

What is going on has nothing to do with lambdas.

The "RemotableSupport" code is requesting the URL (via getResource) of 
an internal generated JShell wrapper class (user code is wrapped up in a 
synthetic class).  This class file is intentionally never made visible 
(file system or otherwise).
It thus has no corresponding URL, and getResource returns null.

This can be seen with the following executed in a jshell started with 
--no-startup

     class C { }
C.class.getClassLoader().loadClass("REPL.$JShell$1").getDeclaredClasses()
     C.class.getClassLoader().getResource("REPL/$JShell$1.class")

I suspect it would be hard to work around this, but it would definitely 
be cool to be able to demo Coherence in JShell.

Robert



On 03/08/17 09:54, Brian Oliver wrote:
> I’m attempting to use JShell with Coherence (for distributed lambdas / distributed streams) and I’ve noticed that some lambda expressions defined by the Shell are not available / resolvable via the RemoteClassLoader as expected.
>
> For example:  (assume RockStars is a Map<UID, String> where the String is “firstname lastname”)
>
> The following attempts to determine the distinct number of rockstar last names.
>
> jshell> rockstars.stream().map(e -> e.getValue().split(" ")[1]).distinct().count();
> |  java.lang.IllegalStateException thrown: ClassFile for the remote lambda could not be introspected. jdk.jshell.execution.DefaultLoaderDelegate$RemoteClassLoader at 91161c7.getResource(REPL/$JShell$20.class) unexpectedly returned null
> |        at RemotableSupport.createRemoteConstructor (RemotableSupport.java:82)
> |        at Lambdas.ensureRemotable (Lambdas.java:205)
> |        at RemoteStream.map (RemoteStream.java:154)
> |        at (#10:1)
>
> Coherence is asking for the ClassFile instance in which a (remote) lambda is defined, but it’s not available via the RemoteClassLoader.
>
> I’m wondering if the DefaultLoaderDelegate$RemoteClassLoader is missing support for resolving Lambdas?
>
> Without this support we can’t really demonstrate using remote / distributed lambdas / distributed lambdas across a Cloud - which would be very helpful!
>
> Thoughts?
>
> — Brian



More information about the kulla-dev mailing list