Thats some serious hacking. Definitely agree that distributed clojure
would be awesome.

Two points/questions:

1) Is this just a bug in DynamicClassLoader? Why doesn't it call
super.defineClass instead of falling back on the URLClassLoader?:

public Class defineClass(String name, byte[] bytes){
        return defineClass(name, bytes, 0, bytes.length);
}

If it simply called super, then I believe I can pass in the right
"bytecode preserving" class with the context class loader, thus
avoiding modifications to the clojure source.

2) Do you know how to serialize an entire namespace? This largely
avoids the issue of closures.

Right now I'm serializing the classes, and serializing all the vars in
the NS, and then containing them in some ad-hoc format on disk.
Obviously this somehow can be done with a single class, but how the
compiler does it is too hairy for me to understand.


On Thu, Apr 28, 2011 at 9:28 AM, Jules <jules.gosn...@gmail.com> wrote:
> well spotted :-)
>
> I have ported it up to 1.3.0-alpha5 - alpha6 gave me some trouble that I
> haven't had time to sort out.
>
> [BTW - the following is from memory]
>
> You set the JVM's UID via a sys property.
>
> If this property is set it is incorporated into the names of new classes
> created in this JVM.
>
> The DynamicClassLoader maintains a map of classname : bytecode.
>
> I run a Jetty in this JVM which knows how to respond to URLClassLoader
> requests for class bytecode by looking them up in this map.
>
> I think I hacked DynamicClassLoader (which ?inherits? from URLClassLoader)
> so that you can optionally set a system property that is a URL from which it
> can request classes that it cannot find locally. So you do this on client
> JVMs
>
> Putting this all together, you can basically create types/fns on the-fly in
> a one JVM, serialise instances of these and send them to another JVM, then
> deserialise them (transparently pulling their class over from their parent
> JVM) and use them as if they had been created at compile rather than
> runtime.
>
> This plugs what I have found to be a bit of a hole in Clojure, namely
> dynamism is great, but I want to use it in a distributed app...
>
> The patches are not prodction ready, but I have been using them for some
> time with no problem. I'd be very happy to find other people with similar
> interest, improve the patches and see if we can persuade the powers that be
> to accept them or something providing similar fn-ality into e.g. Clojure-1.4
> :-)
>
> If you need any help getting this stuff to work, just shout.
>
>
> Jules
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to