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