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