author | hlopkmar |
Fri, 09 Dec 2011 12:33:57 +0000 | |
branch | jk_new_structure |
changeset 1249 | 3c82fe50483c |
parent 1213 | fc90769151e8 |
child 1691 | 826f8d7dc0df |
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 |
Process subclass:#JavaProcess |
|
24 |
instanceVariableNames:'suspendedContext' |
|
25 |
classVariableNames:'' |
|
26 |
poolDictionaries:'' |
|
27 |
category:'Languages-Java-Classes' |
|
28 |
! |
|
29 |
||
30 |
Object subclass:#Helper |
|
31 |
instanceVariableNames:'javaThreadObject javaProcess' |
|
32 |
classVariableNames:'' |
|
33 |
poolDictionaries:'' |
|
34 |
privateIn:JavaProcess |
|
35 |
! |
|
36 |
||
37 |
!JavaProcess class methodsFor:'documentation'! |
|
38 |
||
39 |
copyright |
|
40 |
" |
|
877 | 41 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
1152 | 42 |
|
1155 | 43 |
New code and modifications done at SWING Research Group [1]: |
1152 | 44 |
|
877 | 45 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
46 |
SWING Research Group, Czech Technical University in Prague |
|
47 |
||
752 | 48 |
This software is furnished under a license and may be used |
49 |
only in accordance with the terms of that license and with the |
|
50 |
inclusion of the above copyright notice. This software may not |
|
51 |
be provided or otherwise made available to, or used by, any |
|
52 |
other person. No title to or ownership of the software is |
|
53 |
hereby transferred. |
|
877 | 54 |
|
1155 | 55 |
[1] Code written at SWING Research Group contains a signature |
56 |
of one of the above copright owners. For exact set of such code, |
|
57 |
see the differences between this version and version stx:libjava |
|
1152 | 58 |
as of 1.9.2010 |
877 | 59 |
|
752 | 60 |
" |
61 |
! ! |
|
62 |
||
63 |
!JavaProcess class methodsFor:'instance creation'! |
|
64 |
||
65 |
newHelper |
|
66 |
||
67 |
^Helper new |
|
68 |
||
69 |
"Created: / 15-12-2010 / 11:11:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
70 |
! ! |
|
71 |
||
72 |
!JavaProcess methodsFor:'accessing'! |
|
73 |
||
74 |
suspendedContext |
|
75 |
|con| |
|
76 |
||
77 |
"/ suspendedContext notNil ifTrue:[^ suspendedContext]. |
|
78 |
"/ state ~~ #debug ifTrue:[ |
|
79 |
"/ "/ hide non-JAVA contexts ... |
|
80 |
"/ con := super suspendedContext. |
|
81 |
"/ [con notNil] whileTrue:[ |
|
82 |
"/ (con isMemberOf:JavaContext) ifTrue:[^ con]. |
|
83 |
"/ con := con sender. |
|
84 |
"/ ]. |
|
85 |
"/ ]. |
|
86 |
^ super suspendedContext |
|
87 |
||
88 |
"Created: / 7.5.1996 / 09:02:03 / cg" |
|
89 |
"Modified: / 4.2.1998 / 20:44:31 / cg" |
|
90 |
! |
|
91 |
||
92 |
suspendedContext:aContext |
|
93 |
suspendedContext := aContext |
|
94 |
||
95 |
"Created: 7.5.1996 / 09:02:12 / cg" |
|
96 |
! ! |
|
97 |
||
98 |
!JavaProcess methodsFor:'interrupts'! |
|
99 |
||
100 |
clearInterruptActions |
|
101 |
interruptActions := nil |
|
102 |
||
103 |
"Created: 14.8.1997 / 17:27:22 / cg" |
|
104 |
! |
|
105 |
||
106 |
isInterrupted |
|
107 |
^ interruptActions notNil |
|
108 |
||
109 |
"Created: 14.8.1997 / 17:26:40 / cg" |
|
110 |
! |
|
111 |
||
112 |
markInterrupted |
|
113 |
super interruptWith:[] |
|
114 |
||
115 |
"Modified: / 10.4.1998 / 15:20:58 / cg" |
|
116 |
"Created: / 10.4.1998 / 15:21:15 / cg" |
|
117 |
! ! |
|
118 |
||
119 |
!JavaProcess methodsFor:'suspend & resume'! |
|
120 |
||
121 |
terminateNoSignal |
|
122 |
| jThread | |
|
1249 | 123 |
jThread := Java threadForStProcess: self. |
1179 | 124 |
JavaVM acquireMonitorAndNotifyAll: jThread. |
752 | 125 |
super terminateNoSignal |
126 |
||
127 |
"Created: / 15-12-2010 / 00:18:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
128 |
"Modified: / 15-12-2010 / 11:19:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1249 | 129 |
"Modified: / 09-12-2011 / 12:51:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 130 |
! ! |
131 |
||
132 |
!JavaProcess::Helper methodsFor:'initialization'! |
|
133 |
||
134 |
javaProcess:something |
|
135 |
javaProcess := something. |
|
136 |
! |
|
137 |
||
138 |
javaThreadObject:something |
|
139 |
javaThreadObject := something. |
|
140 |
! ! |
|
141 |
||
142 |
!JavaProcess::Helper methodsFor:'support'! |
|
143 |
||
144 |
value |
|
1118 | 145 |
| procName | |
905 | 146 |
Object abortSignal |
1118 | 147 |
handle: [ |
148 |
:ex | |
|
752 | 149 |
procName := javaProcess name. |
1118 | 150 |
(procName startsWith: 'JAVA-AWT-EventQueue') ifTrue: [ |
151 |
Logger |
|
152 |
log: ('thread ' , procName , ' aborted - restarting process.') |
|
153 |
severity: #info |
|
154 |
facility: 'JVM'. |
|
905 | 155 |
ex restart. |
1118 | 156 |
] ifFalse: [ |
157 |
(javaProcess == (Smalltalk at: #'JavaVM:JavaScreenUpdaterThread') |
|
158 |
or: [ javaProcess == (Smalltalk at: #'JavaVM:JavaEventQueueThread') ]) |
|
159 |
ifTrue: [ |
|
160 |
Logger |
|
161 |
log: ('thread ' , procName , ' aborted - restarting process.') |
|
162 |
severity: #info |
|
163 |
facility: 'JVM'. |
|
905 | 164 |
ex restart |
1118 | 165 |
] |
166 |
ifFalse: [ |
|
167 |
Logger |
|
168 |
log: ('thread ' , procName , ' aborted.') |
|
169 |
severity: #info |
|
170 |
facility: 'JVM'. |
|
905 | 171 |
] |
172 |
]. |
|
173 |
] |
|
1118 | 174 |
do: [ |
905 | 175 |
[ |
176 |
JavaVM javaExceptionSignal |
|
1118 | 177 |
handle: [ |
178 |
:ex | |
|
179 |
| exClass | |
|
905 | 180 |
procName := javaProcess name. |
181 |
exClass := ex parameter class. |
|
1118 | 182 |
exClass == (Java at: 'java.lang.ThreadDeath') ifTrue: [ |
183 |
Logger |
|
184 |
log: ('thread ' , procName , ' terminated') |
|
185 |
severity: #info |
|
186 |
facility: 'JVM'. |
|
187 |
] ifFalse: [ |
|
188 |
Logger |
|
189 |
log: ('JAVA: thread ''' , procName , ''' terminated with exception: ' |
|
190 |
, exClass name) |
|
191 |
severity: #info |
|
192 |
facility: 'JVM'. |
|
905 | 193 |
]. |
194 |
ex return. |
|
195 |
] |
|
1118 | 196 |
do: [ |
905 | 197 |
Object messageNotUnderstoodSignal |
1118 | 198 |
handle: [ |
199 |
:ex | |
|
200 |
| |
|
905 | 201 |
"/ remap doesNotUnderstand with nil-receiver to |
202 |
"/ a nullPointerException ... |
|
1118 | 203 |
con m | |
905 | 204 |
con := ex suspendedContext. |
1118 | 205 |
con receiver isNil ifTrue: [ |
206 |
((m := con sender method) notNil and: [ m isJavaMethod ]) ifTrue: [ |
|
905 | 207 |
JavaVM throwNullPointerException. |
208 |
AbortSignal raise. |
|
209 |
||
210 |
"/ ex proceed. |
|
211 |
] |
|
212 |
]. |
|
213 |
ex reject. |
|
214 |
] |
|
1118 | 215 |
do: [ |
905 | 216 |
"/ Transcript showCR:(Timestamp now printString , 'start thread: ', stProcess name). |
1110
7413fa7769ec
- call Thread.exit() even if thread is aborted by user (or Smalltalk code)
vranyj1
parents:
1109
diff
changeset
|
217 |
[ |
1249 | 218 |
javaThreadObject instVarNamed: 'tid' put: javaProcess id. |
1118 | 219 |
javaThreadObject perform: #'run()V'. |
220 |
(Smalltalk at: #'JavaVM:ThreadTrace') == true ifTrue: [ |
|
221 |
Logger |
|
222 |
log: ('thread ' , javaProcess name , ' terminated') |
|
223 |
severity: #info |
|
224 |
facility: 'JVM'. |
|
1110
7413fa7769ec
- call Thread.exit() even if thread is aborted by user (or Smalltalk code)
vranyj1
parents:
1109
diff
changeset
|
225 |
]. |
1118 | 226 |
] ensure: [ |
227 |
javaThreadObject perform: #'exit()V'. |
|
228 |
(Smalltalk at: #'JavaVM:ThreadTrace') == true ifTrue: [ |
|
229 |
Logger |
|
230 |
log: ('after exit of thread ' , javaProcess name) |
|
231 |
severity: #info |
|
232 |
facility: 'JVM'. |
|
1110
7413fa7769ec
- call Thread.exit() even if thread is aborted by user (or Smalltalk code)
vranyj1
parents:
1109
diff
changeset
|
233 |
] |
905 | 234 |
] |
235 |
] |
|
236 |
] |
|
1118 | 237 |
] ensure: [ |
1122 | 238 |
JavaVM leaveMonitorsOfProcess: javaProcess. |
1118 | 239 |
javaProcess == (Smalltalk at: #'JavaVM:JavaScreenUpdaterThread') ifTrue: [ |
240 |
Smalltalk at: #'JavaVM:JavaScreenUpdaterThread' put: nil. |
|
1090 | 241 |
]. |
1118 | 242 |
javaProcess == (Smalltalk at: #'JavaVM:JavaEventQueueThread') ifTrue: [ |
243 |
Smalltalk at: #'JavaVM:JavaEventQueueThread' put: nil. |
|
1090 | 244 |
]. |
1118 | 245 |
|
752 | 246 |
"/ screenUpdaterClass := Java at:'sun.awt.ScreenUpdater'. |
247 |
"/ screenUpdaterClass notNil ifTrue:[ |
|
248 |
"/ screenUpdaterClass instVarNamed:'updater' put:nil. |
|
249 |
"/ ]. |
|
1118 | 250 |
|
1249 | 251 |
Java removeThread: javaThreadObject ifAbsent: []. |
905 | 252 |
] |
253 |
] |
|
752 | 254 |
|
255 |
"Created: / 15-12-2010 / 11:06:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1213
fc90769151e8
- fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents:
1179
diff
changeset
|
256 |
"Modified: / 04-12-2011 / 20:14:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1249 | 257 |
"Modified: / 09-12-2011 / 12:51:55 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 258 |
! ! |
259 |
||
260 |
!JavaProcess class methodsFor:'documentation'! |
|
261 |
||
262 |
version |
|
1022 | 263 |
^ '$Id$' |
752 | 264 |
! |
265 |
||
266 |
version_SVN |
|
1022 | 267 |
^ '$Id$' |
1000 | 268 |
! ! |