There is an issue in that if one tries to create a runtime class that is not in a package, it causes an error. I don't know why, nor does Russel, so until we do I suggest we add the following at the entry to jnew-runtime-class

(assert (find #\. class-name :test 'char=) (class-name)
 "Runtime classes need to be in some package and '~a' isn't" class-name)


On Fri, May 22, 2009 at 9:11 AM, Russell McManus <> wrote:
OK, here's the patch.  The simplest test case that I have works, but some of the more
complicated test cases that I have for this code are not presently working because of
recent abcl changes.

You need asm3.1 in class path for this.

I have another patch somewhere, not included here, that allows you to redefine
java classes on the fly. This is necessary if you really want to work in a lispy
style, changing things at will.  I'll try to dig this up and submit it as well.

You have to manually load src/org/armedbear/lisp/runtime-class.lisp.

Here is the simplest case:

 "FOO.Bar3" "java.lang.Object"
 nil     ;;interfaces
 nil     ;;constructors
 `(("a_method"  ;;name
   "int"       ;;return type
   ("int" "int")                               ;;argument types
   (lambda (x y &optional this)
     (+ x y))  ;;the method itself
 nil                  ;;fields
 "/tmp/Bar.class"     ;; this is optional

(let ((bar (jnew (jconstructor "FOO.Bar3"))))
 (jcall (jmethod "FOO.Bar3" "a_method" "int" "int") bar 1 2))