author | vranyj1 |
Fri, 07 Sep 2012 10:34:24 +0000 | |
branch | jk_new_structure |
changeset 1699 | 73003b9f58fc |
parent 1698 | d32a2a3dce36 |
child 1728 | 0d275432230d |
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:#JavaClassReader |
|
24 |
instanceVariableNames:'inStream msb constants majorVsn minorVsn constNeeds2Slots |
|
775 | 25 |
constSlot classBeingLoaded' |
752 | 26 |
classVariableNames:'Verbose AnnotationsVerbose Silent AbsolutelySilent |
27 |
LazyClassLoading InvalidClassFormatSignal ClassLoaderQuerySignal |
|
1693 | 28 |
JavaArchiveCache MaxContextSize MaxContextSizeLimit' |
1055 | 29 |
poolDictionaries:'JavaConstants' |
752 | 30 |
category:'Languages-Java-Support' |
31 |
! |
|
32 |
||
33 |
!JavaClassReader class methodsFor:'documentation'! |
|
34 |
||
35 |
copyright |
|
36 |
" |
|
877 | 37 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
1152 | 38 |
|
1155 | 39 |
New code and modifications done at SWING Research Group [1]: |
1152 | 40 |
|
877 | 41 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
42 |
SWING Research Group, Czech Technical University in Prague |
|
43 |
||
752 | 44 |
This software is furnished under a license and may be used |
45 |
only in accordance with the terms of that license and with the |
|
46 |
inclusion of the above copyright notice. This software may not |
|
47 |
be provided or otherwise made available to, or used by, any |
|
48 |
other person. No title to or ownership of the software is |
|
49 |
hereby transferred. |
|
877 | 50 |
|
1155 | 51 |
[1] Code written at SWING Research Group contains a signature |
52 |
of one of the above copright owners. For exact set of such code, |
|
53 |
see the differences between this version and version stx:libjava |
|
1152 | 54 |
as of 1.9.2010 |
877 | 55 |
|
752 | 56 |
" |
57 |
! ! |
|
58 |
||
59 |
!JavaClassReader class methodsFor:'initialization'! |
|
60 |
||
61 |
initialize |
|
62 |
InvalidClassFormatSignal := Signal new mayProceed: true. |
|
63 |
InvalidClassFormatSignal notifierString: 'class load failure'. |
|
64 |
InvalidClassFormatSignal nameClass: self message: #invalidClassFormatSignal. |
|
65 |
Verbose := false. |
|
66 |
Silent := true. |
|
67 |
AbsolutelySilent := false. |
|
68 |
||
69 |
"/LazyClassLoading := false. |
|
70 |
||
71 |
LazyClassLoading := true. |
|
72 |
ClassLoaderQuerySignal := QuerySignal new. |
|
1605 | 73 |
OperatingSystem isMSWINDOWSlike ifFalse:[ |
1598 | 74 |
JavaArchiveCache := CacheDictionary new: 32. |
1605 | 75 |
] ifTrue:[ |
76 |
JavaArchiveCache := CacheDictionary new: 8. |
|
1598 | 77 |
]. |
752 | 78 |
AnnotationsVerbose := false. |
1693 | 79 |
MaxContextSize := 0. |
771 | 80 |
|
1614
f7d4888fb1a2
- JavaClassReader: added check for VM stack-depth limit
vranyj1
parents:
1612
diff
changeset
|
81 |
"Maximum stack depth supported by the VM. |
f7d4888fb1a2
- JavaClassReader: added check for VM stack-depth limit
vranyj1
parents:
1612
diff
changeset
|
82 |
if you change it, make sure it is equal (or lower) |
1694
c9c3667b4e55
Increased MaxContextSizeLimit to 100 (max seen value so far is 80)
vranyj1
parents:
1693
diff
changeset
|
83 |
to CONSIZE in jinterpret.c (line 111 or so) |
1614
f7d4888fb1a2
- JavaClassReader: added check for VM stack-depth limit
vranyj1
parents:
1612
diff
changeset
|
84 |
Otherwise, VM may crash!!!!!!" |
1694
c9c3667b4e55
Increased MaxContextSizeLimit to 100 (max seen value so far is 80)
vranyj1
parents:
1693
diff
changeset
|
85 |
MaxContextSizeLimit := 100. |
1614
f7d4888fb1a2
- JavaClassReader: added check for VM stack-depth limit
vranyj1
parents:
1612
diff
changeset
|
86 |
|
f7d4888fb1a2
- JavaClassReader: added check for VM stack-depth limit
vranyj1
parents:
1612
diff
changeset
|
87 |
|
752 | 88 |
" |
89 |
JavaClassReader initialize" |
|
90 |
||
91 |
"Modified: / 27-01-1998 / 17:54:23 / cg" |
|
92 |
"Modified: / 17-12-2010 / 17:37:45 / Marcel Hlopko <hlopik@gmail.com>" |
|
772
0f92c23b80ee
testing new project structure + fixing tiny litle bug which caused java not to work at all :)
hlopkmar
parents:
771
diff
changeset
|
93 |
"Modified: / 10-05-2011 / 23:59:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
1598 | 94 |
"Modified: / 14-08-2012 / 02:01:37 / jv" |
1693 | 95 |
"Modified: / 04-09-2012 / 11:55:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 96 |
! ! |
97 |
||
98 |
!JavaClassReader class methodsFor:'Signal constants'! |
|
99 |
||
100 |
classLoaderQuerySignal |
|
101 |
^ ClassLoaderQuerySignal |
|
102 |
||
103 |
"Created: 14.8.1997 / 19:56:03 / cg" |
|
104 |
! |
|
105 |
||
106 |
invalidClassFormatSignal |
|
107 |
^ InvalidClassFormatSignal |
|
108 |
||
109 |
"Created: 3.8.1997 / 18:17:21 / cg" |
|
110 |
! ! |
|
111 |
||
112 |
!JavaClassReader class methodsFor:'constants'! |
|
113 |
||
114 |
fileMajorVersions |
|
831 | 115 |
^#( |
1612 | 116 |
45 "Java 1.0.2" |
831 | 117 |
46 "Java 1.2" |
920 | 118 |
47 "???" |
119 |
48 "???" |
|
831 | 120 |
49 "Java 5" |
121 |
50 "Java 6" |
|
122 |
). |
|
123 |
||
124 |
" |
|
125 |
JSR 202: |
|
126 |
The Java virtual machine implementation of Sun's JDK release 1.0.2 supports |
|
127 |
class file format versions 45.0 through 45.3 inclusive. Sun's JDK releases |
|
128 |
1.1.X can support class file formats of versions in the range 45.0 through |
|
129 |
45.65535 inclusive. For k > 1 implementations of version 1.k of the Java 2 |
|
130 |
platform can support class file formats of versions in the range 45.0 through |
|
131 |
44+k.0 inclusive. |
|
132 |
" |
|
752 | 133 |
|
134 |
"Created: / 19-10-2010 / 21:40:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
831 | 135 |
"Modified: / 02-06-2011 / 22:50:17 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
920 | 136 |
"Modified: / 18-08-2011 / 19:32:37 / jv" |
1612 | 137 |
"Modified (comment): / 16-08-2012 / 15:34:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 138 |
! |
139 |
||
140 |
fileMinorVersions |
|
141 |
^ #( |
|
1612 | 142 |
3 "Java 1.0.2 , Java 1.2" |
752 | 143 |
0 "Java 6" |
144 |
) |
|
145 |
||
146 |
"Created: / 19-10-2010 / 21:41:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
147 |
! |
|
148 |
||
149 |
magic_LSB |
|
150 |
^ 16rBEBAFECA |
|
151 |
||
152 |
"Modified: / 7.5.1998 / 13:14:27 / cg" |
|
153 |
"Created: / 7.5.1998 / 13:15:05 / cg" |
|
154 |
! |
|
155 |
||
156 |
magic_MSB |
|
157 |
^ 16rCAFEBABE |
|
158 |
||
159 |
"Modified: / 7.5.1998 / 13:14:27 / cg" |
|
160 |
! ! |
|
161 |
||
162 |
!JavaClassReader class methodsFor:'debugging'! |
|
163 |
||
164 |
annotationsVerbose:aBoolean |
|
165 |
AnnotationsVerbose := aBoolean |
|
166 |
||
167 |
" |
|
168 |
Java flushClasses. |
|
169 |
JavaClassReader verbose:true |
|
170 |
JavaClassReader verbose:false" |
|
171 |
||
172 |
"Created: / 25-02-2011 / 12:25:23 / Marcel Hlopko <hlopik@gmail.com>" |
|
173 |
! |
|
174 |
||
175 |
verbose:aBoolean |
|
176 |
Verbose := aBoolean |
|
177 |
||
178 |
" |
|
179 |
Java flushClasses. |
|
180 |
JavaClassReader verbose:true |
|
181 |
JavaClassReader verbose:false |
|
182 |
" |
|
183 |
! ! |
|
184 |
||
185 |
!JavaClassReader class methodsFor:'file reading'! |
|
186 |
||
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
187 |
readClass: aClassName |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
188 |
"reads a class, and returns it. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
189 |
<clinit> is called, class is not installed" |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
190 |
|
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
191 |
^ self readClass: aClassName ignoring: Set new. |
752 | 192 |
|
960 | 193 |
"Created: / 15-04-1996 / 14:58:53 / cg" |
194 |
"Modified: / 20-10-1998 / 17:24:54 / cg" |
|
992 | 195 |
"Modified: / 08-09-2011 / 08:10:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 196 |
! |
197 |
||
1059 | 198 |
readClass: aClassName classPath: classPath |
199 |
"reads a class, and returns it. |
|
200 |
<clinit> is called, class is not installed" |
|
201 |
||
202 |
^ self readClass: aClassName ignoring: Set new classPath: classPath |
|
203 |
||
204 |
"Created: / 15-04-1996 / 14:58:53 / cg" |
|
205 |
"Modified: / 20-10-1998 / 17:24:54 / cg" |
|
206 |
"Modified: / 08-09-2011 / 08:10:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
207 |
"Created: / 30-10-2011 / 12:27:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
208 |
! |
|
209 |
||
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
210 |
readClass: className ignoring: classesBeingLoadedOrNil |
1041 | 211 |
|
212 |
"This method is bit hacky, as it tries to supply 'correct' |
|
213 |
classloader. |
|
214 |
||
215 |
If the class is loaded from Java release classPath (containing |
|
216 |
base java classes shipped with JDK/JRE), then set the classloader |
|
217 |
to null. Otherwise set class's loader to system class loader |
|
218 |
(as returned by ClassLoader#getSystemClassLoader()) |
|
219 |
||
220 |
This is required to run groovy and other SW that uses resources |
|
221 |
or other classloader dependent stuff. When changing, make sure |
|
222 |
Groovy is running afterwards!!!!!! |
|
223 |
" |
|
224 |
||
1059 | 225 |
| class | |
1041 | 226 |
class := self |
227 |
readClass: className ignoring: classesBeingLoadedOrNil |
|
228 |
classPath: Java release classPath. |
|
229 |
class notNil ifTrue:[ ^ class ]. |
|
230 |
||
1058
1db06119bf3e
Temporary commit (fixing class loaders - classes gets registered twice)
vranyj1
parents:
1055
diff
changeset
|
231 |
class isNil ifTrue:[ |
1041 | 232 |
JavaVM booted ifFalse:[ |
1060 | 233 |
^nil |
1041 | 234 |
]. |
1059 | 235 |
JavaClassReader classLoaderQuerySignal answer: JavaVM systemClassLoader do:[ |
1058
1db06119bf3e
Temporary commit (fixing class loaders - classes gets registered twice)
vranyj1
parents:
1055
diff
changeset
|
236 |
class := self |
1db06119bf3e
Temporary commit (fixing class loaders - classes gets registered twice)
vranyj1
parents:
1055
diff
changeset
|
237 |
readClass: className ignoring: classesBeingLoadedOrNil |
1db06119bf3e
Temporary commit (fixing class loaders - classes gets registered twice)
vranyj1
parents:
1055
diff
changeset
|
238 |
classPath: Java classPath. |
1db06119bf3e
Temporary commit (fixing class loaders - classes gets registered twice)
vranyj1
parents:
1055
diff
changeset
|
239 |
]. |
1041 | 240 |
]. |
241 |
||
242 |
^class |
|
243 |
||
244 |
"Created: / 15-04-1996 / 14:58:53 / cg" |
|
245 |
"Modified: / 20-10-1998 / 17:24:54 / cg" |
|
246 |
"Modified: / 21-10-2011 / 13:39:14 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1060 | 247 |
"Modified: / 30-10-2011 / 16:50:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1041 | 248 |
! |
249 |
||
250 |
readClass: className ignoring: classesBeingLoadedOrNil classPath: classPath |
|
1036 | 251 |
"searches classspath for a class, loads it and returns. |
252 |
<clinit> is not called, class is not installed as global" |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
253 |
|
1036 | 254 |
| rslt clsName classesBeingLoaded | |
255 |
clsName := className asInternalJavaClassName. |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
256 |
classesBeingLoadedOrNil isNil ifTrue: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
257 |
classesBeingLoaded := Set with: clsName |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
258 |
] ifFalse: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
259 |
classesBeingLoaded := classesBeingLoadedOrNil |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
260 |
add: clsName; |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
261 |
yourself. |
1021
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
262 |
]. |
1041 | 263 |
classPath do: [:path | |
1021
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
264 |
| nm p zar entry zipFile read | |
1041 | 265 |
|
1562 | 266 |
p := path asString. |
1021
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
267 |
p asFilename isDirectory ifTrue: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
268 |
(p endsWith: Filename separator) ifFalse: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
269 |
p := p , (Filename separator asString) |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
270 |
]. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
271 |
(Array |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
272 |
with: clsName |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
273 |
with: clsName asLowercase |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
274 |
with: clsName asUppercase) |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
275 |
do: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
276 |
:tryName | |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
277 |
nm := p , tryName , '.class'. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
278 |
nm asFilename exists ifTrue: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
279 |
(Java isExcludedFromClassPath: nm) ifFalse: [ |
1079 | 280 |
|
1032 | 281 |
"means we are successfully going to read something :)" |
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
282 |
rslt := self readFile: nm ignoring: classesBeingLoaded. |
1032 | 283 |
rslt notNil ifTrue: [ ^ rslt. ]. |
1021
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
284 |
] |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
285 |
]. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
286 |
] |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
287 |
] ifFalse: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
288 |
((zipFile := p asFilename withSuffix: 'jar') exists |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
289 |
or: [ (zipFile := p asFilename withSuffix: 'zip') exists ]) |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
290 |
ifTrue: [ |
1605 | 291 |
"/ Do not use at:ifAbsentPut: here, JavaArchiveCache is a CacheDictionary!!!!!! |
292 |
zar := JavaArchiveCache at: zipFile ifAbsent: nil. |
|
293 |
zar isNil ifTrue:[ |
|
294 |
JavaVM commonOpenStreamUsing:[ zar := ZipArchive oldFileNamed: zipFile ]. |
|
295 |
JavaArchiveCache at: zipFile put: zar |
|
296 |
]. |
|
1021
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
297 |
read := [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
298 |
nm := clsName , '.class'. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
299 |
entry := zar extract: nm. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
300 |
entry notNil ifTrue: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
301 |
(Java isExcludedFromClassPath: nm) ifFalse: [ |
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
302 |
rslt := self readStream: (entry readStream) ignoring: classesBeingLoaded. |
1021
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
303 |
rslt notNil ifTrue: [ ^ rslt ]. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
304 |
] |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
305 |
] |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
306 |
]. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
307 |
JavaClassReader invalidClassFormatSignal |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
308 |
handle: [ |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
309 |
"Kludge, sometimes zar gets corrupted" |
1598 | 310 |
zar := JavaArchiveCache at: zipFile put: (JavaVM commonOpenStreamUsing: [ZipArchive oldFileNamed: zipFile]). |
1021
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
311 |
read value |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
312 |
] |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
313 |
do: [ read value ]. |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
314 |
] |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
315 |
] |
8ae6c261878a
changed class loaders order, loading of primitive arrays, refactoring coming soon..
hlopkmar
parents:
1000
diff
changeset
|
316 |
]. |
1037 | 317 |
^nil |
752 | 318 |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
319 |
"Created: / 15-04-1996 / 14:58:53 / cg" |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
320 |
"Modified: / 20-10-1998 / 17:24:54 / cg" |
1041 | 321 |
"Created: / 23-10-2011 / 21:48:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1079 | 322 |
"Modified: / 03-11-2011 / 18:14:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
1598 | 323 |
"Modified: / 14-08-2012 / 02:17:59 / jv" |
1605 | 324 |
"Modified: / 14-08-2012 / 21:44:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 325 |
! |
326 |
||
1602 | 327 |
readFile:aFilename ignoring:classesBeingLoaded |
752 | 328 |
"reads a class from aFilename and returns it. |
329 |
The JavaClass is NOT installed as global and unresolved |
|
330 |
refs are NOT patched." |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
331 |
|
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
332 |
| inStream javaClass | |
752 | 333 |
|
1602 | 334 |
[ |
335 |
JavaVM commonOpenStreamUsing:[ inStream := aFilename asFilename readStream ] |
|
336 |
] on:StreamError do:[:ex | |
|
337 |
Logger |
|
338 |
log:('cannot read .class file: ' , ex description) severity:#error facility:'JVM'. |
|
339 |
self breakPoint: #jv. |
|
340 |
^ nil |
|
752 | 341 |
]. |
1602 | 342 |
|
343 |
[ |
|
344 |
javaClass := self readStream:inStream ignoring:classesBeingLoaded. |
|
345 |
(javaClass notNil and:[ javaClass isJavaClass ]) ifTrue:[ |
|
346 |
javaClass setBinaryFilePath:(inStream pathName). |
|
347 |
]. |
|
348 |
] ensure:[ |
|
349 |
inStream close. |
|
350 |
]. |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
351 |
^ javaClass. |
752 | 352 |
|
898 | 353 |
"Created: / 15-04-1996 / 14:58:53 / cg" |
354 |
"Modified: / 09-05-1998 / 01:44:24 / cg" |
|
1598 | 355 |
"Modified: / 14-08-2012 / 02:17:26 / jv" |
1602 | 356 |
"Modified: / 14-08-2012 / 17:08:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 357 |
! |
358 |
||
1041 | 359 |
readStream: aStream |
360 |
"reads a class from aStream and returns it. |
|
361 |
The JavaClass is not installed as global" |
|
362 |
||
363 |
^self readStream: aStream ignoring: Set new. |
|
364 |
||
365 |
"Created: / 24-10-2011 / 00:12:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
366 |
! |
|
367 |
||
771 | 368 |
readStream: aStream ignoring: classesBeingLoaded |
752 | 369 |
"reads a class from aStream and returns it. |
370 |
The JavaClass is not installed as global" |
|
771 | 371 |
|
372 |
| javaClass | |
|
373 |
||
1060 | 374 |
javaClass := JavaClassReader new readStream: aStream ignoring: classesBeingLoaded. |
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
375 |
Logger |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
376 |
log: 'loaded class ' , javaClass displayString |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
377 |
severity: #info |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
378 |
facility: 'JVM'. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
379 |
^ javaClass. |
752 | 380 |
|
771 | 381 |
"Modified: / 30-03-1998 / 18:14:40 / cg" |
382 |
"Modified: / 09-05-2011 / 23:15:30 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1000 | 383 |
"Modified: / 14-09-2011 / 22:21:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1060 | 384 |
"Modified (format): / 30-10-2011 / 18:02:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 385 |
! ! |
386 |
||
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
387 |
!JavaClassReader class methodsFor:'obsolete'! |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
388 |
|
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
389 |
resolveClass: aJavaClass |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
390 |
"Resolve a particular classes' constants. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
391 |
Perform all class initialization functions |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
392 |
(of those which are not yet initialized)." |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
393 |
|
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
394 |
| loader classToLoad | |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
395 |
|
1118 | 396 |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
397 |
"new resolving does not need this - shouldn't be called at all" |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
398 |
LazyClassLoading ifFalse: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
399 |
loader := (aJavaClass classLoader). |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
400 |
[ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
401 |
classToLoad := nil. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
402 |
aJavaClass constantPool do: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
403 |
:item | |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
404 |
| itemClass | |
771 | 405 |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
406 |
itemClass := item class. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
407 |
itemClass == JavaUnresolvedClassConstant ifTrue: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
408 |
classToLoad := item className. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
409 |
|
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
410 |
"/ ] ifFalse:[ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
411 |
"/ itemClass == JavaUnresolvedMethodrefConstant ifTrue:[ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
412 |
"/self halt. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
413 |
"/ ] ifFalse:[ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
414 |
"/ itemClass == JavaUnresolvedInterfaceMethodrefConstant ifTrue:[ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
415 |
"/self halt. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
416 |
"/ ] |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
417 |
"/ ] |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
418 |
]. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
419 |
]. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
420 |
classToLoad notNil ifTrue: [ |
1033 | 421 |
loader isNil ifTrue: [ JavaVM classForName: classToLoad. ] ifFalse: [ |
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
422 |
"/ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
423 |
"/ the aquired loader is a javaClassLoader |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
424 |
"/ which expects an URL as arg. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
425 |
"/ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
426 |
"/ classURL := Java as_URL:('file:' , nextUnresolved asString , '.class'). |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
427 |
"/ loader loadClass:classURL |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
428 |
loader perform: #'loadClass(Ljava/lang/String;)Ljava/lang/Class;' |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
429 |
with: (Java as_String: (classToLoad asString)). |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
430 |
] |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
431 |
]. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
432 |
classToLoad notNil. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
433 |
] whileTrue. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
434 |
aJavaClass isInitialized ifFalse: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
435 |
Silent ifFalse: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
436 |
'performing class initialization of ' print. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
437 |
aJavaClass fullName printCR. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
438 |
]. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
439 |
aJavaClass classInit |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
440 |
]. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
441 |
] |
771 | 442 |
|
1118 | 443 |
"Created: / 20-10-1998 / 17:53:22 / cg" |
444 |
"Modified: / 16-11-2011 / 14:39:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
771 | 445 |
! ! |
446 |
||
447 |
!JavaClassReader methodsFor:'accessing'! |
|
448 |
||
449 |
constants |
|
450 |
^ constants. |
|
451 |
||
452 |
"Created: / 10-05-2011 / 13:48:30 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
453 |
! |
|
454 |
||
455 |
constants: aJavaConstantPool |
|
456 |
constants := aJavaConstantPool. |
|
457 |
||
458 |
"Created: / 10-05-2011 / 13:48:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
459 |
! |
|
460 |
||
461 |
stream |
|
462 |
^ inStream. |
|
463 |
||
464 |
"Created: / 09-05-2011 / 23:22:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
465 |
! |
|
466 |
||
467 |
stream:aReadStream |
|
468 |
inStream := aReadStream. |
|
469 |
||
470 |
"Created: / 09-05-2011 / 23:23:11 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
471 |
! ! |
|
472 |
||
752 | 473 |
!JavaClassReader methodsFor:'file reading'! |
474 |
||
771 | 475 |
readClassFileIgnoring: classesbeingLoaded |
752 | 476 |
"reads a class from inStream and returns it. |
477 |
The JavaClass is not installed as global and its constants |
|
478 |
(especially strings) may not be fully resolved." |
|
479 |
||
798
b534e73eaf7e
JavaClassReader2 now uses correct superclass loading
hlopkmar
parents:
797
diff
changeset
|
480 |
| magic access_flags this_class_index super_class super_class_index this_class_ref existingSuperClass fields interfaces staticFields nStatic superClassName thisClassName existing_class thisMetaClass | |
752 | 481 |
|
482 |
"/ |
|
483 |
"/ read magic, determine byte order |
|
484 |
"/ |
|
485 |
msb := true. |
|
771 | 486 |
magic := inStream nextUnsignedLongMSB: true. |
1028
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
487 |
magic = (self class magic_MSB) ifFalse: [ |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
488 |
magic = (self class magic_LSB) ifFalse: [ |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
489 |
InvalidClassFormatSignal raiseErrorString: 'not a java class file'. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
490 |
^ nil |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
491 |
]. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
492 |
msb := false. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
493 |
Verbose ifTrue: [ Transcript showCR: 'file is lsb' ]. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
494 |
] ifTrue: [ Verbose ifTrue: [ Transcript showCR: 'file is msb' ]. ]. |
752 | 495 |
|
496 |
"/ |
|
497 |
"/ get version |
|
498 |
"/ |
|
499 |
||
771 | 500 |
minorVsn := inStream nextUnsignedShortMSB: msb. |
501 |
majorVsn := inStream nextUnsignedShortMSB: msb. |
|
502 |
((self class fileMajorVersions includes: majorVsn) not |
|
503 |
or: [ (self class fileMinorVersions includes: minorVsn) not ]) |
|
1028
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
504 |
ifTrue: [ |
1612 | 505 |
| path | |
506 |
||
507 |
path := inStream isFileStream ifTrue:[ |
|
508 |
path := inStream pathName |
|
509 |
] ifFalse:[ |
|
510 |
path := '<memory>' |
|
511 |
]. |
|
512 |
self info: |
|
513 |
('class reader: file ', path , ' has version ' , |
|
514 |
majorVsn printString , |
|
515 |
'.' , minorVsn printString) |
|
516 |
||
517 |
]. |
|
752 | 518 |
"/ |
519 |
"/ get constant pool |
|
520 |
"/ |
|
521 |
||
522 |
self readConstantPool. |
|
523 |
||
524 |
"/ |
|
525 |
"/ access flags |
|
526 |
"/ |
|
527 |
||
771 | 528 |
access_flags := inStream nextUnsignedShortMSB: msb. |
529 |
this_class_index := inStream nextUnsignedShortMSB: msb. |
|
530 |
super_class_index := inStream nextUnsignedShortMSB: msb. |
|
1028
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
531 |
super_class_index == 0 ifTrue: [ super_class := nil ] ifFalse: [ |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
532 |
super_class := constants at: super_class_index. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
533 |
superClassName := super_class fullName. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
534 |
|
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
535 |
"/ special for ST-classes |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
536 |
|
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
537 |
(superClassName startsWith: 'smalltalk.') ifTrue: [ |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
538 |
"/ a Smalltalk class |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
539 |
superClassName := superClassName copyFrom: 11. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
540 |
existingSuperClass := Smalltalk at: superClassName asSymbol. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
541 |
existingSuperClass notNil ifTrue: [ super_class := existingSuperClass ] ifFalse: [ |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
542 |
"/ self halt - must load superclass ... |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
543 |
] |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
544 |
] ifFalse: [ |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
545 |
"/ a JAVA class |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
546 |
super_class := Java classNamed: superClassName. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
547 |
super_class |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
548 |
ifNil: [ |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
549 |
super_class := self |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
550 |
loadSuperclassIdentifiedBy: (constants at: super_class_index) |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
551 |
ignoring: classesbeingLoaded |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
552 |
]. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
553 |
super_class ifNil: [ self halt: 'Cannot find super class?!!' ]. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
554 |
]. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
555 |
]. |
752 | 556 |
|
557 |
"/ |
|
558 |
"/ get interfaces |
|
559 |
"/ |
|
560 |
||
561 |
interfaces := self readInterfaces. |
|
562 |
||
563 |
"/ |
|
564 |
"/ get fields |
|
565 |
"/ |
|
566 |
||
567 |
fields := self readFieldInfofields. |
|
568 |
||
569 |
"/ |
|
570 |
"/ create the fields as instVars |
|
571 |
"/ static fields are created as class-InstVars |
|
572 |
"/ |
|
798
b534e73eaf7e
JavaClassReader2 now uses correct superclass loading
hlopkmar
parents:
797
diff
changeset
|
573 |
|
771 | 574 |
staticFields := fields select: [:f | f isStatic ]. |
752 | 575 |
nStatic := staticFields size. |
771 | 576 |
this_class_ref := constants at: this_class_index. |
1062
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1060
diff
changeset
|
577 |
thisClassName := this_class_ref fullName asSlashedJavaClassName. |
752 | 578 |
|
579 |
"/ care for smalltalk classes ... |
|
580 |
||
1028
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
581 |
(thisClassName startsWith: 'smalltalk.') ifTrue: [ |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
582 |
thisClassName := thisClassName copyFrom: 11. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
583 |
existing_class := Smalltalk at: thisClassName asSymbol. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
584 |
existing_class notNil ifTrue: [ |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
585 |
self halt: ('overloading existing class: ' , thisClassName). |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
586 |
thisClassName := (thisClassName , '_new') asSymbol. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
587 |
]. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
588 |
thisMetaClass := Metaclass new. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
589 |
thisMetaClass setSuperclass: super_class class. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
590 |
thisMetaClass instSize: (super_class class instSize + nStatic). |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
591 |
classBeingLoaded := thisMetaClass new. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
592 |
classBeingLoaded setSuperclass: super_class. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
593 |
classBeingLoaded setName: thisClassName asSymbol. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
594 |
] ifFalse: [ |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
595 |
"/ a java class |
1139
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
596 |
Class withoutUpdatingChangesDo:[ |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
597 |
classBeingLoaded := JavaClass fullName: thisClassName numStatic: nStatic. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
598 |
classBeingLoaded classLoader: self class classLoaderQuerySignal query. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
599 |
fields := fields select: [:f | f isStatic not ]. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
600 |
JavaClass setInstanceVariableStringFromFields: staticFields |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
601 |
in: classBeingLoaded class. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
602 |
classBeingLoaded setStaticFields: staticFields. |
1205 | 603 |
"/JV@2011-12-03: Don't initialize fields now, java.lang.String may not be present. |
604 |
"/ Static fields are now initialized in #classInit (which is called |
|
605 |
"/ during GETSTATIC/PUTSTATIC field resolving |
|
606 |
"/classBeingLoaded initializeStaticFields. |
|
1139
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
607 |
classBeingLoaded setAccessFlags: access_flags. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
608 |
classBeingLoaded setSuperclass: super_class. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
609 |
classBeingLoaded setConstantPool: constants. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
610 |
classBeingLoaded setFields: fields. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
611 |
classBeingLoaded setInterfaces: interfaces. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
612 |
] |
1028
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
613 |
]. |
752 | 614 |
|
615 |
"/ |
|
616 |
"/ get methods |
|
617 |
"/ |
|
618 |
||
775 | 619 |
self readMethodsFor: classBeingLoaded. |
620 |
self readAttributesFor: classBeingLoaded. |
|
1698
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
621 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
622 |
"/ |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
623 |
"/ get extensions |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
624 |
"/ |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
625 |
self readExtensionsFor: classBeingLoaded. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
626 |
|
796
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
627 |
classBeingLoaded fields do: [:each | self updateOwnerInField: each ]. |
1033 | 628 |
classBeingLoaded staticFields do: [:each | self updateOwnerInField: each ]. |
1038 | 629 |
classesbeingLoaded remove: classBeingLoaded name ifAbsent:[]. |
775 | 630 |
^ classBeingLoaded. |
752 | 631 |
|
632 |
" |
|
633 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
634 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
635 |
JavaClassReader loadFile:'foo.cls' |
|
636 |
||
637 |
JavaClassReader verbose:true. |
|
638 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/java/lang/ArithmeticException.class' |
|
639 |
JavaClassReader loadFile:'/phys/ibm3/java/lib/java/lang/ArithmeticException.class'" |
|
1035 | 640 |
|
752 | 641 |
"Created: / 15-04-1996 / 15:02:47 / cg" |
642 |
"Modified: / 12-11-1998 / 21:14:45 / cg" |
|
643 |
"Modified: / 15-10-2010 / 17:37:38 / Jan Kurs <kurs.jan@post.cz>" |
|
644 |
"Modified: / 28-01-2011 / 15:09:48 / Marcel Hlopko <hlopik@gmail.com>" |
|
800
11f2222f816d
forgotten return and fixed broken class reading (static field were not set up correctly)..
hlopkmar
parents:
799
diff
changeset
|
645 |
"Modified: / 18-05-2011 / 15:30:29 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
1698
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
646 |
"Modified: / 06-09-2012 / 11:37:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 647 |
! |
648 |
||
649 |
readStream:aStream ignoring:classesBeingLoaded |
|
650 |
"reads a class from aStream and returns it. |
|
651 |
The JavaClass is not installed as global" |
|
652 |
||
653 |
inStream := aStream. |
|
654 |
inStream binary. |
|
655 |
||
656 |
^ self readClassFileIgnoring:classesBeingLoaded |
|
657 |
||
658 |
" |
|
659 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
660 |
" |
|
661 |
||
662 |
"Created: 15.4.1996 / 15:00:55 / cg" |
|
663 |
"Modified: 15.4.1996 / 15:06:18 / cg" |
|
664 |
! ! |
|
665 |
||
666 |
!JavaClassReader methodsFor:'file reading - attributes'! |
|
667 |
||
668 |
readAnnotationDefaultAttributeFor:something |
|
669 |
"/ ('JAVA [info]: unhandled attribute: AnnotationDefault') infoPrintCR. |
|
670 |
||
671 |
|len startPos endPos annotationDefault| |
|
672 |
||
673 |
self assert:something isJavaMethod |
|
674 |
description:'AnnotationDefault may only occure for methods!!'. |
|
675 |
len := inStream nextUnsignedLongMSB:msb. |
|
676 |
startPos := inStream position. |
|
677 |
annotationDefault := (something ensureHasAnnotations) |
|
678 |
default:(JavaAnnotationDefault new |
|
679 |
value:(self readAnnotationValueFor:something)); |
|
680 |
default. |
|
681 |
endPos := inStream position. |
|
682 |
inStream position:startPos. |
|
683 |
annotationDefault bytes:(inStream next:len). |
|
684 |
self assert:inStream position = endPos |
|
685 |
description:'self readAnnotationValueFor: something is reading what it shouldn'. |
|
686 |
||
687 |
"Modified: / 28-02-2011 / 17:08:28 / Marcel Hlopko <hlopik@gmail.com>" |
|
688 |
"Modified: / 03-03-2011 / 23:06:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
689 |
! |
|
690 |
||
691 |
readAnnotationFor:something |
|
692 |
| typeIndex type result attrsCount | |
|
693 |
||
694 |
typeIndex := inStream nextUnsignedShortMSB:msb. |
|
879 | 695 |
type := constants at:typeIndex. |
752 | 696 |
attrsCount := inStream nextUnsignedShortMSB:msb. |
697 |
result := JavaAnnotation for:something. |
|
698 |
result name:type. |
|
699 |
attrsCount timesRepeat: |
|
700 |
[ | nameIndex name valueIndex attr | |
|
701 |
||
702 |
nameIndex := inStream nextUnsignedShortMSB:msb. |
|
879 | 703 |
name := constants at:nameIndex. |
752 | 704 |
attr := self readAnnotationValueFor:something. |
705 |
attr name:name. |
|
706 |
result values at:attr name put:attr. |
|
707 |
AnnotationsVerbose |
|
708 |
ifTrue:[ ('JAVA [INFO]: Reading annotation attribute: ' , name) infoPrintCR. ]. ]. |
|
709 |
^ result. |
|
710 |
||
711 |
"Created: / 17-12-2010 / 16:21:28 / Marcel Hlopko <hlopik@gmail.com>" |
|
712 |
"Modified: / 25-02-2011 / 12:25:36 / Marcel Hlopko <hlopik@gmail.com>" |
|
879 | 713 |
"Modified: / 27-07-2011 / 09:37:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 714 |
! |
715 |
||
716 |
readAnnotationValueFor:something |
|
717 |
| tag result | |
|
718 |
||
719 |
tag := (inStream nextByte) asCharacter. |
|
720 |
tag = $e |
|
721 |
ifTrue: |
|
722 |
[ result := JavaAnnotationEnumValue for:something. |
|
723 |
result nameIndex:(inStream nextUnsignedShortMSB:msb). |
|
724 |
result valueIndex:(inStream nextUnsignedShortMSB:msb). |
|
725 |
AnnotationsVerbose |
|
726 |
ifTrue: |
|
727 |
[ ('JAVA [INFO]: Reading annotation enum value: ' , result name printString, ' -> ' |
|
728 |
, result value printString) infoPrintCR ]. |
|
729 |
^ result ]. |
|
730 |
tag = $c |
|
731 |
ifTrue: |
|
732 |
[ result := JavaAnnotationClassValue for:something. |
|
733 |
result classIndex:(inStream nextUnsignedShortMSB:msb). |
|
734 |
AnnotationsVerbose |
|
735 |
ifTrue: |
|
736 |
[ ('JAVA [INFO]: Reading annotation class value: ' , result name printString, ' -> ' |
|
737 |
, result value printString) infoPrintCR ]. |
|
738 |
^ result ]. |
|
739 |
tag = $@ |
|
740 |
ifTrue: |
|
741 |
[ result := JavaAnnotationNestedAnnotationValue for:something. |
|
742 |
result classIndex:(inStream nextUnsignedShortMSB:msb). |
|
743 |
AnnotationsVerbose |
|
744 |
ifTrue: |
|
745 |
[ ('JAVA [INFO]: Reading annotation nested annotation value: ' , result name printString |
|
746 |
, ' -> ' , result value printString) |
|
747 |
infoPrintCR ]. |
|
748 |
^ result ]. |
|
749 |
tag = $[ |
|
750 |
ifTrue: |
|
751 |
[ result := JavaAnnotationArrayValue for:something. |
|
752 |
result count:(inStream nextUnsignedShortMSB:msb). |
|
753 |
AnnotationsVerbose |
|
754 |
ifTrue:[ ('JAVA [INFO]: Reading annotation array value') infoPrintCR ]. |
|
755 |
1 to:result count |
|
756 |
do:[:index | result values at:index put:(self readAnnotationValueFor:something) ]. |
|
757 |
AnnotationsVerbose |
|
758 |
ifTrue: |
|
759 |
[ ('JAVA [INFO]: Finished reading annotation array value: ' |
|
760 |
, result value printString) infoPrintCR ]. |
|
761 |
^ result ]. |
|
762 |
result := JavaAnnotationPrimitiveValue for:something. |
|
763 |
result valueIndex:(inStream nextUnsignedShortMSB:msb). |
|
764 |
AnnotationsVerbose |
|
765 |
ifTrue: |
|
766 |
[ ('JAVA [INFO]: Finished reading annotation primitive value: ' |
|
767 |
, result name printString , ' -> ' , result value printString) infoPrintCR ]. |
|
768 |
^ result. |
|
769 |
||
770 |
"Created: / 17-12-2010 / 16:44:14 / Marcel Hlopko <hlopik@gmail.com>" |
|
771 |
"Modified: / 28-02-2011 / 16:12:09 / Marcel Hlopko <hlopik@gmail.com>" |
|
772 |
! |
|
773 |
||
774 |
readAttribute:attributeName for:something |
|
775 |
"/ implemented JAVA attributes |
|
776 |
||
777 |
(attributeName = 'ConstantValue') |
|
778 |
ifTrue: |
|
779 |
[ self readConstantValueAttributeFor:something. |
|
780 |
^ self. ]. |
|
781 |
(attributeName = 'Code') |
|
782 |
ifTrue: |
|
783 |
[ self readCodeAttributeFor:something. |
|
784 |
^ self. ]. |
|
785 |
(attributeName = 'Exceptions') |
|
786 |
ifTrue: |
|
787 |
[ self readExceptionsAttributeFor:something. |
|
788 |
^ self. ]. |
|
789 |
(attributeName = 'InnerClasses') |
|
790 |
ifTrue: |
|
791 |
[ self readInnerClassesAttributeFor:something. |
|
792 |
^ self. ]. |
|
793 |
(attributeName = 'EnclosingMethod') |
|
794 |
ifTrue: |
|
795 |
[ self readEnclosingMethodAttributeFor:something. |
|
796 |
^ self. ]. |
|
797 |
(attributeName = 'LineNumberTable') |
|
798 |
ifTrue: |
|
799 |
[ self readLineNumberTableAttributeFor:something. |
|
800 |
^ self. ]. |
|
801 |
(attributeName = 'LocalVariableTable') |
|
802 |
ifTrue: |
|
803 |
[ self readLocalVariableTableAttributeFor:something. |
|
804 |
^ self. ]. |
|
805 |
(attributeName = 'LocalVariableTypeTable') |
|
806 |
ifTrue: |
|
807 |
[ self readLocalVariableTypeTableAttributeFor:something. |
|
808 |
^ self. ]. |
|
809 |
(attributeName = 'SourceFile') |
|
810 |
ifTrue: |
|
811 |
[ self readSourceFileAttributeFor:something. |
|
812 |
^ self. ]. |
|
813 |
(attributeName = 'SourceDebugExtension') |
|
814 |
ifTrue: |
|
815 |
[ self readSourceDebugExtensionAttributeFor:something. |
|
816 |
^ self. ]. |
|
817 |
(attributeName = 'Synthetic') |
|
818 |
ifTrue: |
|
819 |
[ self readSyntheticAttributeFor:something. |
|
820 |
^ self. ]. |
|
821 |
(attributeName = 'Signature') |
|
822 |
ifTrue: |
|
823 |
[ self readSignatureAttributeFor:something. |
|
824 |
^ self. ]. |
|
825 |
(attributeName = 'Deprecated') |
|
826 |
ifTrue: |
|
827 |
[ self readDeprecatedAttributeFor:something. |
|
828 |
^ self. ]. |
|
829 |
(attributeName = 'RuntimeVisibleAnnotations') |
|
830 |
ifTrue: |
|
831 |
[ self readRuntimeAnnotationsAttributeFor:something visible:true. |
|
832 |
^ self. ]. |
|
833 |
(attributeName = 'RuntimeInvisibleAnnotations') |
|
834 |
ifTrue: |
|
835 |
[ self readRuntimeAnnotationsAttributeFor:something visible:false. |
|
836 |
^ self. ]. |
|
837 |
(attributeName = 'RuntimeVisibleParameterAnnotations') |
|
838 |
ifTrue: |
|
839 |
[ self readRuntimeParameterAnnotationsAttributeFor:something visible:true. |
|
840 |
^ self. ]. |
|
841 |
(attributeName = 'RuntimeInvisibleParameterAnnotations') |
|
842 |
ifTrue: |
|
843 |
[ self readRuntimeParameterAnnotationsAttributeFor:something visible:false. |
|
844 |
^ self. ]. |
|
845 |
(attributeName = 'AnnotationDefault') |
|
846 |
ifTrue: |
|
847 |
[ self readAnnotationDefaultAttributeFor:something. |
|
848 |
^ self. ]. |
|
849 |
||
850 |
"/ ignored JAVA attributes |
|
851 |
||
852 |
(attributeName = 'FastJavac1.0') |
|
853 |
ifTrue: |
|
854 |
[ "/ ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR. |
|
855 |
self skipAttribute:attributeName. |
|
856 |
^ self. ]. |
|
857 |
(attributeName = 'AbsoluteSourcePath') |
|
858 |
ifTrue: |
|
859 |
[ ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR. |
|
860 |
self skipAttribute:attributeName. |
|
861 |
^ self. ]. |
|
862 |
(attributeName startsWith:((Character value:13) asString , 'WARNING:')) |
|
863 |
ifTrue: |
|
864 |
[ "/ ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR. |
|
865 |
self skipAttribute:attributeName. |
|
866 |
^ self. ]. |
|
867 |
(attributeName = 'StackMapTable') |
|
868 |
ifTrue: |
|
869 |
[ "/ ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR. |
|
870 |
self readStackMapTableAttributeFor:something. |
|
871 |
^ self. ]. |
|
872 |
||
873 |
"/ implemented ST attributes |
|
874 |
||
875 |
(attributeName = 'STLiterals') |
|
876 |
ifTrue: |
|
877 |
[ self readSTLiteralsAttributeFor:something. |
|
878 |
^ self. ]. |
|
879 |
(attributeName = 'ClassRevision') |
|
880 |
ifTrue: |
|
881 |
[ self readSTClassRevisionAttributeFor:something. |
|
882 |
^ self. ]. |
|
883 |
(attributeName = 'ClassPackage') |
|
884 |
ifTrue: |
|
885 |
[ self readSTClassPackageAttributeFor:something. |
|
886 |
^ self. ]. |
|
887 |
(attributeName = 'ClassCategory') |
|
888 |
ifTrue: |
|
889 |
[ self readSTClassCategoryAttributeFor:something. |
|
890 |
^ self. ]. |
|
891 |
(attributeName = 'ClassVarNames') |
|
892 |
ifTrue: |
|
893 |
[ self readSTClassVarNamesAttributeFor:something. |
|
894 |
^ self. ]. |
|
895 |
(attributeName = 'ClassInstVarNames') |
|
896 |
ifTrue: |
|
897 |
[ self readSTClassInstVarNamesAttributeFor:something. |
|
898 |
^ self. ]. |
|
899 |
(attributeName = 'InstVarNames') |
|
900 |
ifTrue: |
|
901 |
[ self readSTInstVarNamesAttributeFor:something. |
|
902 |
^ self. ]. |
|
903 |
(attributeName = 'STCode') |
|
904 |
ifTrue: |
|
905 |
[ self readSTCodeAttributeFor:something. |
|
906 |
^ self. ]. |
|
907 |
(attributeName = 'MethodCategory') |
|
908 |
ifTrue: |
|
909 |
[ self readSTMethodCategoryAttributeFor:something. |
|
910 |
^ self. ]. |
|
911 |
||
912 |
"/ unknown attributes |
|
913 |
||
914 |
('JAVA [warning]: unrecognized attribute: ' , attributeName) infoPrintCR. |
|
915 |
self skipAttribute:attributeName. |
|
916 |
||
917 |
"Modified: / 03-12-1998 / 13:13:42 / cg" |
|
918 |
"Modified: / 25-02-2011 / 18:09:21 / Marcel Hlopko <hlopik@gmail.com>" |
|
919 |
! |
|
920 |
||
921 |
readAttributeFor:something |
|
922 |
|attribute_name_index attribute_name attribute_length attribute_info| |
|
923 |
||
924 |
Verbose ifTrue:[Transcript show:'attrib at pos: '; showCR:inStream position]. |
|
925 |
||
926 |
attribute_name_index := inStream nextUnsignedShortMSB:msb. |
|
927 |
attribute_name_index == 0 ifTrue:[ |
|
928 |
self halt. |
|
929 |
"/self skipAttribute:'unnamed'. |
|
930 |
^ self. |
|
931 |
]. |
|
932 |
||
933 |
"/ |
|
934 |
"/ UNDOC feature ? |
|
935 |
"/ |
|
936 |
attribute_name_index > constants size ifTrue:[ |
|
937 |
attribute_name_index == 16rb700 ifTrue:[ |
|
938 |
self halt. |
|
939 |
] |
|
940 |
]. |
|
941 |
||
942 |
attribute_name := constants at:attribute_name_index. |
|
943 |
||
944 |
Verbose ifTrue:[Transcript show:'attrib name: '; showCR:attribute_name]. |
|
945 |
||
946 |
self readAttribute:attribute_name for:something. |
|
947 |
||
948 |
" |
|
949 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
950 |
" |
|
951 |
||
952 |
"Created: / 15-04-1996 / 15:40:17 / cg" |
|
953 |
"Modified: / 09-04-1998 / 18:13:34 / cg" |
|
954 |
"Modified: / 19-10-2010 / 21:43:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
955 |
! |
|
956 |
||
957 |
readAttributesFor:something |
|
958 |
|attributes_count| |
|
959 |
||
960 |
attributes_count := inStream nextUnsignedShortMSB:msb. |
|
961 |
||
962 |
1 to:attributes_count do:[:i | |
|
963 |
self readAttributeFor:something. |
|
964 |
]. |
|
965 |
||
966 |
"Modified: 15.4.1996 / 15:33:28 / cg" |
|
967 |
"Created: 15.4.1996 / 15:40:17 / cg" |
|
968 |
! |
|
969 |
||
970 |
readDeprecatedAttributeFor:aJavaMethodWithHandler |
|
971 |
||
972 |
self skipAttribute:'Deprecated'. |
|
973 |
^self |
|
974 |
||
975 |
"Created: / 18-10-2010 / 22:26:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
976 |
! |
|
977 |
||
978 |
readEnclosingMethodAttributeFor:something |
|
979 |
"/ ('JAVA [info]: unhandled attribute: EnclosingMethod') infoPrintCR. |
|
980 |
self skipAttribute:'EnclosingMethod'. |
|
981 |
! |
|
982 |
||
983 |
readInnerClassesAttributeFor:something |
|
984 |
"/ ('JAVA [info]: unhandled attribute: InnerClasses') infoPrintCR. |
|
985 |
self skipAttribute:'InnerClasses'. |
|
986 |
! |
|
987 |
||
988 |
readLocalVariableTypeTableAttributeFor:something |
|
989 |
"/ ('JAVA [info]: unhandled attribute: LocalVariableTypeTable') infoPrintCR. |
|
990 |
self skipAttribute:'LocalVariableTypeTable'. |
|
991 |
! |
|
992 |
||
993 |
readRuntimeAnnotationsAttributeFor: something visible: visible |
|
994 |
| length annotationsCount annotations rawAnnotations startPos endPos | |
|
995 |
||
996 |
self assert: inStream isPositionable |
|
997 |
message: '.class file stream must be positionable'. |
|
998 |
length := inStream nextUnsignedLongMSB: msb. |
|
999 |
startPos := inStream position. |
|
1000 |
annotationsCount := inStream nextUnsignedShortMSB: msb. |
|
1001 |
annotationsCount = 0 ifTrue: [ ^ nil ]. |
|
1002 |
annotations := visible ifTrue: [something ensureHasAnnotations ensureRuntimeVisible] ifFalse: [something ensureHasAnnotations ensureRuntimeInvisible]. |
|
1003 |
annotationsCount timesRepeat: |
|
1004 |
[ | currentAnnotation | |
|
1005 |
||
1006 |
currentAnnotation := self readAnnotationFor: something. |
|
1007 |
annotations at: currentAnnotation name put: currentAnnotation. ]. |
|
1008 |
"Cut raw annotations as required by getRawAnnotations()" |
|
1009 |
endPos := inStream position. |
|
1010 |
inStream position: startPos. |
|
1011 |
rawAnnotations := inStream next: length. |
|
1012 |
inStream position ~= endPos |
|
1013 |
ifTrue: [ self halt: 'annotations are probably reading what they shouldnt' ]. |
|
1014 |
annotations rawAnnotations: rawAnnotations. |
|
1015 |
||
1016 |
"Modified: / 07-01-2011 / 22:00:07 / Jan Kurs <kurs.jan@post.cz>" |
|
1017 |
"Modified: / 25-02-2011 / 18:45:58 / Marcel Hlopko <hlopik@gmail.com>" |
|
1018 |
"Modified: / 03-03-2011 / 23:01:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1019 |
"Modified: / 16-03-2011 / 16:57:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1020 |
! |
|
1021 |
||
1022 |
readRuntimeParameterAnnotationsAttributeFor: javaMethod visible: visible |
|
1023 |
| length paramsCount annotationsCount rawAnnotations startPos endPos | |
|
1024 |
||
1025 |
self assert: inStream isPositionable |
|
1026 |
message: '.class file stream must be positionable'. |
|
1027 |
length := inStream nextUnsignedLongMSB: msb. |
|
1028 |
startPos := inStream position. |
|
1029 |
paramsCount := inStream nextByte. |
|
1030 |
paramsCount = 0 ifTrue: [ ^ nil ]. |
|
1031 |
1 to: paramsCount |
|
1032 |
do: |
|
1033 |
[:paramIndex | |
|
1034 |
annotationsCount := inStream nextUnsignedShortMSB: msb. |
|
1035 |
annotationsCount > 0 |
|
1036 |
ifTrue: |
|
1037 |
[ | annotations | |
|
1038 |
annotations := visible |
|
1039 |
ifTrue: |
|
1040 |
[ javaMethod ensureHasAnnotations ensureVisibleParameterAnnotationsAt: paramIndex ] |
|
1041 |
ifFalse: |
|
1042 |
[javaMethod ensureHasAnnotations ensureInvisibleParameterAnnotationsAt: paramIndex ]. |
|
1043 |
annotationsCount timesRepeat: |
|
1044 |
[ | annotation | |
|
1045 |
||
1046 |
annotation := self readAnnotationFor: javaMethod. |
|
1047 |
annotations at: (annotation name) put: annotation. ] ]]. |
|
1048 |
endPos := inStream position. |
|
1049 |
rawAnnotations := inStream position: startPos. |
|
1050 |
rawAnnotations := inStream next: length. |
|
1051 |
inStream position ~= endPos |
|
1052 |
ifTrue: [ self halt: 'annotations are probably reading what they shouldnt' ]. |
|
1053 |
javaMethod annotations rawAnnotations: rawAnnotations. |
|
1054 |
||
1055 |
"Modified: / 28-02-2011 / 17:05:47 / Marcel Hlopko <hlopik@gmail.com>" |
|
1056 |
"Modified: / 16-03-2011 / 17:26:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1057 |
! |
|
1058 |
||
1059 |
readSignatureAttributeFor:something |
|
912
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1060 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1061 |
|attribute_length signature_index signature| |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1062 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1063 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1064 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1065 |
signature_index := inStream nextUnsignedShortMSB:msb. |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1066 |
signature := constants at:signature_index. |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1067 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1068 |
something setSignature: signature. |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1069 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1070 |
"Modified: / 13-08-2011 / 00:28:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 1071 |
! |
1072 |
||
1073 |
readSourceDebugExtensionAttributeFor:something |
|
1074 |
"/ ('JAVA [info]: unhandled attribute: SourceDebugExtension') infoPrintCR. |
|
1075 |
self skipAttribute:'SourceDebugExtension'. |
|
1076 |
! |
|
1077 |
||
1078 |
readSourceFileAttributeFor:aClass |
|
1079 |
|attribute_length sourceFile_index sourceFile| |
|
1080 |
||
1081 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1082 |
||
1083 |
sourceFile_index := inStream nextUnsignedShortMSB:msb. |
|
1084 |
sourceFile := constants at:sourceFile_index. |
|
1085 |
||
1086 |
aClass isJavaClass ifTrue:[ |
|
1087 |
aClass setSourceFile:sourceFile. |
|
1088 |
] ifFalse:[ |
|
1089 |
aClass setClassFilename:sourceFile |
|
1090 |
]. |
|
1091 |
||
1092 |
Verbose ifTrue:[Transcript show:'sourceFile: '; showCR:sourceFile]. |
|
1093 |
^ true |
|
1094 |
||
1095 |
" |
|
1096 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1097 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1098 |
JavaClassReader loadFile:'foo.cls' |
|
1099 |
" |
|
1100 |
||
1101 |
"Created: / 15.4.1996 / 15:40:17 / cg" |
|
1102 |
"Modified: / 12.5.1998 / 22:01:07 / cg" |
|
1103 |
! |
|
1104 |
||
1105 |
readStackMapTableAttributeFor:something |
|
1106 |
"/ ('JAVA [info]: unhandled attribute: StackMapTable') infoPrintCR. |
|
1107 |
self skipAttribute:'StackMapTable'. |
|
1108 |
||
1109 |
"Created: / 09-02-2011 / 01:19:20 / Marcel Hlopko <hlopik@gmail.com>" |
|
1110 |
! |
|
1111 |
||
1112 |
readSyntheticAttributeFor:something |
|
1113 |
"/ ('JAVA [info]: unhandled attribute: Synthetic') infoPrintCR. |
|
1114 |
self skipAttribute:'Synthetic'. |
|
1115 |
! |
|
1116 |
||
1117 |
skipAttribute:attributeName |
|
1118 |
"dont know about this attribute - skip it here" |
|
1119 |
||
1120 |
|attribute_length attribute_info| |
|
1121 |
||
1122 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1123 |
attribute_info := ByteArray new:(attribute_length). |
|
1124 |
inStream nextBytes:attribute_length into:attribute_info startingAt:1. |
|
1125 |
||
1126 |
Verbose ifTrue:[Transcript show:'skipped '; show:attributeName; showCR:'-attribute']. |
|
1127 |
||
1128 |
"Created: / 9.4.1998 / 18:12:46 / cg" |
|
1129 |
"Modified: / 9.4.1998 / 18:13:20 / cg" |
|
1130 |
! ! |
|
1131 |
||
1132 |
!JavaClassReader methodsFor:'file reading - attributes-ST'! |
|
1133 |
||
1134 |
readSTClassCategoryAttributeFor:aClass |
|
1135 |
|attribute_length categoryString_index categoryString| |
|
1136 |
||
1137 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1138 |
||
1139 |
categoryString_index := inStream nextUnsignedShortMSB:msb. |
|
1140 |
categoryString := constants at:categoryString_index. |
|
1141 |
||
1142 |
aClass category:categoryString. |
|
1143 |
||
1144 |
Verbose ifTrue:[Transcript show:'categoryString: '; showCR:categoryString]. |
|
1145 |
^ true |
|
1146 |
||
1147 |
" |
|
1148 |
JavaClassReader loadFile:'foo.cls' |
|
1149 |
" |
|
1150 |
||
1151 |
"Created: / 9.5.1998 / 02:33:13 / cg" |
|
1152 |
"Modified: / 9.5.1998 / 02:36:55 / cg" |
|
1153 |
! |
|
1154 |
||
1155 |
readSTClassInstVarNamesAttributeFor:aClass |
|
1156 |
|attribute_length nameString_index nameString| |
|
1157 |
||
1158 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1159 |
||
1160 |
nameString_index := inStream nextUnsignedShortMSB:msb. |
|
1161 |
nameString := constants at:nameString_index. |
|
1162 |
||
1163 |
aClass class instanceVariableString:nameString. |
|
1164 |
||
1165 |
Verbose ifTrue:[Transcript show:'nameString: '; showCR:nameString]. |
|
1166 |
^ true |
|
1167 |
||
1168 |
" |
|
1169 |
JavaClassReader loadFile:'foo.cls' |
|
1170 |
" |
|
1171 |
||
1172 |
"Modified: / 12.5.1998 / 22:18:03 / cg" |
|
1173 |
"Created: / 12.5.1998 / 22:18:24 / cg" |
|
1174 |
! |
|
1175 |
||
1176 |
readSTClassPackageAttributeFor:aClass |
|
1177 |
|attribute_length packageString_index packageString| |
|
1178 |
||
1179 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1180 |
||
1181 |
packageString_index := inStream nextUnsignedShortMSB:msb. |
|
1182 |
packageString := constants at:packageString_index. |
|
1183 |
||
1184 |
aClass package:packageString asSymbol. |
|
1185 |
||
1186 |
Verbose ifTrue:[Transcript show:'packageString: '; showCR:packageString]. |
|
1187 |
^ true |
|
1188 |
||
1189 |
" |
|
1190 |
JavaClassReader loadFile:'foo.cls' |
|
1191 |
" |
|
1192 |
||
1193 |
"Modified: / 9.5.1998 / 02:32:38 / cg" |
|
1194 |
"Created: / 9.5.1998 / 02:33:44 / cg" |
|
1195 |
! |
|
1196 |
||
1197 |
readSTClassRevisionAttributeFor:aClass |
|
1198 |
|attribute_length revisionString_index revisionString| |
|
1199 |
||
1200 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1201 |
||
1202 |
revisionString_index := inStream nextUnsignedShortMSB:msb. |
|
1203 |
revisionString := constants at:revisionString_index. |
|
1204 |
||
1205 |
aClass setBinaryRevision:revisionString. |
|
1206 |
||
1207 |
Verbose ifTrue:[Transcript show:'revisionString: '; showCR:revisionString]. |
|
1208 |
^ true |
|
1209 |
||
1210 |
" |
|
1211 |
JavaClassReader loadFile:'foo.cls' |
|
1212 |
" |
|
1213 |
||
1214 |
"Created: / 9.5.1998 / 02:33:13 / cg" |
|
1215 |
"Modified: / 9.5.1998 / 02:35:01 / cg" |
|
1216 |
! |
|
1217 |
||
1218 |
readSTClassVarNamesAttributeFor:aClass |
|
1219 |
|attribute_length nameString_index nameString| |
|
1220 |
||
1221 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1222 |
||
1223 |
nameString_index := inStream nextUnsignedShortMSB:msb. |
|
1224 |
nameString := constants at:nameString_index. |
|
1225 |
||
1226 |
aClass classVariableString:nameString. |
|
1227 |
||
1228 |
Verbose ifTrue:[Transcript show:'nameString: '; showCR:nameString]. |
|
1229 |
^ true |
|
1230 |
||
1231 |
" |
|
1232 |
JavaClassReader loadFile:'foo.cls' |
|
1233 |
" |
|
1234 |
||
1235 |
"Created: / 9.5.1998 / 02:33:13 / cg" |
|
1236 |
"Modified: / 12.5.1998 / 22:18:03 / cg" |
|
1237 |
! |
|
1238 |
||
1239 |
readSTInstVarNamesAttributeFor:aClass |
|
1240 |
|attribute_length nameString_index nameString| |
|
1241 |
||
1242 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1243 |
||
1244 |
nameString_index := inStream nextUnsignedShortMSB:msb. |
|
1245 |
nameString := constants at:nameString_index. |
|
1246 |
||
1247 |
aClass setInstanceVariableString:nameString. |
|
1248 |
||
1249 |
Verbose ifTrue:[Transcript show:'nameString: '; showCR:nameString]. |
|
1250 |
^ true |
|
1251 |
||
1252 |
" |
|
1253 |
JavaClassReader loadFile:'foo.cls' |
|
1254 |
" |
|
1255 |
||
1256 |
"Created: / 12.5.1998 / 22:18:14 / cg" |
|
1257 |
"Modified: / 12.5.1998 / 22:21:10 / cg" |
|
1258 |
! ! |
|
1259 |
||
1260 |
!JavaClassReader methodsFor:'file reading - constants'! |
|
1261 |
||
1262 |
readConstant |
|
1263 |
|tag constReader const| |
|
1264 |
||
1265 |
||
1266 |
constNeeds2Slots := false. |
|
1267 |
||
1268 |
"/ |
|
1269 |
"/ get tag |
|
1270 |
"/ |
|
1271 |
tag := inStream nextByte. |
|
1272 |
Verbose ifTrue:[Transcript show:'tag = '; showCR:tag]. |
|
1273 |
||
1274 |
tag >= 250 ifTrue:[ |
|
1275 |
constReader := #( |
|
1276 |
"/ ST types |
|
1277 |
readConstant_ST_Large "/ 249 |
|
1278 |
readConstant_ST_Special "/ 250 |
|
1279 |
readConstant_ST_Character "/ 251 |
|
1280 |
readConstant_ST_ByteArray "/ 252 |
|
1281 |
readConstant_ST_Array "/ 253 |
|
1282 |
readConstant_ST_Symbol "/ 254 |
|
1283 |
readConstant_ST_Reserved "/ 255 |
|
1284 |
) at:tag-249+1. |
|
1285 |
] ifFalse:[ |
|
1286 |
constReader := #( |
|
1287 |
"/ JAVA types |
|
1288 |
readConstant_Utf8 "/ 1 - now called Utf8 |
|
1289 |
readConstant_Unicode "/ 2 |
|
1290 |
readConstant_Integer "/ 3 |
|
1291 |
readConstant_Float "/ 4 |
|
1292 |
readConstant_Long "/ 5 |
|
1293 |
readConstant_Double "/ 6 |
|
1294 |
readConstant_Class "/ 7 |
|
1295 |
readConstant_String "/ 8 |
|
1296 |
readConstant_Fieldref "/ 9 |
|
1297 |
readConstant_Methodref "/ 10 |
|
1298 |
readConstant_InterfaceMethodref "/ 11 |
|
1299 |
readConstant_NameAndType "/ 12 |
|
1300 |
) at:tag ifAbsent:[#readConstant_Undef]. |
|
1301 |
]. |
|
1302 |
^ self perform:constReader. |
|
1303 |
||
1304 |
" |
|
1305 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1306 |
" |
|
1307 |
||
1308 |
"Created: / 15.4.1996 / 15:46:32 / cg" |
|
1309 |
"Modified: / 9.5.1998 / 01:26:05 / cg" |
|
1310 |
! |
|
1311 |
||
1312 |
readConstantPool |
|
877 | 1313 |
| constantPoolSize const | |
752 | 1314 |
|
1315 |
"/ |
|
1316 |
"/ get constant pool |
|
1317 |
"/ |
|
877 | 1318 |
constantPoolSize := inStream nextUnsignedShortMSB: msb. |
1319 |
self info: 'constantPoolSize = ' , constantPoolSize printString. |
|
1320 |
constants := JavaConstantPool new: constantPoolSize - 1. |
|
752 | 1321 |
constSlot := 1. |
877 | 1322 |
[ constSlot < constantPoolSize ] whileTrue: [ |
1323 |
self info: 'const slot: ' , constSlot printString. |
|
1324 |
const := self readConstant. |
|
1325 |
constants at: constSlot put: const. |
|
1326 |
||
1327 |
"/ long & double consts take 2 slots |
|
1328 |
"/ (only first is used) |
|
1329 |
||
1330 |
constNeeds2Slots |
|
1331 |
ifTrue: [ constSlot := constSlot + 2. ] |
|
1332 |
ifFalse: [ constSlot := constSlot + 1. ]]. |
|
752 | 1333 |
constSlot := -1. |
877 | 1334 |
|
1335 |
1 to: constantPoolSize - 1 |
|
1336 |
do: |
|
1337 |
[:i | |
|
1338 |
| const value | |
|
1339 |
||
1340 |
const := constants at: i. |
|
1341 |
const ifNotNil: |
|
1342 |
[ "/ kludge for 2-slot constants (which only take 1 slot in ST/X) |
|
1343 |
(const isKindOf: JavaUnresolvedConstant) |
|
1344 |
ifTrue: |
|
1345 |
[ value := const preResolve. |
|
1346 |
value ~~ const ifTrue: [ constants at: i put: value. ] ] ] ]. |
|
752 | 1347 |
|
1348 |
" |
|
1349 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
877 | 1350 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'" |
1351 |
||
1352 |
"Modified: / 07-05-1998 / 11:44:06 / cg" |
|
1353 |
"Created: / 13-05-2011 / 16:52:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 1354 |
! |
1355 |
||
1356 |
readConstant_Asciz |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1357 |
| len string | |
782 | 1358 |
|
1359 |
||
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1360 |
len := inStream nextUnsignedShortMSB: msb. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1361 |
string := String new: len. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1362 |
inStream |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1363 |
nextBytes: len |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1364 |
into: string |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1365 |
startingAt: 1. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1366 |
Verbose |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1367 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1368 |
[ Transcript |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1369 |
show: 'asciz; string= '; |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1370 |
showCR: string ]. |
752 | 1371 |
^ string |
1372 |
||
1373 |
" |
|
1374 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1375 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'" |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1376 |
|
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1377 |
"Created: / 15-04-1996 / 15:15:35 / cg" |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1378 |
"Modified: / 15-04-1996 / 16:33:45 / cg" |
782 | 1379 |
"Modified: / 13-05-2011 / 17:31:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 1380 |
! |
1381 |
||
1382 |
readConstant_Class |
|
877 | 1383 |
| nameIndex | |
1384 |
||
1385 |
nameIndex := inStream nextUnsignedShortMSB: msb. |
|
1386 |
((constants at: nameIndex) isNil) |
|
1387 |
ifTrue: |
|
1388 |
[ self info: ('reading class; index=' , nameIndex printString , ' name=' |
|
1389 |
, (constants at: nameIndex) printString) ] |
|
1390 |
ifFalse: [ self info: ('reading class; index= ' , nameIndex printString) ]. |
|
1391 |
^ JavaClassRef2 in: constants withNameAt: nameIndex. |
|
1392 |
||
1393 |
"Modified: / 18-05-2011 / 18:21:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 1394 |
! |
1395 |
||
1396 |
readConstant_Double |
|
1397 |
|high low aFloat bytes| |
|
1398 |
||
1399 |
"/ new code - to be tested |
|
1400 |
"/ bytes := ByteArray new:8. |
|
1401 |
"/ |
|
1402 |
"/ inStream nextBytes:8 into:bytes startingAt:1. |
|
1403 |
"/ msb ~~ UninterpretedBytes isBigEndian ifTrue:[ |
|
1404 |
"/ bytes reverse |
|
1405 |
"/ ]. |
|
1406 |
"/ aFloat := bytes doubleAt:1. |
|
1407 |
||
1408 |
"/ old code |
|
1409 |
||
1410 |
high := inStream nextUnsignedLongMSB:msb. |
|
1411 |
low := inStream nextUnsignedLongMSB:msb. |
|
1412 |
||
1413 |
aFloat := Float new. |
|
1414 |
UninterpretedBytes isBigEndian ifTrue:[ |
|
1415 |
aFloat basicAt:1 put:((high bitShift:-24) bitAnd:16rFF). |
|
1416 |
aFloat basicAt:2 put:((high bitShift:-16) bitAnd:16rFF). |
|
1417 |
aFloat basicAt:3 put:((high bitShift:-8) bitAnd:16rFF). |
|
1418 |
aFloat basicAt:4 put:(high bitAnd:16rFF). |
|
1419 |
aFloat basicAt:5 put:((low bitShift:-24) bitAnd:16rFF). |
|
1420 |
aFloat basicAt:6 put:((low bitShift:-16) bitAnd:16rFF). |
|
1421 |
aFloat basicAt:7 put:((low bitShift:-8) bitAnd:16rFF). |
|
1422 |
aFloat basicAt:8 put:(low bitAnd:16rFF). |
|
1423 |
] ifFalse:[ |
|
1424 |
aFloat basicAt:1 put:(low bitAnd:16rFF). |
|
1425 |
aFloat basicAt:2 put:((low bitShift:-8) bitAnd:16rFF). |
|
1426 |
aFloat basicAt:3 put:((low bitShift:-16) bitAnd:16rFF). |
|
1427 |
aFloat basicAt:4 put:((low bitShift:-24) bitAnd:16rFF). |
|
1428 |
aFloat basicAt:5 put:(high bitAnd:16rFF). |
|
1429 |
aFloat basicAt:6 put:((high bitShift:-8) bitAnd:16rFF). |
|
1430 |
aFloat basicAt:7 put:((high bitShift:-16) bitAnd:16rFF). |
|
1431 |
aFloat basicAt:8 put:((high bitShift:-24) bitAnd:16rFF). |
|
1432 |
]. |
|
1433 |
||
1434 |
constNeeds2Slots := true. |
|
1435 |
||
1436 |
Verbose ifTrue:[Transcript show:'double; value= '; showCR:aFloat]. |
|
1437 |
^ aFloat |
|
1438 |
||
1439 |
" |
|
1440 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1441 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1442 |
" |
|
1443 |
||
1444 |
"Created: / 15.4.1996 / 16:34:42 / cg" |
|
1445 |
"Modified: / 8.5.1998 / 22:06:07 / cg" |
|
1446 |
! |
|
1447 |
||
877 | 1448 |
readConstant_Fieldref |
1449 |
"incrementally changing resolving logic, fields will come later" |
|
1450 |
||
1451 |
| classIndex nameAndTypeIndex | |
|
1452 |
||
1453 |
classIndex := inStream nextUnsignedShortMSB: msb. |
|
1454 |
nameAndTypeIndex := inStream nextUnsignedShortMSB: msb. |
|
1455 |
self |
|
1456 |
info: 'reading fieldref; classindex=' , classIndex printString |
|
1457 |
, ' nameAndTypeIndex=' , nameAndTypeIndex printString. |
|
1458 |
^ JavaFieldRef2 |
|
1459 |
in: constants |
|
1460 |
withNameAndTypeAt: nameAndTypeIndex |
|
1461 |
andClassAt: classIndex. |
|
1462 |
||
1463 |
"Modified: / 15-05-2011 / 14:20:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 1464 |
! |
1465 |
||
1466 |
readConstant_Float |
|
1467 |
|b1 b2 b3 b4 aFloat bytes| |
|
1468 |
||
1469 |
"/ new code - to be tested ... |
|
1470 |
"/ |
|
1471 |
"/ bytes := ByteArray new:4. |
|
1472 |
"/ inStream nextBytes:4 into:bytes startingAt:1. |
|
1473 |
"/ msb ~~ UninterpretedBytes isBigEndian ifTrue:[ |
|
1474 |
"/ bytes reverse |
|
1475 |
"/ ]. |
|
1476 |
"/ aFloat := bytes floatAt:1. |
|
1477 |
"/ Verbose ifTrue:[Transcript show:'float; value= '; showCR:aFloat]. |
|
1478 |
"/ ^ aFloat. |
|
1479 |
||
1480 |
"/ old code |
|
1481 |
||
1482 |
aFloat := ShortFloat basicNew. |
|
1483 |
||
1484 |
b1 := inStream nextByte. |
|
1485 |
b2 := inStream nextByte. |
|
1486 |
b3 := inStream nextByte. |
|
1487 |
b4 := inStream nextByte. |
|
1488 |
||
1489 |
UninterpretedBytes isBigEndian ifTrue:[ |
|
1490 |
aFloat basicAt:1 put:b1. |
|
1491 |
aFloat basicAt:2 put:b2. |
|
1492 |
aFloat basicAt:3 put:b3. |
|
1493 |
aFloat basicAt:4 put:b4. |
|
1494 |
] ifFalse:[ |
|
1495 |
aFloat basicAt:4 put:b1. |
|
1496 |
aFloat basicAt:3 put:b2. |
|
1497 |
aFloat basicAt:2 put:b3. |
|
1498 |
aFloat basicAt:1 put:b4. |
|
1499 |
]. |
|
1500 |
Verbose ifTrue:[Transcript show:'float; value= '; showCR:aFloat]. |
|
1501 |
^ aFloat |
|
1502 |
||
1503 |
" |
|
1504 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1505 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1506 |
" |
|
1507 |
||
1508 |
"Created: / 15.4.1996 / 16:34:42 / cg" |
|
1509 |
"Modified: / 10.11.1998 / 22:04:59 / cg" |
|
1510 |
! |
|
1511 |
||
1512 |
readConstant_Integer |
|
1513 |
|value| |
|
1514 |
||
1515 |
value := inStream nextLongMSB:msb. |
|
1516 |
||
1517 |
Verbose ifTrue:[Transcript show:'integer; value= '; showCR:value]. |
|
1518 |
||
1519 |
^ value |
|
1520 |
||
1521 |
" |
|
1522 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1523 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1524 |
" |
|
1525 |
||
1526 |
"Modified: 15.4.1996 / 15:42:16 / cg" |
|
1527 |
"Created: 15.4.1996 / 16:34:42 / cg" |
|
1528 |
! |
|
1529 |
||
1530 |
readConstant_InterfaceMethodref |
|
877 | 1531 |
| classIndex nameAndTypeIndex | |
1532 |
||
1533 |
classIndex := inStream nextUnsignedShortMSB: msb. |
|
1534 |
nameAndTypeIndex := inStream nextUnsignedShortMSB: msb. |
|
1535 |
self |
|
1536 |
info: 'reading interface methodref; classindex=' , classIndex printString |
|
1537 |
, ' nameAndTypeIndex=' , nameAndTypeIndex printString. |
|
1538 |
^ JavaInterfaceMethodRef2 |
|
1539 |
in: constants |
|
1540 |
withNameAndTypeAt: nameAndTypeIndex |
|
1541 |
andClassAt: classIndex. |
|
1542 |
||
1543 |
"Modified: / 12-05-2011 / 18:57:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 1544 |
! |
1545 |
||
1546 |
readConstant_Long |
|
1547 |
|high low value| |
|
1548 |
||
1549 |
high := inStream nextUnsignedLongMSB:msb. |
|
1550 |
low := inStream nextUnsignedLongMSB:msb. |
|
1551 |
||
1552 |
value := (high bitShift:32) bitOr:low. |
|
1553 |
(high bitTest:16r80000000) ifTrue:[ |
|
1554 |
value := value - 16r10000000000000000. |
|
1555 |
]. |
|
1556 |
constNeeds2Slots := true. |
|
1557 |
||
1558 |
Verbose ifTrue:[Transcript show:'long; value= '; showCR:value]. |
|
1559 |
^ value |
|
1560 |
||
1561 |
" |
|
1562 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1563 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1564 |
" |
|
1565 |
||
1566 |
"Modified: 15.4.1996 / 15:42:16 / cg" |
|
1567 |
"Created: 15.4.1996 / 16:34:42 / cg" |
|
1568 |
! |
|
1569 |
||
1570 |
readConstant_Methodref |
|
877 | 1571 |
| classIndex nameAndTypeIndex | |
1572 |
||
1573 |
classIndex := inStream nextUnsignedShortMSB: msb. |
|
1574 |
nameAndTypeIndex := inStream nextUnsignedShortMSB: msb. |
|
1575 |
self |
|
1576 |
info: 'reading methodref; classindex=' , classIndex printString , ' nameAndTypeIndex=' |
|
1577 |
, nameAndTypeIndex printString. |
|
1578 |
^ JavaMethodRef2 |
|
1579 |
in: constants |
|
1580 |
withNameAndTypeAt: nameAndTypeIndex |
|
1581 |
andClassAt: classIndex. |
|
1582 |
||
1583 |
"Modified: / 15-05-2011 / 14:20:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 1584 |
! |
1585 |
||
1586 |
readConstant_NameAndType |
|
877 | 1587 |
| nameIndex descriptorIndex | |
1588 |
||
1589 |
nameIndex := inStream nextUnsignedShortMSB: msb. |
|
1590 |
descriptorIndex := inStream nextUnsignedShortMSB: msb. |
|
1591 |
self |
|
1592 |
info: 'reading nameAndType; nameindex=' , nameIndex printString |
|
1593 |
, ' descriptorIndex= ' , descriptorIndex printString. |
|
1594 |
^JavaNameAndType2 |
|
1595 |
in: constants |
|
1596 |
withNameAt: nameIndex |
|
1597 |
andDescriptorAt: descriptorIndex. |
|
1598 |
||
1599 |
"Modified: / 10-05-2011 / 17:09:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 1600 |
! |
1601 |
||
1602 |
readConstant_String |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
1603 |
| string_index | |
782 | 1604 |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1605 |
string_index := inStream nextUnsignedShortMSB: msb. |
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
1606 |
^ JavaStringRef2 in: constants withValueAt: string_index. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
1607 |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1608 |
|
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
1609 |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1610 |
"Created: / 15-04-1996 / 15:20:33 / cg" |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1611 |
"Modified: / 07-05-1998 / 11:42:45 / cg" |
782 | 1612 |
"Modified: / 13-05-2011 / 17:31:54 / 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:
898
diff
changeset
|
1613 |
"Modified: / 10-08-2011 / 23:25:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 1614 |
! |
1615 |
||
1616 |
readConstant_Unicode |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1617 |
| len string ascii | |
782 | 1618 |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1619 |
len := inStream nextUnsignedShortMSB: msb. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1620 |
string := TwoByteString new: len. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1621 |
1 to: len |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1622 |
do: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1623 |
[:idx | |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1624 |
ascii := inStream nextUnsignedShortMSB: msb. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1625 |
string at: idx put: (Character value: ascii). ]. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1626 |
Verbose |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1627 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1628 |
[ Transcript |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1629 |
show: 'asciz; unicodeString= '; |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1630 |
showCR: string ]. |
752 | 1631 |
^ string |
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1632 |
|
782 | 1633 |
"Modified: / 13-05-2011 / 17:31:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 1634 |
! |
1635 |
||
1636 |
readConstant_Utf8 |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1637 |
| len bytes string | |
782 | 1638 |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1639 |
len := inStream nextUnsignedShortMSB: msb. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1640 |
bytes := ByteArray new: len. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1641 |
inStream |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1642 |
nextBytes: len |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1643 |
into: bytes |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1644 |
startingAt: 1. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1645 |
string := CharacterArray fromJavaUTF8Bytes: bytes. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1646 |
Verbose |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1647 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1648 |
[ Transcript |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1649 |
show: 'asciz; string= '; |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1650 |
showCR: string ]. |
752 | 1651 |
^ string |
1652 |
||
1653 |
"Modified: / 19-10-2010 / 12:38:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
782 | 1654 |
"Modified: / 13-05-2011 / 17:31:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 1655 |
! ! |
1656 |
||
1657 |
!JavaClassReader methodsFor:'file reading - constants-ST'! |
|
1658 |
||
1659 |
readConstant_ST_Array |
|
1660 |
|aSize arr| |
|
1661 |
||
1662 |
aSize := inStream nextUnsignedShortMSB:msb. |
|
1663 |
arr := Array new:aSize. |
|
1664 |
||
1665 |
1 to:aSize do:[:i | |
|
1666 |
|element_index element| |
|
1667 |
||
1668 |
element_index := inStream nextUnsignedShortMSB:msb. |
|
1669 |
arr at:i put:element_index. |
|
1670 |
]. |
|
1671 |
Verbose ifTrue:[Transcript show:'array; size= '; showCR:aSize]. |
|
1672 |
||
1673 |
^ JavaUnresolvedSTArrayConstant |
|
1674 |
pool:constants |
|
1675 |
poolIndex:constSlot |
|
1676 |
array:arr |
|
1677 |
||
1678 |
"Created: / 7.5.1998 / 11:47:01 / cg" |
|
1679 |
"Modified: / 9.5.1998 / 00:25:34 / cg" |
|
1680 |
! |
|
1681 |
||
1682 |
readConstant_ST_ByteArray |
|
1683 |
|aSize arr| |
|
1684 |
||
1685 |
aSize := inStream nextUnsignedShortMSB:msb. |
|
1686 |
arr := ByteArray new:aSize. |
|
1687 |
||
1688 |
1 to:aSize do:[:i | |
|
1689 |
|element_index| |
|
1690 |
||
1691 |
arr at:i put:(inStream nextByte). |
|
1692 |
]. |
|
1693 |
Verbose ifTrue:[Transcript show:'byteArray; size= '; showCR:aSize]. |
|
1694 |
||
1695 |
^ arr |
|
1696 |
||
1697 |
"Created: / 7.5.1998 / 11:47:12 / cg" |
|
1698 |
! |
|
1699 |
||
1700 |
readConstant_ST_Character |
|
1701 |
|ascii| |
|
1702 |
||
1703 |
ascii := inStream nextUnsignedShortMSB:msb. |
|
1704 |
||
1705 |
Verbose ifTrue:[Transcript show:'char; ascii= '; showCR:ascii]. |
|
1706 |
^ Character value:ascii |
|
1707 |
||
1708 |
"Created: / 7.5.1998 / 11:48:12 / cg" |
|
1709 |
! |
|
1710 |
||
1711 |
readConstant_ST_Special |
|
1712 |
|type| |
|
1713 |
||
1714 |
type := inStream nextUnsignedShortMSB:msb. |
|
1715 |
^ #( |
|
1716 |
nil |
|
1717 |
true |
|
1718 |
false |
|
1719 |
) at:(type + 1) |
|
1720 |
||
1721 |
"Created: / 8.5.1998 / 23:06:56 / cg" |
|
1722 |
"Modified: / 9.5.1998 / 00:40:14 / cg" |
|
1723 |
! |
|
1724 |
||
1725 |
readConstant_ST_String |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1726 |
| tag string_index chars | |
782 | 1727 |
|
1728 |
||
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1729 |
string_index := inStream nextUnsignedShortMSB: msb. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1730 |
Verbose |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1731 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1732 |
[ Transcript |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1733 |
show: 'string; index= '; |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1734 |
showCR: string_index ]. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1735 |
|
752 | 1736 |
"/ resolve here if possible |
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1737 |
|
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1738 |
string_index < constSlot |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1739 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1740 |
[ chars := (constants at: string_index). |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1741 |
^ chars ]. |
752 | 1742 |
^ JavaUnresolvedSTStringConstant |
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1743 |
pool: constants |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1744 |
poolIndex: constSlot |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1745 |
stringIndex: string_index |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1746 |
|
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1747 |
"Created: / 07-05-1998 / 11:49:55 / cg" |
782 | 1748 |
"Modified: / 13-05-2011 / 17:32:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 1749 |
! |
1750 |
||
1751 |
readConstant_ST_Symbol |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1752 |
| tag string_index chars | |
782 | 1753 |
|
1754 |
||
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1755 |
string_index := inStream nextUnsignedShortMSB: msb. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1756 |
Verbose |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1757 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1758 |
[ Transcript |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1759 |
show: 'symbol; index= '; |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1760 |
showCR: string_index ]. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1761 |
|
752 | 1762 |
"/ resolve here if possible |
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1763 |
|
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1764 |
string_index < constSlot |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1765 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1766 |
[ chars := (constants at: string_index). |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1767 |
chars isString ifFalse: [ self halt: 'should not happen' ]. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1768 |
^ chars asSymbol ]. |
752 | 1769 |
^ JavaUnresolvedSTSymbolConstant |
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1770 |
pool: constants |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1771 |
poolIndex: constSlot |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1772 |
stringIndex: string_index |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1773 |
|
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1774 |
"Modified: / 07-05-1998 / 11:48:28 / cg" |
782 | 1775 |
"Modified: / 13-05-2011 / 17:32:09 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 1776 |
! ! |
1777 |
||
1698
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1778 |
!JavaClassReader methodsFor:'file reading - extensions'! |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1779 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1780 |
readExtensionsFor: class |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1781 |
"Given a class, load extensions (i.e., non-java methods) for that class" |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1782 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1783 |
| classnameAsPath | |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1784 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1785 |
classnameAsPath := class name copyReplaceAll: $/ with: Filename separator. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1786 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1787 |
Java effectiveExtensionsPath do:[:each| |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1788 |
ProgrammingLanguage allDo:[:lang| |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1789 |
lang supportsExtensionMethods ifTrue:[ |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1790 |
| file | |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1791 |
file := each asString , Filename separator , classnameAsPath , '.' , lang sourceFileSuffix. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1792 |
file := file asFilename. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1793 |
file exists ifTrue:[ |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1794 |
self readExtensionsFor: class from: file language: lang |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1795 |
] |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1796 |
] |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1797 |
] |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1798 |
] |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1799 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1800 |
"Created: / 06-09-2012 / 11:37:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1801 |
! |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1802 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1803 |
readExtensionsFor: class from: file |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1804 |
"Given a class, load extensions (i.e., non-java methods) for that class" |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1805 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1806 |
JAVA isNil ifTrue:[ JavaPackage initialize ]. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1807 |
[ |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1808 |
Smalltalk fileIn: file. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1809 |
] on: JavaClassQuery do:[:query | |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1810 |
query className = class name ifTrue:[ |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1811 |
query resumeWith: class |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1812 |
] ifFalse:[ |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1813 |
query resumeWith: nil. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1814 |
] |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1815 |
]. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1816 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1817 |
"Created: / 06-09-2012 / 12:04:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1818 |
! |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1819 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1820 |
readExtensionsFor: class from: file language: language |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1821 |
"Given a class, load extensions (i.e., non-java methods) for that class" |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1822 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1823 |
JAVA isNil ifTrue:[ JavaPackage initialize ]. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1824 |
[ |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1825 |
"Do not enable it now, requires some changes is filing-in code" |
1699
73003b9f58fc
- Support for extension methods finished (ready for testing)
vranyj1
parents:
1698
diff
changeset
|
1826 |
language fileIn: file. |
1698
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1827 |
] on: JavaClassQuery do:[:query | |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1828 |
query className = class name ifTrue:[ |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1829 |
query resumeWith: class |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1830 |
] ifFalse:[ |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1831 |
query resumeWith: nil. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1832 |
] |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1833 |
]. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1834 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1835 |
"Created: / 06-09-2012 / 12:14:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1836 |
! ! |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1837 |
|
752 | 1838 |
!JavaClassReader methodsFor:'file reading - fields'! |
1839 |
||
1840 |
readConstantValueAttributeFor:aField |
|
1841 |
|attribute_length constantvalue_index constantValue| |
|
1842 |
||
1843 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1844 |
||
1845 |
constantvalue_index := inStream nextUnsignedShortMSB:msb. |
|
1846 |
constantValue := constants at:constantvalue_index. |
|
1847 |
||
1848 |
aField constantValue:constantValue. |
|
1849 |
||
1850 |
Verbose ifTrue:[Transcript show:'constantValue: '; showCR:constantValue]. |
|
1851 |
^ true |
|
1852 |
||
1853 |
" |
|
1854 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1855 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1856 |
" |
|
1857 |
||
1858 |
"Modified: 15.4.1996 / 15:33:28 / cg" |
|
1859 |
"Created: 15.4.1996 / 15:40:17 / cg" |
|
1860 |
! |
|
1861 |
||
1862 |
readFieldInfofield |
|
913 | 1863 |
| access_flags name_index descriptor_index attributes_count field | |
797
8d4e7c17eadd
fixed JavaClassReader so it always sets staticFields
hlopkmar
parents:
796
diff
changeset
|
1864 |
|
752 | 1865 |
access_flags := inStream nextUnsignedShortMSB: msb. |
1866 |
name_index := inStream nextUnsignedShortMSB: msb. |
|
913 | 1867 |
descriptor_index := inStream nextUnsignedShortMSB: msb. |
752 | 1868 |
field := JavaField new. |
1869 |
field setAccessFlags: access_flags. |
|
1870 |
field setName: (constants at: name_index) asSymbol. |
|
913 | 1871 |
field setDescriptor: (constants at: descriptor_index) asSymbol. |
879 | 1872 |
field setConstantPool: constants. |
752 | 1873 |
attributes_count := inStream nextUnsignedShortMSB: msb. |
1874 |
Verbose |
|
1875 |
ifTrue: |
|
1876 |
[ Transcript |
|
1877 |
show: ' field name: '; |
|
1878 |
show: (constants at: name_index); |
|
1879 |
show: ' access: '; |
|
1880 |
show: access_flags; |
|
1881 |
show: ' attrib_cnt: '; |
|
1882 |
showCR: attributes_count ]. |
|
1883 |
1 to: attributes_count do: [:i | self readAttributeFor: field. ]. |
|
1884 |
^ field. |
|
1885 |
||
1886 |
" |
|
1887 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'" |
|
1888 |
||
1889 |
"Created: / 15-04-1996 / 15:38:43 / cg" |
|
1890 |
"Modified: / 15-10-1998 / 10:38:01 / cg" |
|
1891 |
"Modified: / 17-12-2010 / 18:44:30 / Marcel Hlopko <hlopik@gmail.com>" |
|
797
8d4e7c17eadd
fixed JavaClassReader so it always sets staticFields
hlopkmar
parents:
796
diff
changeset
|
1892 |
"Modified: / 18-05-2011 / 14:11:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
913 | 1893 |
"Modified: / 14-08-2011 / 19:40:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 1894 |
! |
1895 |
||
1896 |
readFieldInfofields |
|
1897 |
|nFields fields| |
|
1898 |
||
1899 |
"/ |
|
1900 |
"/ get fieldInfos |
|
1901 |
"/ |
|
1902 |
nFields := inStream nextUnsignedShortMSB:msb. |
|
1903 |
Verbose ifTrue:[Transcript show:'fieldsCount = '; showCR:nFields]. |
|
1904 |
||
1905 |
fields := Array new:nFields. |
|
1906 |
||
1907 |
1 to:nFields do:[:i | |
|
1908 |
Verbose ifTrue:[Transcript show:'field: '; showCR:i]. |
|
1909 |
fields at:i put:(self readFieldInfofield) |
|
1910 |
]. |
|
1911 |
^ fields |
|
1912 |
||
1913 |
" |
|
1914 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1915 |
" |
|
1916 |
||
1917 |
"Created: 15.4.1996 / 15:34:41 / cg" |
|
1918 |
"Modified: 15.4.1996 / 15:35:28 / cg" |
|
1919 |
! ! |
|
1920 |
||
1921 |
!JavaClassReader methodsFor:'file reading - interfaces'! |
|
1922 |
||
1923 |
readInterfaces |
|
1924 |
|interfacesCount interface_index interface interfaces| |
|
1925 |
||
1926 |
"/ |
|
1927 |
"/ get interfaces |
|
1928 |
"/ |
|
1929 |
interfacesCount := inStream nextUnsignedShortMSB:msb. |
|
1930 |
Verbose ifTrue:[Transcript show:'interfacesCount = '; showCR:interfacesCount]. |
|
1931 |
||
1932 |
interfaces := Array new:interfacesCount. |
|
1933 |
||
1934 |
1 to:interfacesCount do:[:i | |
|
1935 |
Verbose ifTrue:[Transcript show:'interface: '; showCR:i]. |
|
1936 |
interface_index := inStream nextUnsignedShortMSB:msb. |
|
1937 |
interface := constants at:interface_index. |
|
1938 |
||
1939 |
interfaces at:i put:interface. |
|
1940 |
]. |
|
1941 |
^ interfaces |
|
1942 |
||
1943 |
" |
|
1944 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1945 |
" |
|
1946 |
||
1947 |
"Created: 15.4.1996 / 15:31:59 / cg" |
|
1948 |
"Modified: 15.4.1996 / 15:33:28 / cg" |
|
1949 |
! ! |
|
1950 |
||
1951 |
!JavaClassReader methodsFor:'file reading - methods'! |
|
1952 |
||
1953 |
readCodeAttributeFor:aJavaMethod |
|
1954 |
|attribute_length max_stack max_locals code_length code |
|
1955 |
exception_table_length exception_table unknown1 unknown2| |
|
1956 |
||
1957 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1958 |
||
1959 |
Verbose ifTrue:[Transcript show:'code_attribute_length: 0x'; showCR:(attribute_length printStringRadix:16)]. |
|
1960 |
||
1961 |
((minorVsn > 2) or:[majorVsn > 45]) ifTrue:[ |
|
1962 |
"/ should be: |
|
1963 |
max_stack := inStream nextUnsignedShortMSB:msb. |
|
1693 | 1964 |
max_locals := inStream nextUnsignedShortMSB:msb. |
1965 |
code_length := inStream nextUnsignedLongMSB:msb. |
|
1966 |
"/ Remember max context size so far, will be used to |
|
1223
317186c66234
JavaClassReader: remembers max stack depth over all loaded methods
vranyj1
parents:
1205
diff
changeset
|
1967 |
"/ optimize context size as alloca() won't work. |
1693 | 1968 |
MaxContextSize := MaxContextSize max: (max_stack + max_locals + 4"safe area"). |
1969 |
MaxContextSize > MaxContextSizeLimit ifTrue:[ |
|
1614
f7d4888fb1a2
- JavaClassReader: added check for VM stack-depth limit
vranyj1
parents:
1612
diff
changeset
|
1970 |
self error:'method''s stack depth overflows VM limit'. |
f7d4888fb1a2
- JavaClassReader: added check for VM stack-depth limit
vranyj1
parents:
1612
diff
changeset
|
1971 |
^false |
f7d4888fb1a2
- JavaClassReader: added check for VM stack-depth limit
vranyj1
parents:
1612
diff
changeset
|
1972 |
]. |
1693 | 1973 |
|
752 | 1974 |
|
1975 |
"/ unknown1 := inStream nextByte. |
|
1976 |
"/ max_stack := inStream nextByte. |
|
1977 |
"/ max_locals := inStream nextUnsignedShortMSB:msb. |
|
1978 |
"/ unknown2 := inStream nextUnsignedShortMSB:msb. |
|
1979 |
"/ code_length := inStream nextUnsignedShortMSB:msb. |
|
1980 |
"/ Verbose ifTrue:[Transcript show:'?1: '; showCR:unknown1]. |
|
1981 |
"/ Verbose ifTrue:[Transcript show:'?2: '; showCR:unknown2]. |
|
1982 |
] ifFalse:[ |
|
1983 |
max_stack := inStream nextByte. |
|
1984 |
max_locals := inStream nextByte. |
|
1985 |
code_length := inStream nextUnsignedShortMSB:msb. |
|
1986 |
]. |
|
1987 |
||
1988 |
Verbose ifTrue:[ |
|
1989 |
Transcript show:'code_length: '; showCR:(code_length printStringRadix:16). |
|
1990 |
Transcript show:'code at pos: '; showCR:inStream position |
|
1991 |
]. |
|
1992 |
||
1993 |
code_length ~~ 0 ifTrue:[ |
|
1994 |
code := ByteArray new:code_length. |
|
1995 |
inStream nextBytes:code_length into:code startingAt:1. |
|
1996 |
]. |
|
1997 |
Verbose ifTrue:[Transcript show:'method code: '; showCR:code.]. |
|
1998 |
||
1999 |
exception_table_length := inStream nextUnsignedShortMSB:msb. |
|
2000 |
Verbose ifTrue:[Transcript show:'exception_table_length: '; showCR:(exception_table_length printStringRadix:16)]. |
|
2001 |
exception_table_length ~~ 0 ifTrue:[ |
|
2002 |
Verbose ifTrue:[Transcript show:'exceptionTable length:'; showCR:exception_table_length.]. |
|
2003 |
||
2004 |
exception_table := Array new:exception_table_length. |
|
2005 |
1 to:exception_table_length do:[:i | |
|
2006 |
|start_pc end_pc handler_pc catch_type| |
|
2007 |
||
2008 |
start_pc := inStream nextUnsignedShortMSB:msb. |
|
2009 |
end_pc := inStream nextUnsignedShortMSB:msb. |
|
2010 |
handler_pc := inStream nextUnsignedShortMSB:msb. |
|
2011 |
catch_type := inStream nextUnsignedShortMSB:msb. |
|
2012 |
catch_type ~= 0 ifTrue:[ |
|
2013 |
catch_type := constants at:catch_type. |
|
2014 |
]. |
|
2015 |
exception_table at:i put:(JavaExceptionTableEntry |
|
2016 |
startPC:start_pc |
|
2017 |
endPC:end_pc |
|
2018 |
handlerPC:handler_pc |
|
2019 |
catchType:catch_type). |
|
2020 |
]. |
|
2021 |
aJavaMethod setExceptionHandlerTable:exception_table. |
|
2022 |
]. |
|
2023 |
||
2024 |
aJavaMethod |
|
2025 |
setCode:code |
|
2026 |
maxStack:max_stack |
|
2027 |
maxLocals:max_locals |
|
2028 |
u1:unknown1 |
|
2029 |
u2:unknown2. |
|
2030 |
||
2031 |
self readAttributesFor:aJavaMethod. |
|
2032 |
^ true |
|
2033 |
||
2034 |
" |
|
2035 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2036 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
2037 |
" |
|
2038 |
||
2039 |
"Created: / 15-04-1996 / 15:40:17 / cg" |
|
2040 |
"Modified: / 16-05-1998 / 01:39:42 / cg" |
|
1693 | 2041 |
"Modified: / 04-09-2012 / 11:58:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 2042 |
! |
2043 |
||
2044 |
readExceptionsAttributeFor:aJavaMethod |
|
2045 |
|attribute_length exception_table_length exception_table| |
|
2046 |
||
2047 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2048 |
||
2049 |
exception_table_length := inStream nextUnsignedShortMSB:msb. |
|
2050 |
exception_table_length ~~ 0 ifTrue:[ |
|
2051 |
exception_table := Array new:exception_table_length. |
|
2052 |
1 to:exception_table_length do:[:i | |
|
2053 |
|idx ex| |
|
2054 |
||
2055 |
idx := inStream nextUnsignedShortMSB:msb. |
|
2056 |
ex := constants at:idx. |
|
2057 |
exception_table at:i put:ex. |
|
2058 |
]. |
|
2059 |
]. |
|
2060 |
||
2061 |
Verbose ifTrue:[Transcript showCR:'method has an exceptionTable']. |
|
2062 |
||
2063 |
aJavaMethod setExceptionTable:exception_table. |
|
2064 |
^ true |
|
2065 |
||
2066 |
"Modified: 15.4.1996 / 15:33:28 / cg" |
|
2067 |
"Created: 15.4.1996 / 15:40:17 / cg" |
|
2068 |
! |
|
2069 |
||
2070 |
readLineNumberTableAttributeFor:aJavaMethod |
|
2071 |
|attribute_length line_number_table_length line_number_table| |
|
2072 |
||
2073 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2074 |
||
2075 |
line_number_table_length := inStream nextUnsignedShortMSB:msb. |
|
2076 |
line_number_table_length ~~ 0 ifTrue:[ |
|
2077 |
line_number_table := Array new:line_number_table_length. |
|
2078 |
1 to:line_number_table_length do:[:i | |
|
2079 |
|start_pc line_number| |
|
2080 |
||
2081 |
start_pc := inStream nextUnsignedShortMSB:msb. |
|
2082 |
line_number := inStream nextUnsignedShortMSB:msb. |
|
2083 |
line_number_table at:i put:(start_pc -> line_number). |
|
2084 |
]. |
|
2085 |
Verbose ifTrue:[Transcript showCR:'method has a lineNumberTable']. |
|
2086 |
||
2087 |
aJavaMethod setLineNumberTable:line_number_table. |
|
2088 |
]. |
|
2089 |
||
2090 |
^ true |
|
2091 |
||
2092 |
" |
|
2093 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2094 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/java/lang/Boolean.class' |
|
2095 |
" |
|
2096 |
||
2097 |
"Created: / 15.4.1996 / 15:40:17 / cg" |
|
2098 |
"Modified: / 7.4.1998 / 19:08:42 / cg" |
|
2099 |
! |
|
2100 |
||
2101 |
readLocalVariableTableAttributeFor:aJavaMethod |
|
2102 |
|attribute_length local_variable_table_length local_variable_table| |
|
2103 |
||
2104 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2105 |
||
2106 |
local_variable_table_length := inStream nextUnsignedShortMSB:msb. |
|
2107 |
local_variable_table_length ~~ 0 ifTrue:[ |
|
2108 |
local_variable_table := JavaLocalVariableTable new:local_variable_table_length. |
|
2109 |
1 to:local_variable_table_length do:[:i | |
|
2110 |
|start_pc length name_index sig_index slot name signature| |
|
2111 |
||
2112 |
start_pc := inStream nextUnsignedShortMSB:msb. |
|
2113 |
length := inStream nextUnsignedShortMSB:msb. |
|
2114 |
name_index := inStream nextUnsignedShortMSB:msb. |
|
2115 |
name := constants at:name_index. |
|
2116 |
sig_index := inStream nextUnsignedShortMSB:msb. |
|
2117 |
signature := constants at:sig_index. |
|
2118 |
slot := inStream nextUnsignedShortMSB:msb. |
|
2119 |
||
2120 |
local_variable_table at:i put:(JavaLocalVariableTableEntry new |
|
2121 |
startPC:start_pc |
|
2122 |
length:length |
|
2123 |
name:name |
|
2124 |
signature:signature |
|
2125 |
slot:slot) |
|
2126 |
]. |
|
2127 |
]. |
|
2128 |
||
2129 |
Verbose ifTrue:[Transcript showCR:'method has a localvariableTable']. |
|
2130 |
||
2131 |
aJavaMethod setLocalVariableTable:local_variable_table. |
|
2132 |
^ true |
|
2133 |
||
2134 |
" |
|
2135 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2136 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/java/lang/Boolean.class' |
|
2137 |
" |
|
2138 |
||
2139 |
"Modified: 15.4.1996 / 15:33:28 / cg" |
|
2140 |
"Created: 15.4.1996 / 15:40:17 / cg" |
|
2141 |
! |
|
2142 |
||
2143 |
readMethodFor:aClass |
|
913 | 2144 |
|m access_flags name_index name descriptor_index descriptor |
752 | 2145 |
tooManyArgs| |
2146 |
||
2147 |
"/ |
|
2148 |
"/ get a method |
|
2149 |
"/ |
|
2150 |
access_flags := inStream nextUnsignedShortMSB:msb. |
|
2151 |
name_index := inStream nextUnsignedShortMSB:msb. |
|
913 | 2152 |
descriptor_index := inStream nextUnsignedShortMSB:msb. |
752 | 2153 |
|
2154 |
name := constants at:name_index. |
|
913 | 2155 |
descriptor := constants at:descriptor_index. |
752 | 2156 |
|
2157 |
Verbose ifTrue:[ |
|
2158 |
Transcript show:'method name:'; showCR:name. |
|
913 | 2159 |
Transcript show:'descriptor:'; showCR:descriptor. |
752 | 2160 |
]. |
2161 |
||
2162 |
aClass isJavaClass ifTrue:[ |
|
1055 | 2163 |
(access_flags bitAnd:ACC_NATIVE) ~~ 0 ifTrue:[ |
752 | 2164 |
m := JavaNativeMethod new. |
2165 |
] ifFalse:[ |
|
2166 |
m := JavaMethodWithHandler new. |
|
2167 |
]. |
|
2168 |
m setAccessFlags:access_flags. |
|
2169 |
tooManyArgs := false. |
|
2170 |
ArgumentError handle:[:ex | |
|
1000 | 2171 |
Logger log: 'java method has too many arguments - will fail to execute' severity: #warn facility: 'JVM'. |
752 | 2172 |
tooManyArgs := true. |
2173 |
ex proceed. |
|
2174 |
] do:[ |
|
913 | 2175 |
m setName:name descriptor:descriptor. |
752 | 2176 |
]. |
2177 |
m setJavaClass:aClass. |
|
2178 |
||
2179 |
self readAttributesFor:m. |
|
2180 |
||
2181 |
tooManyArgs ifTrue:[ |
|
2182 |
m code:nil. |
|
2183 |
m byteCode:nil. |
|
2184 |
]. |
|
1050 | 2185 |
|
752 | 2186 |
(m exceptionHandlerTable isNil) ifTrue:[ |
2187 |
m isNative ifFalse:[ |
|
2188 |
m getExceptionTable isNil ifTrue:[ |
|
2189 |
m := JavaMethod fromMethod:m |
|
2190 |
] ifFalse:[ |
|
2191 |
m := JavaMethodWithException fromMethod:m |
|
2192 |
] |
|
2193 |
] |
|
2194 |
] ifFalse:[ |
|
1435 | 2195 |
| newAccessFlags | |
2196 |
||
2197 |
newAccessFlags := m accessFlags. |
|
1523
f5ffdad83ab9
Access to ACC_* and ACX_* constants unified. The only definition is in JavaConstants
vranyj1
parents:
1453
diff
changeset
|
2198 |
newAccessFlags := newAccessFlags bitOr:ACX_HASHANDLER. |
1435 | 2199 |
m hasFinallyBasedOnExceptionTable ifTrue:[ |
2200 |
newAccessFlags := newAccessFlags bitOr:ACX_HASFINALLY. |
|
2201 |
]. |
|
2202 |
m setAccessFlags:newAccessFlags. |
|
752 | 2203 |
]. |
913 | 2204 |
aClass addMethod:m name:name signature:descriptor. |
752 | 2205 |
] ifFalse:[ |
2206 |
m := Method new. |
|
2207 |
self readAttributesFor:m. |
|
1055 | 2208 |
(access_flags bitTest:ACC_STATIC) ifTrue:[ |
752 | 2209 |
aClass class primAddSelector:name asSymbol withMethod:m. |
2210 |
] ifFalse:[ |
|
2211 |
aClass primAddSelector:name asSymbol withMethod:m. |
|
2212 |
] |
|
2213 |
]. |
|
2214 |
||
2215 |
" |
|
2216 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2217 |
" |
|
2218 |
||
2219 |
"Created: / 15-04-1996 / 16:48:49 / cg" |
|
2220 |
"Modified: / 25-09-1999 / 23:16:25 / cg" |
|
1055 | 2221 |
"Modified: / 28-10-2011 / 16:56:48 / m" |
1435 | 2222 |
"Modified: / 29-03-2012 / 09:18:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 2223 |
! |
2224 |
||
2225 |
readMethodsFor:aJavaClass |
|
2226 |
|methodsCount method| |
|
2227 |
||
2228 |
"/ |
|
2229 |
"/ get methods |
|
2230 |
"/ |
|
2231 |
methodsCount := inStream nextUnsignedShortMSB:msb. |
|
2232 |
Verbose ifTrue:[Transcript show:'methodsCount = '; showCR:methodsCount]. |
|
2233 |
||
2234 |
1 to:methodsCount do:[:i | |
|
2235 |
Verbose ifTrue:[Transcript show:'method: '; showCR:i]. |
|
2236 |
method := self readMethodFor:aJavaClass |
|
2237 |
]. |
|
2238 |
||
1453 | 2239 |
Smalltalk changed: #methodDictionary with: aJavaClass. |
2240 |
||
752 | 2241 |
" |
2242 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2243 |
" |
|
2244 |
||
1453 | 2245 |
"Created: / 15-04-1996 / 16:46:30 / cg" |
2246 |
"Modified: / 08-05-1998 / 21:20:59 / cg" |
|
2247 |
"Modified: / 04-04-2012 / 01:18:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
752 | 2248 |
! ! |
2249 |
||
2250 |
!JavaClassReader methodsFor:'file reading - methods-ST'! |
|
2251 |
||
2252 |
readSTCodeAttributeFor:aSmalltalkMethod |
|
2253 |
|attribute_length max_stack max_locals code_length code |
|
2254 |
exception_table_length unknown1 unknown2| |
|
2255 |
||
2256 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2257 |
||
2258 |
Verbose ifTrue:[Transcript show:'attribute_length: 0x'; showCR:(attribute_length printStringRadix:16)]. |
|
2259 |
||
2260 |
max_stack := inStream nextUnsignedShortMSB:msb. |
|
2261 |
max_locals := inStream nextUnsignedShortMSB:msb. |
|
2262 |
||
2263 |
code_length := inStream nextUnsignedLongMSB:msb. |
|
2264 |
Verbose ifTrue:[Transcript show:'code_length: '; showCR:(code_length printStringRadix:16)]. |
|
2265 |
Verbose ifTrue:[Transcript show:'code at pos: '; showCR:inStream position]. |
|
2266 |
||
2267 |
code_length ~~ 0 ifTrue:[ |
|
2268 |
code := ByteArray new:code_length. |
|
2269 |
inStream nextBytes:code_length into:code startingAt:1. |
|
2270 |
]. |
|
2271 |
Verbose ifTrue:[Transcript show:'method code: '; showCR:code.]. |
|
2272 |
||
2273 |
exception_table_length := inStream nextUnsignedShortMSB:msb. |
|
2274 |
Verbose ifTrue:[Transcript show:'exception_table_length: '; showCR:(exception_table_length printStringRadix:16)]. |
|
2275 |
exception_table_length ~~ 0 ifTrue:[ |
|
2276 |
self error:'unexpected exceptionTable length'. |
|
2277 |
"/ skip it. |
|
2278 |
1 to:exception_table_length do:[:i | |
|
2279 |
"start_pc :=" inStream nextUnsignedShortMSB:msb. |
|
2280 |
"end_pc :=" inStream nextUnsignedShortMSB:msb. |
|
2281 |
"handler_pc :=" inStream nextUnsignedShortMSB:msb. |
|
2282 |
"catch_type :=" inStream nextUnsignedShortMSB:msb. |
|
2283 |
]. |
|
2284 |
]. |
|
2285 |
||
2286 |
aSmalltalkMethod byteCode:code. |
|
2287 |
aSmalltalkMethod stackSize:max_stack . |
|
2288 |
aSmalltalkMethod numberOfVars:max_locals. |
|
2289 |
||
2290 |
self readAttributesFor:aSmalltalkMethod. |
|
2291 |
^ true |
|
2292 |
||
2293 |
"Modified: / 16.5.1998 / 01:39:30 / cg" |
|
2294 |
! |
|
2295 |
||
2296 |
readSTLiteralsAttributeFor:aSmalltalkMethod |
|
2297 |
|attribute_length literal_table_length literal_table litIndex literal| |
|
2298 |
||
2299 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2300 |
||
2301 |
literal_table_length := inStream nextUnsignedShortMSB:msb. |
|
2302 |
literal_table_length ~~ 0 ifTrue:[ |
|
2303 |
literal_table := Array new:literal_table_length. |
|
2304 |
1 to:literal_table_length do:[:i | |
|
2305 |
litIndex := inStream nextUnsignedShortMSB:msb. |
|
2306 |
literal := (constants at:litIndex). |
|
2307 |
literal_table at:i put:literal. |
|
2308 |
]. |
|
2309 |
]. |
|
2310 |
Verbose ifTrue:[Transcript show:'literals: '; showCR:literal_table storeString.]. |
|
2311 |
||
2312 |
"Created: / 7.5.1998 / 11:52:28 / cg" |
|
2313 |
"Modified: / 16.5.1998 / 01:52:27 / cg" |
|
2314 |
! |
|
2315 |
||
2316 |
readSTMethodCategoryAttributeFor:aSmalltalkMethod |
|
2317 |
|attribute_length name_index name| |
|
2318 |
||
2319 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2320 |
||
2321 |
name_index := inStream nextUnsignedShortMSB:msb. |
|
2322 |
name := (constants at:name_index). |
|
2323 |
||
2324 |
aSmalltalkMethod category:name. |
|
2325 |
||
2326 |
"Modified: / 8.5.1998 / 20:39:59 / cg" |
|
2327 |
"Created: / 16.5.1998 / 01:04:19 / cg" |
|
2328 |
! ! |
|
2329 |
||
775 | 2330 |
!JavaClassReader methodsFor:'helpers'! |
2331 |
||
798
b534e73eaf7e
JavaClassReader2 now uses correct superclass loading
hlopkmar
parents:
797
diff
changeset
|
2332 |
loadSuperclassIdentifiedBy: something ignoring: classesBeingLoaded |
877 | 2333 |
"overriding method, here we expect something to be new JavaClassRef2" |
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
2334 |
|
877 | 2335 |
self assert: something isJavaRef |
2336 |
message: 'class identifier is not a java reference'. |
|
2337 |
self assert: something isJavaClassRef |
|
1033 | 2338 |
message: 'class identifier is not a java class reference'. |
1026
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
2339 |
(classesBeingLoaded includes: something name) ifTrue: [ |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
2340 |
self |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
2341 |
error: 'class we want to load is being loaded and that means something went wrong. tell mh' |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
2342 |
]. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
2343 |
"hint in case of bug - is parent of something set? surely jv will know more :)" "find out which classloader is used" |
1033 | 2344 |
^ JavaVM classForName: something name. |
877 | 2345 |
|
2346 |
"Created: / 18-05-2011 / 14:55:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
960 | 2347 |
"Modified: / 31-08-2011 / 21:25:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
798
b534e73eaf7e
JavaClassReader2 now uses correct superclass loading
hlopkmar
parents:
797
diff
changeset
|
2348 |
! |
b534e73eaf7e
JavaClassReader2 now uses correct superclass loading
hlopkmar
parents:
797
diff
changeset
|
2349 |
|
775 | 2350 |
updateOwnerInCPItem: each |
2351 |
((each isJavaRef and: [ each isNewJavaRef ]) |
|
2352 |
or: [ each isJavaNameAndType and: [ each isNewJavaNameAndType ] ]) |
|
2353 |
ifTrue: [ each owner: classBeingLoaded ]. |
|
2354 |
||
2355 |
"Created: / 12-05-2011 / 17:40:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
796
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2356 |
! |
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2357 |
|
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2358 |
updateOwnerInField: each |
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2359 |
|
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2360 |
each setClass: classBeingLoaded. |
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2361 |
|
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2362 |
"Created: / 18-05-2011 / 13:57:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
775 | 2363 |
! ! |
2364 |
||
799 | 2365 |
!JavaClassReader methodsFor:'logging'! |
2366 |
||
2367 |
info: message |
|
1000 | 2368 |
Verbose ifTrue: [ Logger log: message severity: #info facility: 'JVM' ]. |
799 | 2369 |
|
2370 |
"Created: / 18-05-2011 / 15:06:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1000 | 2371 |
"Modified (format): / 14-09-2011 / 21:39:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
799 | 2372 |
! ! |
2373 |
||
752 | 2374 |
!JavaClassReader class methodsFor:'documentation'! |
2375 |
||
2376 |
version |
|
1022 | 2377 |
^ '$Id$' |
752 | 2378 |
! |
2379 |
||
2380 |
version_CVS |
|
2381 |
^ '§Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaClassReader.st,v 1.92 2009/10/09 14:21:53 cg Exp §' |
|
2382 |
! |
|
2383 |
||
2384 |
version_SVN |
|
1022 | 2385 |
^ '$Id$' |
752 | 2386 |
! ! |
2387 |
||
959 | 2388 |
JavaClassReader initialize! |