Hi,
hopefully this is the correct list. If not please let me know.
Background:
I am trying to use abcl to generate jars to send off to a hadoop cluster
for execution. The svn version of the jnew-runtime-class does not store the
actual method bodies in the generated class file, but rather loads the
generated class file and sets the relevant field. Here is the relevant code
:
(multiple-value-bind (class-file method-implementation-fields)
(apply #'java::%jnew-runtime-class class-name stream args)
(sys::put-memory-function memory-class-loader
class-name (sys::%get-output-stream-bytes
stream))
* (let ((jclass (java:jcall "loadClass" memory-class-loader
class-name)))*
* (dolist (method method-implementation-fields)*
* (setf (java:jfield jclass (car method)) (cdr method)))*
jclass))))
This means that the generated jar file cannot be easily used from standard
java code. I would like to add some code in the static initialization block
of generated class file to do something equivalent. I will have to save the
lambda expression for the method and have been experimenting as follows:
(defvar *cf*)
(defvar *mif*)
(with-open-file (stream "test.class" :direction :output :element-type
'(unsigned-byte 8))
(multiple-value-bind (class-file method-implementation-field)
(java::%jnew-runtime-class "test" stream :methods
`(("forty_two_method1" :int () ,(lambda (this) 42))))
(setf *cf* class-file)
(setf *mif* method-implementation-field)))
(with-open-file (stream "test_forms" :direction :output)
(dolist (m *mif*)
(system:dump-form (list (car m) (function-lambda-expression (cdr m)))
stream)))
This assumes that the lambda expression does not refer to any variable or
user defined function, but perhaps the asdf-jar contrib might help here.
I was going to write the relevant code and start using it for my project,
but I was wondering if I am duplicating work that others have already done
or are doing and whether there are other libraries (jffli perhaps, I am not
very familiar with it) that have similar functionality. Also if there are
other interactions with other parts of the system that I am perhaps missing.
I would e grateful for any advice.
Archi