Changeset 12524
- Timestamp:
- 03/11/10 15:49:05 (13 years ago)
- Location:
- trunk/abcl/src/org/armedbear/lisp
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/Debug.java
r12441 r12524 42 42 { 43 43 if (!b) { 44 System.err.println("Assertion failed!"); 45 Error e = new Error(); 44 String msg = "ABCL Debug.assertTrue() assertion failed!"; 45 System.err.println(msg); 46 Error e = new Error(msg); 46 47 e.printStackTrace(); 47 48 throw e; -
trunk/abcl/src/org/armedbear/lisp/Lisp.java
r12516 r12524 1227 1227 load = Pathname.mergePathnames(name, (Pathname) truename, Keyword.NEWEST); 1228 1228 } else { 1229 load = name; 1230 } 1231 InputStream input = load.getInputStream(); 1229 if (!Pathname.truename(name).equals(NIL)) { 1230 load = name; 1231 } else { 1232 load = null; 1233 } 1234 } 1235 InputStream input = null; 1236 if (load != null) { 1237 input = load.getInputStream(); 1238 } else { 1239 // Make a last-ditch attempt to load from the boot classpath XXX OSGi hack 1240 URL url = null; 1241 try { 1242 url = Lisp.class.getResource(name.getNamestring()); 1243 input = url.openStream(); 1244 } catch (IOException e) { 1245 error(new LispError("Failed to read class bytes from boot class " + url)); 1246 } 1247 } 1232 1248 byte[] bytes = new byte[4096]; 1233 1249 try { 1234 1250 if (input == null) { 1235 Debug.trace("Pathname: " + name);1236 Debug.trace("LOAD_TRUENAME_FASL: " + truenameFasl);1237 Debug.trace("LOAD_TRUENAME: " + truename);1238 Debug.assertTrue(input != null);1251 Debug.trace("Pathname: " + name); 1252 Debug.trace("LOAD_TRUENAME_FASL: " + truenameFasl); 1253 Debug.trace("LOAD_TRUENAME: " + truename); 1254 Debug.assertTrue(input != null); 1239 1255 } 1240 1256 -
trunk/abcl/src/org/armedbear/lisp/Load.java
r12513 r12524 253 253 Pathname truename = null; 254 254 pathname = new Pathname(filename); 255 Pathname mergedPathname = Pathname.mergePathnames(pathname, Site.getLispHome()); 255 LispObject bootPath = Site.getLispHome(); 256 Pathname mergedPathname; 257 if (bootPath instanceof Pathname) { 258 mergedPathname = Pathname.mergePathnames(pathname, (Pathname)bootPath); 259 } else { 260 mergedPathname = pathname; 261 } 262 URL url = null; 256 263 truename = findLoadableFile(mergedPathname); 257 if (truename == null || truename.equals(NIL) ) {264 if (truename == null || truename.equals(NIL) || bootPath.equals(NIL)) { 258 265 // Make an attempt to use the boot classpath 259 266 String path = pathname.asEntryPath(); 260 URLurl = Lisp.class.getResource(path);267 url = Lisp.class.getResource(path); 261 268 if (url == null || url.toString().endsWith("/")) { 262 269 url = Lisp.class.getResource(path + ".abcl"); … … 270 277 + " in boot classpath.")); 271 278 } 272 Pathname urlPathname = new Pathname(url); 273 truename = findLoadableFile(urlPathname); 274 if (truename == null) { 275 return error(new LispError("Failed to find loadable system file in boot classpath " 276 + "'" + url + "'")); 279 if (!bootPath.equals(NIL)) { 280 Pathname urlPathname = new Pathname(url); 281 truename = findLoadableFile(urlPathname); 282 if (truename == null) { 283 return error(new LispError("Failed to find loadable system file in boot classpath " 284 + "'" + url + "'")); 285 } 286 } else { 287 truename = null; // We can't represent the FASL in a Pathname (q.v. OSGi) 277 288 } 278 289 } 279 290 280 291 // Look for a init FASL inside a packed FASL 281 if (truename.type.writeToString().equals(COMPILE_FILE_TYPE) && Utilities.checkZipFile(truename)) { 292 if (truename != null 293 && truename.type.writeToString().equals(COMPILE_FILE_TYPE) && Utilities.checkZipFile(truename)) { 282 294 Pathname init = new Pathname(truename.getNamestring()); 283 295 init.type = COMPILE_FILE_INIT_FASL_TYPE; … … 291 303 } 292 304 293 in = truename.getInputStream(); 305 if (truename != null) { 306 in = truename.getInputStream(); 307 } else { 308 try { 309 Debug.assertTrue(url != null); 310 in = url.openStream(); 311 } catch (IOException e) { 312 error(new FileError("Failed to load system file: " 313 + "'" + filename + "'" 314 + " from URL: " 315 + "'" + url + "'")); 316 } 317 } 294 318 295 319 if (in != null) { … … 374 398 boolean auto) 375 399 { 376 return loadFileFromStream(pathname, truename, in, verbose, print, auto, false); 400 return loadFileFromStream(pathname == null ? NIL : pathname, 401 truename == null ? NIL : truename, 402 in, verbose, print, auto, false); 377 403 } 378 404 -
trunk/abcl/src/org/armedbear/lisp/Pathname.java
r12513 r12524 152 152 } 153 153 154 public static boolean isSupportedProtocol(String protocol) { 155 return "jar".equals(protocol) || "file".equals(protocol); 156 } 157 154 158 public Pathname(URL url) { 155 159 String protocol = url.getProtocol(); 160 if (!isSupportedProtocol(protocol)) { 161 error(new LispError("Unsupported URL: '" + url.toString() + "'")); 162 } 163 156 164 if ("jar".equals(protocol)) { 157 165 init(url.toString()); … … 182 190 } 183 191 } 184 error(new LispError("Unsupported URL: '" + url.toString() + "'")); 192 error(new LispError("Failed to construct Pathname from URL: " 193 + "'" + url.toString() + "'")); 185 194 } 186 195 -
trunk/abcl/src/org/armedbear/lisp/Site.java
r12422 r12524 43 43 public final class Site 44 44 { 45 private static PathnameLISP_HOME;45 private static LispObject LISP_HOME; 46 46 47 47 private static void init() { … … 50 50 String fileSeparator = System.getProperty("file.separator"); 51 51 if (!s.endsWith(fileSeparator)) { 52 s += fileSeparator; ;52 s += fileSeparator; 53 53 } 54 54 LISP_HOME = new Pathname(s); 55 return;56 55 } 57 56 URL url = Lisp.class.getResource("boot.lisp"); 58 57 if (url != null) { 59 LISP_HOME = new Pathname(url); 60 LISP_HOME.name = NIL; 61 LISP_HOME.type = NIL; 62 LISP_HOME.invalidateNamestring(); 58 if (!Pathname.isSupportedProtocol(url.getProtocol())) { 59 LISP_HOME = NIL; 60 } else { 61 Pathname p = new Pathname(url); 62 p.name = NIL; 63 p.type = NIL; 64 p.invalidateNamestring(); 65 LISP_HOME = p; 66 } 63 67 return; 64 68 } … … 66 70 } 67 71 68 69 public static final Pathname getLispHome() 72 public static final LispObject getLispHome() 70 73 { 71 74 if (LISP_HOME == null) { … … 80 83 81 84 static { 82 Pathnamep = Site.getLispHome();85 LispObject p = Site.getLispHome(); 83 86 if (p != null) 84 87 _LISP_HOME_.setSymbolValue(p);
Note: See TracChangeset
for help on using the changeset viewer.