722
|
1 |
"
|
2151
|
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
3 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
|
|
4 |
SWING Research Group, Czech Technical University in Prague
|
|
5 |
|
|
6 |
Parts of the code written by Claus Gittinger are under following
|
|
7 |
license:
|
722
|
8 |
|
|
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.
|
2151
|
15 |
|
|
16 |
Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
|
|
17 |
|
|
18 |
Permission is hereby granted, free of charge, to any person
|
|
19 |
obtaining a copy of this software and associated documentation
|
|
20 |
files (the 'Software'), to deal in the Software without
|
|
21 |
restriction, including without limitation the rights to use,
|
|
22 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
23 |
copies of the Software, and to permit persons to whom the
|
|
24 |
Software is furnished to do so, subject to the following
|
|
25 |
conditions:
|
|
26 |
|
|
27 |
The above copyright notice and this permission notice shall be
|
|
28 |
included in all copies or substantial portions of the Software.
|
|
29 |
|
|
30 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
31 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
32 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
33 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
34 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
35 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
36 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
37 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
38 |
|
|
39 |
[1] Code written at SWING Research Group contain a signature
|
|
40 |
of one of the above copright owners.
|
2118
|
41 |
"
|
722
|
42 |
"{ Package: 'stx:libjava' }"
|
|
43 |
|
|
44 |
Class subclass:#JavaBehavior
|
|
45 |
instanceVariableNames:'constantPool interfaces accessFlags'
|
|
46 |
classVariableNames:'InitialValuePerType A_OBSOLETE A_INTERFACE A_PUBLIC A_FINAL
|
|
47 |
A_ABSTRACT A_INITIALIZED A_SMALLTALK A_ABSTRACT_OR_INTERFACE
|
2146
|
48 |
A_STATIC A_NATIVE A_SYNTHETIC A_ANNOTATION A_ENUM'
|
722
|
49 |
poolDictionaries:''
|
|
50 |
category:'Languages-Java-Classes'
|
|
51 |
!
|
|
52 |
|
|
53 |
!JavaBehavior class methodsFor:'documentation'!
|
|
54 |
|
|
55 |
copyright
|
|
56 |
"
|
2151
|
57 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
58 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
|
|
59 |
SWING Research Group, Czech Technical University in Prague
|
|
60 |
|
|
61 |
Parts of the code written by Claus Gittinger are under following
|
|
62 |
license:
|
722
|
63 |
|
|
64 |
This software is furnished under a license and may be used
|
|
65 |
only in accordance with the terms of that license and with the
|
|
66 |
inclusion of the above copyright notice. This software may not
|
|
67 |
be provided or otherwise made available to, or used by, any
|
|
68 |
other person. No title to or ownership of the software is
|
|
69 |
hereby transferred.
|
2151
|
70 |
|
|
71 |
Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
|
|
72 |
|
|
73 |
Permission is hereby granted, free of charge, to any person
|
|
74 |
obtaining a copy of this software and associated documentation
|
|
75 |
files (the 'Software'), to deal in the Software without
|
|
76 |
restriction, including without limitation the rights to use,
|
|
77 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
78 |
copies of the Software, and to permit persons to whom the
|
|
79 |
Software is furnished to do so, subject to the following
|
|
80 |
conditions:
|
|
81 |
|
|
82 |
The above copyright notice and this permission notice shall be
|
|
83 |
included in all copies or substantial portions of the Software.
|
|
84 |
|
|
85 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
86 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
87 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
88 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
89 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
91 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
92 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
93 |
|
|
94 |
[1] Code written at SWING Research Group contain a signature
|
|
95 |
of one of the above copright owners.
|
|
96 |
|
722
|
97 |
"
|
|
98 |
!
|
|
99 |
|
|
100 |
documentation
|
|
101 |
"
|
|
102 |
Describes what is known and required by the VM.
|
|
103 |
"
|
|
104 |
! !
|
|
105 |
|
|
106 |
!JavaBehavior class methodsFor:'initialization'!
|
|
107 |
|
|
108 |
initialize
|
|
109 |
"/ those are defined in Java and read from the classFile
|
|
110 |
A_PUBLIC := 16r000001.
|
|
111 |
"/ A_PRIVATE := 16r000002.
|
|
112 |
"/ A_PROTECTED := 16r000004.
|
|
113 |
A_STATIC := 16r000008.
|
|
114 |
A_FINAL := 16r000010.
|
|
115 |
"/ A_SUPER := 16r000020.
|
|
116 |
"/ A_SYNCHRONIZED := 16r000020.
|
|
117 |
"/ A_VOLATILE := 16r000040.
|
|
118 |
"/ A_TRANSIENT := 16r000080.
|
|
119 |
A_NATIVE := 16r000100.
|
|
120 |
|
|
121 |
A_INTERFACE := 16r000200.
|
|
122 |
A_ABSTRACT := 16r000400.
|
2146
|
123 |
A_SYNTHETIC := 16r001000. "/ 1.1
|
|
124 |
A_ANNOTATION := 16r002000. "/ 1.1
|
|
125 |
A_ENUM := 16r004000. "/ 1.1
|
722
|
126 |
A_OBSOLETE := 16r008000.
|
|
127 |
|
|
128 |
"/ those are local to the ST/X implementation
|
|
129 |
A_INITIALIZED := 16r100000.
|
|
130 |
A_SMALLTALK := 16r200000.
|
|
131 |
|
|
132 |
A_ABSTRACT_OR_INTERFACE := A_ABSTRACT bitOr:A_INTERFACE.
|
|
133 |
|
|
134 |
InitialValuePerType := IdentityDictionary new.
|
|
135 |
InitialValuePerType at:$B put:0.
|
|
136 |
InitialValuePerType at:$C put:0.
|
|
137 |
InitialValuePerType at:$D put:0.0.
|
|
138 |
InitialValuePerType at:$F put:(0.0 asShortFloat).
|
|
139 |
InitialValuePerType at:$I put:0.
|
|
140 |
InitialValuePerType at:$J put:0.
|
|
141 |
InitialValuePerType at:$S put:0.
|
|
142 |
InitialValuePerType at:$Z put:0.
|
|
143 |
InitialValuePerType at:$L put:nil.
|
|
144 |
InitialValuePerType at:$[ put:nil.
|
|
145 |
|
|
146 |
"
|
|
147 |
JavaBehavior initialize
|
|
148 |
"
|
|
149 |
|
|
150 |
"Modified: / 13.11.1998 / 14:09:52 / cg"
|
|
151 |
! !
|
|
152 |
|
|
153 |
!JavaBehavior class methodsFor:'constants'!
|
|
154 |
|
|
155 |
A_NATIVE
|
|
156 |
^ A_NATIVE
|
|
157 |
|
|
158 |
"Created: / 16.5.1998 / 01:18:43 / cg"
|
|
159 |
!
|
|
160 |
|
|
161 |
A_PUBLIC
|
|
162 |
^ A_PUBLIC
|
|
163 |
|
|
164 |
"Created: / 13.5.1998 / 13:03:18 / cg"
|
|
165 |
!
|
|
166 |
|
|
167 |
A_STATIC
|
|
168 |
^ A_STATIC
|
|
169 |
|
|
170 |
"Created: / 16.5.1998 / 00:02:07 / cg"
|
|
171 |
! !
|
|
172 |
|
|
173 |
!JavaBehavior class methodsFor:'signature parsing'!
|
|
174 |
|
|
175 |
initialValueFromSignature:aSignature
|
|
176 |
"given a signature, return an initializer value"
|
|
177 |
|
|
178 |
|s|
|
|
179 |
|
|
180 |
s := aSignature readStream.
|
|
181 |
^ self initialValueFromStream:s.
|
|
182 |
|
|
183 |
"
|
|
184 |
JavaBehavior initialValueFromSignature:'LObject;'
|
|
185 |
JavaBehavior initialValueFromSignature:'B'
|
|
186 |
JavaBehavior initialValueFromSignature:'I'
|
|
187 |
"
|
|
188 |
!
|
|
189 |
|
|
190 |
initialValueFromStream:s
|
|
191 |
"parse a fieldTypeSpec - see java doc"
|
|
192 |
|
|
193 |
|typeChar|
|
|
194 |
|
|
195 |
typeChar := s next.
|
|
196 |
^ InitialValuePerType at:typeChar ifAbsent:nil.
|
|
197 |
! !
|
|
198 |
|
|
199 |
!JavaBehavior methodsFor:'accessing'!
|
|
200 |
|
2151
|
201 |
accessFlags
|
|
202 |
^ accessFlags
|
|
203 |
!
|
|
204 |
|
722
|
205 |
constantPool
|
|
206 |
^ constantPool
|
|
207 |
!
|
|
208 |
|
|
209 |
interfaces
|
|
210 |
interfaces notNil ifTrue:[
|
|
211 |
interfaces := interfaces collect:[:clsRef |
|
|
212 |
clsRef isUnresolved ifTrue:[
|
|
213 |
clsRef preResolve
|
|
214 |
] ifFalse:[
|
|
215 |
clsRef
|
|
216 |
]
|
|
217 |
].
|
|
218 |
].
|
|
219 |
^ interfaces
|
|
220 |
! !
|
|
221 |
|
2151
|
222 |
!JavaBehavior methodsFor:'compiler interface'!
|
|
223 |
|
|
224 |
programmingLanguage
|
|
225 |
|
|
226 |
^JavaLanguage instance
|
|
227 |
|
|
228 |
"Created: / 26-10-2010 / 23:42:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
229 |
! !
|
|
230 |
|
722
|
231 |
!JavaBehavior methodsFor:'private accessing'!
|
|
232 |
|
|
233 |
makeObsolete
|
|
234 |
accessFlags := accessFlags bitOr:A_OBSOLETE
|
|
235 |
|
|
236 |
"Created: 7.8.1997 / 19:04:48 / cg"
|
|
237 |
!
|
|
238 |
|
|
239 |
markUninitialized
|
|
240 |
(accessFlags bitAnd:A_INITIALIZED) ~~ 0 ifTrue:[
|
|
241 |
accessFlags := accessFlags bitXor:A_INITIALIZED
|
|
242 |
].
|
|
243 |
!
|
|
244 |
|
|
245 |
setAccessFlags:flags
|
|
246 |
accessFlags := flags.
|
|
247 |
|
|
248 |
"Created: 15.4.1996 / 16:42:52 / cg"
|
|
249 |
!
|
|
250 |
|
2151
|
251 |
setConstantPool: aJavaConstantPool
|
|
252 |
constantPool := aJavaConstantPool.
|
|
253 |
constantPool ifNotNil:[constantPool owner: self].
|
722
|
254 |
|
2151
|
255 |
"Created: / 15-04-1996 / 16:42:52 / cg"
|
|
256 |
"Modified: / 22-05-2011 / 13:16:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
722
|
257 |
!
|
|
258 |
|
|
259 |
setInterfaces:i
|
|
260 |
i size > 0 ifTrue:[
|
|
261 |
interfaces := i
|
|
262 |
] ifFalse:[
|
|
263 |
interfaces := nil
|
|
264 |
]
|
|
265 |
|
|
266 |
"Modified: 7.4.1997 / 15:44:53 / cg"
|
2139
|
267 |
! !
|
722
|
268 |
|
|
269 |
!JavaBehavior methodsFor:'queries'!
|
|
270 |
|
|
271 |
hasInterface:aJavaInterface
|
|
272 |
"return true, if I respond to all methods as
|
|
273 |
required by the argument, an aJavaInterface"
|
|
274 |
|
|
275 |
interfaces size > 0 ifTrue:[
|
|
276 |
self interfaces do:[:if |
|
|
277 |
aJavaInterface == if ifTrue:[
|
|
278 |
^ true
|
|
279 |
].
|
|
280 |
]
|
|
281 |
].
|
|
282 |
superclass isJavaClass ifTrue:[
|
|
283 |
^ superclass hasInterface:aJavaInterface
|
|
284 |
].
|
|
285 |
^ false.
|
|
286 |
|
|
287 |
"/ aJavaInterface methodDictionary keysAndValuesDo:[:sel :mthd |
|
|
288 |
"/ (self canUnderstand:sel) ifFalse:[
|
|
289 |
"/ ^ false.
|
|
290 |
"/ ]
|
|
291 |
"/ ].
|
|
292 |
^ true
|
|
293 |
|
|
294 |
"Modified: / 28.1.1998 / 01:46:16 / cg"
|
|
295 |
|
|
296 |
!
|
|
297 |
|
|
298 |
isAbstract
|
|
299 |
"return true, if the receiver is abstract
|
|
300 |
(i.e. may not have instances)"
|
|
301 |
|
|
302 |
^ (accessFlags bitAnd:A_ABSTRACT) ~~ 0
|
|
303 |
|
|
304 |
"Modified: / 7.5.1998 / 12:24:42 / cg"
|
|
305 |
!
|
|
306 |
|
|
307 |
isFinal
|
|
308 |
"return true, if the receiver is final
|
|
309 |
(i.e. may not be subclassed)"
|
|
310 |
|
|
311 |
^ (accessFlags bitAnd:A_FINAL) ~~ 0
|
|
312 |
|
|
313 |
"Modified: / 7.5.1998 / 12:24:21 / cg"
|
|
314 |
!
|
|
315 |
|
|
316 |
isInitialized
|
|
317 |
"return true, if the receiver is initialized"
|
|
318 |
|
|
319 |
^ (accessFlags bitAnd:A_INITIALIZED) ~~ 0
|
|
320 |
|
|
321 |
"Modified: / 7.5.1998 / 12:23:54 / cg"
|
|
322 |
!
|
|
323 |
|
|
324 |
isInterface
|
|
325 |
"return true, if the receiver is an interface"
|
|
326 |
|
|
327 |
^ (accessFlags bitAnd:A_INTERFACE) ~~ 0
|
|
328 |
|
|
329 |
"Modified: / 7.5.1998 / 12:23:39 / cg"
|
|
330 |
!
|
|
331 |
|
|
332 |
isObsolete
|
|
333 |
"return true, if the receiver is obsolete
|
|
334 |
Java classes are never."
|
|
335 |
|
|
336 |
^ (accessFlags bitAnd:A_OBSOLETE) ~~ 0.
|
|
337 |
|
|
338 |
"Modified: 7.8.1997 / 19:04:28 / cg"
|
|
339 |
!
|
|
340 |
|
|
341 |
isPublic
|
|
342 |
"return true, if the receiver is public"
|
|
343 |
|
|
344 |
^ (accessFlags bitAnd:A_PUBLIC) ~~ 0
|
|
345 |
|
|
346 |
"Modified: / 7.5.1998 / 12:22:44 / cg"
|
|
347 |
! !
|
|
348 |
|
|
349 |
!JavaBehavior class methodsFor:'documentation'!
|
|
350 |
|
|
351 |
version
|
2151
|
352 |
^ '$Header: /cvs/stx/stx/libjava/JavaBehavior.st,v 1.4 2011-08-18 18:42:48 vrany Exp $'
|
2146
|
353 |
!
|
|
354 |
|
|
355 |
version_CVS
|
2151
|
356 |
^ '§Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaBehavior.st,v 1.3 2009/10/09 14:04:26 cg Exp §'
|
|
357 |
!
|
|
358 |
|
|
359 |
version_SVN
|
|
360 |
^ '$Id: JavaBehavior.st,v 1.4 2011-08-18 18:42:48 vrany Exp $'
|
722
|
361 |
! !
|
|
362 |
|
2118
|
363 |
JavaBehavior initialize!
|