Changeset 12427


Ignore:
Timestamp:
02/07/10 16:46:47 (11 years ago)
Author:
Mark Evenson
Message:

Fix ClassCastException? occuring when LOAD from streams.

File:
1 edited

Legend:

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

    r12426 r12427  
    405405        try {
    406406            thread.bindSpecial(Symbol.LOAD_PATHNAME, pathname);
    407             Pathname truePathname = new Pathname(((Pathname)truename).getNamestring());
    408             String type = truePathname.type.getStringValue();
    409             if (type.equals(COMPILE_FILE_TYPE)
    410                 || type.equals(COMPILE_FILE_INIT_FASL_TYPE.toString())) {
    411                 thread.bindSpecial(Symbol.LOAD_TRUENAME_FASL, truePathname);
    412             }
    413             if (truePathname.type.getStringValue().equals(COMPILE_FILE_INIT_FASL_TYPE.getStringValue())
    414                 && truePathname.isJar()) {
    415                 if (truePathname.device.cdr() != NIL ) {
    416                     // set truename to the enclosing JAR
    417                     truePathname.host = NIL;
    418                     truePathname.directory = NIL;
    419                     truePathname.name = NIL;
    420                     truePathname.type = NIL;
    421                     truePathname.invalidateNamestring();
     407
     408            // The motivation behind the following piece of complexity
     409            // is the need to preserve the semantics of
     410            // *LOAD-TRUENAME* as always containing the truename of
     411            // the current "Lisp file".  Since an ABCL packed FASL
     412            // actually has a Lisp file (aka "the init FASL") and one
     413            // or more Java classes from the compiler, we endeavor to
     414            // make *LOAD-TRUENAME* refer to the "overall" truename so
     415            // that a (LOAD *LOAD-TRUENAME*) would be equivalent to
     416            // reloading the complete current "Lisp file".  If this
     417            // value diverges from the "true" truename, we set the
     418            // symbol SYS::*LOAD-TRUENAME-FASL* to that divergent
     419            // value.  Currently the only code that uses this value is
     420            // Lisp.readFunctionBytes().
     421            Pathname truePathname = null;
     422            if (!truename.equals(NIL)) {
     423                truePathname = new Pathname(((Pathname)truename).getNamestring());
     424                String type = truePathname.type.getStringValue();
     425                if (type.equals(COMPILE_FILE_TYPE)
     426                    || type.equals(COMPILE_FILE_INIT_FASL_TYPE.toString())) {
     427                    thread.bindSpecial(Symbol.LOAD_TRUENAME_FASL, truePathname);
     428                }
     429                if (truePathname.type.getStringValue()
     430                    .equals(COMPILE_FILE_INIT_FASL_TYPE.getStringValue())
     431                    && truePathname.isJar()) {
     432                    if (truePathname.device.cdr() != NIL ) {
     433                        // set truename to the enclosing JAR
     434                        truePathname.host = NIL;
     435                        truePathname.directory = NIL;
     436                        truePathname.name = NIL;
     437                        truePathname.type = NIL;
     438                        truePathname.invalidateNamestring();
     439                    } else {
     440                        // XXX There is something fishy in the asymmetry
     441                        // between the "jar:jar:http:" and "jar:jar:file:"
     442                        // cases but this currently passes the tests.
     443                        if (!(truePathname.device.car() instanceof AbstractString)) {
     444                            truePathname = (Pathname)truePathname.device.car();
     445                            truePathname.invalidateNamestring();
     446                        }
     447                    }
     448                    thread.bindSpecial(Symbol.LOAD_TRUENAME, truePathname);
    422449                } else {
    423                     // XXX There is something fishy in the asymmetry
    424                     // between the "jar:jar:http:" and "jar:jar:file:"
    425                     // cases but this currently passes the tests.
    426                     if (!(truePathname.device.car() instanceof AbstractString)) {
    427                          truePathname = (Pathname)truePathname.device.car();
    428                          truePathname.invalidateNamestring();
    429                     }
    430                }
    431                 thread.bindSpecial(Symbol.LOAD_TRUENAME, truePathname);
     450                    thread.bindSpecial(Symbol.LOAD_TRUENAME, truename);
     451                }
    432452            } else {
    433453                thread.bindSpecial(Symbol.LOAD_TRUENAME, truename);
Note: See TracChangeset for help on using the changeset viewer.