author | vranyj1 |
Mon, 03 Sep 2012 14:57:38 +0000 | |
branch | jk_new_structure |
changeset 1691 | 826f8d7dc0df |
parent 1249 | 3c82fe50483c |
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. |
1691 | 124 |
jThread notNil ifTrue:[ |
125 |
JavaVM acquireMonitorAndNotifyAll: jThread. |
|
126 |
]. |
|
752 | 127 |
super terminateNoSignal |
128 |
||
129 |
"Created: / 15-12-2010 / 00:18:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1249 | 130 |
"Modified: / 09-12-2011 / 12:51:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
1691 | 131 |
"Modified: / 27-08-2012 / 11:50:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 132 |
! ! |
133 |
||
134 |
!JavaProcess::Helper methodsFor:'initialization'! |
|
135 |
||
136 |
javaProcess:something |
|
137 |
javaProcess := something. |
|
138 |
! |
|
139 |
||
140 |
javaThreadObject:something |
|
141 |
javaThreadObject := something. |
|
142 |
! ! |
|
143 |
||
144 |
!JavaProcess::Helper methodsFor:'support'! |
|
145 |
||
146 |
value |
|
1118 | 147 |
| procName | |
905 | 148 |
Object abortSignal |
1118 | 149 |
handle: [ |
150 |
:ex | |
|
752 | 151 |
procName := javaProcess name. |
1118 | 152 |
(procName startsWith: 'JAVA-AWT-EventQueue') ifTrue: [ |
153 |
Logger |
|
154 |
log: ('thread ' , procName , ' aborted - restarting process.') |
|
155 |
severity: #info |
|
156 |
facility: 'JVM'. |
|
905 | 157 |
ex restart. |
1118 | 158 |
] ifFalse: [ |
159 |
(javaProcess == (Smalltalk at: #'JavaVM:JavaScreenUpdaterThread') |
|
160 |
or: [ javaProcess == (Smalltalk at: #'JavaVM:JavaEventQueueThread') ]) |
|
161 |
ifTrue: [ |
|
162 |
Logger |
|
163 |
log: ('thread ' , procName , ' aborted - restarting process.') |
|
164 |
severity: #info |
|
165 |
facility: 'JVM'. |
|
905 | 166 |
ex restart |
1118 | 167 |
] |
168 |
ifFalse: [ |
|
169 |
Logger |
|
170 |
log: ('thread ' , procName , ' aborted.') |
|
171 |
severity: #info |
|
172 |
facility: 'JVM'. |
|
905 | 173 |
] |
174 |
]. |
|
175 |
] |
|
1118 | 176 |
do: [ |
905 | 177 |
[ |
178 |
JavaVM javaExceptionSignal |
|
1118 | 179 |
handle: [ |
180 |
:ex | |
|
181 |
| exClass | |
|
905 | 182 |
procName := javaProcess name. |
183 |
exClass := ex parameter class. |
|
1118 | 184 |
exClass == (Java at: 'java.lang.ThreadDeath') ifTrue: [ |
185 |
Logger |
|
186 |
log: ('thread ' , procName , ' terminated') |
|
187 |
severity: #info |
|
188 |
facility: 'JVM'. |
|
189 |
] ifFalse: [ |
|
190 |
Logger |
|
191 |
log: ('JAVA: thread ''' , procName , ''' terminated with exception: ' |
|
192 |
, exClass name) |
|
193 |
severity: #info |
|
194 |
facility: 'JVM'. |
|
905 | 195 |
]. |
196 |
ex return. |
|
197 |
] |
|
1118 | 198 |
do: [ |
905 | 199 |
Object messageNotUnderstoodSignal |
1118 | 200 |
handle: [ |
201 |
:ex | |
|
202 |
| |
|
905 | 203 |
"/ remap doesNotUnderstand with nil-receiver to |
204 |
"/ a nullPointerException ... |
|
1118 | 205 |
con m | |
905 | 206 |
con := ex suspendedContext. |
1118 | 207 |
con receiver isNil ifTrue: [ |
208 |
((m := con sender method) notNil and: [ m isJavaMethod ]) ifTrue: [ |
|
905 | 209 |
JavaVM throwNullPointerException. |
210 |
AbortSignal raise. |
|
211 |
||
212 |
"/ ex proceed. |
|
213 |
] |
|
214 |
]. |
|
215 |
ex reject. |
|
216 |
] |
|
1118 | 217 |
do: [ |
905 | 218 |
"/ 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
|
219 |
[ |
1249 | 220 |
javaThreadObject instVarNamed: 'tid' put: javaProcess id. |
1118 | 221 |
javaThreadObject perform: #'run()V'. |
222 |
(Smalltalk at: #'JavaVM:ThreadTrace') == true ifTrue: [ |
|
223 |
Logger |
|
224 |
log: ('thread ' , javaProcess name , ' terminated') |
|
225 |
severity: #info |
|
226 |
facility: 'JVM'. |
|
1110
7413fa7769ec
- call Thread.exit() even if thread is aborted by user (or Smalltalk code)
vranyj1
parents:
1109
diff
changeset
|
227 |
]. |
1118 | 228 |
] ensure: [ |
229 |
javaThreadObject perform: #'exit()V'. |
|
230 |
(Smalltalk at: #'JavaVM:ThreadTrace') == true ifTrue: [ |
|
231 |
Logger |
|
232 |
log: ('after exit of thread ' , javaProcess name) |
|
233 |
severity: #info |
|
234 |
facility: 'JVM'. |
|
1110
7413fa7769ec
- call Thread.exit() even if thread is aborted by user (or Smalltalk code)
vranyj1
parents:
1109
diff
changeset
|
235 |
] |
905 | 236 |
] |
237 |
] |
|
238 |
] |
|
1118 | 239 |
] ensure: [ |
1122 | 240 |
JavaVM leaveMonitorsOfProcess: javaProcess. |
1118 | 241 |
javaProcess == (Smalltalk at: #'JavaVM:JavaScreenUpdaterThread') ifTrue: [ |
242 |
Smalltalk at: #'JavaVM:JavaScreenUpdaterThread' put: nil. |
|
1090 | 243 |
]. |
1118 | 244 |
javaProcess == (Smalltalk at: #'JavaVM:JavaEventQueueThread') ifTrue: [ |
245 |
Smalltalk at: #'JavaVM:JavaEventQueueThread' put: nil. |
|
1090 | 246 |
]. |
1118 | 247 |
|
752 | 248 |
"/ screenUpdaterClass := Java at:'sun.awt.ScreenUpdater'. |
249 |
"/ screenUpdaterClass notNil ifTrue:[ |
|
250 |
"/ screenUpdaterClass instVarNamed:'updater' put:nil. |
|
251 |
"/ ]. |
|
1118 | 252 |
|
1249 | 253 |
Java removeThread: javaThreadObject ifAbsent: []. |
905 | 254 |
] |
255 |
] |
|
752 | 256 |
|
257 |
"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
|
258 |
"Modified: / 04-12-2011 / 20:14:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1249 | 259 |
"Modified: / 09-12-2011 / 12:51:55 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 260 |
! ! |
261 |
||
262 |
!JavaProcess class methodsFor:'documentation'! |
|
263 |
||
264 |
version |
|
1022 | 265 |
^ '$Id$' |
752 | 266 |
! |
267 |
||
268 |
version_SVN |
|
1022 | 269 |
^ '$Id$' |
1000 | 270 |
! ! |
1691 | 271 |