<div dir="ltr">Thanks, Mark.  Here is a portion of what I am doing (written many years ago):<div><br></div><div><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt"><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt"><span style="color:rgb(0,0,128);font-weight:bold">public class </span>ABCL {<br>   <span style="color:rgb(0,0,128);font-weight:bold">private static </span>Interpreter <span style="color:rgb(102,14,122);font-style:italic">interpreter</span>;<br>   <span style="color:rgb(0,0,128);font-weight:bold">private static boolean </span><span style="color:rgb(102,14,122);font-style:italic">invertCase </span>= <span style="color:rgb(0,0,128);font-weight:bold">false</span>;<br>   <span style="color:rgb(0,0,128);font-weight:bold">private static </span>Function <span style="color:rgb(102,14,122);font-style:italic">makeWebServiceArgs</span>;<br>   <span style="color:rgb(0,0,128);font-weight:bold">private static int </span><span style="color:rgb(102,14,122);font-style:italic">lispRelease </span>= <span style="color:rgb(0,0,255)">0</span>;<br>   <span style="color:rgb(0,0,128);font-weight:bold">private static boolean </span><span style="color:rgb(102,14,122);font-style:italic">once </span>= <span style="color:rgb(0,0,128);font-weight:bold">true</span>;<br><br>   <span style="color:rgb(0,0,128);font-weight:bold">public static void </span>init() {  // only called once<br>      <span style="color:rgb(102,14,122);font-style:italic">interpreter </span>= Interpreter.<span style="font-style:italic">createInstance</span>();<br>      <span style="font-style:italic">invertCase</span>();<br><br>      <span style="font-style:italic">load</span>(<span style="color:rgb(0,128,0);font-weight:bold">"com/xxx/lisp/clos-utils"</span>);<br>      <span style="font-style:italic">load</span>(<span style="color:rgb(0,128,0);font-weight:bold">"com/xxx/lisp/package-lru"</span>);<br>      <span style="font-style:italic">load</span>(<span style="color:rgb(0,128,0);font-weight:bold">"com/xxx/lisp/utils"</span>);<br>      <span style="font-style:italic">load</span>(<span style="color:rgb(0,128,0);font-weight:bold">"com/xxx/lisp/mappings"</span>);<br>      <span style="color:rgb(102,14,122);font-style:italic">makeWebServiceArgs </span>= <span style="font-style:italic">findLispFunction</span>(<span style="color:rgb(0,128,0);font-weight:bold">"UTILS"</span>, <span style="color:rgb(0,128,0);font-weight:bold">"make-web-service-args"</span>); <span style="color:rgb(128,128,128);font-style:italic">// this line is repeated in multiple places<br></span><span style="color:rgb(128,128,128);font-style:italic">   </span>}<br><br>   <span style="color:rgb(0,0,128);font-weight:bold">private static void </span>invertCase() {<br>      <span style="color:rgb(102,14,122);font-style:italic">interpreter</span>.eval(<span style="color:rgb(0,128,0);font-weight:bold">"(setf (readtable-case *readtable*) :invert)"</span>);  <span style="color:rgb(128,128,128);font-style:italic">// make lisp case sensitive<br></span><span style="color:rgb(128,128,128);font-style:italic">      </span><span style="color:rgb(102,14,122);font-style:italic">invertCase </span>= <span style="color:rgb(0,0,128);font-weight:bold">true</span>;<br>   }<br><br>   <span style="color:rgb(0,0,128);font-weight:bold">public static </span>String fixCase(String symbol) {<br>      <span style="color:rgb(0,0,128);font-weight:bold">if </span>(<span style="color:rgb(102,14,122);font-style:italic">invertCase</span>) {<br>         <span style="color:rgb(0,0,128);font-weight:bold">int </span>ucl = <span style="color:rgb(0,0,255)">0</span>, lcl = <span style="color:rgb(0,0,255)">0</span>;<br>         <span style="color:rgb(0,0,128);font-weight:bold">char</span>[] vec = symbol.toCharArray();<br>         <span style="color:rgb(0,0,128);font-weight:bold">for </span>(<span style="color:rgb(0,0,128);font-weight:bold">int </span>i=<span style="color:rgb(0,0,255)">0 </span>; i < vec.<span style="color:rgb(102,14,122);font-weight:bold">length </span>&& (ucl == <span style="color:rgb(0,0,255)">0  </span>||  lcl == <span style="color:rgb(0,0,255)">0</span>) ; i++)<br>            <span style="color:rgb(0,0,128);font-weight:bold">if </span>(Character.<span style="font-style:italic">isUpperCase</span>(vec[i]))<br>               ucl++;<br>            <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(Character.<span style="font-style:italic">isLowerCase</span>(vec[i]))<br>               lcl++;<br>         <span style="color:rgb(0,0,128);font-weight:bold">if </span>(ucl != <span style="color:rgb(0,0,255)">0  </span>&&  lcl != <span style="color:rgb(0,0,255)">0  </span>||  ucl == <span style="color:rgb(0,0,255)">0  </span>&&  lcl == <span style="color:rgb(0,0,255)">0</span>)<br>            <span style="color:rgb(0,0,128);font-weight:bold">return </span>symbol;<br>         <span style="color:rgb(0,0,128);font-weight:bold">else<br></span><span style="color:rgb(0,0,128);font-weight:bold">            if </span>(ucl != <span style="color:rgb(0,0,255)">0</span>)<br>               <span style="color:rgb(0,0,128);font-weight:bold">return </span>symbol.toLowerCase();<br>            <span style="color:rgb(0,0,128);font-weight:bold">else<br></span><span style="color:rgb(0,0,128);font-weight:bold">               return </span>symbol.toUpperCase();<br>      } <span style="color:rgb(0,0,128);font-weight:bold">else<br></span><span style="color:rgb(0,0,128);font-weight:bold">         return </span>symbol.toUpperCase();<br>   }<br><br>   <span style="color:rgb(0,0,128);font-weight:bold">public static void </span>reset() {<br><span style="color:rgb(128,128,128);font-style:italic">//    if (interpreter == null)<br></span><span style="color:rgb(128,128,128);font-style:italic">//       return;<br></span><span style="color:rgb(128,128,128);font-style:italic">//    try {<br></span><span style="color:rgb(128,128,128);font-style:italic">//       interpreter.eval("(delete-package \"ARAHANT-UTILS\")");<br></span><span style="color:rgb(128,128,128);font-style:italic">//    } catch (Throwable t) {<br></span><span style="color:rgb(128,128,128);font-style:italic">//    }<br></span><span style="color:rgb(128,128,128);font-style:italic"><br></span><span style="color:rgb(128,128,128);font-style:italic">      </span><span style="color:rgb(0,0,128);font-weight:bold">if </span>(<span style="color:rgb(102,14,122);font-style:italic">interpreter </span>== <span style="color:rgb(0,0,128);font-weight:bold">null</span>)<br>         <span style="color:rgb(0,0,128);font-weight:bold">return</span>;<br>      <span style="color:rgb(0,0,128);font-weight:bold">try </span>{<br>         <span style="color:rgb(102,14,122);font-style:italic">interpreter</span>.eval(<span style="color:rgb(0,128,0);font-weight:bold">"(delete-package </span><span style="color:rgb(0,0,128);font-weight:bold">\"</span><span style="color:rgb(0,128,0);font-weight:bold">MAPPINGS</span><span style="color:rgb(0,0,128);font-weight:bold">\"</span><span style="color:rgb(0,128,0);font-weight:bold">)"</span>);<br>      } <span style="color:rgb(0,0,128);font-weight:bold">catch </span>(Throwable t) {<br>      }<br>      <span style="color:rgb(0,0,128);font-weight:bold">if </span>(<span style="color:rgb(102,14,122);font-style:italic">interpreter </span>== <span style="color:rgb(0,0,128);font-weight:bold">null</span>)<br>         <span style="color:rgb(0,0,128);font-weight:bold">return</span>;<br>      <span style="color:rgb(0,0,128);font-weight:bold">try </span>{<br>         <span style="color:rgb(102,14,122);font-style:italic">interpreter</span>.eval(<span style="color:rgb(0,128,0);font-weight:bold">"(delete-package </span><span style="color:rgb(0,0,128);font-weight:bold">\"</span><span style="color:rgb(0,128,0);font-weight:bold">UTILS</span><span style="color:rgb(0,0,128);font-weight:bold">\"</span><span style="color:rgb(0,128,0);font-weight:bold">)"</span>);<br>      } <span style="color:rgb(0,0,128);font-weight:bold">catch </span>(Throwable t) {<br>      }<br>      <span style="color:rgb(0,0,128);font-weight:bold">if </span>(<span style="color:rgb(102,14,122);font-style:italic">interpreter </span>== <span style="color:rgb(0,0,128);font-weight:bold">null</span>)<br>         <span style="color:rgb(0,0,128);font-weight:bold">return</span>;<br>      <span style="color:rgb(0,0,128);font-weight:bold">try </span>{<br>         <span style="color:rgb(102,14,122);font-style:italic">interpreter</span>.eval(<span style="color:rgb(0,128,0);font-weight:bold">"(delete-package </span><span style="color:rgb(0,0,128);font-weight:bold">\"</span><span style="color:rgb(0,128,0);font-weight:bold">PACKAGE-LRU</span><span style="color:rgb(0,0,128);font-weight:bold">\"</span><span style="color:rgb(0,128,0);font-weight:bold">)"</span>);<br>      } <span style="color:rgb(0,0,128);font-weight:bold">catch </span>(Throwable t) {<br>      }<br>      <span style="color:rgb(0,0,128);font-weight:bold">if </span>(<span style="color:rgb(102,14,122);font-style:italic">interpreter </span>== <span style="color:rgb(0,0,128);font-weight:bold">null</span>)<br>         <span style="color:rgb(0,0,128);font-weight:bold">return</span>;<br>      <span style="color:rgb(0,0,128);font-weight:bold">try </span>{<br>         <span style="color:rgb(102,14,122);font-style:italic">interpreter</span>.eval(<span style="color:rgb(0,128,0);font-weight:bold">"(delete-package </span><span style="color:rgb(0,0,128);font-weight:bold">\"</span><span style="color:rgb(0,128,0);font-weight:bold">CLOS-UTILS</span><span style="color:rgb(0,0,128);font-weight:bold">\"</span><span style="color:rgb(0,128,0);font-weight:bold">)"</span>);<br>      } <span style="color:rgb(0,0,128);font-weight:bold">catch </span>(Throwable t) {<br>      }<br>      <span style="font-style:italic">load</span>(<span style="color:rgb(0,128,0);font-weight:bold">"com/xxx/lisp/clos-utils"</span>);<br>      <span style="font-style:italic">load</span>(<span style="color:rgb(0,128,0);font-weight:bold">"com/xxx/lisp/package-lru"</span>);<br>      <span style="font-style:italic">load</span>(<span style="color:rgb(0,128,0);font-weight:bold">"com/xxx/lisp/utils"</span>);<br>      <span style="font-style:italic">load</span>(<span style="color:rgb(0,128,0);font-weight:bold">"com/xxx/lisp/mappings"</span>);<br>      <span style="color:rgb(102,14,122);font-style:italic">makeWebServiceArgs </span>= <span style="font-style:italic">findLispFunction</span>(<span style="color:rgb(0,128,0);font-weight:bold">"UTILS"</span>, <span style="color:rgb(0,128,0);font-weight:bold">"make-web-service-args"</span>); <span style="color:rgb(128,128,128);font-style:italic">// this line is repeated in multiple places<br></span><span style="color:rgb(128,128,128);font-style:italic">   </span>}<br><br>   <span style="color:rgb(0,0,128);font-weight:bold">public static </span>LispObject load(String fileName) {<br>      <span style="color:rgb(0,0,128);font-weight:bold">return </span><span style="font-style:italic">eval</span>(<span style="color:rgb(0,128,0);font-weight:bold">"(load </span><span style="color:rgb(0,0,128);font-weight:bold">\"</span><span style="color:rgb(0,128,0);font-weight:bold">" </span>+ FileSystemUtils.<span style="font-style:italic">getSourcePath</span>() + fileName + <span style="color:rgb(0,128,0);font-weight:bold">"</span><span style="color:rgb(0,0,128);font-weight:bold">\"</span><span style="color:rgb(0,128,0);font-weight:bold">)"</span>);<br>   }<br><br>   <span style="color:rgb(0,0,128);font-weight:bold">public static </span>LispObject compileFile(String fileName) {<br>      <span style="color:rgb(0,0,128);font-weight:bold">return </span><span style="font-style:italic">eval</span>(<span style="color:rgb(0,128,0);font-weight:bold">"(compile-file </span><span style="color:rgb(0,0,128);font-weight:bold">\"</span><span style="color:rgb(0,128,0);font-weight:bold">" </span>+ FileSystemUtils.<span style="font-style:italic">getSourcePath</span>() + fileName + <span style="color:rgb(0,128,0);font-weight:bold">"</span><span style="color:rgb(0,0,128);font-weight:bold">\"</span><span style="color:rgb(0,128,0);font-weight:bold">)"</span>);<br>   }<br><br>   <span style="color:rgb(0,0,128);font-weight:bold">public static void </span>loadPackage(String lispPackage, String fileName) <span style="color:rgb(0,0,128);font-weight:bold">throws </span>Exception {<br>      <span style="color:rgb(0,0,128);font-weight:bold">try </span>{<br>         <span style="font-style:italic">eval</span>(<span style="color:rgb(0,128,0);font-weight:bold">"(package-lru:load-package </span><span style="color:rgb(0,0,128);font-weight:bold">\"</span><span style="color:rgb(0,128,0);font-weight:bold">" </span>+ lispPackage + <span style="color:rgb(0,128,0);font-weight:bold">"</span><span style="color:rgb(0,0,128);font-weight:bold">\" \"</span><span style="color:rgb(0,128,0);font-weight:bold">" </span>+ FileSystemUtils.<span style="font-style:italic">getSourcePath</span>() + fileName + <span style="color:rgb(0,128,0);font-weight:bold">"</span><span style="color:rgb(0,0,128);font-weight:bold">\"</span><span style="color:rgb(0,128,0);font-weight:bold">)"</span>);<br>      } <span style="color:rgb(0,0,128);font-weight:bold">catch </span>(Throwable t) {<br>         <span style="color:rgb(128,128,128);font-style:italic">// Convert Throwable to Exception<br></span><span style="color:rgb(128,128,128);font-style:italic">         </span><span style="color:rgb(0,0,128);font-weight:bold">throw new </span>Exception(<span style="color:rgb(0,128,0);font-weight:bold">"Error loading lisp file " </span>+ fileName, t);<br>      }<br>   }<br><br>   <span style="color:rgb(0,0,128);font-weight:bold">public static void </span>packageDone(String lispPackage) {<br>      <span style="color:rgb(0,0,128);font-weight:bold">if </span>(FileSystemUtils.<span style="font-style:italic">isUnderIDE</span>())<br>         <span style="font-style:italic">eval</span>(<span style="color:rgb(0,128,0);font-weight:bold">"(package-lru:package-done-unload </span><span style="color:rgb(0,0,128);font-weight:bold">\"</span><span style="color:rgb(0,128,0);font-weight:bold">" </span>+ lispPackage + <span style="color:rgb(0,128,0);font-weight:bold">"</span><span style="color:rgb(0,0,128);font-weight:bold">\"</span><span style="color:rgb(0,128,0);font-weight:bold">)"</span>);<br>      <span style="color:rgb(0,0,128);font-weight:bold">else<br></span><span style="color:rgb(0,0,128);font-weight:bold">         </span><span style="font-style:italic">eval</span>(<span style="color:rgb(0,128,0);font-weight:bold">"(package-lru:package-done </span><span style="color:rgb(0,0,128);font-weight:bold">\"</span><span style="color:rgb(0,128,0);font-weight:bold">" </span>+ lispPackage + <span style="color:rgb(0,128,0);font-weight:bold">"</span><span style="color:rgb(0,0,128);font-weight:bold">\"</span><span style="color:rgb(0,128,0);font-weight:bold">)"</span>);<br>   }<br><br>    <span style="color:rgb(0,0,128);font-weight:bold">public static </span>LispObject eval(String str) {<br>        <span style="color:rgb(0,0,128);font-weight:bold">return </span><span style="color:rgb(102,14,122);font-style:italic">interpreter</span>.eval(str);<br>    }<br><br>    <span style="color:rgb(0,0,128);font-weight:bold">public static </span>Function findLispFunction(String packageName, String funName) {<br>        <span style="color:rgb(0,0,128);font-weight:bold">if </span>(packageName == <span style="color:rgb(0,0,128);font-weight:bold">null  </span>||  packageName.isEmpty())<br>            packageName = <span style="color:rgb(0,128,0);font-weight:bold">"CL-USER"</span>;<br><span style="color:rgb(128,128,128);font-style:italic">//        else<br></span><span style="color:rgb(128,128,128);font-style:italic">//            packageName = fixCase(packageName);<br></span><span style="color:rgb(128,128,128);font-style:italic">        </span>org.armedbear.lisp.Package lispPackage = Packages.<span style="font-style:italic">findPackage</span>(packageName);<br>      <span style="color:rgb(0,0,128);font-weight:bold">if </span>(lispPackage == <span style="color:rgb(0,0,128);font-weight:bold">null</span>)<br>         <span style="color:rgb(0,0,128);font-weight:bold">throw new </span>RuntimeException(<span style="color:rgb(0,128,0);font-weight:bold">"Package " </span>+ packageName + <span style="color:rgb(0,128,0);font-weight:bold">" not found"</span>);<br>        Symbol symbol = lispPackage.findAccessibleSymbol(<span style="font-style:italic">fixCase</span>(funName));<br>      <span style="color:rgb(0,0,128);font-weight:bold">if </span>(symbol == <span style="color:rgb(0,0,128);font-weight:bold">null</span>)<br>         <span style="color:rgb(0,0,128);font-weight:bold">throw new </span>RuntimeException(<span style="color:rgb(0,128,0);font-weight:bold">"Symbol " </span>+ packageName + <span style="color:rgb(0,128,0);font-weight:bold">":" </span>+ <span style="font-style:italic">fixCase</span>(funName) + <span style="color:rgb(0,128,0);font-weight:bold">" not found"</span>);<br>        Function fun = (Function) symbol.getSymbolFunction();<br>        <span style="color:rgb(0,0,128);font-weight:bold">return </span>fun;<br>    }<br><br>    <span style="color:rgb(0,0,128);font-weight:bold">public static </span>LispObject executeLispFunction(Function fun, Object ... args) {<br>        LispObject [] jargs;<br>        jargs = <span style="color:rgb(0,0,128);font-weight:bold">new </span>LispObject[args.<span style="color:rgb(102,14,122);font-weight:bold">length</span>];<br>        <span style="color:rgb(0,0,128);font-weight:bold">for </span>(<span style="color:rgb(0,0,128);font-weight:bold">int </span>i=<span style="color:rgb(0,0,255)">0 </span>; i < args.<span style="color:rgb(102,14,122);font-weight:bold">length </span>; i++)<br>            jargs[i] = JavaObject.<span style="font-style:italic">getInstance</span>(args[i], <span style="color:rgb(0,0,128);font-weight:bold">true</span>);<br>        <span style="color:rgb(0,0,128);font-weight:bold">return </span>fun.execute(jargs);<br>    }<br><br>    <span style="color:rgb(0,0,128);font-weight:bold">public static </span>LispObject executeLisp(String packageName, String funName, Object ... args) {<br>        Function fun = <span style="font-style:italic">findLispFunction</span>(packageName, funName);<br>      <span style="color:rgb(0,0,128);font-weight:bold">if </span>(fun == <span style="color:rgb(0,0,128);font-weight:bold">null</span>)<br>         <span style="color:rgb(0,0,128);font-weight:bold">return null</span>;<br>        LispObject [] jargs;<br>        jargs = <span style="color:rgb(0,0,128);font-weight:bold">new </span>LispObject[args.<span style="color:rgb(102,14,122);font-weight:bold">length</span>];<br>        <span style="color:rgb(0,0,128);font-weight:bold">for </span>(<span style="color:rgb(0,0,128);font-weight:bold">int </span>i=<span style="color:rgb(0,0,255)">0 </span>; i < args.<span style="color:rgb(102,14,122);font-weight:bold">length </span>; i++)<br>            jargs[i] = JavaObject.<span style="font-style:italic">getInstance</span>(args[i], <span style="color:rgb(0,0,128);font-weight:bold">true</span>);<br>        <span style="color:rgb(0,0,128);font-weight:bold">return </span>fun.execute(jargs);<br>    }<br><br>    <span style="color:rgb(0,0,128);font-weight:bold">public static </span>LispObject executeLispArray(String packageName, String funName, Object [] args) {<br>        Function fun = <span style="font-style:italic">findLispFunction</span>(packageName, funName);<br>      <span style="color:rgb(0,0,128);font-weight:bold">if </span>(fun == <span style="color:rgb(0,0,128);font-weight:bold">null</span>)<br>         <span style="color:rgb(0,0,128);font-weight:bold">return null</span>;<br>        LispObject [] jargs;<br>        jargs = <span style="color:rgb(0,0,128);font-weight:bold">new </span>LispObject[args.<span style="color:rgb(102,14,122);font-weight:bold">length</span>];<br>        <span style="color:rgb(0,0,128);font-weight:bold">for </span>(<span style="color:rgb(0,0,128);font-weight:bold">int </span>i=<span style="color:rgb(0,0,255)">0 </span>; i < args.<span style="color:rgb(102,14,122);font-weight:bold">length </span>; i++)<br>            jargs[i] = JavaObject.<span style="font-style:italic">getInstance</span>(args[i], <span style="color:rgb(0,0,128);font-weight:bold">true</span>);<br>        <span style="color:rgb(0,0,128);font-weight:bold">return </span>fun.execute(jargs);<br>    }<br><br>   <span style="color:rgb(0,0,128);font-weight:bold">public static </span>Function getMakeWebServiceArgs() {<br>      <span style="color:rgb(0,0,128);font-weight:bold">return </span><span style="color:rgb(102,14,122);font-style:italic">makeWebServiceArgs</span>;<br>   }<br><br><span style="color:rgb(128,128,0)">@SuppressWarnings</span>(<span style="color:rgb(0,128,0);font-weight:bold">"unchecked"</span>)<br>   <span style="color:rgb(0,0,128);font-weight:bold">public static </span>Object LispObjectToJavaObject(LispObject obj) {<br>      <span style="color:rgb(0,0,128);font-weight:bold">if </span>(obj.atom())<br>         <span style="color:rgb(0,0,128);font-weight:bold">if </span>(obj.characterp())<br>            <span style="color:rgb(0,0,128);font-weight:bold">return </span>obj.princToString().charAt(<span style="color:rgb(0,0,255)">0</span>);<br>         <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(obj.stringp())<br>            <span style="color:rgb(0,0,128);font-weight:bold">return </span>obj.princToString();<br>         <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(obj.integerp())<br>            <span style="color:rgb(0,0,128);font-weight:bold">return </span>obj.intValue();<br>         <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(obj.realp())<br>            <span style="color:rgb(0,0,128);font-weight:bold">return </span>obj.doubleValue();<br>         <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(obj.listp())<br>            <span style="color:rgb(0,0,128);font-weight:bold">return null</span>;<br>         <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(obj.constantp())<br>            <span style="color:rgb(0,0,128);font-weight:bold">return true</span>;<br>         <span style="color:rgb(0,0,128);font-weight:bold">else<br></span><span style="color:rgb(0,0,128);font-weight:bold">            return </span>obj.princToString();<br>      <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(obj.listp()) {<br>         LinkedList ll = <span style="color:rgb(0,0,128);font-weight:bold">new </span>LinkedList();<br>         <span style="color:rgb(0,0,128);font-weight:bold">while </span>(!obj.endp()) {<br>            ll.addLast(<span style="font-style:italic">LispObjectToJavaObject</span>(obj.car()));<br>            obj = obj.cdr();<br>         }<br>         <span style="color:rgb(0,0,128);font-weight:bold">return </span>ll;<br>      } <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(obj.vectorp()) {<br>         <span style="color:rgb(0,0,128);font-weight:bold">int </span>len = obj.length();<br>         Object [] vec = <span style="color:rgb(0,0,128);font-weight:bold">new </span>Object[len];<br>         <span style="color:rgb(0,0,128);font-weight:bold">for </span>(<span style="color:rgb(0,0,128);font-weight:bold">int </span>i=<span style="color:rgb(0,0,255)">0 </span>; i < len ; i++)<br>            vec[i] = <span style="font-style:italic">LispObjectToJavaObject</span>(obj.AREF(i));<br>         <span style="color:rgb(0,0,128);font-weight:bold">return </span>vec;<br>      } <span style="color:rgb(0,0,128);font-weight:bold">else<br></span><span style="color:rgb(0,0,128);font-weight:bold">         return null</span>;<br>   }<br><br>   <span style="color:rgb(0,0,128);font-weight:bold">public static </span>LispObject JavaObjectToLispObject(Object jobj) {<br>      <span style="color:rgb(0,0,128);font-weight:bold">if </span>(jobj <span style="color:rgb(0,0,128);font-weight:bold">instanceof </span>Boolean)<br>         <span style="color:rgb(0,0,128);font-weight:bold">return </span>((Boolean)jobj) ? Lisp.<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">T </span>: Lisp.<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">NIL</span>;<br>      <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(jobj <span style="color:rgb(0,0,128);font-weight:bold">instanceof </span>Character)<br>         <span style="color:rgb(0,0,128);font-weight:bold">return </span>LispCharacter.<span style="font-style:italic">getInstance</span>((Character)jobj);<br>      <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(jobj <span style="color:rgb(0,0,128);font-weight:bold">instanceof </span>Short)<br>         <span style="color:rgb(0,0,128);font-weight:bold">return </span>LispInteger.<span style="font-style:italic">getInstance</span>((Short)jobj);<br>      <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(jobj <span style="color:rgb(0,0,128);font-weight:bold">instanceof </span>Integer)<br>         <span style="color:rgb(0,0,128);font-weight:bold">return </span>LispInteger.<span style="font-style:italic">getInstance</span>((Integer)jobj);<br>      <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(jobj <span style="color:rgb(0,0,128);font-weight:bold">instanceof </span>Long)<br>         <span style="color:rgb(0,0,128);font-weight:bold">return </span>LispInteger.<span style="font-style:italic">getInstance</span>((Long)jobj);<br>      <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(jobj <span style="color:rgb(0,0,128);font-weight:bold">instanceof </span>Float)<br>         <span style="color:rgb(0,0,128);font-weight:bold">return </span>SingleFloat.<span style="font-style:italic">getInstance</span>((Float)jobj);<br>      <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(jobj <span style="color:rgb(0,0,128);font-weight:bold">instanceof </span>Double)<br>         <span style="color:rgb(0,0,128);font-weight:bold">return </span>DoubleFloat.<span style="font-style:italic">getInstance</span>((Double)jobj);<br>      <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(jobj <span style="color:rgb(0,0,128);font-weight:bold">instanceof </span>String)<br>         <span style="color:rgb(0,0,128);font-weight:bold">return new </span>SimpleString((String)jobj);<br>      <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(jobj <span style="color:rgb(0,0,128);font-weight:bold">instanceof </span>StringBuilder)<br>         <span style="color:rgb(0,0,128);font-weight:bold">return new </span>SimpleString((StringBuilder)jobj);<br>      <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(jobj <span style="color:rgb(0,0,128);font-weight:bold">instanceof </span>LinkedList) {<br>         LispObject lobj = Lisp.<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">NIL</span>;<br>         ListIterator it = ((LinkedList) jobj).listIterator();<br>         <span style="color:rgb(0,0,128);font-weight:bold">while </span>(it.hasNext())<br>            lobj = <span style="color:rgb(0,0,128);font-weight:bold">new </span>Cons(<span style="font-style:italic">JavaObjectToLispObject</span>(it.next()), lobj);<br>         <span style="color:rgb(0,0,128);font-weight:bold">return </span>lobj;<br>      } <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(jobj <span style="color:rgb(0,0,128);font-weight:bold">instanceof </span>Set) {<br>         LispObject lobj = Lisp.<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">NIL</span>;<br>         Iterator it = ((Set) jobj).iterator();<br>         <span style="color:rgb(0,0,128);font-weight:bold">while </span>(it.hasNext())<br>            lobj = <span style="color:rgb(0,0,128);font-weight:bold">new </span>Cons(<span style="font-style:italic">JavaObjectToLispObject</span>(it.next()), lobj);<br>         <span style="color:rgb(0,0,128);font-weight:bold">return </span>lobj;<br>      } <span style="color:rgb(0,0,128);font-weight:bold">else if </span>(jobj <span style="color:rgb(0,0,128);font-weight:bold">instanceof </span>Array) {<br>         Array a = (Array) jobj;<br>         <span style="color:rgb(0,0,128);font-weight:bold">int </span>len = Array.<span style="font-style:italic">getLength</span>(a);<br>         SimpleVector vec = <span style="color:rgb(0,0,128);font-weight:bold">new </span>SimpleVector(len);<br>         <span style="color:rgb(0,0,128);font-weight:bold">for </span>(<span style="color:rgb(0,0,128);font-weight:bold">int </span>i=<span style="color:rgb(0,0,255)">0 </span>; i < len ; i++)<br>            vec.setSlotValue(i, <span style="font-style:italic">JavaObjectToLispObject</span>(Array.<span style="font-style:italic">get</span>(a, i)));<br>         <span style="color:rgb(0,0,128);font-weight:bold">return null</span>;<br>      }<br>      <span style="color:rgb(0,0,128);font-weight:bold">return null</span>;<br>   }<br><br>   <span style="color:rgb(0,0,128);font-weight:bold">public static void </span>printStackTrace(Throwable e) {<br>      <span style="color:rgb(0,0,128);font-weight:bold">try </span>{<br>         Function fun = <span style="font-style:italic">findLispFunction</span>(<span style="color:rgb(0,128,0);font-weight:bold">"UTILS"</span>, <span style="color:rgb(0,128,0);font-weight:bold">"print-stack-trace"</span>);<br>         <span style="color:rgb(0,0,128);font-weight:bold">if </span>(fun != <span style="color:rgb(0,0,128);font-weight:bold">null</span>) {<br>            LispObject stackTrace = LispThread.<span style="font-style:italic">currentThread</span>().backtrace(<span style="color:rgb(0,0,255)">0</span>);<br>            <span style="color:rgb(0,0,128);font-weight:bold">if </span>(stackTrace != <span style="color:rgb(0,0,128);font-weight:bold">null </span>&& stackTrace != Lisp.<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">NIL</span>) {<br>               System.<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">err</span>.println(<span style="color:rgb(0,128,0);font-weight:bold">"Lisp execution error"</span>);<br>               fun.execute(stackTrace);<br>            }<br>         }<br>      } <span style="color:rgb(0,0,128);font-weight:bold">catch </span>(Throwable t) {<br>      }<br>      e.printStackTrace();<br>   }<br><span style="color:rgb(128,128,128);font-style:italic"><br></span><span style="color:rgb(128,128,128);font-style:italic">   </span><span style="color:rgb(0,0,128);font-weight:bold">public static int </span>getLispRelease() {<br>      <span style="color:rgb(0,0,128);font-weight:bold">return </span><span style="color:rgb(102,14,122);font-style:italic">lispRelease</span>;<br>   }<br><span style="color:rgb(128,128,128);font-style:italic"><br></span><span style="color:rgb(128,128,128);font-style:italic">   </span><span style="color:rgb(0,0,128);font-weight:bold">public static void </span>setLispRelease(<span style="color:rgb(0,0,128);font-weight:bold">int </span>lispRelease) {<br>      ABCL.<span style="color:rgb(102,14,122);font-style:italic">lispRelease </span>= lispRelease;<br>   }<br><br>}<br></pre><br></pre><br></div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 20, 2018 at 5:36 AM, Mark Evenson <span dir="ltr"><<a href="mailto:evenson@panix.com" target="_blank">evenson@panix.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
<br>
> On Apr 20, 2018, at 11:10, Blake McBride <<a href="mailto:blake@mcbride.name">blake@mcbride.name</a>> wrote:<br>
> <br>
> Greetings,<br>
> <br>
> Does ABCL safely support re-entrant and multi-entrant calls?  What I mean by that is the following:<br>
> <br>
> Re-entrant:  on a single OS thread - my Java program calls into ABCL, then ABCL calls into my Java application, and then the Java application calls back into ABCL.  So the stack has Java, ABCL, JAVA, and then ABCL again.<br>
> <br>
> Multi-entrant:  my Java application has many threads.  One of my threads calls into ABCL.  Then, while one thread is still in ABCL, another thread evokes ABCL.  So now we have two calls into ABCL by two independent Java/OS threads running at the same time.<br>
> <br>
> I understand the typical problems associated with application-level shared variables.  This is expected.  The question revolves around ABCL's internals.  I presume ABCL would have some shared data that is internal to ABCL.  That's what I am unclear about.  ABCL would have had to be designed for these scenarios from the ground up.<br>
> <br>
> This is a little hard to test because if it can't always correctly handle these situations, it may not become clear until certain scenarios arrive.  It may be hard for any "test" program I write to cause those scenarios, so I thought this may be a known answer.<br>
<br>
<br>
</span>As long as one is referencing the org.armedbear.lisp.Interpreter singleton for<br>
the calls into ABCL, everything should work fine.  Most of the logic can be<br>
understood by studying what [LispThread.java][1] does to mark global/local<br>
special variables, and how each Java thread is associated with a LispThread<br>
call stack.<br>
<br>
[1]: <a href="https://gitlab.common-lisp.net/abcl/abcl/blob/master/src/org/armedbear/lisp/LispThread.java#L55" rel="noreferrer" target="_blank">https://gitlab.common-lisp.<wbr>net/abcl/abcl/blob/master/src/<wbr>org/armedbear/lisp/LispThread.<wbr>java#L55</a><br>
<br>
How exactly are you calling into ABCL from Java?  A snippet of code would be<br>
useful.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
<br>
-- <br>
"A screaming comes across the sky.  It has happened before but there is nothing <br>
to compare to it now."<br>
<br>
<br>
<br>
<br>
<br>
</font></span></blockquote></div><br></div></div>