From: Luke H. <ruk...@gm...> - 2005-10-27 00:43:35
|
Hi all, I recently posted these two questions: > > 1. How do I subclass java classes with lisp code? I presume it'd be > > similar to %jnew-proxy, but I can't find a function that does it. > > > > 2. How do I make these subclasses/interfaces available to be called > > from java source code (i.e. callbacks)? > > Andras forwarded me some sample code on the usage of "jnew-runtime-class", which efficiently answered the first question.=20 However, the second question seems to me to be quite tricky, but I think it's worth solving, because then I could redevelop "in place" classes which were initially written in Java and replace them piecewise with Lisp code. I've thought of a possible solution for the second question. The solution comes in two parts: first keeping javac happy so you can compile the java source, and second keeping java itself happy. Satisfying javac should be easy, just create java stub code (probably autogenerated). Satisfying java seems hard. I briefly (and naively) thought that the class output of jnew-runtime-class would work, but of course it doesn't (presumably because the Lisp environment itself doesn't get booted, and it's doubtful that the class file saves the lexical environment in which the runtime class is defined anyway). So my next thought is implementing, say, an ABCLClassLoader, which initialises Lisp, and then instead of looking for the class foo.Bar by resolving foo/Bar.class, looks for foo/Bar.abcl or foo/Bar.lisp which contains code which creates the runtime class foo.Bar. I had a quick look at the abcl source and noticed there's a "JavaClassLoader.java" I couldn't work out what it did, and a grep told me that it wasn't called by anything else. 1. Am I missing a really simple solution? 2. Any Lisp complications I may have overlooked? 3. What's the minimum amount of abcl code I need to execute to boot lisp and Load other files? I've looked at Interpreter.java, but I don't quite know whether I need to have a toplevel, etc. 4. Any ClassLoader complications I may have overlooked? Sorry if this is a bit newbie-ish, but I haven't dug this deep in Java before, and I feel it's probably better to ask questions first and not waste my time re-inventing the wheel. -Luke P.S. for jnew-runtime-class, am I correct in assuming the method implementations are full closures? |