source: trunk/abcl/doc/design/pathnames/abcl-jar-url.text @ 12433

Last change on this file since 12433 was 12433, checked in by Mark Evenson, 14 years ago

Update jar pathname design document with current implementation status.

File size: 6.4 KB
Line 
1JARs and JAR entries in ABCL
2============================
3
4Mark Evenson
5Created: 09 JAN 2010
6Modified: 08 FEB 2010
7
8Notes towards sketching an implementation of "jar:" references to be
9contained in PATHNAMEs within ABCL. 
10
11Goals
12-----
13
141.  Use Common Lisp pathnames to refer to entries in a JAR file.
15
16   
172.  Use 'jar:' schema as documented in java.net.JarURLConnection for
18    namestring representation.
19
20An entry in a JAR file:
21    #p"jar:file:baz.jar!/foo"
22   
23A JAR file:
24    #p"jar:file:baz.jar!/"
25
26A JAR file accessible via URL
27    #p"jar:http://example.org/abcl.jar!/"
28
29An entry in a ABCL FASL in a URL accessible JAR file
30    #p"jar:jar:http://example.org/abcl.jar!/foo.abcl!/foo-1.cls"
31
323.  MERGE-PATHNAMES working for JAR entries in the following use cases:
33
34    (merge-pathnames "foo-1.cls" "jar:jar:file:baz.jar!/foo.abcl!/foo._")
35    "jar:jar:file:baz.jar!/foo.abcl!/foo-1.cls"
36
37    (merge-pathnames "foo-1.cls" "jar:file:foo.abcl!/")
38    "jar:file:foo.abcl!/foo-1.cls"
39
404.  TRUENAME and PROBE-FILE working with "jar:"
41
424.1  TRUENAME cannonicalizing the JAR reference.
43
445.  DIRECTORY working within JAR files (and within JAR in JAR).
45
466.  References "jar:<URL>" for all strings <URL> that java.net.URL can
47    resolve works.
48
497.  Make jar pathnames work as a valid argument for OPEN.
50
518.  Enable the loading of ASDF systems packaged within jar files.
52
53Status
54------
55
56As of svn r12431, all the above goals have been implemented and tested
57*except* for:
58
595.  DIRECTORY working within JAR files
60
617.  Make jar pathnames work as a valid argument for OPEN.
62
63
64Implementation
65--------------
66
67Using PATHNAMES
68
69*   A PATHNAME refering to a file within a JAR is known as a JAR
70    PATHNAME.  It can either refer to the entire JAR file or an entry
71    within the JAR file.
72
73*   A JAR PATHNAME always has a DEVICE which is a proper list.  This
74    distinguishes it from other uses of Pathname. 
75
76*   The DEVICE of a JAR PATHNAME will be a list with either one or two
77    elements.  The first element of the JAR PATHNAME can be either a
78    PATHNAME representing a JAR on the filesystem, or a SimpleString
79    representing a URL.
80
81*   a PATHNAME occuring in the list in the DEVICE of a JAR PATHNAME is
82    known as a DEVICE PATHNAME.
83
84*   If the DEVICE is a String it must be a String that successfully
85    references a URL via the java.net.URL(String) constructor
86
87*   Only the first entry in the the DEVICE list may be a String.
88
89*   Otherwise the the DEVICE PATHAME denotes the PATHNAME of the JAR file
90
91*   The DEVICE PATHNAME list of enclosing JARs runs from outermost to
92    innermost.
93   
94
95
96Use Cases
97---------
98
99// UC1 -- JAR
100pathname: {
101  namestring: "jar:file:foo/baz.jar!/"
102  device: (
103    pathname: { 
104      device: "jar:file:"
105      directory: (:RELATIVE "foo")
106      name: "baz"
107      type: "jar"
108    }
109  )
110}
111
112
113// UC2 -- JAR entry
114pathname: {
115  namestring: "jar:file:baz.jar!/foo.abcl"
116  device: ( pathname: {
117    device: "jar:file:"
118    name: "baz"
119    type: "jar"
120  })
121  name: "foo"
122  type: "abcl"
123}
124
125
126// UC3 -- JAR file in a JAR entry
127pathname: {
128  namestring: "jar:jar:file:baz.jar!/foo.abcl!/"
129  device: (
130    pathname: {
131      name: "baz"
132      type: "jar"
133    }
134    pathname: {
135      name: "foo"
136      type: "abcl"
137    }
138  )
139}
140
141// UC4 -- JAR entry in a JAR entry with directories
142pathname: {
143  namestring: "jar:jar:file:a/baz.jar!/b/c/foo.abcl!/this/that/foo-20.cls"
144  device: (
145    pathname {
146      directory: (:RELATIVE "a")     
147      name: "bar"
148      type: "jar"
149    }
150    pathname {
151      directory: (:RELATIVE "b")
152      name: "foo"
153      type: "abcl"
154    }
155  )
156  directory: (:RELATIVE "this" "that")
157  name: "foo-20"
158  type: "cls"
159}
160
161// UC5 -- JAR Entry in a JAR Entry
162pathname: {
163  namestring: "jar:jar:file:a/foo/baz.jar!/foo.abcl!/a/b/bar-1.cls"
164  device: (
165    pathname: {
166      device: "jar:file:"
167      name: "baz"
168      type: "jar"
169    }
170    pathname: {
171      name: "foo"
172      type: "abcl"
173    }
174  )
175  name: "bar-1"
176  type: "cls"
177}
178
179// UC6 -- JAR entry in a http: accessible JAR file
180pathname: {
181  namestring: "jar:http://example.org/abcl.jar!/org/armedbear/lisp/Version.class",
182  device: (
183    "http://example.org/abcl.jar"
184    pathname: {
185      directory: (:relative "org" "armedbear" "lisp")
186      name: "Version"
187      type: "class"
188   }
189}
190
191// UC7 -- JAR Entry in a JAR Entry in a URL accessible JAR FILE
192pathname: {
193   namestring  "jar:jar:http://example.org/abcl.jar!/foo.abcl!/foo-1.cls"
194   device: (
195     "http://example.org/abcl.jar"
196     pathname: {
197       name: "foo"
198       type: "abcl"
199     }
200  )
201  name: "foo-1"
202  type: "cls"
203}
204
205// UC8 -- JAR in an absolute directory
206
207pathame: {
208   namestring: "jar:file:/a/b/foo.jar!/"
209   device: (
210     pathname: {
211       directory: (:ABSOLUTE "a" "b")
212       name: "foo"
213       type: "jar"
214     }
215   )
216}
217
218// UC9 -- JAR in an relative directory with entry
219pathname: {
220   namestring: "jar:file:a/b/foo.jar!/c/d/foo.lisp"
221   device: (
222     directory: (:RELATIVE "a" "b")
223     name: "foo"
224     type: "jar"
225   )
226   directory: (:RELATIVE "c" "d")
227   name: "foo"
228   type: "lisp
229}
230
231
232History
233-------
234
235Previously, ABCL did have some support for jar pathnames. This support
236used the convention that the if the device field was itself a
237pathname, the device pathname contained the location of the jar.
238
239In the analysis of the desire to treat jar pathnames as valid
240locations for LOAD, we determined that we needed a "double" pathname
241so we could refer to the components of a packed FASL in jar.  At first
242we thought we could support such a syntax by having the device
243pathname's device refer to the inner jar.  But with in this use of
244PATHNAMEs linked by the DEVICE field, we found the problem that UNC
245path support uses the DEVICE field so JARs located on UNC mounts can't
246be referenced. via '\\'.
247
248           i.e.  jar:jar:file:\\server\share\a\b\foo.jar!/this\that!/foo.java
249
250would not have a valid representation.
251
252So instead of having DEVICE point to a PATHNAME, we decided that the
253DEVICE shall be a list of PATHNAMES, so we would have:
254
255pathname: {
256  namestring: "jar:jar:file:\\server\share\foo.jar!/foo.abcl!/"
257  device: (
258            pathname: {
259              host: "server"
260              device: "share"
261              name: "foo"
262              type: "jar"
263            }
264            pathname: {
265              name: "foo"
266              type: "abcl"
267            }
268}
269
270Although there is a fair amount of special logic inside Pathname.java
271itself in the resulting implementation, the logic in Load.java seems
272to have been considerably simplified. 
273
Note: See TracBrowser for help on using the repository browser.