Changeset 15408
- Timestamp:
- 10/14/20 07:07:14 (2 years ago)
- Location:
- trunk/abcl
- Files:
-
- 4 added
- 4 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/JavaClassLoader.java
r15400 r15408 338 338 LispObject list = NIL; 339 339 for(URL u : ((URLClassLoader) o).getURLs()) { 340 list = list.push( PathnameURL.create(u));340 list = list.push(URLPathname.create(u)); 341 341 } 342 342 return new Cons(new JavaObject(o), list.nreverse()); -
trunk/abcl/src/org/armedbear/lisp/Load.java
r15406 r15408 171 171 172 172 if (ZipCache.checkZipFile(truename)) { 173 if (truename instanceof PathnameJar) {174 truename = PathnameJar.createFromEntry((PathnameJar)truename);173 if (truename instanceof JarPathname) { 174 truename = JarPathname.createFromEntry((JarPathname)truename); 175 175 } else { 176 truename = PathnameJar.createFromPathname(truename);176 truename = JarPathname.createFromPathname(truename); 177 177 } 178 178 Pathname loader = Pathname.create("__loader__._"); // FIXME use constants … … 323 323 } 324 324 if (!bootPath.equals(NIL)) { 325 Pathname urlPathname = (Pathname) PathnameURL.create(url);325 Pathname urlPathname = (Pathname)URLPathname.create(url); 326 326 loadableFile = findLoadableFile(urlPathname); 327 327 truename = (Pathname)Symbol.PROBE_FILE.execute(loadableFile); -
trunk/abcl/src/org/armedbear/lisp/Pathname.java
r15406 r15408 54 54 55 55 protected static Pathname create(Pathname p) { 56 if (p instanceof PathnameJar) {57 return ( PathnameJar)PathnameJar.create(p.getNamestring());58 } else if (p instanceof PathnameURL) {59 return ( PathnameURL)PathnameURL.create(((PathnameURL)p).getNamestringAsURI());56 if (p instanceof JarPathname) { 57 return (JarPathname)JarPathname.create(p.getNamestring()); 58 } else if (p instanceof URLPathname) { 59 return (URLPathname)URLPathname.create(((URLPathname)p).getNamestringAsURI()); 60 60 } else { 61 61 return new Pathname(p); … … 67 67 // which we can meaningfully parse. 68 68 69 if (s.startsWith( PathnameJar.JAR_URI_PREFIX)) {70 return PathnameJar.create(s);69 if (s.startsWith(JarPathname.JAR_URI_PREFIX)) { 70 return JarPathname.create(s); 71 71 } 72 72 if (isValidURL(s)) { 73 return PathnameURL.create(s);73 return URLPathname.create(s); 74 74 } else { 75 75 if (LogicalPathname.isValidLogicalPathname(s)) { … … 187 187 LispObject jars = p.getDevice(); 188 188 setDevice(NIL); 189 PathnameURL root = PathnameURL.create((Pathname)jars.car());189 URLPathname root = URLPathname.create((Pathname)jars.car()); 190 190 device = device.push(root); 191 191 jars = jars.cdr(); … … 318 318 319 319 // A JAR file 320 if (s.startsWith( PathnameJar.JAR_URI_PREFIX)321 && s.endsWith( PathnameJar.JAR_URI_SUFFIX)) {322 return ( PathnameJar)PathnameJar.create(s);320 if (s.startsWith(JarPathname.JAR_URI_PREFIX) 321 && s.endsWith(JarPathname.JAR_URI_SUFFIX)) { 322 return (JarPathname)JarPathname.create(s); 323 323 } 324 324 325 325 // An entry in a JAR file 326 final int separatorIndex = s.lastIndexOf( PathnameJar.JAR_URI_SUFFIX);327 if (separatorIndex > 0 && s.startsWith( PathnameJar.JAR_URI_PREFIX)) {328 return ( PathnameJar)PathnameJar.create(s);326 final int separatorIndex = s.lastIndexOf(JarPathname.JAR_URI_SUFFIX); 327 if (separatorIndex > 0 && s.startsWith(JarPathname.JAR_URI_PREFIX)) { 328 return (JarPathname)JarPathname.create(s); 329 329 } 330 330 … … 332 332 // pathname, and not a JAR file or an entry in a JAR file) 333 333 if (isValidURL(s)) { 334 return ( PathnameURL)PathnameURL.create(s);334 return (URLPathname)URLPathname.create(s); 335 335 } 336 336 … … 507 507 || isURL()); 508 508 if (isURL()) { 509 LispObject scheme = Symbol.GETF.execute(getHost(), PathnameURL.SCHEME, NIL);510 LispObject authority = Symbol.GETF.execute(getHost(), PathnameURL.AUTHORITY, NIL);509 LispObject scheme = Symbol.GETF.execute(getHost(), URLPathname.SCHEME, NIL); 510 LispObject authority = Symbol.GETF.execute(getHost(), URLPathname.AUTHORITY, NIL); 511 511 Debug.assertTrue(scheme != NIL); 512 512 sb.append(scheme.getStringValue()); … … 1226 1226 p.validateDirectory(true); 1227 1227 1228 // ??? need to check for downcast to PathnameURLas well?1229 // Possibly downcast type to PathnameJar1228 // ??? need to check for downcast to URLPathname as well? 1229 // Possibly downcast type to JarPathname 1230 1230 if (p.getDevice() instanceof Cons) { 1231 PathnameJar result = new PathnameJar();1231 JarPathname result = new JarPathname(); 1232 1232 result 1233 1233 .copyFrom(p) 1234 .setDevice( PathnameJar.makeJarDeviceFrom(p));1234 .setDevice(JarPathname.makeJarDeviceFrom(p)); 1235 1235 1236 1236 // sanity check that the pathname has been constructed correctly … … 1375 1375 LispObject result = NIL; 1376 1376 if (pathname.isJar()) { 1377 return PathnameJar.listDirectory((PathnameJar)pathname);1377 return JarPathname.listDirectory((JarPathname)pathname); 1378 1378 } 1379 1379 … … 1632 1632 d = Pathname.create(defaultPathname); 1633 1633 } else { 1634 if (pathname instanceof PathnameJar1634 if (pathname instanceof JarPathname 1635 1635 // If the defaults contain a JAR-PATHNAME, and the pathname 1636 1636 // to be be merged is not a JAR-PATHNAME, does not have a 1637 1637 // specified DEVICE or a specified HOST and has a NIL or 1638 1638 // relative directory then the result will be a JAR-PATHNAME. 1639 || (defaultPathname instanceof PathnameJar1640 && !(pathname instanceof PathnameJar)1639 || (defaultPathname instanceof JarPathname 1640 && !(pathname instanceof JarPathname) 1641 1641 && pathname.getHost().equals(NIL) 1642 1642 && pathname.getDevice().equals(NIL) 1643 1643 && (pathname.getDirectory().equals(NIL) 1644 1644 || pathname.getDirectory().car().equals(Keyword.RELATIVE)))) { 1645 result = PathnameJar.create();1646 } else if (pathname instanceof PathnameURL) {1647 result = PathnameURL.create();1645 result = JarPathname.create(); 1646 } else if (pathname instanceof URLPathname) { 1647 result = URLPathname.create(); 1648 1648 } else { 1649 1649 result = Pathname.create(); … … 1653 1653 d = LogicalPathname.translateLogicalPathname((LogicalPathname) defaultPathname); 1654 1654 } else { 1655 if (defaultPathname instanceof PathnameJar) {1656 d = PathnameJar.create((PathnameJar)defaultPathname);1657 } else if (defaultPathname instanceof PathnameURL) {1658 d = PathnameURL.create(defaultPathname);1655 if (defaultPathname instanceof JarPathname) { 1656 d = JarPathname.create((JarPathname)defaultPathname); 1657 } else if (defaultPathname instanceof URLPathname) { 1658 d = URLPathname.create(defaultPathname); 1659 1659 } else { 1660 1660 d = Pathname.create(defaultPathname); … … 1673 1673 result.setDevice(p.getDevice()); 1674 1674 } else { 1675 if (d instanceof PathnameJar1676 && p instanceof PathnameJar) {1675 if (d instanceof JarPathname 1676 && p instanceof JarPathname) { 1677 1677 result.setDevice(d.getDevice()); 1678 1678 } else { … … 1686 1686 // relative DIRECTORY, then on non-MSDOG, set its device to 1687 1687 // :UNSPECIFIC. 1688 if ((d instanceof PathnameJar)1689 && !(result instanceof PathnameJar)) {1688 if ((d instanceof JarPathname) 1689 && !(result instanceof JarPathname)) { 1690 1690 if (!Utilities.isPlatformWindows) { 1691 1691 result.setDevice(Keyword.UNSPECIFIC); … … 1701 1701 // default directory. 1702 1702 // if (pathname.isJar()) { 1703 // Pathname root = (( PathnameJar)result).getRootJar();1703 // Pathname root = ((JarPathname)result).getRootJar(); 1704 1704 1705 1705 … … 2134 2134 public boolean isLocalFile() { 2135 2135 if (getHost().equals(NIL) 2136 || Symbol.GETF.execute(getHost(), PathnameURL.SCHEME, NIL).equals("file")) {2136 || Symbol.GETF.execute(getHost(), URLPathname.SCHEME, NIL).equals("file")) { 2137 2137 return true; 2138 2138 } … … 2169 2169 2170 2170 boolean isRemote() { 2171 if (this instanceof PathnameURL) {2172 PathnameURL p = (PathnameURL) this;2173 LispObject scheme = Symbol.GETF.execute(p.getHost(), PathnameURL.SCHEME, NIL);2171 if (this instanceof URLPathname) { 2172 URLPathname p = (URLPathname) this; 2173 LispObject scheme = Symbol.GETF.execute(p.getHost(), URLPathname.SCHEME, NIL); 2174 2174 if (scheme.equals(NIL) 2175 2175 || p.getHost().getStringValue().equals("file")) { … … 2177 2177 } 2178 2178 return true; 2179 } else if (this instanceof PathnameJar) {2180 Pathname root = (Pathname) (( PathnameJar)this).getRootJar();2179 } else if (this instanceof JarPathname) { 2180 Pathname root = (Pathname) ((JarPathname)this).getRootJar(); 2181 2181 return root.isRemote(); 2182 2182 } else { -
trunk/abcl/src/org/armedbear/lisp/Site.java
r15400 r15408 58 58 LISP_HOME = NIL; 59 59 } else { 60 Pathname p = (Pathname) PathnameURL.create(url);60 Pathname p = (Pathname)URLPathname.create(url); 61 61 p.setName(NIL).setType(NIL); 62 62 LISP_HOME = p; -
trunk/abcl/src/org/armedbear/lisp/ZipCache.java
r15406 r15408 165 165 } 166 166 167 public static InputStream getEntryAsInputStream( PathnameJararchiveEntry) {168 PathnameJararchiveJar = archiveEntry.getArchive();167 public static InputStream getEntryAsInputStream(JarPathname archiveEntry) { 168 JarPathname archiveJar = archiveEntry.getArchive(); 169 169 Archive archive = ZipCache.getArchive(archiveJar); 170 170 InputStream result = archive.getEntryAsInputStream(archiveEntry); … … 182 182 // ZipFile via a CachedZipFile does not work because there is not 183 183 // a null arg constructor for ZipFile. 184 static HashMap< PathnameJar, Archive> cache = new HashMap<PathnameJar, Archive>();184 static HashMap<JarPathname, Archive> cache = new HashMap<JarPathname, Archive>(); 185 185 186 186 abstract static public class Archive { 187 PathnameJarroot;188 LinkedHashMap< PathnameJar, ZipEntry> entries189 = new LinkedHashMap< PathnameJar, ZipEntry>();187 JarPathname root; 188 LinkedHashMap<JarPathname, ZipEntry> entries 189 = new LinkedHashMap<JarPathname, ZipEntry>(); 190 190 long lastModified; 191 191 192 abstract InputStream getEntryAsInputStream( PathnameJarentry);193 abstract ZipEntry getEntry( PathnameJarentry);192 abstract InputStream getEntryAsInputStream(JarPathname entry); 193 abstract ZipEntry getEntry(JarPathname entry); 194 194 abstract void populateAllEntries(); 195 195 abstract void close(); … … 202 202 203 203 // TODO wrap in a weak reference to allow JVM to possibly reclaim memory 204 LinkedHashMap< PathnameJar, ByteArrayOutputStream> contents205 = new LinkedHashMap< PathnameJar, ByteArrayOutputStream>();206 207 public InputStream getEntryAsInputStream( PathnameJarentry) {204 LinkedHashMap<JarPathname, ByteArrayOutputStream> contents 205 = new LinkedHashMap<JarPathname, ByteArrayOutputStream>(); 206 207 public InputStream getEntryAsInputStream(JarPathname entry) { 208 208 ByteArrayOutputStream bytes = contents.get(entry); 209 209 if (bytes != null) { … … 215 215 boolean populated = false; 216 216 217 public ZipEntry getEntry( PathnameJarentry) {217 public ZipEntry getEntry(JarPathname entry) { 218 218 if (!populated) { 219 219 populateAllEntries(); … … 231 231 while ((entry = source.getNextEntry()) != null) { 232 232 String name = entry.getName(); 233 PathnameJarentryPathname234 = ( PathnameJar)PathnameJar.createEntryFromJar(root, name);233 JarPathname entryPathname 234 = (JarPathname)JarPathname.createEntryFromJar(root, name); 235 235 entries.put(entryPathname, entry); 236 236 ByteArrayOutputStream bytes … … 260 260 JarURLConnection connection; 261 261 262 public ArchiveURL( PathnameJarjar)262 public ArchiveURL(JarPathname jar) 263 263 throws java.io.IOException 264 264 { … … 289 289 ArchiveFile() {} 290 290 291 public ArchiveFile( PathnameJarjar)291 public ArchiveFile(JarPathname jar) 292 292 throws ZipException, IOException 293 293 { … … 298 298 } 299 299 300 public ZipEntry getEntry( PathnameJarentryPathname) {300 public ZipEntry getEntry(JarPathname entryPathname) { 301 301 ZipEntry result = entries.get(entryPathname); 302 302 if (result != null) { … … 332 332 ZipEntry entry = e.nextElement(); 333 333 String name = entry.getName(); 334 PathnameJarentryPathname335 = ( PathnameJar)PathnameJar.createEntryFromJar(root, name);334 JarPathname entryPathname 335 = (JarPathname)JarPathname.createEntryFromJar(root, name); 336 336 entries.put(entryPathname, entry); 337 337 } 338 338 } 339 339 340 InputStream getEntryAsInputStream( PathnameJarentry) {340 InputStream getEntryAsInputStream(JarPathname entry) { 341 341 InputStream result = null; 342 342 ZipEntry zipEntry = getEntry(entry); … … 376 376 } 377 377 378 synchronized public static LinkedHashMap< PathnameJar,ZipEntry> getEntries(PathnameJarjar) {378 synchronized public static LinkedHashMap<JarPathname,ZipEntry> getEntries(JarPathname jar) { 379 379 Archive archive = getArchive(jar); 380 380 archive.populateAllEntries(); // Very expensive for jars with large number of entries … … 382 382 } 383 383 384 synchronized public static Iterator<Map.Entry< PathnameJar,ZipEntry>> getEntriesIterator(PathnameJarjar) {385 LinkedHashMap< PathnameJar,ZipEntry> entries = getEntries(jar);386 Set<Map.Entry< PathnameJar,ZipEntry>> set = entries.entrySet();384 synchronized public static Iterator<Map.Entry<JarPathname,ZipEntry>> getEntriesIterator(JarPathname jar) { 385 LinkedHashMap<JarPathname,ZipEntry> entries = getEntries(jar); 386 Set<Map.Entry<JarPathname,ZipEntry>> set = entries.entrySet(); 387 387 return set.iterator(); 388 388 } 389 389 390 static ZipEntry getZipEntry( PathnameJararchiveEntry) {391 PathnameJararchiveJar = archiveEntry.getArchive();390 static ZipEntry getZipEntry(JarPathname archiveEntry) { 391 JarPathname archiveJar = archiveEntry.getArchive(); 392 392 Archive zip = getArchive(archiveJar); 393 393 ZipEntry entry = zip.getEntry(archiveEntry); … … 396 396 397 397 // ??? we assume that DIRECTORY, NAME, and TYPE components are NIL 398 synchronized public static Archive getArchive( PathnameJarjar) {398 synchronized public static Archive getArchive(JarPathname jar) { 399 399 Archive result = cache.get(jar); 400 400 if (result != null) { … … 412 412 return getArchiveFile(jar); 413 413 } else { 414 PathnameJar root = new PathnameJar();414 JarPathname root = new JarPathname(); 415 415 root.setDevice(new Cons(rootJar, NIL)); 416 416 ArchiveFile rootArchiveFile = (ArchiveFile)getArchiveFile(root); 417 417 418 PathnameJar innerArchive = new PathnameJar();418 JarPathname innerArchive = new JarPathname(); 419 419 Pathname nextJar = (Pathname)innerJars.car(); 420 420 LispObject jars = list(rootJar, nextJar); 421 421 innerArchive.setDevice(jars); 422 422 423 PathnameJar innerArchiveAsEntry = new PathnameJar();423 JarPathname innerArchiveAsEntry = new JarPathname(); 424 424 innerArchiveAsEntry 425 425 .setDevice(new Cons(rootJar, NIL)) … … 453 453 } 454 454 455 public static Archive getArchiveURL( PathnameJarjar) {455 public static Archive getArchiveURL(JarPathname jar) { 456 456 Pathname rootJar = (Pathname) jar.getRootJar(); 457 457 … … 470 470 } 471 471 472 static public Archive getArchiveFile( PathnameJarjar) {472 static public Archive getArchiveFile(JarPathname jar) { 473 473 try { 474 474 ArchiveFile result = new ArchiveFile(jar); … … 528 528 // Replace older item in cache 529 529 if (date == null || date.getTime() > archive.lastModified) { 530 PathnameJarroot = archive.root;530 JarPathname root = archive.root; 531 531 Archive entry = getArchiveURL(root); 532 532 cache.put(root, entry); … … 553 553 Pathname p = coerceToPathname(arg); 554 554 boolean result = false; 555 if (p instanceof PathnameJar) {556 result = ZipCache.remove(( PathnameJar)p);555 if (p instanceof JarPathname) { 556 result = ZipCache.remove((JarPathname)p); 557 557 } 558 558 return result ? T : NIL; … … 560 560 } 561 561 562 synchronized public static boolean remove( PathnameJarp) {562 synchronized public static boolean remove(JarPathname p) { 563 563 Archive archive = cache.get(p.getNamestring()); 564 564 if (archive != null) { -
trunk/abcl/src/org/armedbear/lisp/delete_file.java
r15406 r15408 68 68 if (defaultedPathname.isRemote()) { 69 69 return error(new FileError("Unable to delete remote pathnames", defaultedPathname)); 70 } else if (defaultedPathname instanceof PathnameJar) {71 PathnameJar jar = (PathnameJar)defaultedPathname;70 } else if (defaultedPathname instanceof JarPathname) { 71 JarPathname jar = (JarPathname)defaultedPathname; 72 72 Pathname root = (Pathname)jar.getRootJar(); 73 73 Cons jars = (Cons)jar.getJars(); -
trunk/abcl/src/org/armedbear/lisp/probe_file.java
r15406 r15408 61 61 } 62 62 // TODO: refactor Pathname{,Jar,URL}.truename() to be non-static? 63 if (p instanceof PathnameJar) {64 return PathnameJar.truename(p, false);65 } else if (p instanceof PathnameURL) {66 return PathnameURL.truename((PathnameURL)p, false);63 if (p instanceof JarPathname) { 64 return JarPathname.truename(p, false); 65 } else if (p instanceof URLPathname) { 66 return URLPathname.truename((URLPathname)p, false); 67 67 } else { 68 68 return Pathname.truename(p, false); … … 90 90 91 91 // TODO: refactor Pathname{,Jar,URL}.truename() to be non-static? 92 if (p instanceof PathnameJar) {93 return PathnameJar.truename(p, true);94 } else if (p instanceof PathnameURL) {95 return PathnameURL.truename((PathnameURL)p, true);92 if (p instanceof JarPathname) { 93 return JarPathname.truename(p, true); 94 } else if (p instanceof URLPathname) { 95 return URLPathname.truename((URLPathname)p, true); 96 96 } else { 97 97 return Pathname.truename(p, true); -
trunk/abcl/test/src/org/armedbear/lisp/PathnameTest.java
r15400 r15408 29 29 System.out.println(e.getMessage()); 30 30 } 31 Pathname pathname = (Pathname) PathnameURL.create(url);31 Pathname pathname = (Pathname)URLPathname.create(url); 32 32 assertNotNull(pathname); 33 33 assertNotNull(pathname.getNamestring()); … … 132 132 assertTrue("Java equals() for Pathname", result); 133 133 134 PathnameJar p3 = (PathnameJar)Pathname.create("jar:file:///abcl.jar!/tmp/");135 PathnameJar p4 = (PathnameJar)Pathname.create("jar:file:///abcl.jar!/tmp/");134 JarPathname p3 = (JarPathname)Pathname.create("jar:file:///abcl.jar!/tmp/"); 135 JarPathname p4 = (JarPathname)Pathname.create("jar:file:///abcl.jar!/tmp/"); 136 136 result = p3.equals(p4); 137 137 assertTrue("Java equals() for PathnameJar", result); -
trunk/abcl/test/src/org/armedbear/lisp/ZipTest.java
r15405 r15408 25 25 // (asdf-jar:package :cl-ppcre) 26 26 String nestedJarFile = "/var/tmp/cl-ppcre-all-2.1.1.jar"; 27 PathnameJarzip;28 PathnameJarnestedJar;27 JarPathname zip; 28 JarPathname nestedJar; 29 29 30 30 @Before 31 31 public void setup() { 32 zip = ( PathnameJar) PathnameJar.createFromFile(zipFile);33 nestedJar = ( PathnameJar) PathnameJar.createFromFile(nestedJarFile);32 zip = (JarPathname) JarPathname.createFromFile(zipFile); 33 nestedJar = (JarPathname) JarPathname.createFromFile(nestedJarFile); 34 34 } 35 35 … … 40 40 archive1 instanceof ZipCache.ArchiveFile 41 41 && ((ZipCache.ArchiveFile)archive1).file != null); 42 PathnameJarzip243 = ( PathnameJar) PathnameJar.createFromFile(zipFile);42 JarPathname zip2 43 = (JarPathname) JarPathname.createFromFile(zipFile); 44 44 ZipCache.Archive archive2 = ZipCache.getArchive(zip2); 45 45 assertTrue("Get cached ZipArchive from pathname", … … 53 53 public void getEntry() { 54 54 String entryPath = "abcl-asdf/abcl-asdf-tests.asd"; 55 PathnameJarentryPathname56 = ( PathnameJar) PathnameJar.createEntryFromFile(zipFile, entryPath);55 JarPathname entryPathname 56 = (JarPathname) JarPathname.createEntryFromFile(zipFile, entryPath); 57 57 ZipEntry entry = ZipCache.getZipEntry(entryPathname); 58 58 assertTrue("Getting entry from jar", 59 59 entry.getName().equals(entryPath)); 60 PathnameJarentryPathname261 = ( PathnameJar) PathnameJar.createEntryFromFile(zipFile, entryPath);60 JarPathname entryPathname2 61 = (JarPathname) JarPathname.createEntryFromFile(zipFile, entryPath); 62 62 ZipEntry entry2 = ZipCache.getZipEntry(entryPathname2); 63 63 assertTrue("Cached ZipEntry returns same object", … … 68 68 public void getNestedJar() { 69 69 String nestedNamestring = "jar:jar:file:/var/tmp/cl-ppcre-all-2.1.1.jar!/cl-ppcre/packages.abcl!/"; 70 PathnameJar nested = (PathnameJar)PathnameJar.create(nestedNamestring);70 JarPathname nested = (JarPathname)JarPathname.create(nestedNamestring); 71 71 ZipCache.Archive archive = ZipCache.getArchive(nested); 72 72 assertTrue("Able to retrieve nested jar archive",
Note: See TracChangeset
for help on using the changeset viewer.