Commit 0b72635c authored by mevenson@1c010e3e-69d0-11dd-93a8-456734b0d56f's avatar mevenson@1c010e3e-69d0-11dd-93a8-456734b0d56f
Browse files

Restore Packages.findPackage() API for obtaining the current package in Java.

Restore examples/java-to-lisp-1/ to this use of
the API.

Fixes #324.
parent 05ce86f1
......@@ -19,7 +19,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import org.armedbear.lisp.*;
import org.armedbear.lisp.Function;
import org.armedbear.lisp.Interpreter;
import org.armedbear.lisp.Package;
import org.armedbear.lisp.Packages;
import org.armedbear.lisp.Symbol;
public class MainAlternative
......@@ -36,12 +40,11 @@ public class MainAlternative
interpreter.eval("(load \"lispfunction.lisp\")");
// the function is not in a separate package, thus the
// correct package is CL-USER. Symbol names are
// upper case. Package needs the prefix, because java
// also has a class named Package.
org.armedbear.lisp.Package defaultPackage =
Symbol sym =
// (usually) upper case.
Package defaultPackage
= Packages.findPackage("CL-USER");
Symbol sym
= defaultPackage.findAccessibleSymbol("LISPFUNCTION");
Function function = (Function) sym.getSymbolFunction();
......@@ -64,7 +64,7 @@ public final class Package extends LispObject implements
private transient ArrayList<String> nicknames;
private transient LispObject useList = null;
private transient ArrayList<Package> usedByList = null;
private transient ConcurrentHashMap<String, Package> localNicknames;
private transient ConcurrentHashMap<String, Package> localNicknames;
// Anonymous package.
public Package()
......@@ -86,6 +86,16 @@ public final class Packages
Returns the current package of the current LispThread.
Intended to be used from Java code manipulating an Interpreter
public static final synchronized Package findPackage(String name) {
return getCurrentPackage().findPackage(name);
// Finds package named `name'. Returns null if package doesn't exist.
// Called by Package.findPackage after checking package-local package
// nicknames.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment