Changeset 13369


Ignore:
Timestamp:
07/01/11 14:00:27 (10 years ago)
Author:
Mark Evenson
Message:

Make JAVA:ADD-TO-CLASSPATH a generic function.

With this change we can customize the mechanism for changing the
classpath. The first planned use is for JSS to use an :after method
to be informed of classpath additions, so we can factor out the ASDF
portion into the ABCL-ASDF extension package.

Add JAVA:GET-CURRENT-CLASSLOADER to access a wrapped instance of the
underlying current JVM classloader being used by ABCL.

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/Autoload.java

    r13250 r13369  
    533533        autoload(PACKAGE_JAVA, "get-default-classloader", "JavaClassLoader");
    534534        autoload(PACKAGE_JAVA, "make-classloader", "JavaClassLoader");
    535         autoload(PACKAGE_JAVA, "add-to-classpath", "JavaClassLoader");
     535        autoload(PACKAGE_JAVA, "%add-to-classpath", "JavaClassLoader");
    536536        autoload(PACKAGE_JAVA, "dump-classpath", "JavaClassLoader");
    537537        autoload(PACKAGE_MOP, "funcallable-instance-function", "StandardGenericFunction", false);
  • trunk/abcl/src/org/armedbear/lisp/JavaClassLoader.java

    r13097 r13369  
    198198    };
    199199
    200     // ### add-to-classpath jar-or-jars &optional (classloader (get-current-classloader))
     200    private static final Primitive GET_CURRENT_CLASSLOADER = new pf_get_current_classloader();
     201    @DocString(name="get-current-classloader")
     202    private static final class pf_get_current_classloader extends Primitive {
     203        pf_get_current_classloader() {
     204            super("get-current-classloader", PACKAGE_JAVA, true);
     205        }
     206        @Override
     207        public LispObject execute() {
     208            return new JavaObject(getCurrentClassLoader());
     209        }
     210    };
     211       
     212    // ### %add-to-classpath jar-or-jars &optional (classloader (get-current-classloader))
    201213    private static final Primitive ADD_TO_CLASSPATH = new pf_add_to_classpath();
    202214    private static final class pf_add_to_classpath extends Primitive
     
    204216        pf_add_to_classpath()
    205217        {
    206             super("add-to-classpath", PACKAGE_JAVA, true, "jar-or-jars &optional (classloader (get-current-classloader))");
     218            super("%add-to-classpath", PACKAGE_JAVA, false,
     219                  "jar-or-jars &optional (classloader (get-current-classloader))");
    207220        }
    208221
  • trunk/abcl/src/org/armedbear/lisp/Symbol.java

    r13310 r13369  
    29772977    PACKAGE_JAVA.addExternalSymbol("JAVA-OBJECT");
    29782978  public static final Symbol JAVA_CLASS =
    2979       PACKAGE_JAVA.addExternalSymbol("JAVA-CLASS");
     2979    PACKAGE_JAVA.addExternalSymbol("JAVA-CLASS");
    29802980  public static final Symbol JCALL =
    29812981    PACKAGE_JAVA.addExternalSymbol("JCALL");
     
    29922992  public static final Symbol JRESOLVE_METHOD =
    29932993    PACKAGE_JAVA.addExternalSymbol("JRESOLVE-METHOD");
     2994  public static final Symbol ADD_TO_CLASSPATH =
     2995    PACKAGE_JAVA.addExternalSymbol("ADD-TO-CLASSPATH");
    29942996
    29952997  // External symbols in SYSTEM package.
  • trunk/abcl/src/org/armedbear/lisp/java.lisp

    r13368 r13369  
    4343  (dolist (url urls)
    4444    (add-url-to-classpath url)))
     45
     46(defgeneric add-to-classpath (jar-or-jars &optional classloader))
     47
     48(defmethod add-to-classpath (jar-or-jars &optional (classloader (get-current-classloader)))
     49  (%add-to-classpath jar-or-jars classloader))
    4550
    4651(defun jregister-handler (object event handler &key data count)
Note: See TracChangeset for help on using the changeset viewer.