Hi,<div><br></div><div>hopefully this is the correct list. If not please let me know.</div><div><br></div><div>Background:</div><div>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 :</div>
<div><br></div><div><div> (multiple-value-bind (class-file method-implementation-fields)</div><div> (apply #'java::%jnew-runtime-class class-name stream args)</div><div> (sys::put-memory-function memory-class-loader</div>
<div> class-name (sys::%get-output-stream-bytes stream))</div><div><b> (let ((jclass (java:jcall "loadClass" memory-class-loader class-name)))</b></div><div><b> (dolist (method method-implementation-fields)</b></div>
<div><b> (setf (java:jfield jclass (car method)) (cdr method)))</b></div><div> jclass))))</div></div><div><br></div><div><br></div><div><br></div><div>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:</div>
<div><br></div><div><div>(defvar *cf*)</div><div>(defvar *mif*)</div><div><br></div><div>(with-open-file (stream "test.class" :direction :output :element-type '(unsigned-byte 8))</div><div> (multiple-value-bind (class-file method-implementation-field)</div>
<div> (java::%jnew-runtime-class "test" stream :methods `(("forty_two_method1" :int () ,(lambda (this) 42))))</div><div> (setf *cf* class-file)</div><div> (setf *mif* method-implementation-field)))</div>
<div><br></div><div>(with-open-file (stream "test_forms" :direction :output)</div><div> (dolist (m *mif*)</div><div> (system:dump-form (list (car m) (function-lambda-expression (cdr m))) stream)))</div><div>
<br></div><div><br></div></div><div>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.</div><div><br></div><div>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.</div>
<div><br></div><div>I would e grateful for any advice.</div><div><br></div><div>Archi</div><div><br></div>