author | cg |
Thu, 23 Dec 1999 17:40:41 +0000 | |
changeset 641 | 79545e4f055c |
parent 615 | 2645eb9c9d3b |
child 648 | 33e16bf2722f |
permissions | -rw-r--r-- |
454 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
||
14 |
||
17 | 15 |
Object subclass:#Java |
557 | 16 |
instanceVariableNames:'' |
17 |
classVariableNames:'Classes UnresolvedClassRefs ClassPath SourceDirectories JavaHome |
|
18 |
Java_lang_String Java_lang_Class PrettyPrintStyle |
|
19 |
LastArgumentString Threads ExcludedClassPath FailedToLoadClasses' |
|
20 |
poolDictionaries:'' |
|
21 |
category:'Java-Support' |
|
17 | 22 |
! |
23 |
||
454 | 24 |
!Java class methodsFor:'documentation'! |
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
29 |
All Rights Reserved |
|
30 |
||
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
||
39 |
||
40 |
! ! |
|
17 | 41 |
|
135 | 42 |
!Java class methodsFor:'accessing'! |
24 | 43 |
|
147 | 44 |
classForName:aString |
45 |
"return a javaClass - either existing or loaded" |
|
46 |
||
255 | 47 |
|cls loader classURL| |
147 | 48 |
|
49 |
cls := self at:aString. |
|
50 |
cls isNil ifTrue:[ |
|
340
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
51 |
FailedToLoadClasses notNil ifTrue:[ |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
52 |
(FailedToLoadClasses includes:aString) ifTrue:[ |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
53 |
"/ ('JAVA [info]: class loading already failed: ' , aString) infoPrintCR. |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
54 |
^ nil |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
55 |
] |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
56 |
]. |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
57 |
|
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
58 |
('JAVA [info]: late class loading: ' , aString) infoPrintCR. |
548 | 59 |
loader := JavaClassReader classLoaderQuerySignal query. |
340
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
60 |
loader isNil ifTrue:[ |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
61 |
"/ load using default (ST/X) loader |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
62 |
cls := JavaClassReader loadClass:aString. |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
63 |
] ifFalse:[ |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
64 |
"/ load using a Java class loader |
255 | 65 |
"/ classURL := Java as_URL:('file:' , aString , '.class'). |
66 |
"/ loader loadClass:classURL. |
|
340
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
67 |
loader perform:#'loadClass(Ljava/lang/String;)Ljava/lang/Class;' |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
68 |
with:(Java as_String:aString). |
255 | 69 |
|
340
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
70 |
cls := self at:aString. |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
71 |
]. |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
72 |
cls isNil ifTrue:[ |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
73 |
FailedToLoadClasses isNil ifTrue:[ |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
74 |
FailedToLoadClasses := Set new. |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
75 |
]. |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
76 |
FailedToLoadClasses add:aString |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
77 |
] |
147 | 78 |
]. |
79 |
^ cls |
|
80 |
||
255 | 81 |
"Created: / 18.3.1997 / 16:45:57 / cg" |
340
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
82 |
"Modified: / 27.4.1998 / 15:00:52 / cg" |
147 | 83 |
! |
84 |
||
90 | 85 |
classNamed:aString |
86 |
^ self at:aString |
|
32 | 87 |
! |
88 |
||
167 | 89 |
java_lang_Class |
90 |
Java_lang_Class isNil ifTrue:[ |
|
552 | 91 |
Java_lang_Class := self at:'java.lang.Class' |
167 | 92 |
]. |
93 |
^ Java_lang_Class |
|
94 |
||
95 |
"Created: 26.3.1997 / 13:42:59 / cg" |
|
96 |
"Modified: 26.3.1997 / 13:46:24 / cg" |
|
97 |
! |
|
98 |
||
99 |
java_lang_String |
|
100 |
Java_lang_String isNil ifTrue:[ |
|
552 | 101 |
Java_lang_String := self at:'java.lang.String' |
167 | 102 |
]. |
103 |
^ Java_lang_String |
|
104 |
||
105 |
"Created: 26.3.1997 / 13:43:17 / cg" |
|
106 |
"Modified: 26.3.1997 / 13:50:21 / cg" |
|
76 | 107 |
! |
108 |
||
188 | 109 |
prettyPrintStyle |
110 |
^ PrettyPrintStyle |
|
111 |
||
112 |
"Created: 1.8.1997 / 10:37:57 / cg" |
|
248 | 113 |
! |
114 |
||
538 | 115 |
systemPropertyAt:key put:something |
116 |
JavaVM systemProperties at:key put:something |
|
117 |
||
118 |
"Created: / 9.1.1999 / 14:49:35 / cg" |
|
119 |
! |
|
120 |
||
248 | 121 |
threads |
122 |
Threads isNil ifTrue:[ |
|
552 | 123 |
Threads := WeakIdentityDictionary new. |
248 | 124 |
]. |
125 |
^ Threads |
|
126 |
||
127 |
"Created: 26.8.1997 / 19:53:57 / cg" |
|
128 |
"Modified: 26.8.1997 / 19:55:27 / cg" |
|
192 | 129 |
! ! |
130 |
||
131 |
!Java class methodsFor:'accessing paths'! |
|
132 |
||
133 |
addToClassPath:aPath |
|
134 |
(ClassPath includes:aPath) ifFalse:[ |
|
369 | 135 |
ClassPath add:aPath. |
136 |
FailedToLoadClasses := nil |
|
192 | 137 |
] |
138 |
||
369 | 139 |
"Created: / 1.8.1997 / 21:10:07 / cg" |
140 |
"Modified: / 17.9.1998 / 20:43:55 / cg" |
|
192 | 141 |
! |
142 |
||
198 | 143 |
addToSourcePath:aPath |
144 |
(SourceDirectories includes:aPath) ifFalse:[ |
|
552 | 145 |
SourceDirectories add:aPath |
198 | 146 |
] |
147 |
||
148 |
"Modified: 7.2.1997 / 19:23:55 / cg" |
|
149 |
"Created: 2.8.1997 / 14:12:31 / cg" |
|
150 |
! |
|
151 |
||
192 | 152 |
classPath |
153 |
^ ClassPath |
|
154 |
||
155 |
"Created: 7.2.1997 / 19:23:45 / cg" |
|
156 |
"Modified: 7.2.1997 / 19:23:55 / cg" |
|
157 |
! |
|
158 |
||
159 |
classPath:aCollectionOfPaths |
|
369 | 160 |
ClassPath := aCollectionOfPaths asOrderedCollection. |
161 |
FailedToLoadClasses := nil |
|
192 | 162 |
|
369 | 163 |
"Created: / 7.2.1997 / 19:23:45 / cg" |
164 |
"Modified: / 17.9.1998 / 20:44:09 / cg" |
|
192 | 165 |
! |
166 |
||
276 | 167 |
excludedClassPath |
168 |
^ ExcludedClassPath |
|
169 |
||
170 |
"Modified: / 7.2.1997 / 19:23:55 / cg" |
|
171 |
"Created: / 27.1.1998 / 21:57:13 / cg" |
|
172 |
! |
|
173 |
||
174 |
isExcludedFromClassPath:fileName |
|
175 |
|nm| |
|
176 |
||
177 |
nm := fileName asFilename pathName. |
|
178 |
ExcludedClassPath do:[:excludedPath | |
|
179 |
(nm startsWith:excludedPath) ifTrue:[^ true]. |
|
180 |
]. |
|
181 |
^ false |
|
182 |
||
183 |
"Created: / 27.1.1998 / 22:00:40 / cg" |
|
184 |
! |
|
185 |
||
201 | 186 |
javaHome |
187 |
^ JavaHome |
|
188 |
||
189 |
"Created: 6.8.1997 / 00:53:19 / cg" |
|
190 |
! |
|
191 |
||
192 |
javaHome:aPath |
|
193 |
JavaHome := aPath |
|
194 |
||
195 |
"Created: 6.8.1997 / 00:53:23 / cg" |
|
196 |
! |
|
197 |
||
192 | 198 |
removeFromClassPath:aPath |
199 |
(ClassPath includes:aPath) ifTrue:[ |
|
552 | 200 |
ClassPath remove:aPath |
192 | 201 |
] |
202 |
||
203 |
"Modified: 7.2.1997 / 19:23:55 / cg" |
|
204 |
"Created: 1.8.1997 / 21:10:21 / cg" |
|
188 | 205 |
! |
206 |
||
198 | 207 |
removeFromSourcePath:aPath |
208 |
(SourceDirectories includes:aPath) ifTrue:[ |
|
552 | 209 |
SourceDirectories remove:aPath |
198 | 210 |
] |
211 |
||
212 |
"Modified: 7.2.1997 / 19:23:55 / cg" |
|
213 |
"Created: 2.8.1997 / 14:13:01 / cg" |
|
214 |
! |
|
215 |
||
76 | 216 |
sourceDirectories |
217 |
^ SourceDirectories |
|
218 |
! |
|
219 |
||
220 |
sourceDirectories:aCollectionOfPaths |
|
221 |
SourceDirectories := aCollectionOfPaths asOrderedCollection |
|
222 |
||
223 |
" |
|
224 |
Java |
|
552 | 225 |
sourceDirectories:#( |
226 |
'/phys/ibm3/java/src' |
|
227 |
) |
|
76 | 228 |
" |
229 |
||
230 |
||
261 | 231 |
! |
232 |
||
233 |
sourcePath |
|
234 |
^ SourceDirectories |
|
235 |
||
236 |
"Created: / 16.1.1998 / 13:26:55 / cg" |
|
24 | 237 |
! ! |
238 |
||
135 | 239 |
!Java class methodsFor:'class initialization'! |
47 | 240 |
|
241 |
initAllClasses |
|
340
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
242 |
|system| |
147 | 243 |
|
340
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
244 |
FailedToLoadClasses := nil. |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
245 |
self initAllStaticFields. |
147 | 246 |
|
340
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
247 |
system := self classForName:'java.lang.System'. |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
248 |
system isInitialized ifFalse:[ |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
249 |
self initSystemClass. |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
250 |
]. |
147 | 251 |
|
340
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
252 |
self allClassesDo:[:cls | |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
253 |
cls isInitialized ifFalse:[ |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
254 |
cls classInit |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
255 |
] |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
256 |
] |
47 | 257 |
|
509 | 258 |
" |
259 |
Java initAllClasses |
|
260 |
" |
|
261 |
||
262 |
"Modified: / 27.11.1998 / 00:33:05 / cg" |
|
47 | 263 |
! |
264 |
||
102 | 265 |
initAllStaticFields |
266 |
self allClassesDo:[:cls | |
|
552 | 267 |
cls initializeStaticFields |
102 | 268 |
] |
269 |
||
270 |
! |
|
271 |
||
146 | 272 |
initSystemClass |
198 | 273 |
|system| |
274 |
||
275 |
system := Java at:'java.lang.System'. |
|
255 | 276 |
system isNil ifTrue:[ |
542 | 277 |
"/ JavaVM initializeVM. |
278 |
"/ system := Java at:'java.lang.System'. |
|
279 |
"/ system isNil ifTrue:[ |
|
550 | 280 |
self warn:'JavaVM: no ''' , 'java.lang.System' asText allBold , ''' class.'. |
281 |
"/ self error:'no ''java.lang.System'' class'. |
|
261 | 282 |
^ self |
542 | 283 |
"/ ]. |
255 | 284 |
]. |
429 | 285 |
|
286 |
system classInit. |
|
200 | 287 |
(system implements:#'initializeSystemClass()V') ifTrue:[ |
414 | 288 |
system perform: "invokeStatic:" #'initializeSystemClass()V'. |
198 | 289 |
]. |
146 | 290 |
|
147 | 291 |
" |
292 |
Java initSystemClass |
|
215 | 293 |
|
294 |
(Java at:'java.lang.System') |
|
261 | 295 |
perform:#'getProperty(Ljava/lang/String;)Ljava/lang/String;' |
255 | 296 |
with:(Java as_String:'java.home') |
147 | 297 |
" |
298 |
||
429 | 299 |
"Modified: / 10.11.1998 / 12:39:58 / cg" |
146 | 300 |
! |
301 |
||
76 | 302 |
initialize |
602 | 303 |
|tryJDK1_2 tryJDK1_2beta tryJDK1_17 tryJDK1_16 tryJDK1_15 tryJDK1_13 tryJDK1_11 tryJDK1_03 |
567 | 304 |
tryJDK1_02 directoriesToSearch possibleJavaDirs |
381 | 305 |
jHome jClasses jSources mozillaHome tryNetscape4_0 |
641 | 306 |
tryMS tryBorland tryVA tryJRE1_1 fn d| |
364 | 307 |
|
567 | 308 |
"/ those dirs are tried to search for a java system ... |
309 |
possibleJavaDirs := #( |
|
310 |
'/opt' |
|
311 |
'/opt/java' |
|
312 |
'/home/java' |
|
313 |
'/home2/java' |
|
314 |
'/phys/exept/home2/java' |
|
315 |
'/usr/local/java' |
|
602 | 316 |
'/usr/local/lib' |
567 | 317 |
'/usr/local' |
602 | 318 |
'/usr/lib' |
567 | 319 |
'/usr/java' |
320 |
'/usr' |
|
321 |
'c:\' |
|
322 |
'c:\java\' |
|
323 |
'c:\Programs\' |
|
324 |
'c:\Programme\' |
|
325 |
'c:\Program Files\' |
|
326 |
'c:\Program Files\JavaSoft\' |
|
327 |
'c:\Program Files\JavaSoft\JRE\' |
|
606 | 328 |
'd:\' |
329 |
'd:\java\' |
|
330 |
'd:\Programs\' |
|
331 |
'd:\Programme\' |
|
332 |
'd:\Program Files\' |
|
333 |
'd:\Program Files\JavaSoft\' |
|
334 |
'd:\Program Files\JavaSoft\JRE\' |
|
567 | 335 |
'\\exept\home2\java\' |
336 |
'\\exept\cg\home2\java\' |
|
337 |
). |
|
338 |
||
339 |
possibleJavaDirs := possibleJavaDirs collect:[:dirName | dirName asFilename]. |
|
340 |
possibleJavaDirs := possibleJavaDirs select:[:dir | dir exists]. |
|
341 |
possibleJavaDirs := possibleJavaDirs select:[:dir | dir isDirectory]. |
|
342 |
||
364 | 343 |
FailedToLoadClasses := nil. |
283 | 344 |
|
345 |
"/ cannot use JDK1.2 yet (they made so many changes ...) |
|
559 | 346 |
"/ tryJDK1_2 := true. |
347 |
"/ tryJDK1_2beta := true. |
|
348 |
||
349 |
"/ cannot use those yet (they also made changes ...) |
|
557 | 350 |
"/ tryVA := true. |
351 |
"/ tryNetscape4_0 := true. |
|
352 |
"/ tryMS := true. |
|
559 | 353 |
|
381 | 354 |
tryBorland := true. |
607 | 355 |
"/ tryJDK1_17 := true. "/ needs String_intern |
372 | 356 |
tryJDK1_16 := true. |
364 | 357 |
tryJDK1_15 := true. |
358 |
tryJDK1_13 := true. |
|
372 | 359 |
tryJDK1_11 := true. |
557 | 360 |
"/ tryJDK1_03 := false. |
361 |
"/ tryJDK1_02 := false. |
|
457 | 362 |
|
559 | 363 |
tryJRE1_1 := true. |
364 |
||
276 | 365 |
ExcludedClassPath := OrderedCollection new. |
366 |
||
364 | 367 |
directoriesToSearch := OrderedCollection new. |
381 | 368 |
|
559 | 369 |
tryJRE1_1 == true ifTrue:[ |
567 | 370 |
possibleJavaDirs do:[:d | |
371 |
directoriesToSearch add:(d construct:'JRE\1.1'). |
|
372 |
directoriesToSearch add:(d construct:'JRE/1.1'). |
|
373 |
] |
|
559 | 374 |
]. |
557 | 375 |
tryVA == true ifTrue:[ |
567 | 376 |
directoriesToSearch add:('C:\IBMVJava\EAB\jdk' asFilename). |
407 | 377 |
]. |
557 | 378 |
tryBorland == true ifTrue:[ |
567 | 379 |
directoriesToSearch add:('c:\jbuilder2\java' asFilename). |
381 | 380 |
]. |
457 | 381 |
|
557 | 382 |
tryMS == true ifTrue:[ |
457 | 383 |
"/ (fn := 'c:\windows\java\classes' asFilename) exists ifTrue:[ |
567 | 384 |
"/ directoriesToSearch add:('c:\windows\java\classes' asFilename). |
457 | 385 |
"/ fn directoryContents do:[:f | |
386 |
"/ (f asFilename hasSuffix:'zip') ifTrue:[ |
|
567 | 387 |
"/ directoriesToSearch add:(fn construct:f) |
457 | 388 |
"/ ] |
389 |
"/ ] |
|
390 |
"/ ]. |
|
391 |
(fn := 'c:\windows\java\packages' asFilename) exists ifTrue:[ |
|
392 |
fn directoryContents do:[:f | |
|
381 | 393 |
(f asFilename hasSuffix:'zip') ifTrue:[ |
567 | 394 |
directoriesToSearch add:(fn construct:f) |
381 | 395 |
] |
396 |
] |
|
397 |
]. |
|
457 | 398 |
(fn := 'c:\windows\java\trustlib' asFilename) exists ifTrue:[ |
399 |
fn directoryContents do:[:f | |
|
381 | 400 |
(f asFilename hasSuffix:'zip') ifTrue:[ |
567 | 401 |
directoriesToSearch add:(fn construct:f) |
381 | 402 |
] |
403 |
] |
|
404 |
] |
|
405 |
]. |
|
457 | 406 |
|
567 | 407 |
tryJDK1_2 == true ifTrue:[ |
408 |
possibleJavaDirs do:[:d | |
|
409 |
directoriesToSearch add:(d construct:'jdk1.2'). |
|
410 |
directoriesToSearch add:(d construct:'jdk12'). |
|
411 |
] |
|
364 | 412 |
]. |
457 | 413 |
|
557 | 414 |
tryJDK1_2beta == true ifTrue:[ |
567 | 415 |
possibleJavaDirs do:[:d | |
416 |
directoriesToSearch add:(d construct:'jdk12beta2'). |
|
417 |
directoriesToSearch add:(d construct:'jdk1.2beta2'). |
|
418 |
] |
|
552 | 419 |
]. |
420 |
||
602 | 421 |
tryJDK1_17 == true ifTrue:[ |
422 |
possibleJavaDirs do:[:d | |
|
423 |
directoriesToSearch add:(d construct:'jdk117'). |
|
424 |
directoriesToSearch add:(d construct:'jdk1.1.7'). |
|
425 |
] |
|
426 |
]. |
|
427 |
||
557 | 428 |
tryJDK1_16 == true ifTrue:[ |
567 | 429 |
possibleJavaDirs do:[:d | |
430 |
directoriesToSearch add:(d construct:'jdk116'). |
|
431 |
directoriesToSearch add:(d construct:'jdk1.1.6'). |
|
432 |
] |
|
372 | 433 |
]. |
457 | 434 |
|
557 | 435 |
tryJDK1_15 == true ifTrue:[ |
567 | 436 |
possibleJavaDirs do:[:d | |
437 |
directoriesToSearch add:(d construct:'jdk115'). |
|
438 |
directoriesToSearch add:(d construct:'jdk1.1.5'). |
|
439 |
] |
|
283 | 440 |
]. |
457 | 441 |
|
557 | 442 |
tryJDK1_13 == true ifTrue:[ |
567 | 443 |
possibleJavaDirs do:[:d | |
444 |
directoriesToSearch add:(d construct:'jdk113'). |
|
445 |
directoriesToSearch add:(d construct:'jdk1.1.3'). |
|
446 |
] |
|
364 | 447 |
]. |
457 | 448 |
|
557 | 449 |
tryJDK1_11 == true ifTrue:[ |
567 | 450 |
possibleJavaDirs do:[:d | |
451 |
directoriesToSearch add:(d construct:'jdk111'). |
|
452 |
directoriesToSearch add:(d construct:'jdk1.1.1'). |
|
453 |
] |
|
372 | 454 |
]. |
457 | 455 |
|
557 | 456 |
tryJDK1_03 == true ifTrue:[ |
567 | 457 |
possibleJavaDirs do:[:d | |
458 |
directoriesToSearch add:(d construct:'jdk103'). |
|
459 |
directoriesToSearch add:(d construct:'jdk1.0.3'). |
|
460 |
] |
|
372 | 461 |
]. |
364 | 462 |
|
557 | 463 |
tryJDK1_02 == true ifTrue:[ |
567 | 464 |
possibleJavaDirs do:[:d | |
465 |
directoriesToSearch add:(d construct:'jdk102'). |
|
466 |
directoriesToSearch add:(d construct:'jdk1.0.2'). |
|
467 |
] |
|
550 | 468 |
]. |
567 | 469 |
directoriesToSearch := directoriesToSearch collect:[:dirName | dirName asFilename]. |
470 |
directoriesToSearch := directoriesToSearch select:[:dir | dir exists]. |
|
471 |
directoriesToSearch := directoriesToSearch select:[:dir | dir isDirectory]. |
|
550 | 472 |
|
457 | 473 |
jClasses := OrderedCollection new. |
474 |
||
364 | 475 |
directoriesToSearch do:[:aPath | |
476 |
|dir libDir| |
|
477 |
||
478 |
dir := aPath asFilename. |
|
479 |
(jHome isNil and:[dir exists]) ifTrue:[ |
|
381 | 480 |
((dir hasSuffix:'jar') |
481 |
or:[dir hasSuffix:'zip']) ifTrue:[ |
|
457 | 482 |
jClasses add:dir. |
381 | 483 |
] ifFalse:[ |
484 |
||
485 |
"/ there must be either a classes directory, |
|
486 |
"/ or a classes.zip file ... |
|
487 |
(libDir := dir construct:'lib') exists ifTrue:[ |
|
615 | 488 |
((libDir construct:'classes') exists |
489 |
and:[(libDir construct:'classes') isDirectory]) ifTrue:[ |
|
381 | 490 |
jHome := aPath. |
615 | 491 |
jClasses add:(libDir constructString:'classes'). |
381 | 492 |
] ifFalse:[ |
615 | 493 |
(libDir construct:'classes.zip') exists ifTrue:[ |
559 | 494 |
jHome := aPath. |
615 | 495 |
jClasses add:(libDir constructString:'classes.zip'). |
559 | 496 |
] ifFalse:[ |
615 | 497 |
(libDir construct:'rt.zip') exists ifTrue:[ |
498 |
jHome := aPath. |
|
499 |
jClasses add:(libDir constructString:'rt.zip'). |
|
500 |
] |
|
364 | 501 |
] |
502 |
] |
|
381 | 503 |
]. |
358 | 504 |
]. |
274 | 505 |
]. |
239 | 506 |
]. |
188 | 507 |
|
239 | 508 |
self javaHome:jHome. |
457 | 509 |
self classPath:jClasses. |
364 | 510 |
|
457 | 511 |
jHome isNil ifTrue:[ |
512 |
Transcript showCR:'no java home directory found'. |
|
513 |
] ifFalse:[ |
|
567 | 514 |
jHome := jHome asFilename. |
515 |
Transcript showCR:'Found javaHome in: ' , jHome pathName. |
|
457 | 516 |
|
567 | 517 |
(jSources := jHome construct:'source') exists ifFalse:[ |
518 |
(jSources := jHome construct:'src') exists ifFalse:[ |
|
519 |
(jSources := jHome construct:'sources') exists ifFalse:[ |
|
571
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
520 |
(jSources := jHome construct:'src.zip') exists ifFalse:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
521 |
jSources := nil. |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
522 |
] |
457 | 523 |
] |
364 | 524 |
] |
457 | 525 |
]. |
364 | 526 |
|
457 | 527 |
jSources isNil ifTrue:[ |
528 |
Transcript showCR:'no java source directory found'. |
|
529 |
] ifFalse:[ |
|
530 |
Transcript showCR:'Found javaSources in: ' , jSources pathName. |
|
531 |
self sourceDirectories:(Array with:jSources pathName). |
|
532 |
]. |
|
364 | 533 |
]. |
188 | 534 |
|
367 | 535 |
directoriesToSearch := OrderedCollection new. |
536 |
directoriesToSearch add:'/usr/local/java/moz3_0/lib_unix'. |
|
605 | 537 |
directoriesToSearch add:'..\..\..\cg\java\java\ns30_unix.zip'. |
641 | 538 |
d := Smalltalk projectDirectoryForClass:self. |
539 |
d notNil ifTrue:[ |
|
540 |
directoriesToSearch add:((d asFilename construct:'java') constructString:'ns30_unix.zip'). |
|
541 |
]. |
|
367 | 542 |
|
557 | 543 |
tryVA == true ifTrue:[ |
407 | 544 |
directoriesToSearch add:'C:\IBMVJava\EAB\bdk'. |
545 |
]. |
|
557 | 546 |
tryNetscape4_0 == true ifTrue:[ |
381 | 547 |
directoriesToSearch add:'C:\Programme\Netscape\Communicator\Program\Java\Classes\java40.jar'. |
548 |
]. |
|
557 | 549 |
tryBorland == true ifTrue:[ |
414 | 550 |
directoriesToSearch addAll:#( |
551 |
'C:\jbuilder2\lib\jbuilder.zip' |
|
552 |
'C:\jbuilder2\lib\jbcl2.0.jar' |
|
553 |
'C:\jbuilder2\lib\jbcl2.0-res.jar' |
|
554 |
'C:\jbuilder2\lib\swingall.jar' |
|
555 |
'C:\jbuilder2\lib\jgl3.1.0.jar' |
|
556 |
'C:\jbuilder2\lib\jctable.jar' |
|
557 |
'C:\jbuilder2\lib\jcchart.jar' |
|
558 |
'C:\jbuilder2\lib\jcbwt.jar' |
|
559 |
) |
|
381 | 560 |
]. |
561 |
||
367 | 562 |
directoriesToSearch do:[:aPath | |
563 |
|dir classDir| |
|
564 |
||
565 |
dir := aPath asFilename. |
|
605 | 566 |
(dir exists) ifTrue:[ |
381 | 567 |
((dir hasSuffix:'jar') |
568 |
or:[dir hasSuffix:'zip']) ifTrue:[ |
|
605 | 569 |
Transcript showCR:'Adding to classPath: ' , dir pathName. |
381 | 570 |
Java addToClassPath:dir. |
571 |
] ifFalse:[ |
|
572 |
mozillaHome := dir. |
|
573 |
classDir := (dir construct:'classes'). |
|
605 | 574 |
classDir exists ifTrue:[ |
575 |
Transcript showCR:'Adding to classPath: ' , classDir pathName. |
|
576 |
Java addToClassPath:classDir pathName. |
|
577 |
]. |
|
578 |
||
381 | 579 |
"/ |
580 |
"/ care to only load mozilla classes from there ... |
|
581 |
"/ i.e. ignore the java/sun stuff found there. |
|
582 |
"/ |
|
583 |
ExcludedClassPath add:(classDir construct:'java') pathName. |
|
584 |
ExcludedClassPath add:(classDir construct:'sun') pathName. |
|
585 |
] |
|
367 | 586 |
] |
241 | 587 |
]. |
188 | 588 |
self initializePrettyPrintStyle. |
589 |
||
274 | 590 |
" |
364 | 591 |
Java initialize. |
274 | 592 |
JavaVM initializeVM |
593 |
" |
|
76 | 594 |
|
607 | 595 |
"Modified: / 25.9.1999 / 22:12:07 / cg" |
188 | 596 |
! |
597 |
||
598 |
initializePrettyPrintStyle |
|
599 |
PrettyPrintStyle := IdentityDictionary new. |
|
600 |
PrettyPrintStyle at:#accessAttribute put:(#color -> (Color red:0 green:0 blue:25)). |
|
601 |
PrettyPrintStyle at:#className put:(Array with:(#color -> Color black) with:#bold). |
|
602 |
PrettyPrintStyle at:#methodName put:(Array with:(#color -> Color black) with:#bold). |
|
603 |
PrettyPrintStyle at:#code put:(#color -> Color black). |
|
604 |
||
605 |
||
606 |
" |
|
607 |
Java initializePrettyPrintStyle |
|
608 |
" |
|
609 |
||
610 |
"Created: 1.8.1997 / 11:08:43 / cg" |
|
611 |
"Modified: 1.8.1997 / 11:09:58 / cg" |
|
76 | 612 |
! |
613 |
||
47 | 614 |
reinitAllClasses |
615 |
self markAllClassesUninitialized. |
|
616 |
self initAllClasses |
|
252 | 617 |
|
618 |
" |
|
619 |
Java reinitAllClasses |
|
620 |
" |
|
621 |
||
622 |
"Modified: / 4.1.1998 / 00:34:29 / cg" |
|
248 | 623 |
! |
624 |
||
625 |
reinitialize |
|
626 |
"/ all JavaThreads are lost on a restart (for now) |
|
627 |
||
340
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
628 |
FailedToLoadClasses := nil. |
248 | 629 |
Threads := nil. |
630 |
||
285 | 631 |
" |
632 |
Java reinitialize |
|
633 |
" |
|
248 | 634 |
|
285 | 635 |
"Created: / 26.8.1997 / 20:07:00 / cg" |
340
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
636 |
"Modified: / 27.4.1998 / 14:57:23 / cg" |
248 | 637 |
! |
638 |
||
639 |
startupJavaSystem |
|
527 | 640 |
|javaEventThread haveEventThread haveScreenUpdater| |
285 | 641 |
|
340
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
642 |
FailedToLoadClasses := nil. |
79f09bb1ac21
remember classes which failed to load - dont try those again.
cg
parents:
324
diff
changeset
|
643 |
|
248 | 644 |
"/ |
645 |
"/ check if already running |
|
646 |
"/ |
|
301
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
647 |
|
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
648 |
haveEventThread := true. |
527 | 649 |
javaEventThread := JavaVM javaEventThread. |
650 |
(javaEventThread isNil or:[javaEventThread isDead]) ifTrue:[ |
|
301
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
651 |
haveEventThread := false |
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
652 |
]. |
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
653 |
|
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
654 |
haveScreenUpdater := false. |
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
655 |
haveEventThread ifTrue:[ |
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
656 |
self threads do:[:aJavaThread | |
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
657 |
aJavaThread name = 'JAVA-Screen Updater' ifTrue:[ |
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
658 |
aJavaThread isDead ifFalse:[ |
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
659 |
"/ already running |
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
660 |
haveScreenUpdater := true |
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
661 |
] |
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
662 |
] |
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
663 |
]. |
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
664 |
]. |
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
665 |
|
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
666 |
(haveEventThread and:[haveScreenUpdater]) ifTrue:[ |
2945ec2eee92
better reinit (look for both event-thread AND screenUpdater thread)
cg
parents:
285
diff
changeset
|
667 |
^ self |
248 | 668 |
]. |
669 |
||
436 | 670 |
JavaClass orderOfClassInits isNil ifTrue:[ |
671 |
"/ the very first start ... |
|
672 |
'JAVA [info]: (re)initializing JAVA environment completely ...' infoPrintCR. |
|
285 | 673 |
|
436 | 674 |
JavaVM initializeVM. |
285 | 675 |
|
436 | 676 |
] ifFalse:[ |
527 | 677 |
javaEventThread := JavaVM javaEventThread. |
678 |
(javaEventThread isNil or:[javaEventThread isDead]) ifTrue:[ |
|
457 | 679 |
JavaVM initializeVM |
680 |
"/ ] ifFalse:[ |
|
681 |
"/ 'JAVA [info]: re-initializing JAVA classes ...' infoPrintCR. |
|
682 |
"/ JavaVM reinitializeVM. |
|
683 |
]. |
|
436 | 684 |
]. |
248 | 685 |
'JAVA [info]: done JAVA initialization.' infoPrintCR. |
686 |
||
285 | 687 |
" |
688 |
Java startupJavaSystem |
|
689 |
" |
|
248 | 690 |
|
527 | 691 |
"Modified: / 8.1.1999 / 17:05:48 / cg" |
248 | 692 |
! |
693 |
||
694 |
terminateAllThreads |
|
305 | 695 |
|myself threadsToKill| |
248 | 696 |
|
697 |
Threads isNil ifTrue:[ |
|
270 | 698 |
^ self |
248 | 699 |
]. |
700 |
||
701 |
myself := Processor activeProcess. |
|
702 |
||
305 | 703 |
threadsToKill := IdentitySet new. |
248 | 704 |
Threads do:[:aJavaThread | |
270 | 705 |
aJavaThread ~~ myself ifTrue:[ |
706 |
(aJavaThread isNil or:[aJavaThread == 0]) ifFalse:[ |
|
707 |
(aJavaThread isMemberOf:JavaProcess) ifTrue:[ |
|
708 |
aJavaThread isDead ifFalse:[ |
|
305 | 709 |
threadsToKill add:aJavaThread |
270 | 710 |
] |
711 |
] |
|
712 |
] |
|
713 |
] |
|
248 | 714 |
]. |
305 | 715 |
threadsToKill do:[:aThread | |
527 | 716 |
aThread == JavaVM javaScreenUpdaterThread ifTrue:[self halt]. |
305 | 717 |
aThread terminate |
718 |
]. |
|
248 | 719 |
Threads := nil. |
720 |
||
721 |
" |
|
722 |
Java terminateAllThreads |
|
723 |
" |
|
724 |
||
270 | 725 |
"Created: / 26.8.1997 / 19:57:40 / cg" |
527 | 726 |
"Modified: / 8.1.1999 / 17:17:28 / cg" |
47 | 727 |
! ! |
728 |
||
135 | 729 |
!Java class methodsFor:'enumerating'! |
43 | 730 |
|
90 | 731 |
allClasses |
208 | 732 |
^ Classes ? #() |
733 |
||
280 | 734 |
" |
735 |
|if| |
|
736 |
||
737 |
if := Java at:'java.awt.GraphicsEnvironment'. |
|
738 |
Java allClasses select:[:aClass | |
|
739 |
aClass hasInterface:if |
|
740 |
] |
|
741 |
" |
|
742 |
||
743 |
"Modified: / 28.1.1998 / 01:42:04 / cg" |
|
90 | 744 |
! |
745 |
||
43 | 746 |
allClassesDo:aBlock |
747 |
Classes notNil ifTrue:[ |
|
552 | 748 |
Classes do:aBlock |
43 | 749 |
] |
750 |
! ! |
|
751 |
||
205 | 752 |
!Java class methodsFor:'object conversions'! |
753 |
||
754 |
as_Float:aNumber |
|
755 |
"convert an ST-float into a Java Float" |
|
756 |
||
757 |
|i| |
|
758 |
||
759 |
i := (Java at:'java.lang.Float') new. |
|
261 | 760 |
i perform:#'<init>(F)V' with:(aNumber asShortFloat). |
205 | 761 |
^ i |
762 |
||
763 |
" |
|
764 |
Java as_Float:1 |
|
765 |
Java as_Float:3.14159 |
|
766 |
" |
|
767 |
||
768 |
"Created: 7.8.1997 / 21:21:13 / cg" |
|
769 |
"Modified: 7.8.1997 / 21:22:05 / cg" |
|
770 |
! |
|
771 |
||
772 |
as_Hashtable:aDictionary |
|
261 | 773 |
"given a smalltalk dictionary, create and return |
774 |
a Java hashTable for it" |
|
775 |
||
205 | 776 |
|hashTable| |
777 |
||
778 |
hashTable := (self classForName:'java.util.Hashtable') new. |
|
779 |
aDictionary keysAndValuesDo:[:k :v | |
|
552 | 780 |
|sk sv jk jv| |
205 | 781 |
|
552 | 782 |
(sk := k) isSymbol ifTrue:[ |
783 |
sk := sk asString |
|
784 |
]. |
|
785 |
(sv := v) isSymbol ifTrue:[ |
|
786 |
sv := sv asString |
|
787 |
]. |
|
788 |
jk := self as_Object:sk. |
|
789 |
jv := self as_Object:sv. |
|
255 | 790 |
|
552 | 791 |
hashTable |
792 |
perform:#'put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;' |
|
793 |
with:jk |
|
794 |
with:jv. |
|
205 | 795 |
]. |
796 |
^ hashTable |
|
797 |
||
798 |
" |
|
799 |
Java as_Hashtable:(Dictionary new |
|
552 | 800 |
at:'hello' put:'Hallo'; |
801 |
at:'world' put:'Welt'; |
|
802 |
yourself) |
|
205 | 803 |
" |
804 |
||
261 | 805 |
"Modified: / 14.1.1998 / 17:02:13 / cg" |
205 | 806 |
! |
807 |
||
808 |
as_Integer:anInteger |
|
809 |
"convert an ST-integer into a Java Integer" |
|
810 |
||
811 |
|i| |
|
812 |
||
813 |
i := (Java at:'java.lang.Integer') new. |
|
261 | 814 |
i perform:#'<init>(I)V' with:anInteger. |
205 | 815 |
^ i |
816 |
||
817 |
" |
|
818 |
Java as_Integer:1 |
|
819 |
" |
|
820 |
||
821 |
"Modified: 7.8.1997 / 21:19:37 / cg" |
|
822 |
"Created: 7.8.1997 / 21:21:13 / cg" |
|
823 |
! |
|
824 |
||
825 |
as_Object:anObject |
|
826 |
"convert an ST-Object into a Java Object" |
|
827 |
||
828 |
anObject isString ifTrue:[ |
|
552 | 829 |
^ self as_String:anObject |
205 | 830 |
]. |
831 |
anObject isInteger ifTrue:[ |
|
552 | 832 |
^ self as_Integer:anObject |
205 | 833 |
]. |
834 |
||
835 |
self halt. |
|
836 |
||
837 |
" |
|
838 |
Java as_Object:'hello world' |
|
839 |
" |
|
840 |
||
841 |
"Created: 7.8.1997 / 21:15:38 / cg" |
|
842 |
"Modified: 7.8.1997 / 21:20:07 / cg" |
|
843 |
! |
|
844 |
||
845 |
as_ST_String:aJavaString |
|
846 |
"hard-coding internas of java.lang.String here is bad ..." |
|
847 |
||
407 | 848 |
|str count offs start stop| |
255 | 849 |
|
514 | 850 |
aJavaString isNil ifTrue:[^ nil]. |
851 |
||
255 | 852 |
"/ count := aJavaString instVarNamed:'count'. |
509 | 853 |
count := aJavaString instVarAt:3. "/ (JavaSlotIndexCache string_slot_count). |
255 | 854 |
|
855 |
"/ str := aJavaString instVarNamed:'value' |
|
509 | 856 |
str := aJavaString instVarAt:1. "/ (JavaSlotIndexCache string_slot_value). |
255 | 857 |
|
858 |
str size == count ifTrue:[ |
|
407 | 859 |
^ str |
255 | 860 |
]. |
205 | 861 |
|
407 | 862 |
"/ offs := (aJavaString instVarNamed:'offset'). |
509 | 863 |
offs := aJavaString instVarAt:2. "/ (JavaSlotIndexCache string_slot_offset). |
407 | 864 |
|
865 |
"/ start := offs + 1. |
|
866 |
start := offs + 1. |
|
205 | 867 |
|
868 |
"/ stop := start + (aJavaString instVarNamed:'count') - 1. |
|
407 | 869 |
stop := start + count - 1. |
205 | 870 |
|
871 |
"/ ^ ((aJavaString instVarNamed:'value') copyFrom:start to:stop) asString |
|
407 | 872 |
^ (str copyFrom:start to:stop) asString |
205 | 873 |
|
255 | 874 |
"Created: / 8.8.1997 / 12:02:55 / cg" |
514 | 875 |
"Modified: / 4.1.1999 / 23:55:08 / cg" |
205 | 876 |
! |
877 |
||
878 |
as_String:aString |
|
879 |
"convert an ST-String into a Java String" |
|
880 |
||
881 |
"hard-coding internas of java.lang.String here is bad ..." |
|
882 |
||
883 |
|s| |
|
884 |
||
885 |
s := Java_lang_String basicNew. |
|
886 |
s instVarNamed:'value' put: aString. |
|
887 |
s instVarNamed:'offset' put: 0. |
|
888 |
s instVarNamed:'count' put: aString size. |
|
889 |
^ s |
|
890 |
||
891 |
" |
|
892 |
Java as_String:'hello world' |
|
893 |
" |
|
894 |
||
895 |
"Created: 7.8.1997 / 21:15:49 / cg" |
|
896 |
"Modified: 7.8.1997 / 21:19:37 / cg" |
|
897 |
! |
|
898 |
||
899 |
as_URL:aString |
|
900 |
"convert an ST-String into a Java String" |
|
901 |
||
902 |
"hard-coding internas of java.lang.String here is bad ..." |
|
903 |
||
608 | 904 |
|u s| |
905 |
||
906 |
s := aString. |
|
205 | 907 |
|
608 | 908 |
"/ kludge for volume |
909 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
910 |
((s size > 1) and:[(s at:2) == $:]) ifTrue:[ |
|
911 |
s := 'file:' , (s copy at:2 put:$|) |
|
912 |
] |
|
913 |
]. |
|
421 | 914 |
u := (self at:'java.net.URL') newCleared. |
608 | 915 |
u perform:#'<init>(Ljava/lang/String;)V' with:(self as_String:s). |
205 | 916 |
^ u |
917 |
||
918 |
" |
|
919 |
Java as_URL:'http://www.altavista.com' |
|
920 |
Java as_URL:'file:/foo/bar' |
|
921 |
" |
|
922 |
||
421 | 923 |
"Created: / 7.8.1997 / 21:15:49 / cg" |
608 | 924 |
"Modified: / 25.9.1999 / 22:22:21 / cg" |
205 | 925 |
! ! |
926 |
||
168 | 927 |
!Java class methodsFor:'queries'! |
928 |
||
929 |
smalltalkClassFor:typeRef |
|
930 |
self halt. |
|
931 |
"/ (typeString startsWith:'[[') ifTrue:[ |
|
932 |
"/ ^ Array |
|
933 |
"/ ]. |
|
934 |
"/ (typeString startsWith:'[F') ifTrue:[ |
|
935 |
"/ ^ FloatArray |
|
936 |
"/ ]. |
|
937 |
self halt. |
|
938 |
||
939 |
"Modified: 7.4.1997 / 13:33:46 / cg" |
|
940 |
! |
|
941 |
||
942 |
smalltalkDerefType:typeString |
|
943 |
(typeString startsWith:'[') ifTrue:[ |
|
552 | 944 |
^ typeString copyFrom:2 |
168 | 945 |
]. |
946 |
self halt. |
|
947 |
||
948 |
"Modified: 7.4.1997 / 13:13:24 / cg" |
|
949 |
! ! |
|
950 |
||
135 | 951 |
!Java class methodsFor:'registering java classes'! |
17 | 952 |
|
953 |
at:aJavaName |
|
43 | 954 |
"search & return for a class by name; |
955 |
if there is no such class, return nil. |
|
956 |
The argument, aJavaName may be either an internal name |
|
957 |
(sep'd by slashes) or an external name (sep'd by periods). |
|
958 |
The 'java/lang' standard packages prefix may be ommitted." |
|
959 |
||
960 |
|sym nm cls| |
|
961 |
||
17 | 962 |
Classes isNil ifTrue:[^ nil]. |
43 | 963 |
|
964 |
sym := aJavaName asSymbolIfInterned. |
|
965 |
sym notNil ifTrue:[ |
|
360 | 966 |
cls := Classes at:sym ifAbsent:nil. |
967 |
cls notNil ifTrue:[^ cls]. |
|
43 | 968 |
]. |
17 | 969 |
|
43 | 970 |
nm := aJavaName. |
971 |
(nm includes:$.) ifTrue:[ |
|
360 | 972 |
nm := (nm asString copyReplaceAll:$. with:$/). |
973 |
sym := nm asSymbolIfInterned. |
|
974 |
sym notNil ifTrue:[ |
|
975 |
cls := Classes at:sym ifAbsent:nil. |
|
976 |
cls notNil ifTrue:[^ cls]. |
|
977 |
]. |
|
43 | 978 |
]. |
979 |
||
980 |
(nm includes:$/) ifFalse:[ |
|
360 | 981 |
"/ |
982 |
"/ try java.lang.Foo |
|
983 |
"/ |
|
984 |
nm := 'java/lang/' , nm. |
|
985 |
sym := nm asSymbolIfInterned. |
|
986 |
sym notNil ifTrue:[ |
|
987 |
cls := Classes at:sym ifAbsent:nil. |
|
988 |
cls notNil ifTrue:[^ cls]. |
|
989 |
]. |
|
43 | 990 |
]. |
991 |
||
992 |
^ nil |
|
993 |
||
994 |
" |
|
995 |
Java at:'java/lang/String' |
|
996 |
Java at:'java.lang.String' |
|
997 |
Java at:'String' |
|
998 |
Java at:'System' |
|
999 |
Java at:'Foo' |
|
1000 |
" |
|
360 | 1001 |
|
1002 |
"Modified: / 18.7.1998 / 22:55:16 / cg" |
|
17 | 1003 |
! |
1004 |
||
1005 |
at:aJavaName put:aJavaClass |
|
591 | 1006 |
|nameSymbol oldClass| |
90 | 1007 |
|
17 | 1008 |
Classes isNil ifTrue:[ |
552 | 1009 |
Classes := IdentityDictionary new. |
17 | 1010 |
]. |
90 | 1011 |
|
1012 |
nameSymbol := aJavaName asSymbol. |
|
1013 |
(Classes includesKey:nameSymbol) ifTrue:[ |
|
591 | 1014 |
oldClass := Classes at:nameSymbol. |
1015 |
oldClass == aJavaClass ifTrue:[ |
|
1016 |
^ self |
|
1017 |
]. |
|
552 | 1018 |
('JAVA: class ' , aJavaName , ' is already loaded') infoPrintCR. |
591 | 1019 |
self updateClassRefsFrom:oldClass to:aJavaClass. |
65 | 1020 |
]. |
54 | 1021 |
|
90 | 1022 |
Classes at:nameSymbol put:aJavaClass. |
1023 |
nameSymbol == #'java/lang/String' ifTrue:[ |
|
552 | 1024 |
Java_lang_String := aJavaClass |
90 | 1025 |
]. |
21 | 1026 |
|
43 | 1027 |
"/ UnresolvedClassRefs notNil ifTrue:[ |
1028 |
"/ UnresolvedClassRefs do:[:toResolve | |
|
1029 |
"/ ] |
|
1030 |
"/ ]. |
|
1031 |
||
27 | 1032 |
self changed:#classes |
17 | 1033 |
|
1034 |
"Created: 17.4.1996 / 23:29:31 / cg" |
|
205 | 1035 |
"Modified: 7.8.1997 / 19:15:58 / cg" |
21 | 1036 |
! |
1037 |
||
168 | 1038 |
flushAllJavaResources |
1039 |
self flushClasses. |
|
1040 |
||
1041 |
ObjectMemory allObjectsDo:[:someObject | |
|
318 | 1042 |
someObject isBehavior ifTrue:[ |
1043 |
someObject isJavaClass ifTrue:[ |
|
1044 |
someObject setConstantPool:nil. |
|
1045 |
someObject setInterfaces:nil. |
|
1046 |
someObject setMethodDictionary:(MethodDictionary new). |
|
1047 |
'JAVA [info]: flushing ' print. someObject fullName printCR. |
|
1048 |
] |
|
1049 |
]. |
|
381 | 1050 |
"/ (someObject isKindOf:JavaMethod) ifTrue:[ |
1051 |
"/ someObject setJavaClass:nil. |
|
1052 |
"/ someObject setExceptionTable:nil. |
|
1053 |
"/ ]. |
|
318 | 1054 |
(someObject isMemberOf:JavaUnresolvedClassConstant) ifTrue:[ |
1055 |
someObject constantPool:nil |
|
1056 |
]. |
|
168 | 1057 |
]. |
1058 |
self flushClasses |
|
1059 |
||
1060 |
" |
|
1061 |
Java flushAllJavaResources |
|
1062 |
" |
|
1063 |
||
381 | 1064 |
"Modified: / 16.10.1998 / 01:21:30 / cg" |
168 | 1065 |
! |
1066 |
||
21 | 1067 |
flushClasses |
167 | 1068 |
Classes := UnresolvedClassRefs := nil. |
168 | 1069 |
Smalltalk keys copy do:[:aKey | |
381 | 1070 |
(aKey startsWith:'JAVA::') ifTrue:[ Smalltalk removeKey:aKey ] |
168 | 1071 |
]. |
167 | 1072 |
Java_lang_String := Java_lang_Class := nil. |
261 | 1073 |
JavaVM releaseAllJavaResources. |
90 | 1074 |
JavaUnresolvedConstant flushPatchLists. |
381 | 1075 |
Debugger newDebugger. |
423 | 1076 |
ObjectMemory flushCaches. |
21 | 1077 |
|
1078 |
" |
|
1079 |
Java flushClasses |
|
1080 |
" |
|
1081 |
||
423 | 1082 |
"Modified: / 5.11.1998 / 20:12:47 / cg" |
21 | 1083 |
! |
1084 |
||
43 | 1085 |
markAllClassesUninitialized |
1086 |
self allClassesDo:[:aJavaClass | |
|
552 | 1087 |
aJavaClass markUninitialized |
43 | 1088 |
]. |
1089 |
||
1090 |
" |
|
1091 |
Java markAllClassesUninitialized |
|
1092 |
" |
|
1093 |
! |
|
1094 |
||
21 | 1095 |
rememberUnresolved:anUnresolvedClassRef |
90 | 1096 |
('JAVA: remember unresolved class: ' , anUnresolvedClassRef fullName) infoPrintCR. |
1097 |
||
1098 |
UnresolvedClassRefs isNil ifTrue:[ |
|
393 | 1099 |
UnresolvedClassRefs := Dictionary new. |
90 | 1100 |
]. |
393 | 1101 |
UnresolvedClassRefs |
1102 |
at:anUnresolvedClassRef fullName |
|
1103 |
put:anUnresolvedClassRef |
|
21 | 1104 |
|
393 | 1105 |
"Created: / 18.4.1996 / 00:05:31 / cg" |
1106 |
"Modified: / 19.10.1998 / 20:57:44 / cg" |
|
90 | 1107 |
! |
1108 |
||
162 | 1109 |
removeClass:aJavaClass |
1110 |
"/ remove it from myself |
|
1111 |
||
393 | 1112 |
|javaName sym nm cls p ns| |
162 | 1113 |
|
1114 |
javaName := aJavaClass fullName. |
|
1115 |
||
1116 |
sym := javaName asSymbolIfInterned. |
|
1117 |
sym notNil ifTrue:[ |
|
360 | 1118 |
cls := Classes at:sym ifAbsent:nil. |
162 | 1119 |
]. |
1120 |
cls isNil ifTrue:[ |
|
360 | 1121 |
nm := javaName. |
1122 |
(nm includes:$.) ifTrue:[ |
|
1123 |
"/ |
|
1124 |
"/ try pckg/.../name |
|
1125 |
"/ |
|
1126 |
nm := (nm asString copyReplaceAll:$. with:$/). |
|
1127 |
sym := nm asSymbolIfInterned. |
|
1128 |
sym notNil ifTrue:[ |
|
1129 |
cls := Classes at:sym ifAbsent:nil. |
|
1130 |
]. |
|
1131 |
]. |
|
162 | 1132 |
]. |
212 | 1133 |
(cls notNil and:[cls == aJavaClass]) ifTrue:[ |
360 | 1134 |
Classes removeKey:sym. |
1135 |
self updateClassRefsFrom:aJavaClass to:nil. |
|
162 | 1136 |
]. |
393 | 1137 |
Smalltalk removeKey:('JAVA::' , javaName) asSymbol. |
592 | 1138 |
Smalltalk removeKey:javaName asSymbol. |
1139 |
Smalltalk removeKey:((javaName , '') copy replaceAll:$/ with:$.) asSymbol. |
|
393 | 1140 |
|
1141 |
"/ remove myself from the JAVA::-::-:: namespace |
|
1142 |
"/ (which exists for convenient smalltalk access only) |
|
162 | 1143 |
|
393 | 1144 |
p := aJavaClass nameSpacePath. |
1145 |
p knownAsSymbol ifTrue:[ |
|
1146 |
ns := Smalltalk at:p asSymbol. |
|
1147 |
(ns notNil and:[ns isNamespace]) ifTrue:[ |
|
592 | 1148 |
Smalltalk removeKey:(p , '::' , aJavaClass lastName) asSymbol |
393 | 1149 |
] |
1150 |
]. |
|
1151 |
||
1152 |
"Modified: / 19.10.1998 / 20:58:49 / cg" |
|
162 | 1153 |
! |
1154 |
||
90 | 1155 |
unresolvedClassRefFor:aClassName |
1156 |
UnresolvedClassRefs isNil ifTrue:[^ nil]. |
|
1157 |
^ UnresolvedClassRefs at:aClassName ifAbsent:nil. |
|
393 | 1158 |
|
1159 |
"Modified: / 19.10.1998 / 20:56:46 / cg" |
|
167 | 1160 |
! |
1161 |
||
1162 |
updateClassRefsFrom:oldClass to:newClass |
|
1163 |
"update all references to oldClass to now refer to newClass. |
|
1164 |
sent, when a class is reloaded" |
|
1165 |
||
214 | 1166 |
newClass notNil ifTrue:[ |
552 | 1167 |
"/ |
1168 |
"/ kludge: the new class might have been resolved with the oldClass ... |
|
1169 |
"/ |
|
1170 |
newClass constantPool |
|
1171 |
updateClassRefsFrom:oldClass to:newClass. |
|
214 | 1172 |
]. |
205 | 1173 |
|
203 | 1174 |
self allClassesDo:[:aJavaClass | |
552 | 1175 |
aJavaClass updateClassRefsFrom:oldClass to:newClass |
203 | 1176 |
]. |
167 | 1177 |
|
1178 |
"Created: 26.3.1997 / 13:49:20 / cg" |
|
214 | 1179 |
"Modified: 12.8.1997 / 03:04:44 / cg" |
17 | 1180 |
! ! |
1181 |
||
135 | 1182 |
!Java class methodsFor:'source management'! |
76 | 1183 |
|
1184 |
classSourceOf:aClass |
|
261 | 1185 |
|package dirName binary sourceFileName sourceFile dirHolder fileName path |
571
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1186 |
loader codeBaseURL protocol dir file codeBaseURLIdx zar src| |
76 | 1187 |
|
1188 |
aClass isNil ifTrue:[ |
|
267 | 1189 |
^ nil |
76 | 1190 |
]. |
1191 |
||
1192 |
"/ first, look in the directory, where the binary |
|
1193 |
"/ was loaded from. |
|
1194 |
||
198 | 1195 |
binary := aClass binaryFile. |
1196 |
binary notNil ifTrue:[ |
|
267 | 1197 |
binary := binary asFilename. |
324 | 1198 |
aClass sourceFile notNil ifTrue:[ |
1199 |
sourceFileName := binary directory constructString:(aClass sourceFile). |
|
1200 |
sourceFileName asFilename exists ifFalse:[ |
|
1201 |
sourceFileName := nil. |
|
1202 |
] |
|
1203 |
]. |
|
1204 |
sourceFileName isNil ifTrue:[ |
|
1205 |
sourceFileName := binary withSuffix:'java'. |
|
1206 |
]. |
|
267 | 1207 |
sourceFile := sourceFileName asFilename. |
261 | 1208 |
] ifFalse:[ |
267 | 1209 |
"/ maybe it was loaded by a java classLoader ... |
1210 |
(loader := aClass classLoader) notNil ifTrue:[ |
|
546 | 1211 |
codeBaseURLIdx := loader class instVarOffsetOf:'codeBaseURL'. |
1212 |
codeBaseURLIdx notNil ifTrue:[ |
|
1213 |
(codeBaseURL := loader instVarAt:codeBaseURLIdx) notNil ifTrue:[ |
|
1214 |
(protocol := codeBaseURL instVarNamed:'protocol') notNil ifTrue:[ |
|
1215 |
(Java as_ST_String:protocol) = 'file' ifTrue:[ |
|
1216 |
dirName := Java as_ST_String:(codeBaseURL instVarNamed:'file'). |
|
571
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1217 |
dirName := dirName asFilename. |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1218 |
dirName exists ifTrue:[ |
546 | 1219 |
aClass sourceFile notNil ifTrue:[ |
571
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1220 |
sourceFile := sourceFileName := dirName construct:aClass sourceFile. |
546 | 1221 |
] |
267 | 1222 |
] |
1223 |
] |
|
1224 |
] |
|
1225 |
] |
|
1226 |
] |
|
1227 |
] |
|
198 | 1228 |
]. |
1229 |
sourceFile notNil ifTrue:[ |
|
267 | 1230 |
sourceFile exists ifFalse:[ |
1231 |
binary notNil ifTrue:[ |
|
1232 |
sourceFileName := binary withSuffix:'jav'. |
|
1233 |
sourceFile := sourceFileName asFilename. |
|
1234 |
sourceFile exists ifFalse:[ |
|
1235 |
sourceFileName := binary withSuffix:'JAV'. |
|
1236 |
sourceFile := sourceFileName asFilename. |
|
1237 |
sourceFile exists ifFalse:[ |
|
1238 |
sourceFileName := binary withSuffix:'JAVA'. |
|
1239 |
sourceFile := sourceFileName asFilename. |
|
1240 |
]. |
|
1241 |
]. |
|
1242 |
] |
|
1243 |
]. |
|
76 | 1244 |
]. |
1245 |
||
176 | 1246 |
"/ special case: there were multiple classes in a single |
76 | 1247 |
"/ source file. |
1248 |
||
601 | 1249 |
(binary notNil and:[aClass sourceFile notNil]) ifTrue:[ |
267 | 1250 |
binary withoutSuffix baseName ~= aClass sourceFile asFilename withoutSuffix baseName ifTrue:[ |
1251 |
'JAVA: trouble extracting fileName: ' print. |
|
1252 |
binary withoutSuffix baseName print. ' vs. ' print. |
|
1253 |
aClass sourceFile asFilename withoutSuffix baseName printCR. |
|
1254 |
]. |
|
76 | 1255 |
]. |
1256 |
||
1257 |
"/ if that fails, look in standard places |
|
1258 |
||
198 | 1259 |
(sourceFile isNil or:[sourceFile exists not]) ifTrue:[ |
324 | 1260 |
package := aClass package. |
1261 |
||
267 | 1262 |
sourceFileName := aClass sourceFile. |
381 | 1263 |
sourceFileName isNil ifTrue:[^nil]. |
1264 |
||
267 | 1265 |
sourceFile := sourceFileName asFilename. |
1266 |
sourceFile exists ifFalse:[ |
|
1267 |
"/ |
|
1268 |
"/ mhmh - look for its directory |
|
1269 |
"/ |
|
571
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1270 |
dirName := sourceFile directory. |
267 | 1271 |
fileName := sourceFile baseName. |
76 | 1272 |
|
571
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1273 |
(dirName exists |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1274 |
and:[(dirName construct:(package , '/' , fileName)) exists]) |
267 | 1275 |
ifFalse:[ |
571
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1276 |
(dirName exists |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1277 |
and:[(dirName construct:(fileName)) exists]) |
267 | 1278 |
ifFalse:[ |
1279 |
dirName := self findSourceDirOf:fileName inPackage:package. |
|
76 | 1280 |
|
1281 |
"/ [dirName isNil] whileTrue:[ |
|
1282 |
"/ dirName := Dialog requestDirectoryName:'top directory for ' , package , '/' , fileName. |
|
1283 |
"/ (dirName isNil or:[dirName isEmpty]) ifTrue:[^ self]. |
|
1284 |
"/ ]. |
|
267 | 1285 |
]. |
1286 |
]. |
|
76 | 1287 |
|
571
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1288 |
(dirName notNil and:[dirName exists]) ifTrue:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1289 |
dirName isDirectory ifTrue:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1290 |
path := dirName construct:(package , '/' , fileName). |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1291 |
path exists ifFalse:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1292 |
path := dirName construct:(fileName). |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1293 |
]. |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1294 |
] ifFalse:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1295 |
"/ a zip-file ? |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1296 |
(dirName hasSuffix:'zip') ifTrue:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1297 |
zar := ZipArchive oldFileNamed:dirName pathName. |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1298 |
src := zar extract:(package , '/' , fileName). |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1299 |
src isNil ifTrue:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1300 |
src := zar extract:fileName. |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1301 |
]. |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1302 |
src notNil ifTrue:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1303 |
^ src asString. |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1304 |
] |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1305 |
] |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1306 |
] |
267 | 1307 |
]. |
76 | 1308 |
|
267 | 1309 |
(path notNil and:[path exists]) ifFalse:[ |
1310 |
^ nil |
|
1311 |
]. |
|
76 | 1312 |
|
571
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1313 |
sourceFile := path. |
267 | 1314 |
]. |
76 | 1315 |
]. |
1316 |
^ (sourceFile contentsOfEntireFile). |
|
1317 |
||
546 | 1318 |
"Modified: / 27.1.1999 / 20:40:30 / cg" |
76 | 1319 |
! |
1320 |
||
1321 |
findSourceDirOf:fileName inPackage:aPackage |
|
571
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1322 |
"return a directory-fileName, a zip-file fileName or nil" |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1323 |
|
76 | 1324 |
SourceDirectories notNil ifTrue:[ |
571
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1325 |
SourceDirectories do:[:aDirOrZipFile | |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1326 |
|fn zar| |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1327 |
|
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1328 |
fn := aDirOrZipFile asFilename. |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1329 |
fn isDirectory ifTrue:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1330 |
aPackage notNil ifTrue:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1331 |
(fn construct:('/' , aPackage , '/' , fileName)) exists ifTrue:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1332 |
^ fn |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1333 |
]. |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1334 |
]. |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1335 |
(fn construct:('/' , fileName)) exists ifTrue:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1336 |
^ fn |
324 | 1337 |
]. |
571
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1338 |
] ifFalse:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1339 |
(fn hasSuffix:'zip') ifTrue:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1340 |
zar := ZipArchive oldFileNamed:fn pathName. |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1341 |
zar notNil ifTrue:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1342 |
aPackage notNil ifTrue:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1343 |
(zar findMember:(aPackage , '/' , fileName)) notNil ifTrue:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1344 |
^ fn |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1345 |
] |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1346 |
] ifFalse:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1347 |
(zar findMember:fileName) notNil ifTrue:[ |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1348 |
^ fn |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1349 |
] |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1350 |
] |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1351 |
] |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1352 |
] |
b5ae2faeb568
allow for the sources to be stored in one big zip-archive
cg
parents:
567
diff
changeset
|
1353 |
] |
324 | 1354 |
] |
76 | 1355 |
]. |
1356 |
^ nil |
|
1357 |
||
324 | 1358 |
"Modified: / 29.3.1998 / 21:46:40 / cg" |
76 | 1359 |
! ! |
1360 |
||
224 | 1361 |
!Java class methodsFor:'starting apps'! |
1362 |
||
1363 |
javaProcessForMainOf:aJavaClass |
|
1364 |
"ask for a commandLine, create a java process to invoke |
|
1365 |
its main and return it. The process is not scheduled for |
|
1366 |
execution." |
|
1367 |
||
508 | 1368 |
^ self javaProcessForMainOf:aJavaClass argumentString:nil |
224 | 1369 |
|
508 | 1370 |
"Modified: / 30.12.1998 / 20:24:25 / cg" |
224 | 1371 |
! |
1372 |
||
508 | 1373 |
javaProcessForMainOf:aJavaClass argumentString:argStringIn |
224 | 1374 |
"create a java process, ready to invoke the classes main |
1375 |
method. Returns the process - ready to run but not yet resumed" |
|
1376 |
||
577 | 1377 |
|p argStringArray t argString stdInReplacement alreadyAskedForStdin| |
508 | 1378 |
|
1379 |
argString := argStringIn. |
|
1380 |
argString isNil ifTrue:[ |
|
1381 |
argString := Dialog |
|
1382 |
request:'argument string:' |
|
1383 |
initialAnswer:LastArgumentString ? '' |
|
1384 |
onCancel:nil. |
|
1385 |
argString isNil ifTrue:[^ nil]. |
|
1386 |
||
1387 |
LastArgumentString := argString. |
|
1388 |
]. |
|
224 | 1389 |
|
261 | 1390 |
JavaVM initializeVMIfNoEventThreadRunning. |
1391 |
(Java at:'java.lang.System') instVarNamed:'security' put:nil. |
|
1392 |
||
224 | 1393 |
argString isEmpty ifTrue:[ |
252 | 1394 |
argStringArray := #() |
224 | 1395 |
] ifFalse:[ |
252 | 1396 |
argStringArray := argString asCollectionOfWords asArray |
1397 |
collect:[:s | Java as_String:s]. |
|
224 | 1398 |
]. |
1399 |
||
1400 |
p := JavaProcess |
|
252 | 1401 |
for:[ |
580 | 1402 |
"/ if the program reads from stdin, let user provide a file |
1403 |
"/ for it. |
|
577 | 1404 |
JavaVM stdinReplacementFileQuerySignal handle:[:ex | |
1405 |
|fn| |
|
1406 |
||
1407 |
alreadyAskedForStdin == true ifFalse:[ |
|
580 | 1408 |
fn := Dialog |
1409 |
requestFileName:'Program reads from Stdin - give inputFile or cancel for EOF' |
|
1410 |
default:nil |
|
1411 |
fromDirectory:(FileSelectionBox lastFileSelectionDirectory). |
|
577 | 1412 |
fn notNil ifTrue:[ |
1413 |
stdInReplacement := fn asFilename readStream. |
|
1414 |
]. |
|
1415 |
alreadyAskedForStdin := true. |
|
1416 |
]. |
|
1417 |
ex proceedWith:stdInReplacement |
|
1418 |
] do:[ |
|
1419 |
aJavaClass |
|
1420 |
performStatic:#'main([Ljava/lang/String;)V' |
|
1421 |
with:argStringArray. |
|
1422 |
] |
|
252 | 1423 |
] |
1424 |
priority:(Processor activePriority - 1). |
|
224 | 1425 |
|
1426 |
p name:(aJavaClass fullName , '::main()'). |
|
1427 |
^ p |
|
1428 |
||
252 | 1429 |
"Created: / 15.8.1997 / 04:41:20 / cg" |
508 | 1430 |
"Modified: / 30.12.1998 / 20:25:26 / cg" |
224 | 1431 |
! ! |
1432 |
||
135 | 1433 |
!Java class methodsFor:'documentation'! |
17 | 1434 |
|
1435 |
version |
|
641 | 1436 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/Java.st,v 1.112 1999/12/23 17:40:41 cg Exp $' |
17 | 1437 |
! ! |
76 | 1438 |
Java initialize! |