author | vranyj1 |
Mon, 03 Dec 2012 22:09:19 +0000 | |
branch | development |
changeset 1859 | 4d42d0099c74 |
parent 1850 | 57d1aafbf884 |
child 1860 | d1397b2288af |
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. |
1792 | 547 |
super_class isNil ifTrue: [ |
548 |
super_class := self |
|
1028
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
549 |
loadSuperclassIdentifiedBy: (constants at: super_class_index) |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
550 |
ignoring: classesbeingLoaded |
1792 | 551 |
]. |
552 |
super_class isNil ifTrue: [ |
|
553 |
self halt: 'Cannot find super class?!!' |
|
554 |
]. |
|
1028
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
555 |
]. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
556 |
]. |
1792 | 557 |
|
558 |
"/ If superclass is finalized, mark class so as well. |
|
559 |
(super_class notNil and:[super_class hasFinalize]) ifTrue:[ |
|
560 |
access_flags := access_flags bitOr: ACX_HASFINALIZE |
|
561 |
]. |
|
752 | 562 |
|
563 |
"/ |
|
564 |
"/ get interfaces |
|
565 |
"/ |
|
566 |
||
567 |
interfaces := self readInterfaces. |
|
568 |
||
569 |
"/ |
|
570 |
"/ get fields |
|
571 |
"/ |
|
572 |
||
573 |
fields := self readFieldInfofields. |
|
574 |
||
575 |
"/ |
|
576 |
"/ create the fields as instVars |
|
577 |
"/ static fields are created as class-InstVars |
|
578 |
"/ |
|
798
b534e73eaf7e
JavaClassReader2 now uses correct superclass loading
hlopkmar
parents:
797
diff
changeset
|
579 |
|
771 | 580 |
staticFields := fields select: [:f | f isStatic ]. |
752 | 581 |
nStatic := staticFields size. |
771 | 582 |
this_class_ref := constants at: this_class_index. |
1062
69aac7194016
Fixes in classloaders to make Groovy running (again)
vranyj1
parents:
1060
diff
changeset
|
583 |
thisClassName := this_class_ref fullName asSlashedJavaClassName. |
752 | 584 |
|
585 |
"/ care for smalltalk classes ... |
|
586 |
||
1028
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
587 |
(thisClassName startsWith: 'smalltalk.') ifTrue: [ |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
588 |
thisClassName := thisClassName copyFrom: 11. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
589 |
existing_class := Smalltalk at: thisClassName asSymbol. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
590 |
existing_class notNil ifTrue: [ |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
591 |
self halt: ('overloading existing class: ' , thisClassName). |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
592 |
thisClassName := (thisClassName , '_new') asSymbol. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
593 |
]. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
594 |
thisMetaClass := Metaclass new. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
595 |
thisMetaClass setSuperclass: super_class class. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
596 |
thisMetaClass instSize: (super_class class instSize + nStatic). |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
597 |
classBeingLoaded := thisMetaClass new. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
598 |
classBeingLoaded setSuperclass: super_class. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
599 |
classBeingLoaded setName: thisClassName asSymbol. |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
600 |
] ifFalse: [ |
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
601 |
"/ a java class |
1139
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
602 |
Class withoutUpdatingChangesDo:[ |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
603 |
classBeingLoaded := JavaClass fullName: thisClassName numStatic: nStatic. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
604 |
classBeingLoaded classLoader: self class classLoaderQuerySignal query. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
605 |
fields := fields select: [:f | f isStatic not ]. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
606 |
JavaClass setInstanceVariableStringFromFields: staticFields |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
607 |
in: classBeingLoaded class. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
608 |
classBeingLoaded setStaticFields: staticFields. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
609 |
classBeingLoaded setAccessFlags: access_flags. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
610 |
classBeingLoaded setSuperclass: super_class. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
611 |
classBeingLoaded setConstantPool: constants. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
612 |
classBeingLoaded setFields: fields. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
613 |
classBeingLoaded setInterfaces: interfaces. |
d7a367bb8ca1
- JavaClassReader: do not uodate changes when loading .class file
vranyj1
parents:
1118
diff
changeset
|
614 |
] |
1028
d30cabc12354
fixed problem with classInit cycle.. still not booting :)
hlopkmar
parents:
1026
diff
changeset
|
615 |
]. |
752 | 616 |
|
617 |
"/ |
|
618 |
"/ get methods |
|
619 |
"/ |
|
620 |
||
775 | 621 |
self readMethodsFor: classBeingLoaded. |
622 |
self readAttributesFor: classBeingLoaded. |
|
1698
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
623 |
|
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 |
"/ get extensions |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
626 |
"/ |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
627 |
self readExtensionsFor: classBeingLoaded. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
628 |
|
796
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
629 |
classBeingLoaded fields do: [:each | self updateOwnerInField: each ]. |
1033 | 630 |
classBeingLoaded staticFields do: [:each | self updateOwnerInField: each ]. |
1038 | 631 |
classesbeingLoaded remove: classBeingLoaded name ifAbsent:[]. |
775 | 632 |
^ classBeingLoaded. |
752 | 633 |
|
634 |
" |
|
635 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
636 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
637 |
JavaClassReader loadFile:'foo.cls' |
|
638 |
||
639 |
JavaClassReader verbose:true. |
|
640 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/java/lang/ArithmeticException.class' |
|
641 |
JavaClassReader loadFile:'/phys/ibm3/java/lib/java/lang/ArithmeticException.class'" |
|
1035 | 642 |
|
752 | 643 |
"Created: / 15-04-1996 / 15:02:47 / cg" |
644 |
"Modified: / 12-11-1998 / 21:14:45 / cg" |
|
645 |
"Modified: / 15-10-2010 / 17:37:38 / Jan Kurs <kurs.jan@post.cz>" |
|
646 |
"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
|
647 |
"Modified: / 18-05-2011 / 15:30:29 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
1792 | 648 |
"Modified: / 02-11-2012 / 19:38:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 649 |
! |
650 |
||
651 |
readStream:aStream ignoring:classesBeingLoaded |
|
652 |
"reads a class from aStream and returns it. |
|
653 |
The JavaClass is not installed as global" |
|
654 |
||
655 |
inStream := aStream. |
|
656 |
inStream binary. |
|
657 |
||
658 |
^ self readClassFileIgnoring:classesBeingLoaded |
|
659 |
||
660 |
" |
|
661 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
662 |
" |
|
663 |
||
664 |
"Created: 15.4.1996 / 15:00:55 / cg" |
|
665 |
"Modified: 15.4.1996 / 15:06:18 / cg" |
|
666 |
! ! |
|
667 |
||
668 |
!JavaClassReader methodsFor:'file reading - attributes'! |
|
669 |
||
670 |
readAnnotationDefaultAttributeFor:something |
|
671 |
"/ ('JAVA [info]: unhandled attribute: AnnotationDefault') infoPrintCR. |
|
672 |
||
673 |
|len startPos endPos annotationDefault| |
|
674 |
||
675 |
self assert:something isJavaMethod |
|
676 |
description:'AnnotationDefault may only occure for methods!!'. |
|
677 |
len := inStream nextUnsignedLongMSB:msb. |
|
678 |
startPos := inStream position. |
|
679 |
annotationDefault := (something ensureHasAnnotations) |
|
680 |
default:(JavaAnnotationDefault new |
|
681 |
value:(self readAnnotationValueFor:something)); |
|
682 |
default. |
|
683 |
endPos := inStream position. |
|
684 |
inStream position:startPos. |
|
685 |
annotationDefault bytes:(inStream next:len). |
|
686 |
self assert:inStream position = endPos |
|
687 |
description:'self readAnnotationValueFor: something is reading what it shouldn'. |
|
688 |
||
689 |
"Modified: / 28-02-2011 / 17:08:28 / Marcel Hlopko <hlopik@gmail.com>" |
|
690 |
"Modified: / 03-03-2011 / 23:06:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
691 |
! |
|
692 |
||
693 |
readAnnotationFor:something |
|
694 |
| typeIndex type result attrsCount | |
|
695 |
||
696 |
typeIndex := inStream nextUnsignedShortMSB:msb. |
|
879 | 697 |
type := constants at:typeIndex. |
752 | 698 |
attrsCount := inStream nextUnsignedShortMSB:msb. |
699 |
result := JavaAnnotation for:something. |
|
700 |
result name:type. |
|
701 |
attrsCount timesRepeat: |
|
702 |
[ | nameIndex name valueIndex attr | |
|
703 |
||
704 |
nameIndex := inStream nextUnsignedShortMSB:msb. |
|
879 | 705 |
name := constants at:nameIndex. |
752 | 706 |
attr := self readAnnotationValueFor:something. |
707 |
attr name:name. |
|
708 |
result values at:attr name put:attr. |
|
709 |
AnnotationsVerbose |
|
710 |
ifTrue:[ ('JAVA [INFO]: Reading annotation attribute: ' , name) infoPrintCR. ]. ]. |
|
711 |
^ result. |
|
712 |
||
713 |
"Created: / 17-12-2010 / 16:21:28 / Marcel Hlopko <hlopik@gmail.com>" |
|
714 |
"Modified: / 25-02-2011 / 12:25:36 / Marcel Hlopko <hlopik@gmail.com>" |
|
879 | 715 |
"Modified: / 27-07-2011 / 09:37:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 716 |
! |
717 |
||
718 |
readAnnotationValueFor:something |
|
719 |
| tag result | |
|
720 |
||
721 |
tag := (inStream nextByte) asCharacter. |
|
722 |
tag = $e |
|
723 |
ifTrue: |
|
724 |
[ result := JavaAnnotationEnumValue for:something. |
|
725 |
result nameIndex:(inStream nextUnsignedShortMSB:msb). |
|
726 |
result valueIndex:(inStream nextUnsignedShortMSB:msb). |
|
727 |
AnnotationsVerbose |
|
728 |
ifTrue: |
|
729 |
[ ('JAVA [INFO]: Reading annotation enum value: ' , result name printString, ' -> ' |
|
730 |
, result value printString) infoPrintCR ]. |
|
731 |
^ result ]. |
|
732 |
tag = $c |
|
733 |
ifTrue: |
|
734 |
[ result := JavaAnnotationClassValue for:something. |
|
735 |
result classIndex:(inStream nextUnsignedShortMSB:msb). |
|
736 |
AnnotationsVerbose |
|
737 |
ifTrue: |
|
738 |
[ ('JAVA [INFO]: Reading annotation class value: ' , result name printString, ' -> ' |
|
739 |
, result value printString) infoPrintCR ]. |
|
740 |
^ result ]. |
|
741 |
tag = $@ |
|
742 |
ifTrue: |
|
743 |
[ result := JavaAnnotationNestedAnnotationValue for:something. |
|
744 |
result classIndex:(inStream nextUnsignedShortMSB:msb). |
|
745 |
AnnotationsVerbose |
|
746 |
ifTrue: |
|
747 |
[ ('JAVA [INFO]: Reading annotation nested annotation value: ' , result name printString |
|
748 |
, ' -> ' , result value printString) |
|
749 |
infoPrintCR ]. |
|
750 |
^ result ]. |
|
751 |
tag = $[ |
|
752 |
ifTrue: |
|
753 |
[ result := JavaAnnotationArrayValue for:something. |
|
754 |
result count:(inStream nextUnsignedShortMSB:msb). |
|
755 |
AnnotationsVerbose |
|
756 |
ifTrue:[ ('JAVA [INFO]: Reading annotation array value') infoPrintCR ]. |
|
757 |
1 to:result count |
|
758 |
do:[:index | result values at:index put:(self readAnnotationValueFor:something) ]. |
|
759 |
AnnotationsVerbose |
|
760 |
ifTrue: |
|
761 |
[ ('JAVA [INFO]: Finished reading annotation array value: ' |
|
762 |
, result value printString) infoPrintCR ]. |
|
763 |
^ result ]. |
|
764 |
result := JavaAnnotationPrimitiveValue for:something. |
|
765 |
result valueIndex:(inStream nextUnsignedShortMSB:msb). |
|
766 |
AnnotationsVerbose |
|
767 |
ifTrue: |
|
768 |
[ ('JAVA [INFO]: Finished reading annotation primitive value: ' |
|
769 |
, result name printString , ' -> ' , result value printString) infoPrintCR ]. |
|
770 |
^ result. |
|
771 |
||
772 |
"Created: / 17-12-2010 / 16:44:14 / Marcel Hlopko <hlopik@gmail.com>" |
|
773 |
"Modified: / 28-02-2011 / 16:12:09 / Marcel Hlopko <hlopik@gmail.com>" |
|
774 |
! |
|
775 |
||
776 |
readAttribute:attributeName for:something |
|
777 |
"/ implemented JAVA attributes |
|
778 |
||
779 |
(attributeName = 'ConstantValue') |
|
780 |
ifTrue: |
|
781 |
[ self readConstantValueAttributeFor:something. |
|
782 |
^ self. ]. |
|
783 |
(attributeName = 'Code') |
|
784 |
ifTrue: |
|
785 |
[ self readCodeAttributeFor:something. |
|
786 |
^ self. ]. |
|
787 |
(attributeName = 'Exceptions') |
|
788 |
ifTrue: |
|
789 |
[ self readExceptionsAttributeFor:something. |
|
790 |
^ self. ]. |
|
791 |
(attributeName = 'InnerClasses') |
|
792 |
ifTrue: |
|
793 |
[ self readInnerClassesAttributeFor:something. |
|
794 |
^ self. ]. |
|
795 |
(attributeName = 'EnclosingMethod') |
|
796 |
ifTrue: |
|
797 |
[ self readEnclosingMethodAttributeFor:something. |
|
798 |
^ self. ]. |
|
799 |
(attributeName = 'LineNumberTable') |
|
800 |
ifTrue: |
|
801 |
[ self readLineNumberTableAttributeFor:something. |
|
802 |
^ self. ]. |
|
803 |
(attributeName = 'LocalVariableTable') |
|
804 |
ifTrue: |
|
805 |
[ self readLocalVariableTableAttributeFor:something. |
|
806 |
^ self. ]. |
|
807 |
(attributeName = 'LocalVariableTypeTable') |
|
808 |
ifTrue: |
|
809 |
[ self readLocalVariableTypeTableAttributeFor:something. |
|
810 |
^ self. ]. |
|
811 |
(attributeName = 'SourceFile') |
|
812 |
ifTrue: |
|
813 |
[ self readSourceFileAttributeFor:something. |
|
814 |
^ self. ]. |
|
815 |
(attributeName = 'SourceDebugExtension') |
|
816 |
ifTrue: |
|
817 |
[ self readSourceDebugExtensionAttributeFor:something. |
|
818 |
^ self. ]. |
|
819 |
(attributeName = 'Synthetic') |
|
820 |
ifTrue: |
|
821 |
[ self readSyntheticAttributeFor:something. |
|
822 |
^ self. ]. |
|
823 |
(attributeName = 'Signature') |
|
824 |
ifTrue: |
|
825 |
[ self readSignatureAttributeFor:something. |
|
826 |
^ self. ]. |
|
827 |
(attributeName = 'Deprecated') |
|
828 |
ifTrue: |
|
829 |
[ self readDeprecatedAttributeFor:something. |
|
830 |
^ self. ]. |
|
831 |
(attributeName = 'RuntimeVisibleAnnotations') |
|
832 |
ifTrue: |
|
833 |
[ self readRuntimeAnnotationsAttributeFor:something visible:true. |
|
834 |
^ self. ]. |
|
835 |
(attributeName = 'RuntimeInvisibleAnnotations') |
|
836 |
ifTrue: |
|
837 |
[ self readRuntimeAnnotationsAttributeFor:something visible:false. |
|
838 |
^ self. ]. |
|
839 |
(attributeName = 'RuntimeVisibleParameterAnnotations') |
|
840 |
ifTrue: |
|
841 |
[ self readRuntimeParameterAnnotationsAttributeFor:something visible:true. |
|
842 |
^ self. ]. |
|
843 |
(attributeName = 'RuntimeInvisibleParameterAnnotations') |
|
844 |
ifTrue: |
|
845 |
[ self readRuntimeParameterAnnotationsAttributeFor:something visible:false. |
|
846 |
^ self. ]. |
|
847 |
(attributeName = 'AnnotationDefault') |
|
848 |
ifTrue: |
|
849 |
[ self readAnnotationDefaultAttributeFor:something. |
|
850 |
^ self. ]. |
|
851 |
||
852 |
"/ ignored JAVA attributes |
|
853 |
||
854 |
(attributeName = 'FastJavac1.0') |
|
855 |
ifTrue: |
|
856 |
[ "/ ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR. |
|
857 |
self skipAttribute:attributeName. |
|
858 |
^ self. ]. |
|
859 |
(attributeName = 'AbsoluteSourcePath') |
|
860 |
ifTrue: |
|
861 |
[ ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR. |
|
862 |
self skipAttribute:attributeName. |
|
863 |
^ self. ]. |
|
864 |
(attributeName startsWith:((Character value:13) asString , 'WARNING:')) |
|
865 |
ifTrue: |
|
866 |
[ "/ ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR. |
|
867 |
self skipAttribute:attributeName. |
|
868 |
^ self. ]. |
|
869 |
(attributeName = 'StackMapTable') |
|
870 |
ifTrue: |
|
871 |
[ "/ ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR. |
|
872 |
self readStackMapTableAttributeFor:something. |
|
873 |
^ self. ]. |
|
874 |
||
875 |
"/ implemented ST attributes |
|
876 |
||
877 |
(attributeName = 'STLiterals') |
|
878 |
ifTrue: |
|
879 |
[ self readSTLiteralsAttributeFor:something. |
|
880 |
^ self. ]. |
|
881 |
(attributeName = 'ClassRevision') |
|
882 |
ifTrue: |
|
883 |
[ self readSTClassRevisionAttributeFor:something. |
|
884 |
^ self. ]. |
|
885 |
(attributeName = 'ClassPackage') |
|
886 |
ifTrue: |
|
887 |
[ self readSTClassPackageAttributeFor:something. |
|
888 |
^ self. ]. |
|
889 |
(attributeName = 'ClassCategory') |
|
890 |
ifTrue: |
|
891 |
[ self readSTClassCategoryAttributeFor:something. |
|
892 |
^ self. ]. |
|
893 |
(attributeName = 'ClassVarNames') |
|
894 |
ifTrue: |
|
895 |
[ self readSTClassVarNamesAttributeFor:something. |
|
896 |
^ self. ]. |
|
897 |
(attributeName = 'ClassInstVarNames') |
|
898 |
ifTrue: |
|
899 |
[ self readSTClassInstVarNamesAttributeFor:something. |
|
900 |
^ self. ]. |
|
901 |
(attributeName = 'InstVarNames') |
|
902 |
ifTrue: |
|
903 |
[ self readSTInstVarNamesAttributeFor:something. |
|
904 |
^ self. ]. |
|
905 |
(attributeName = 'STCode') |
|
906 |
ifTrue: |
|
907 |
[ self readSTCodeAttributeFor:something. |
|
908 |
^ self. ]. |
|
909 |
(attributeName = 'MethodCategory') |
|
910 |
ifTrue: |
|
911 |
[ self readSTMethodCategoryAttributeFor:something. |
|
912 |
^ self. ]. |
|
913 |
||
914 |
"/ unknown attributes |
|
915 |
||
916 |
('JAVA [warning]: unrecognized attribute: ' , attributeName) infoPrintCR. |
|
917 |
self skipAttribute:attributeName. |
|
918 |
||
919 |
"Modified: / 03-12-1998 / 13:13:42 / cg" |
|
920 |
"Modified: / 25-02-2011 / 18:09:21 / Marcel Hlopko <hlopik@gmail.com>" |
|
921 |
! |
|
922 |
||
923 |
readAttributeFor:something |
|
924 |
|attribute_name_index attribute_name attribute_length attribute_info| |
|
925 |
||
926 |
Verbose ifTrue:[Transcript show:'attrib at pos: '; showCR:inStream position]. |
|
927 |
||
928 |
attribute_name_index := inStream nextUnsignedShortMSB:msb. |
|
929 |
attribute_name_index == 0 ifTrue:[ |
|
930 |
self halt. |
|
931 |
"/self skipAttribute:'unnamed'. |
|
932 |
^ self. |
|
933 |
]. |
|
934 |
||
935 |
"/ |
|
936 |
"/ UNDOC feature ? |
|
937 |
"/ |
|
938 |
attribute_name_index > constants size ifTrue:[ |
|
939 |
attribute_name_index == 16rb700 ifTrue:[ |
|
940 |
self halt. |
|
941 |
] |
|
942 |
]. |
|
943 |
||
944 |
attribute_name := constants at:attribute_name_index. |
|
945 |
||
946 |
Verbose ifTrue:[Transcript show:'attrib name: '; showCR:attribute_name]. |
|
947 |
||
948 |
self readAttribute:attribute_name for:something. |
|
949 |
||
950 |
" |
|
951 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
952 |
" |
|
953 |
||
954 |
"Created: / 15-04-1996 / 15:40:17 / cg" |
|
955 |
"Modified: / 09-04-1998 / 18:13:34 / cg" |
|
956 |
"Modified: / 19-10-2010 / 21:43:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
957 |
! |
|
958 |
||
959 |
readAttributesFor:something |
|
960 |
|attributes_count| |
|
961 |
||
962 |
attributes_count := inStream nextUnsignedShortMSB:msb. |
|
963 |
||
964 |
1 to:attributes_count do:[:i | |
|
965 |
self readAttributeFor:something. |
|
966 |
]. |
|
967 |
||
968 |
"Modified: 15.4.1996 / 15:33:28 / cg" |
|
969 |
"Created: 15.4.1996 / 15:40:17 / cg" |
|
970 |
! |
|
971 |
||
972 |
readDeprecatedAttributeFor:aJavaMethodWithHandler |
|
973 |
||
974 |
self skipAttribute:'Deprecated'. |
|
975 |
^self |
|
976 |
||
977 |
"Created: / 18-10-2010 / 22:26:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
978 |
! |
|
979 |
||
980 |
readEnclosingMethodAttributeFor:something |
|
981 |
"/ ('JAVA [info]: unhandled attribute: EnclosingMethod') infoPrintCR. |
|
982 |
self skipAttribute:'EnclosingMethod'. |
|
983 |
! |
|
984 |
||
985 |
readInnerClassesAttributeFor:something |
|
986 |
"/ ('JAVA [info]: unhandled attribute: InnerClasses') infoPrintCR. |
|
987 |
self skipAttribute:'InnerClasses'. |
|
988 |
! |
|
989 |
||
990 |
readLocalVariableTypeTableAttributeFor:something |
|
991 |
"/ ('JAVA [info]: unhandled attribute: LocalVariableTypeTable') infoPrintCR. |
|
992 |
self skipAttribute:'LocalVariableTypeTable'. |
|
993 |
! |
|
994 |
||
995 |
readRuntimeAnnotationsAttributeFor: something visible: visible |
|
996 |
| length annotationsCount annotations rawAnnotations startPos endPos | |
|
997 |
||
998 |
self assert: inStream isPositionable |
|
999 |
message: '.class file stream must be positionable'. |
|
1000 |
length := inStream nextUnsignedLongMSB: msb. |
|
1001 |
startPos := inStream position. |
|
1002 |
annotationsCount := inStream nextUnsignedShortMSB: msb. |
|
1003 |
annotationsCount = 0 ifTrue: [ ^ nil ]. |
|
1004 |
annotations := visible ifTrue: [something ensureHasAnnotations ensureRuntimeVisible] ifFalse: [something ensureHasAnnotations ensureRuntimeInvisible]. |
|
1005 |
annotationsCount timesRepeat: |
|
1006 |
[ | currentAnnotation | |
|
1007 |
||
1008 |
currentAnnotation := self readAnnotationFor: something. |
|
1009 |
annotations at: currentAnnotation name put: currentAnnotation. ]. |
|
1010 |
"Cut raw annotations as required by getRawAnnotations()" |
|
1011 |
endPos := inStream position. |
|
1012 |
inStream position: startPos. |
|
1013 |
rawAnnotations := inStream next: length. |
|
1014 |
inStream position ~= endPos |
|
1015 |
ifTrue: [ self halt: 'annotations are probably reading what they shouldnt' ]. |
|
1016 |
annotations rawAnnotations: rawAnnotations. |
|
1017 |
||
1018 |
"Modified: / 07-01-2011 / 22:00:07 / Jan Kurs <kurs.jan@post.cz>" |
|
1019 |
"Modified: / 25-02-2011 / 18:45:58 / Marcel Hlopko <hlopik@gmail.com>" |
|
1020 |
"Modified: / 03-03-2011 / 23:01:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1021 |
"Modified: / 16-03-2011 / 16:57:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1022 |
! |
|
1023 |
||
1024 |
readRuntimeParameterAnnotationsAttributeFor: javaMethod visible: visible |
|
1848 | 1025 |
| length paramsCount annotationsCount rawAnnotations startPos endPos | |
752 | 1026 |
self assert: inStream isPositionable |
1027 |
message: '.class file stream must be positionable'. |
|
1028 |
length := inStream nextUnsignedLongMSB: msb. |
|
1029 |
startPos := inStream position. |
|
1030 |
paramsCount := inStream nextByte. |
|
1031 |
paramsCount = 0 ifTrue: [ ^ nil ]. |
|
1848 | 1032 |
1 to: paramsCount do: [ |
1033 |
:paramIndex | |
|
1034 |
annotationsCount := inStream nextUnsignedShortMSB: msb. |
|
1035 |
annotationsCount > 0 ifTrue: [ |
|
1036 |
| annotations | |
|
1037 |
annotations := visible ifTrue: [ |
|
1038 |
javaMethod ensureHasAnnotations |
|
1039 |
ensureVisibleParameterAnnotationsAt: paramIndex |
|
1040 |
] ifFalse: [ |
|
1041 |
javaMethod ensureHasAnnotations |
|
1042 |
ensureInvisibleParameterAnnotationsAt: paramIndex |
|
1043 |
]. |
|
1044 |
annotationsCount timesRepeat: [ |
|
1045 |
| annotation | |
|
1046 |
annotation := self readAnnotationFor: javaMethod. |
|
1047 |
annotations at: (annotation name) put: annotation. |
|
1048 |
] |
|
1049 |
] |
|
1050 |
]. |
|
752 | 1051 |
endPos := inStream position. |
1848 | 1052 |
inStream position: startPos. |
752 | 1053 |
rawAnnotations := inStream next: length. |
1848 | 1054 |
inStream position ~= endPos ifTrue: [ |
1055 |
self halt: 'annotations are probably reading what they shouldnt' |
|
1056 |
]. |
|
1849 | 1057 |
self breakPoint:#mh. |
1850 | 1058 |
javaMethod annotations rawParamAnnotations: rawAnnotations. |
752 | 1059 |
|
1060 |
"Modified: / 28-02-2011 / 17:05:47 / Marcel Hlopko <hlopik@gmail.com>" |
|
1850 | 1061 |
"Modified: / 01-12-2012 / 22:54:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 1062 |
! |
1063 |
||
1064 |
readSignatureAttributeFor:something |
|
912
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1065 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1066 |
|attribute_length signature_index signature| |
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 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
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 |
signature_index := inStream nextUnsignedShortMSB:msb. |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1071 |
signature := constants at:signature_index. |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1072 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1073 |
something setSignature: signature. |
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1074 |
|
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
908
diff
changeset
|
1075 |
"Modified: / 13-08-2011 / 00:28:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 1076 |
! |
1077 |
||
1078 |
readSourceDebugExtensionAttributeFor:something |
|
1079 |
"/ ('JAVA [info]: unhandled attribute: SourceDebugExtension') infoPrintCR. |
|
1080 |
self skipAttribute:'SourceDebugExtension'. |
|
1081 |
! |
|
1082 |
||
1083 |
readSourceFileAttributeFor:aClass |
|
1084 |
|attribute_length sourceFile_index sourceFile| |
|
1085 |
||
1086 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1087 |
||
1088 |
sourceFile_index := inStream nextUnsignedShortMSB:msb. |
|
1089 |
sourceFile := constants at:sourceFile_index. |
|
1090 |
||
1091 |
aClass isJavaClass ifTrue:[ |
|
1092 |
aClass setSourceFile:sourceFile. |
|
1093 |
] ifFalse:[ |
|
1094 |
aClass setClassFilename:sourceFile |
|
1095 |
]. |
|
1096 |
||
1097 |
Verbose ifTrue:[Transcript show:'sourceFile: '; showCR:sourceFile]. |
|
1098 |
^ true |
|
1099 |
||
1100 |
" |
|
1101 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1102 |
JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1103 |
JavaClassReader loadFile:'foo.cls' |
|
1104 |
" |
|
1105 |
||
1106 |
"Created: / 15.4.1996 / 15:40:17 / cg" |
|
1107 |
"Modified: / 12.5.1998 / 22:01:07 / cg" |
|
1108 |
! |
|
1109 |
||
1110 |
readStackMapTableAttributeFor:something |
|
1111 |
"/ ('JAVA [info]: unhandled attribute: StackMapTable') infoPrintCR. |
|
1112 |
self skipAttribute:'StackMapTable'. |
|
1113 |
||
1114 |
"Created: / 09-02-2011 / 01:19:20 / Marcel Hlopko <hlopik@gmail.com>" |
|
1115 |
! |
|
1116 |
||
1117 |
readSyntheticAttributeFor:something |
|
1118 |
"/ ('JAVA [info]: unhandled attribute: Synthetic') infoPrintCR. |
|
1119 |
self skipAttribute:'Synthetic'. |
|
1120 |
! |
|
1121 |
||
1122 |
skipAttribute:attributeName |
|
1123 |
"dont know about this attribute - skip it here" |
|
1124 |
||
1125 |
|attribute_length attribute_info| |
|
1126 |
||
1127 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1128 |
attribute_info := ByteArray new:(attribute_length). |
|
1129 |
inStream nextBytes:attribute_length into:attribute_info startingAt:1. |
|
1130 |
||
1131 |
Verbose ifTrue:[Transcript show:'skipped '; show:attributeName; showCR:'-attribute']. |
|
1132 |
||
1133 |
"Created: / 9.4.1998 / 18:12:46 / cg" |
|
1134 |
"Modified: / 9.4.1998 / 18:13:20 / cg" |
|
1135 |
! ! |
|
1136 |
||
1137 |
!JavaClassReader methodsFor:'file reading - attributes-ST'! |
|
1138 |
||
1139 |
readSTClassCategoryAttributeFor:aClass |
|
1140 |
|attribute_length categoryString_index categoryString| |
|
1141 |
||
1142 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1143 |
||
1144 |
categoryString_index := inStream nextUnsignedShortMSB:msb. |
|
1145 |
categoryString := constants at:categoryString_index. |
|
1146 |
||
1147 |
aClass category:categoryString. |
|
1148 |
||
1149 |
Verbose ifTrue:[Transcript show:'categoryString: '; showCR:categoryString]. |
|
1150 |
^ true |
|
1151 |
||
1152 |
" |
|
1153 |
JavaClassReader loadFile:'foo.cls' |
|
1154 |
" |
|
1155 |
||
1156 |
"Created: / 9.5.1998 / 02:33:13 / cg" |
|
1157 |
"Modified: / 9.5.1998 / 02:36:55 / cg" |
|
1158 |
! |
|
1159 |
||
1160 |
readSTClassInstVarNamesAttributeFor:aClass |
|
1161 |
|attribute_length nameString_index nameString| |
|
1162 |
||
1163 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1164 |
||
1165 |
nameString_index := inStream nextUnsignedShortMSB:msb. |
|
1166 |
nameString := constants at:nameString_index. |
|
1167 |
||
1168 |
aClass class instanceVariableString:nameString. |
|
1169 |
||
1170 |
Verbose ifTrue:[Transcript show:'nameString: '; showCR:nameString]. |
|
1171 |
^ true |
|
1172 |
||
1173 |
" |
|
1174 |
JavaClassReader loadFile:'foo.cls' |
|
1175 |
" |
|
1176 |
||
1177 |
"Modified: / 12.5.1998 / 22:18:03 / cg" |
|
1178 |
"Created: / 12.5.1998 / 22:18:24 / cg" |
|
1179 |
! |
|
1180 |
||
1181 |
readSTClassPackageAttributeFor:aClass |
|
1182 |
|attribute_length packageString_index packageString| |
|
1183 |
||
1184 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1185 |
||
1186 |
packageString_index := inStream nextUnsignedShortMSB:msb. |
|
1187 |
packageString := constants at:packageString_index. |
|
1188 |
||
1189 |
aClass package:packageString asSymbol. |
|
1190 |
||
1191 |
Verbose ifTrue:[Transcript show:'packageString: '; showCR:packageString]. |
|
1192 |
^ true |
|
1193 |
||
1194 |
" |
|
1195 |
JavaClassReader loadFile:'foo.cls' |
|
1196 |
" |
|
1197 |
||
1198 |
"Modified: / 9.5.1998 / 02:32:38 / cg" |
|
1199 |
"Created: / 9.5.1998 / 02:33:44 / cg" |
|
1200 |
! |
|
1201 |
||
1202 |
readSTClassRevisionAttributeFor:aClass |
|
1203 |
|attribute_length revisionString_index revisionString| |
|
1204 |
||
1205 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1206 |
||
1207 |
revisionString_index := inStream nextUnsignedShortMSB:msb. |
|
1208 |
revisionString := constants at:revisionString_index. |
|
1209 |
||
1210 |
aClass setBinaryRevision:revisionString. |
|
1211 |
||
1212 |
Verbose ifTrue:[Transcript show:'revisionString: '; showCR:revisionString]. |
|
1213 |
^ true |
|
1214 |
||
1215 |
" |
|
1216 |
JavaClassReader loadFile:'foo.cls' |
|
1217 |
" |
|
1218 |
||
1219 |
"Created: / 9.5.1998 / 02:33:13 / cg" |
|
1220 |
"Modified: / 9.5.1998 / 02:35:01 / cg" |
|
1221 |
! |
|
1222 |
||
1223 |
readSTClassVarNamesAttributeFor:aClass |
|
1224 |
|attribute_length nameString_index nameString| |
|
1225 |
||
1226 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1227 |
||
1228 |
nameString_index := inStream nextUnsignedShortMSB:msb. |
|
1229 |
nameString := constants at:nameString_index. |
|
1230 |
||
1231 |
aClass classVariableString:nameString. |
|
1232 |
||
1233 |
Verbose ifTrue:[Transcript show:'nameString: '; showCR:nameString]. |
|
1234 |
^ true |
|
1235 |
||
1236 |
" |
|
1237 |
JavaClassReader loadFile:'foo.cls' |
|
1238 |
" |
|
1239 |
||
1240 |
"Created: / 9.5.1998 / 02:33:13 / cg" |
|
1241 |
"Modified: / 12.5.1998 / 22:18:03 / cg" |
|
1242 |
! |
|
1243 |
||
1244 |
readSTInstVarNamesAttributeFor:aClass |
|
1245 |
|attribute_length nameString_index nameString| |
|
1246 |
||
1247 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1248 |
||
1249 |
nameString_index := inStream nextUnsignedShortMSB:msb. |
|
1250 |
nameString := constants at:nameString_index. |
|
1251 |
||
1252 |
aClass setInstanceVariableString:nameString. |
|
1253 |
||
1254 |
Verbose ifTrue:[Transcript show:'nameString: '; showCR:nameString]. |
|
1255 |
^ true |
|
1256 |
||
1257 |
" |
|
1258 |
JavaClassReader loadFile:'foo.cls' |
|
1259 |
" |
|
1260 |
||
1261 |
"Created: / 12.5.1998 / 22:18:14 / cg" |
|
1262 |
"Modified: / 12.5.1998 / 22:21:10 / cg" |
|
1263 |
! ! |
|
1264 |
||
1265 |
!JavaClassReader methodsFor:'file reading - constants'! |
|
1266 |
||
1267 |
readConstant |
|
1268 |
|tag constReader const| |
|
1269 |
||
1270 |
||
1271 |
constNeeds2Slots := false. |
|
1272 |
||
1273 |
"/ |
|
1274 |
"/ get tag |
|
1275 |
"/ |
|
1276 |
tag := inStream nextByte. |
|
1277 |
Verbose ifTrue:[Transcript show:'tag = '; showCR:tag]. |
|
1278 |
||
1279 |
tag >= 250 ifTrue:[ |
|
1280 |
constReader := #( |
|
1281 |
"/ ST types |
|
1282 |
readConstant_ST_Large "/ 249 |
|
1283 |
readConstant_ST_Special "/ 250 |
|
1284 |
readConstant_ST_Character "/ 251 |
|
1285 |
readConstant_ST_ByteArray "/ 252 |
|
1286 |
readConstant_ST_Array "/ 253 |
|
1287 |
readConstant_ST_Symbol "/ 254 |
|
1288 |
readConstant_ST_Reserved "/ 255 |
|
1289 |
) at:tag-249+1. |
|
1290 |
] ifFalse:[ |
|
1291 |
constReader := #( |
|
1292 |
"/ JAVA types |
|
1293 |
readConstant_Utf8 "/ 1 - now called Utf8 |
|
1294 |
readConstant_Unicode "/ 2 |
|
1295 |
readConstant_Integer "/ 3 |
|
1296 |
readConstant_Float "/ 4 |
|
1297 |
readConstant_Long "/ 5 |
|
1298 |
readConstant_Double "/ 6 |
|
1299 |
readConstant_Class "/ 7 |
|
1300 |
readConstant_String "/ 8 |
|
1301 |
readConstant_Fieldref "/ 9 |
|
1302 |
readConstant_Methodref "/ 10 |
|
1303 |
readConstant_InterfaceMethodref "/ 11 |
|
1304 |
readConstant_NameAndType "/ 12 |
|
1305 |
) at:tag ifAbsent:[#readConstant_Undef]. |
|
1306 |
]. |
|
1307 |
^ self perform:constReader. |
|
1308 |
||
1309 |
" |
|
1310 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1311 |
" |
|
1312 |
||
1313 |
"Created: / 15.4.1996 / 15:46:32 / cg" |
|
1314 |
"Modified: / 9.5.1998 / 01:26:05 / cg" |
|
1315 |
! |
|
1316 |
||
1317 |
readConstantPool |
|
877 | 1318 |
| constantPoolSize const | |
752 | 1319 |
|
1320 |
"/ |
|
1321 |
"/ get constant pool |
|
1322 |
"/ |
|
877 | 1323 |
constantPoolSize := inStream nextUnsignedShortMSB: msb. |
1324 |
self info: 'constantPoolSize = ' , constantPoolSize printString. |
|
1325 |
constants := JavaConstantPool new: constantPoolSize - 1. |
|
752 | 1326 |
constSlot := 1. |
877 | 1327 |
[ constSlot < constantPoolSize ] whileTrue: [ |
1328 |
self info: 'const slot: ' , constSlot printString. |
|
1329 |
const := self readConstant. |
|
1330 |
constants at: constSlot put: const. |
|
1331 |
||
1332 |
"/ long & double consts take 2 slots |
|
1333 |
"/ (only first is used) |
|
1334 |
||
1335 |
constNeeds2Slots |
|
1336 |
ifTrue: [ constSlot := constSlot + 2. ] |
|
1337 |
ifFalse: [ constSlot := constSlot + 1. ]]. |
|
752 | 1338 |
constSlot := -1. |
1728 | 1339 |
|
1340 |
constants do:[:ref|ref isJavaRef ifTrue:[ref preResolve]]. |
|
1341 |
"/ 1 to: constantPoolSize - 1 |
|
1342 |
"/ do: |
|
1343 |
"/ [:i | |
|
1344 |
"/ | const value | |
|
1345 |
"/ |
|
1346 |
"/ const := constants at: i. |
|
1347 |
"/ const notNil ifTrue: |
|
1348 |
"/ [ "/ kludge for 2-slot constants (which only take 1 slot in ST/X) |
|
1349 |
"/ (const isKindOf: JavaUnresolvedConstant) |
|
1350 |
"/ ifTrue: |
|
1351 |
"/ [ value := const preResolve. |
|
1352 |
"/ value ~~ const ifTrue: [ constants at: i put: value. ] ] ] ]. |
|
752 | 1353 |
|
1354 |
" |
|
1355 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
877 | 1356 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'" |
1357 |
||
1358 |
"Modified: / 07-05-1998 / 11:44:06 / cg" |
|
1359 |
"Created: / 13-05-2011 / 16:52:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1728 | 1360 |
"Modified: / 15-10-2012 / 23:15:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 1361 |
! |
1362 |
||
1363 |
readConstant_Asciz |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1364 |
| len string | |
782 | 1365 |
|
1366 |
||
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1367 |
len := inStream nextUnsignedShortMSB: msb. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1368 |
string := String new: len. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1369 |
inStream |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1370 |
nextBytes: len |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1371 |
into: string |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1372 |
startingAt: 1. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1373 |
Verbose |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1374 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1375 |
[ Transcript |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1376 |
show: 'asciz; string= '; |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1377 |
showCR: string ]. |
752 | 1378 |
^ string |
1379 |
||
1380 |
" |
|
1381 |
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
|
1382 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'" |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1383 |
|
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1384 |
"Created: / 15-04-1996 / 15:15:35 / cg" |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1385 |
"Modified: / 15-04-1996 / 16:33:45 / cg" |
782 | 1386 |
"Modified: / 13-05-2011 / 17:31:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 1387 |
! |
1388 |
||
1389 |
readConstant_Class |
|
877 | 1390 |
| nameIndex | |
1391 |
||
1392 |
nameIndex := inStream nextUnsignedShortMSB: msb. |
|
1393 |
((constants at: nameIndex) isNil) |
|
1394 |
ifTrue: |
|
1395 |
[ self info: ('reading class; index=' , nameIndex printString , ' name=' |
|
1396 |
, (constants at: nameIndex) printString) ] |
|
1397 |
ifFalse: [ self info: ('reading class; index= ' , nameIndex printString) ]. |
|
1398 |
^ JavaClassRef2 in: constants withNameAt: nameIndex. |
|
1399 |
||
1400 |
"Modified: / 18-05-2011 / 18:21:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 1401 |
! |
1402 |
||
1403 |
readConstant_Double |
|
1404 |
|high low aFloat bytes| |
|
1405 |
||
1406 |
"/ new code - to be tested |
|
1407 |
"/ bytes := ByteArray new:8. |
|
1408 |
"/ |
|
1409 |
"/ inStream nextBytes:8 into:bytes startingAt:1. |
|
1410 |
"/ msb ~~ UninterpretedBytes isBigEndian ifTrue:[ |
|
1411 |
"/ bytes reverse |
|
1412 |
"/ ]. |
|
1413 |
"/ aFloat := bytes doubleAt:1. |
|
1414 |
||
1415 |
"/ old code |
|
1416 |
||
1417 |
high := inStream nextUnsignedLongMSB:msb. |
|
1418 |
low := inStream nextUnsignedLongMSB:msb. |
|
1419 |
||
1420 |
aFloat := Float new. |
|
1421 |
UninterpretedBytes isBigEndian ifTrue:[ |
|
1422 |
aFloat basicAt:1 put:((high bitShift:-24) bitAnd:16rFF). |
|
1423 |
aFloat basicAt:2 put:((high bitShift:-16) bitAnd:16rFF). |
|
1424 |
aFloat basicAt:3 put:((high bitShift:-8) bitAnd:16rFF). |
|
1425 |
aFloat basicAt:4 put:(high bitAnd:16rFF). |
|
1426 |
aFloat basicAt:5 put:((low bitShift:-24) bitAnd:16rFF). |
|
1427 |
aFloat basicAt:6 put:((low bitShift:-16) bitAnd:16rFF). |
|
1428 |
aFloat basicAt:7 put:((low bitShift:-8) bitAnd:16rFF). |
|
1429 |
aFloat basicAt:8 put:(low bitAnd:16rFF). |
|
1430 |
] ifFalse:[ |
|
1431 |
aFloat basicAt:1 put:(low bitAnd:16rFF). |
|
1432 |
aFloat basicAt:2 put:((low bitShift:-8) bitAnd:16rFF). |
|
1433 |
aFloat basicAt:3 put:((low bitShift:-16) bitAnd:16rFF). |
|
1434 |
aFloat basicAt:4 put:((low bitShift:-24) bitAnd:16rFF). |
|
1435 |
aFloat basicAt:5 put:(high bitAnd:16rFF). |
|
1436 |
aFloat basicAt:6 put:((high bitShift:-8) bitAnd:16rFF). |
|
1437 |
aFloat basicAt:7 put:((high bitShift:-16) bitAnd:16rFF). |
|
1438 |
aFloat basicAt:8 put:((high bitShift:-24) bitAnd:16rFF). |
|
1439 |
]. |
|
1440 |
||
1441 |
constNeeds2Slots := true. |
|
1442 |
||
1443 |
Verbose ifTrue:[Transcript show:'double; value= '; showCR:aFloat]. |
|
1444 |
^ aFloat |
|
1445 |
||
1446 |
" |
|
1447 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1448 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1449 |
" |
|
1450 |
||
1451 |
"Created: / 15.4.1996 / 16:34:42 / cg" |
|
1452 |
"Modified: / 8.5.1998 / 22:06:07 / cg" |
|
1453 |
! |
|
1454 |
||
877 | 1455 |
readConstant_Fieldref |
1456 |
"incrementally changing resolving logic, fields will come later" |
|
1457 |
||
1458 |
| classIndex nameAndTypeIndex | |
|
1459 |
||
1460 |
classIndex := inStream nextUnsignedShortMSB: msb. |
|
1461 |
nameAndTypeIndex := inStream nextUnsignedShortMSB: msb. |
|
1462 |
self |
|
1463 |
info: 'reading fieldref; classindex=' , classIndex printString |
|
1464 |
, ' nameAndTypeIndex=' , nameAndTypeIndex printString. |
|
1465 |
^ JavaFieldRef2 |
|
1466 |
in: constants |
|
1467 |
withNameAndTypeAt: nameAndTypeIndex |
|
1468 |
andClassAt: classIndex. |
|
1469 |
||
1470 |
"Modified: / 15-05-2011 / 14:20:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 1471 |
! |
1472 |
||
1473 |
readConstant_Float |
|
1474 |
|b1 b2 b3 b4 aFloat bytes| |
|
1475 |
||
1476 |
"/ new code - to be tested ... |
|
1477 |
"/ |
|
1478 |
"/ bytes := ByteArray new:4. |
|
1479 |
"/ inStream nextBytes:4 into:bytes startingAt:1. |
|
1480 |
"/ msb ~~ UninterpretedBytes isBigEndian ifTrue:[ |
|
1481 |
"/ bytes reverse |
|
1482 |
"/ ]. |
|
1483 |
"/ aFloat := bytes floatAt:1. |
|
1484 |
"/ Verbose ifTrue:[Transcript show:'float; value= '; showCR:aFloat]. |
|
1485 |
"/ ^ aFloat. |
|
1486 |
||
1487 |
"/ old code |
|
1488 |
||
1489 |
aFloat := ShortFloat basicNew. |
|
1490 |
||
1491 |
b1 := inStream nextByte. |
|
1492 |
b2 := inStream nextByte. |
|
1493 |
b3 := inStream nextByte. |
|
1494 |
b4 := inStream nextByte. |
|
1495 |
||
1496 |
UninterpretedBytes isBigEndian ifTrue:[ |
|
1497 |
aFloat basicAt:1 put:b1. |
|
1498 |
aFloat basicAt:2 put:b2. |
|
1499 |
aFloat basicAt:3 put:b3. |
|
1500 |
aFloat basicAt:4 put:b4. |
|
1501 |
] ifFalse:[ |
|
1502 |
aFloat basicAt:4 put:b1. |
|
1503 |
aFloat basicAt:3 put:b2. |
|
1504 |
aFloat basicAt:2 put:b3. |
|
1505 |
aFloat basicAt:1 put:b4. |
|
1506 |
]. |
|
1507 |
Verbose ifTrue:[Transcript show:'float; value= '; showCR:aFloat]. |
|
1508 |
^ aFloat |
|
1509 |
||
1510 |
" |
|
1511 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1512 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1513 |
" |
|
1514 |
||
1515 |
"Created: / 15.4.1996 / 16:34:42 / cg" |
|
1516 |
"Modified: / 10.11.1998 / 22:04:59 / cg" |
|
1517 |
! |
|
1518 |
||
1519 |
readConstant_Integer |
|
1520 |
|value| |
|
1521 |
||
1522 |
value := inStream nextLongMSB:msb. |
|
1523 |
||
1524 |
Verbose ifTrue:[Transcript show:'integer; value= '; showCR:value]. |
|
1525 |
||
1526 |
^ value |
|
1527 |
||
1528 |
" |
|
1529 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1530 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1531 |
" |
|
1532 |
||
1533 |
"Modified: 15.4.1996 / 15:42:16 / cg" |
|
1534 |
"Created: 15.4.1996 / 16:34:42 / cg" |
|
1535 |
! |
|
1536 |
||
1537 |
readConstant_InterfaceMethodref |
|
877 | 1538 |
| classIndex nameAndTypeIndex | |
1539 |
||
1540 |
classIndex := inStream nextUnsignedShortMSB: msb. |
|
1541 |
nameAndTypeIndex := inStream nextUnsignedShortMSB: msb. |
|
1542 |
self |
|
1543 |
info: 'reading interface methodref; classindex=' , classIndex printString |
|
1544 |
, ' nameAndTypeIndex=' , nameAndTypeIndex printString. |
|
1545 |
^ JavaInterfaceMethodRef2 |
|
1546 |
in: constants |
|
1547 |
withNameAndTypeAt: nameAndTypeIndex |
|
1548 |
andClassAt: classIndex. |
|
1549 |
||
1550 |
"Modified: / 12-05-2011 / 18:57:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 1551 |
! |
1552 |
||
1553 |
readConstant_Long |
|
1554 |
|high low value| |
|
1555 |
||
1556 |
high := inStream nextUnsignedLongMSB:msb. |
|
1557 |
low := inStream nextUnsignedLongMSB:msb. |
|
1558 |
||
1559 |
value := (high bitShift:32) bitOr:low. |
|
1560 |
(high bitTest:16r80000000) ifTrue:[ |
|
1561 |
value := value - 16r10000000000000000. |
|
1562 |
]. |
|
1563 |
constNeeds2Slots := true. |
|
1564 |
||
1565 |
Verbose ifTrue:[Transcript show:'long; value= '; showCR:value]. |
|
1566 |
^ value |
|
1567 |
||
1568 |
" |
|
1569 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1570 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1571 |
" |
|
1572 |
||
1573 |
"Modified: 15.4.1996 / 15:42:16 / cg" |
|
1574 |
"Created: 15.4.1996 / 16:34:42 / cg" |
|
1575 |
! |
|
1576 |
||
1577 |
readConstant_Methodref |
|
877 | 1578 |
| classIndex nameAndTypeIndex | |
1579 |
||
1580 |
classIndex := inStream nextUnsignedShortMSB: msb. |
|
1581 |
nameAndTypeIndex := inStream nextUnsignedShortMSB: msb. |
|
1582 |
self |
|
1583 |
info: 'reading methodref; classindex=' , classIndex printString , ' nameAndTypeIndex=' |
|
1584 |
, nameAndTypeIndex printString. |
|
1585 |
^ JavaMethodRef2 |
|
1586 |
in: constants |
|
1587 |
withNameAndTypeAt: nameAndTypeIndex |
|
1588 |
andClassAt: classIndex. |
|
1589 |
||
1590 |
"Modified: / 15-05-2011 / 14:20:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 1591 |
! |
1592 |
||
1593 |
readConstant_NameAndType |
|
877 | 1594 |
| nameIndex descriptorIndex | |
1595 |
||
1596 |
nameIndex := inStream nextUnsignedShortMSB: msb. |
|
1597 |
descriptorIndex := inStream nextUnsignedShortMSB: msb. |
|
1598 |
self |
|
1599 |
info: 'reading nameAndType; nameindex=' , nameIndex printString |
|
1600 |
, ' descriptorIndex= ' , descriptorIndex printString. |
|
1601 |
^JavaNameAndType2 |
|
1602 |
in: constants |
|
1603 |
withNameAt: nameIndex |
|
1604 |
andDescriptorAt: descriptorIndex. |
|
1605 |
||
1606 |
"Modified: / 10-05-2011 / 17:09:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
752 | 1607 |
! |
1608 |
||
1609 |
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
|
1610 |
| string_index | |
782 | 1611 |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1612 |
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
|
1613 |
^ 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
|
1614 |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1615 |
|
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
|
1616 |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1617 |
"Created: / 15-04-1996 / 15:20:33 / cg" |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1618 |
"Modified: / 07-05-1998 / 11:42:45 / cg" |
782 | 1619 |
"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
|
1620 |
"Modified: / 10-08-2011 / 23:25:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 1621 |
! |
1622 |
||
1623 |
readConstant_Unicode |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1624 |
| len string ascii | |
782 | 1625 |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1626 |
len := inStream nextUnsignedShortMSB: msb. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1627 |
string := TwoByteString new: len. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1628 |
1 to: len |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1629 |
do: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1630 |
[:idx | |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1631 |
ascii := inStream nextUnsignedShortMSB: msb. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1632 |
string at: idx put: (Character value: ascii). ]. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1633 |
Verbose |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1634 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1635 |
[ Transcript |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1636 |
show: 'asciz; unicodeString= '; |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1637 |
showCR: string ]. |
752 | 1638 |
^ string |
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1639 |
|
782 | 1640 |
"Modified: / 13-05-2011 / 17:31:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 1641 |
! |
1642 |
||
1643 |
readConstant_Utf8 |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1644 |
| len bytes string | |
782 | 1645 |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1646 |
len := inStream nextUnsignedShortMSB: msb. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1647 |
bytes := ByteArray new: len. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1648 |
inStream |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1649 |
nextBytes: len |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1650 |
into: bytes |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1651 |
startingAt: 1. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1652 |
string := CharacterArray fromJavaUTF8Bytes: bytes. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1653 |
Verbose |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1654 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1655 |
[ Transcript |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1656 |
show: 'asciz; string= '; |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1657 |
showCR: string ]. |
752 | 1658 |
^ string |
1659 |
||
1660 |
"Modified: / 19-10-2010 / 12:38:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
782 | 1661 |
"Modified: / 13-05-2011 / 17:31:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 1662 |
! ! |
1663 |
||
1664 |
!JavaClassReader methodsFor:'file reading - constants-ST'! |
|
1665 |
||
1666 |
readConstant_ST_Array |
|
1667 |
|aSize arr| |
|
1668 |
||
1669 |
aSize := inStream nextUnsignedShortMSB:msb. |
|
1670 |
arr := Array new:aSize. |
|
1671 |
||
1672 |
1 to:aSize do:[:i | |
|
1673 |
|element_index element| |
|
1674 |
||
1675 |
element_index := inStream nextUnsignedShortMSB:msb. |
|
1676 |
arr at:i put:element_index. |
|
1677 |
]. |
|
1678 |
Verbose ifTrue:[Transcript show:'array; size= '; showCR:aSize]. |
|
1679 |
||
1680 |
^ JavaUnresolvedSTArrayConstant |
|
1681 |
pool:constants |
|
1682 |
poolIndex:constSlot |
|
1683 |
array:arr |
|
1684 |
||
1685 |
"Created: / 7.5.1998 / 11:47:01 / cg" |
|
1686 |
"Modified: / 9.5.1998 / 00:25:34 / cg" |
|
1687 |
! |
|
1688 |
||
1689 |
readConstant_ST_ByteArray |
|
1690 |
|aSize arr| |
|
1691 |
||
1692 |
aSize := inStream nextUnsignedShortMSB:msb. |
|
1693 |
arr := ByteArray new:aSize. |
|
1694 |
||
1695 |
1 to:aSize do:[:i | |
|
1696 |
|element_index| |
|
1697 |
||
1698 |
arr at:i put:(inStream nextByte). |
|
1699 |
]. |
|
1700 |
Verbose ifTrue:[Transcript show:'byteArray; size= '; showCR:aSize]. |
|
1701 |
||
1702 |
^ arr |
|
1703 |
||
1704 |
"Created: / 7.5.1998 / 11:47:12 / cg" |
|
1705 |
! |
|
1706 |
||
1707 |
readConstant_ST_Character |
|
1708 |
|ascii| |
|
1709 |
||
1710 |
ascii := inStream nextUnsignedShortMSB:msb. |
|
1711 |
||
1712 |
Verbose ifTrue:[Transcript show:'char; ascii= '; showCR:ascii]. |
|
1713 |
^ Character value:ascii |
|
1714 |
||
1715 |
"Created: / 7.5.1998 / 11:48:12 / cg" |
|
1716 |
! |
|
1717 |
||
1718 |
readConstant_ST_Special |
|
1719 |
|type| |
|
1720 |
||
1721 |
type := inStream nextUnsignedShortMSB:msb. |
|
1722 |
^ #( |
|
1723 |
nil |
|
1724 |
true |
|
1725 |
false |
|
1726 |
) at:(type + 1) |
|
1727 |
||
1728 |
"Created: / 8.5.1998 / 23:06:56 / cg" |
|
1729 |
"Modified: / 9.5.1998 / 00:40:14 / cg" |
|
1730 |
! |
|
1731 |
||
1732 |
readConstant_ST_String |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1733 |
| tag string_index chars | |
782 | 1734 |
|
1735 |
||
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1736 |
string_index := inStream nextUnsignedShortMSB: msb. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1737 |
Verbose |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1738 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1739 |
[ Transcript |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1740 |
show: 'string; index= '; |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1741 |
showCR: string_index ]. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1742 |
|
752 | 1743 |
"/ resolve here if possible |
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1744 |
|
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1745 |
string_index < constSlot |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1746 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1747 |
[ chars := (constants at: string_index). |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1748 |
^ chars ]. |
752 | 1749 |
^ JavaUnresolvedSTStringConstant |
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1750 |
pool: constants |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1751 |
poolIndex: constSlot |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1752 |
stringIndex: string_index |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1753 |
|
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1754 |
"Created: / 07-05-1998 / 11:49:55 / cg" |
782 | 1755 |
"Modified: / 13-05-2011 / 17:32:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 1756 |
! |
1757 |
||
1758 |
readConstant_ST_Symbol |
|
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1759 |
| tag string_index chars | |
782 | 1760 |
|
1761 |
||
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1762 |
string_index := inStream nextUnsignedShortMSB: msb. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1763 |
Verbose |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1764 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1765 |
[ Transcript |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1766 |
show: 'symbol; index= '; |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1767 |
showCR: string_index ]. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1768 |
|
752 | 1769 |
"/ resolve here if possible |
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1770 |
|
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1771 |
string_index < constSlot |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1772 |
ifTrue: |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1773 |
[ chars := (constants at: string_index). |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1774 |
chars isString ifFalse: [ self halt: 'should not happen' ]. |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1775 |
^ chars asSymbol ]. |
752 | 1776 |
^ JavaUnresolvedSTSymbolConstant |
781
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1777 |
pool: constants |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1778 |
poolIndex: constSlot |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1779 |
stringIndex: string_index |
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1780 |
|
d27c59bcf38a
added preResolve compatibility method + JavaStringRef - will be used soon
hlopkmar
parents:
775
diff
changeset
|
1781 |
"Modified: / 07-05-1998 / 11:48:28 / cg" |
782 | 1782 |
"Modified: / 13-05-2011 / 17:32:09 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 1783 |
! ! |
1784 |
||
1698
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1785 |
!JavaClassReader methodsFor:'file reading - extensions'! |
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 |
readExtensionsFor: class |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1788 |
"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
|
1789 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1790 |
| classnameAsPath | |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1791 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1792 |
classnameAsPath := class name copyReplaceAll: $/ with: Filename separator. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1793 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1794 |
Java effectiveExtensionsPath do:[:each| |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1795 |
ProgrammingLanguage allDo:[:lang| |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1796 |
lang supportsExtensionMethods ifTrue:[ |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1797 |
| file | |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1798 |
file := each asString , Filename separator , classnameAsPath , '.' , lang sourceFileSuffix. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1799 |
file := file asFilename. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1800 |
file exists ifTrue:[ |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1801 |
self readExtensionsFor: class from: file language: lang |
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 |
] |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1804 |
] |
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 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1807 |
"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
|
1808 |
! |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1809 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1810 |
readExtensionsFor: class from: file |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1811 |
"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
|
1812 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1813 |
JAVA isNil ifTrue:[ JavaPackage initialize ]. |
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 |
Smalltalk fileIn: file. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1816 |
] on: JavaClassQuery do:[:query | |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1817 |
query className = class name ifTrue:[ |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1818 |
query resumeWith: class |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1819 |
] ifFalse:[ |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1820 |
query resumeWith: nil. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1821 |
] |
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 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1824 |
"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
|
1825 |
! |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1826 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1827 |
readExtensionsFor: class from: file language: language |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1828 |
"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
|
1829 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1830 |
JAVA isNil ifTrue:[ JavaPackage initialize ]. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1831 |
[ |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1832 |
"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
|
1833 |
language fileIn: file. |
1698
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1834 |
] on: JavaClassQuery do:[:query | |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1835 |
query className = class name ifTrue:[ |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1836 |
query resumeWith: class |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1837 |
] ifFalse:[ |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1838 |
query resumeWith: nil. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1839 |
] |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1840 |
]. |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1841 |
|
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1842 |
"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
|
1843 |
! ! |
d32a2a3dce36
- Some more support for non-Java extension methods.
vranyj1
parents:
1694
diff
changeset
|
1844 |
|
752 | 1845 |
!JavaClassReader methodsFor:'file reading - fields'! |
1846 |
||
1847 |
readConstantValueAttributeFor:aField |
|
1848 |
|attribute_length constantvalue_index constantValue| |
|
1849 |
||
1850 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1851 |
||
1852 |
constantvalue_index := inStream nextUnsignedShortMSB:msb. |
|
1853 |
constantValue := constants at:constantvalue_index. |
|
1854 |
||
1855 |
aField constantValue:constantValue. |
|
1856 |
||
1857 |
Verbose ifTrue:[Transcript show:'constantValue: '; showCR:constantValue]. |
|
1858 |
^ true |
|
1859 |
||
1860 |
" |
|
1861 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1862 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
1863 |
" |
|
1864 |
||
1865 |
"Modified: 15.4.1996 / 15:33:28 / cg" |
|
1866 |
"Created: 15.4.1996 / 15:40:17 / cg" |
|
1867 |
! |
|
1868 |
||
1869 |
readFieldInfofield |
|
913 | 1870 |
| access_flags name_index descriptor_index attributes_count field | |
797
8d4e7c17eadd
fixed JavaClassReader so it always sets staticFields
hlopkmar
parents:
796
diff
changeset
|
1871 |
|
752 | 1872 |
access_flags := inStream nextUnsignedShortMSB: msb. |
1873 |
name_index := inStream nextUnsignedShortMSB: msb. |
|
913 | 1874 |
descriptor_index := inStream nextUnsignedShortMSB: msb. |
752 | 1875 |
field := JavaField new. |
1876 |
field setAccessFlags: access_flags. |
|
1877 |
field setName: (constants at: name_index) asSymbol. |
|
913 | 1878 |
field setDescriptor: (constants at: descriptor_index) asSymbol. |
879 | 1879 |
field setConstantPool: constants. |
752 | 1880 |
attributes_count := inStream nextUnsignedShortMSB: msb. |
1881 |
Verbose |
|
1882 |
ifTrue: |
|
1883 |
[ Transcript |
|
1884 |
show: ' field name: '; |
|
1885 |
show: (constants at: name_index); |
|
1886 |
show: ' access: '; |
|
1887 |
show: access_flags; |
|
1888 |
show: ' attrib_cnt: '; |
|
1889 |
showCR: attributes_count ]. |
|
1890 |
1 to: attributes_count do: [:i | self readAttributeFor: field. ]. |
|
1891 |
^ field. |
|
1892 |
||
1893 |
" |
|
1894 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'" |
|
1895 |
||
1896 |
"Created: / 15-04-1996 / 15:38:43 / cg" |
|
1897 |
"Modified: / 15-10-1998 / 10:38:01 / cg" |
|
1898 |
"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
|
1899 |
"Modified: / 18-05-2011 / 14:11:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
913 | 1900 |
"Modified: / 14-08-2011 / 19:40:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 1901 |
! |
1902 |
||
1903 |
readFieldInfofields |
|
1904 |
|nFields fields| |
|
1905 |
||
1906 |
"/ |
|
1907 |
"/ get fieldInfos |
|
1908 |
"/ |
|
1909 |
nFields := inStream nextUnsignedShortMSB:msb. |
|
1910 |
Verbose ifTrue:[Transcript show:'fieldsCount = '; showCR:nFields]. |
|
1911 |
||
1912 |
fields := Array new:nFields. |
|
1913 |
||
1914 |
1 to:nFields do:[:i | |
|
1915 |
Verbose ifTrue:[Transcript show:'field: '; showCR:i]. |
|
1916 |
fields at:i put:(self readFieldInfofield) |
|
1917 |
]. |
|
1918 |
^ fields |
|
1919 |
||
1920 |
" |
|
1921 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1922 |
" |
|
1923 |
||
1924 |
"Created: 15.4.1996 / 15:34:41 / cg" |
|
1925 |
"Modified: 15.4.1996 / 15:35:28 / cg" |
|
1926 |
! ! |
|
1927 |
||
1928 |
!JavaClassReader methodsFor:'file reading - interfaces'! |
|
1929 |
||
1930 |
readInterfaces |
|
1931 |
|interfacesCount interface_index interface interfaces| |
|
1932 |
||
1933 |
"/ |
|
1934 |
"/ get interfaces |
|
1935 |
"/ |
|
1936 |
interfacesCount := inStream nextUnsignedShortMSB:msb. |
|
1937 |
Verbose ifTrue:[Transcript show:'interfacesCount = '; showCR:interfacesCount]. |
|
1938 |
||
1939 |
interfaces := Array new:interfacesCount. |
|
1940 |
||
1941 |
1 to:interfacesCount do:[:i | |
|
1942 |
Verbose ifTrue:[Transcript show:'interface: '; showCR:i]. |
|
1943 |
interface_index := inStream nextUnsignedShortMSB:msb. |
|
1944 |
interface := constants at:interface_index. |
|
1945 |
||
1946 |
interfaces at:i put:interface. |
|
1947 |
]. |
|
1948 |
^ interfaces |
|
1949 |
||
1950 |
" |
|
1951 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
1952 |
" |
|
1953 |
||
1954 |
"Created: 15.4.1996 / 15:31:59 / cg" |
|
1955 |
"Modified: 15.4.1996 / 15:33:28 / cg" |
|
1956 |
! ! |
|
1957 |
||
1958 |
!JavaClassReader methodsFor:'file reading - methods'! |
|
1959 |
||
1960 |
readCodeAttributeFor:aJavaMethod |
|
1961 |
|attribute_length max_stack max_locals code_length code |
|
1728 | 1962 |
exception_table_length exception_table unknown1 unknown2 | |
752 | 1963 |
|
1964 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
1965 |
||
1966 |
Verbose ifTrue:[Transcript show:'code_attribute_length: 0x'; showCR:(attribute_length printStringRadix:16)]. |
|
1967 |
||
1968 |
((minorVsn > 2) or:[majorVsn > 45]) ifTrue:[ |
|
1969 |
"/ should be: |
|
1970 |
max_stack := inStream nextUnsignedShortMSB:msb. |
|
1693 | 1971 |
max_locals := inStream nextUnsignedShortMSB:msb. |
1972 |
code_length := inStream nextUnsignedLongMSB:msb. |
|
1973 |
"/ 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
|
1974 |
"/ optimize context size as alloca() won't work. |
1693 | 1975 |
MaxContextSize := MaxContextSize max: (max_stack + max_locals + 4"safe area"). |
1728 | 1976 |
" |
1693 | 1977 |
MaxContextSize > MaxContextSizeLimit ifTrue:[ |
1614
f7d4888fb1a2
- JavaClassReader: added check for VM stack-depth limit
vranyj1
parents:
1612
diff
changeset
|
1978 |
self error:'method''s stack depth overflows VM limit'. |
f7d4888fb1a2
- JavaClassReader: added check for VM stack-depth limit
vranyj1
parents:
1612
diff
changeset
|
1979 |
^false |
f7d4888fb1a2
- JavaClassReader: added check for VM stack-depth limit
vranyj1
parents:
1612
diff
changeset
|
1980 |
]. |
1728 | 1981 |
" |
752 | 1982 |
|
1983 |
"/ unknown1 := inStream nextByte. |
|
1984 |
"/ max_stack := inStream nextByte. |
|
1985 |
"/ max_locals := inStream nextUnsignedShortMSB:msb. |
|
1986 |
"/ unknown2 := inStream nextUnsignedShortMSB:msb. |
|
1987 |
"/ code_length := inStream nextUnsignedShortMSB:msb. |
|
1988 |
"/ Verbose ifTrue:[Transcript show:'?1: '; showCR:unknown1]. |
|
1989 |
"/ Verbose ifTrue:[Transcript show:'?2: '; showCR:unknown2]. |
|
1990 |
] ifFalse:[ |
|
1991 |
max_stack := inStream nextByte. |
|
1992 |
max_locals := inStream nextByte. |
|
1993 |
code_length := inStream nextUnsignedShortMSB:msb. |
|
1994 |
]. |
|
1995 |
||
1996 |
Verbose ifTrue:[ |
|
1997 |
Transcript show:'code_length: '; showCR:(code_length printStringRadix:16). |
|
1998 |
Transcript show:'code at pos: '; showCR:inStream position |
|
1999 |
]. |
|
2000 |
||
2001 |
code_length ~~ 0 ifTrue:[ |
|
2002 |
code := ByteArray new:code_length. |
|
2003 |
inStream nextBytes:code_length into:code startingAt:1. |
|
2004 |
]. |
|
2005 |
Verbose ifTrue:[Transcript show:'method code: '; showCR:code.]. |
|
2006 |
||
2007 |
exception_table_length := inStream nextUnsignedShortMSB:msb. |
|
2008 |
Verbose ifTrue:[Transcript show:'exception_table_length: '; showCR:(exception_table_length printStringRadix:16)]. |
|
2009 |
exception_table_length ~~ 0 ifTrue:[ |
|
2010 |
Verbose ifTrue:[Transcript show:'exceptionTable length:'; showCR:exception_table_length.]. |
|
2011 |
||
2012 |
exception_table := Array new:exception_table_length. |
|
2013 |
1 to:exception_table_length do:[:i | |
|
2014 |
|start_pc end_pc handler_pc catch_type| |
|
2015 |
||
2016 |
start_pc := inStream nextUnsignedShortMSB:msb. |
|
2017 |
end_pc := inStream nextUnsignedShortMSB:msb. |
|
2018 |
handler_pc := inStream nextUnsignedShortMSB:msb. |
|
2019 |
catch_type := inStream nextUnsignedShortMSB:msb. |
|
2020 |
catch_type ~= 0 ifTrue:[ |
|
2021 |
catch_type := constants at:catch_type. |
|
2022 |
]. |
|
2023 |
exception_table at:i put:(JavaExceptionTableEntry |
|
2024 |
startPC:start_pc |
|
2025 |
endPC:end_pc |
|
2026 |
handlerPC:handler_pc |
|
2027 |
catchType:catch_type). |
|
2028 |
]. |
|
2029 |
aJavaMethod setExceptionHandlerTable:exception_table. |
|
2030 |
]. |
|
2031 |
||
1728 | 2032 |
(max_stack + max_locals + 4) > MaxContextSizeLimit ifTrue:[ |
2033 |
code := nil |
|
2034 |
]. |
|
2035 |
||
752 | 2036 |
aJavaMethod |
2037 |
setCode:code |
|
2038 |
maxStack:max_stack |
|
2039 |
maxLocals:max_locals |
|
2040 |
u1:unknown1 |
|
2041 |
u2:unknown2. |
|
2042 |
||
2043 |
self readAttributesFor:aJavaMethod. |
|
2044 |
^ true |
|
2045 |
||
2046 |
" |
|
2047 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2048 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class' |
|
2049 |
" |
|
2050 |
||
2051 |
"Created: / 15-04-1996 / 15:40:17 / cg" |
|
2052 |
"Modified: / 16-05-1998 / 01:39:42 / cg" |
|
1693 | 2053 |
"Modified: / 04-09-2012 / 11:58:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 2054 |
! |
2055 |
||
2056 |
readExceptionsAttributeFor:aJavaMethod |
|
2057 |
|attribute_length exception_table_length exception_table| |
|
2058 |
||
2059 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2060 |
||
2061 |
exception_table_length := inStream nextUnsignedShortMSB:msb. |
|
2062 |
exception_table_length ~~ 0 ifTrue:[ |
|
2063 |
exception_table := Array new:exception_table_length. |
|
2064 |
1 to:exception_table_length do:[:i | |
|
2065 |
|idx ex| |
|
2066 |
||
2067 |
idx := inStream nextUnsignedShortMSB:msb. |
|
2068 |
ex := constants at:idx. |
|
2069 |
exception_table at:i put:ex. |
|
2070 |
]. |
|
2071 |
]. |
|
2072 |
||
2073 |
Verbose ifTrue:[Transcript showCR:'method has an exceptionTable']. |
|
2074 |
||
2075 |
aJavaMethod setExceptionTable:exception_table. |
|
2076 |
^ true |
|
2077 |
||
2078 |
"Modified: 15.4.1996 / 15:33:28 / cg" |
|
2079 |
"Created: 15.4.1996 / 15:40:17 / cg" |
|
2080 |
! |
|
2081 |
||
2082 |
readLineNumberTableAttributeFor:aJavaMethod |
|
2083 |
|attribute_length line_number_table_length line_number_table| |
|
2084 |
||
2085 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2086 |
||
2087 |
line_number_table_length := inStream nextUnsignedShortMSB:msb. |
|
2088 |
line_number_table_length ~~ 0 ifTrue:[ |
|
2089 |
line_number_table := Array new:line_number_table_length. |
|
2090 |
1 to:line_number_table_length do:[:i | |
|
2091 |
|start_pc line_number| |
|
2092 |
||
2093 |
start_pc := inStream nextUnsignedShortMSB:msb. |
|
2094 |
line_number := inStream nextUnsignedShortMSB:msb. |
|
2095 |
line_number_table at:i put:(start_pc -> line_number). |
|
2096 |
]. |
|
2097 |
Verbose ifTrue:[Transcript showCR:'method has a lineNumberTable']. |
|
2098 |
||
2099 |
aJavaMethod setLineNumberTable:line_number_table. |
|
2100 |
]. |
|
2101 |
||
2102 |
^ true |
|
2103 |
||
2104 |
" |
|
2105 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2106 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/java/lang/Boolean.class' |
|
2107 |
" |
|
2108 |
||
2109 |
"Created: / 15.4.1996 / 15:40:17 / cg" |
|
2110 |
"Modified: / 7.4.1998 / 19:08:42 / cg" |
|
2111 |
! |
|
2112 |
||
2113 |
readLocalVariableTableAttributeFor:aJavaMethod |
|
2114 |
|attribute_length local_variable_table_length local_variable_table| |
|
2115 |
||
2116 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2117 |
||
2118 |
local_variable_table_length := inStream nextUnsignedShortMSB:msb. |
|
2119 |
local_variable_table_length ~~ 0 ifTrue:[ |
|
2120 |
local_variable_table := JavaLocalVariableTable new:local_variable_table_length. |
|
2121 |
1 to:local_variable_table_length do:[:i | |
|
2122 |
|start_pc length name_index sig_index slot name signature| |
|
2123 |
||
2124 |
start_pc := inStream nextUnsignedShortMSB:msb. |
|
2125 |
length := inStream nextUnsignedShortMSB:msb. |
|
2126 |
name_index := inStream nextUnsignedShortMSB:msb. |
|
2127 |
name := constants at:name_index. |
|
2128 |
sig_index := inStream nextUnsignedShortMSB:msb. |
|
2129 |
signature := constants at:sig_index. |
|
2130 |
slot := inStream nextUnsignedShortMSB:msb. |
|
2131 |
||
2132 |
local_variable_table at:i put:(JavaLocalVariableTableEntry new |
|
2133 |
startPC:start_pc |
|
2134 |
length:length |
|
2135 |
name:name |
|
2136 |
signature:signature |
|
2137 |
slot:slot) |
|
2138 |
]. |
|
2139 |
]. |
|
2140 |
||
2141 |
Verbose ifTrue:[Transcript showCR:'method has a localvariableTable']. |
|
2142 |
||
2143 |
aJavaMethod setLocalVariableTable:local_variable_table. |
|
2144 |
^ true |
|
2145 |
||
2146 |
" |
|
2147 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2148 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/java/lang/Boolean.class' |
|
2149 |
" |
|
2150 |
||
2151 |
"Modified: 15.4.1996 / 15:33:28 / cg" |
|
2152 |
"Created: 15.4.1996 / 15:40:17 / cg" |
|
2153 |
! |
|
2154 |
||
2155 |
readMethodFor:aClass |
|
913 | 2156 |
|m access_flags name_index name descriptor_index descriptor |
752 | 2157 |
tooManyArgs| |
2158 |
||
2159 |
"/ |
|
2160 |
"/ get a method |
|
2161 |
"/ |
|
2162 |
access_flags := inStream nextUnsignedShortMSB:msb. |
|
2163 |
name_index := inStream nextUnsignedShortMSB:msb. |
|
913 | 2164 |
descriptor_index := inStream nextUnsignedShortMSB:msb. |
752 | 2165 |
|
2166 |
name := constants at:name_index. |
|
913 | 2167 |
descriptor := constants at:descriptor_index. |
752 | 2168 |
|
2169 |
Verbose ifTrue:[ |
|
2170 |
Transcript show:'method name:'; showCR:name. |
|
913 | 2171 |
Transcript show:'descriptor:'; showCR:descriptor. |
752 | 2172 |
]. |
2173 |
||
2174 |
aClass isJavaClass ifTrue:[ |
|
1055 | 2175 |
(access_flags bitAnd:ACC_NATIVE) ~~ 0 ifTrue:[ |
752 | 2176 |
m := JavaNativeMethod new. |
2177 |
] ifFalse:[ |
|
2178 |
m := JavaMethodWithHandler new. |
|
2179 |
]. |
|
2180 |
m setAccessFlags:access_flags. |
|
2181 |
tooManyArgs := false. |
|
2182 |
ArgumentError handle:[:ex | |
|
1000 | 2183 |
Logger log: 'java method has too many arguments - will fail to execute' severity: #warn facility: 'JVM'. |
752 | 2184 |
tooManyArgs := true. |
2185 |
ex proceed. |
|
2186 |
] do:[ |
|
913 | 2187 |
m setName:name descriptor:descriptor. |
752 | 2188 |
]. |
2189 |
m setJavaClass:aClass. |
|
2190 |
||
2191 |
self readAttributesFor:m. |
|
2192 |
||
2193 |
tooManyArgs ifTrue:[ |
|
2194 |
m code:nil. |
|
2195 |
m byteCode:nil. |
|
2196 |
]. |
|
1050 | 2197 |
|
752 | 2198 |
(m exceptionHandlerTable isNil) ifTrue:[ |
2199 |
m isNative ifFalse:[ |
|
2200 |
m getExceptionTable isNil ifTrue:[ |
|
2201 |
m := JavaMethod fromMethod:m |
|
2202 |
] ifFalse:[ |
|
2203 |
m := JavaMethodWithException fromMethod:m |
|
2204 |
] |
|
2205 |
] |
|
2206 |
] ifFalse:[ |
|
1435 | 2207 |
| newAccessFlags | |
2208 |
||
2209 |
newAccessFlags := m accessFlags. |
|
1523
f5ffdad83ab9
Access to ACC_* and ACX_* constants unified. The only definition is in JavaConstants
vranyj1
parents:
1453
diff
changeset
|
2210 |
newAccessFlags := newAccessFlags bitOr:ACX_HASHANDLER. |
1435 | 2211 |
m hasFinallyBasedOnExceptionTable ifTrue:[ |
2212 |
newAccessFlags := newAccessFlags bitOr:ACX_HASFINALLY. |
|
2213 |
]. |
|
2214 |
m setAccessFlags:newAccessFlags. |
|
752 | 2215 |
]. |
913 | 2216 |
aClass addMethod:m name:name signature:descriptor. |
1792 | 2217 |
|
2218 |
( m selector == #'finalize()V' ) ifTrue:[ |
|
1795 | 2219 |
( aClass name ~~ #'java/lang/Object' ) ifTrue:[ |
1792 | 2220 |
aClass setAccessFlags: (aClass accessFlags bitOr:ACX_HASFINALIZE) |
2221 |
] |
|
2222 |
]. |
|
752 | 2223 |
] ifFalse:[ |
2224 |
m := Method new. |
|
2225 |
self readAttributesFor:m. |
|
1055 | 2226 |
(access_flags bitTest:ACC_STATIC) ifTrue:[ |
752 | 2227 |
aClass class primAddSelector:name asSymbol withMethod:m. |
2228 |
] ifFalse:[ |
|
2229 |
aClass primAddSelector:name asSymbol withMethod:m. |
|
2230 |
] |
|
2231 |
]. |
|
2232 |
||
2233 |
" |
|
2234 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2235 |
" |
|
2236 |
||
2237 |
"Created: / 15-04-1996 / 16:48:49 / cg" |
|
2238 |
"Modified: / 25-09-1999 / 23:16:25 / cg" |
|
1055 | 2239 |
"Modified: / 28-10-2011 / 16:56:48 / m" |
1795 | 2240 |
"Modified: / 02-11-2012 / 22:06:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 2241 |
! |
2242 |
||
2243 |
readMethodsFor:aJavaClass |
|
2244 |
|methodsCount method| |
|
2245 |
||
2246 |
"/ |
|
2247 |
"/ get methods |
|
2248 |
"/ |
|
2249 |
methodsCount := inStream nextUnsignedShortMSB:msb. |
|
2250 |
Verbose ifTrue:[Transcript show:'methodsCount = '; showCR:methodsCount]. |
|
2251 |
||
2252 |
1 to:methodsCount do:[:i | |
|
2253 |
Verbose ifTrue:[Transcript show:'method: '; showCR:i]. |
|
2254 |
method := self readMethodFor:aJavaClass |
|
2255 |
]. |
|
2256 |
||
1453 | 2257 |
Smalltalk changed: #methodDictionary with: aJavaClass. |
2258 |
||
752 | 2259 |
" |
2260 |
JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class' |
|
2261 |
" |
|
2262 |
||
1453 | 2263 |
"Created: / 15-04-1996 / 16:46:30 / cg" |
2264 |
"Modified: / 08-05-1998 / 21:20:59 / cg" |
|
2265 |
"Modified: / 04-04-2012 / 01:18:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
752 | 2266 |
! ! |
2267 |
||
2268 |
!JavaClassReader methodsFor:'file reading - methods-ST'! |
|
2269 |
||
2270 |
readSTCodeAttributeFor:aSmalltalkMethod |
|
2271 |
|attribute_length max_stack max_locals code_length code |
|
2272 |
exception_table_length unknown1 unknown2| |
|
2273 |
||
2274 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2275 |
||
2276 |
Verbose ifTrue:[Transcript show:'attribute_length: 0x'; showCR:(attribute_length printStringRadix:16)]. |
|
2277 |
||
2278 |
max_stack := inStream nextUnsignedShortMSB:msb. |
|
2279 |
max_locals := inStream nextUnsignedShortMSB:msb. |
|
2280 |
||
2281 |
code_length := inStream nextUnsignedLongMSB:msb. |
|
2282 |
Verbose ifTrue:[Transcript show:'code_length: '; showCR:(code_length printStringRadix:16)]. |
|
2283 |
Verbose ifTrue:[Transcript show:'code at pos: '; showCR:inStream position]. |
|
2284 |
||
2285 |
code_length ~~ 0 ifTrue:[ |
|
2286 |
code := ByteArray new:code_length. |
|
2287 |
inStream nextBytes:code_length into:code startingAt:1. |
|
2288 |
]. |
|
2289 |
Verbose ifTrue:[Transcript show:'method code: '; showCR:code.]. |
|
2290 |
||
2291 |
exception_table_length := inStream nextUnsignedShortMSB:msb. |
|
2292 |
Verbose ifTrue:[Transcript show:'exception_table_length: '; showCR:(exception_table_length printStringRadix:16)]. |
|
2293 |
exception_table_length ~~ 0 ifTrue:[ |
|
2294 |
self error:'unexpected exceptionTable length'. |
|
2295 |
"/ skip it. |
|
2296 |
1 to:exception_table_length do:[:i | |
|
2297 |
"start_pc :=" inStream nextUnsignedShortMSB:msb. |
|
2298 |
"end_pc :=" inStream nextUnsignedShortMSB:msb. |
|
2299 |
"handler_pc :=" inStream nextUnsignedShortMSB:msb. |
|
2300 |
"catch_type :=" inStream nextUnsignedShortMSB:msb. |
|
2301 |
]. |
|
2302 |
]. |
|
2303 |
||
2304 |
aSmalltalkMethod byteCode:code. |
|
2305 |
aSmalltalkMethod stackSize:max_stack . |
|
2306 |
aSmalltalkMethod numberOfVars:max_locals. |
|
2307 |
||
2308 |
self readAttributesFor:aSmalltalkMethod. |
|
2309 |
^ true |
|
2310 |
||
2311 |
"Modified: / 16.5.1998 / 01:39:30 / cg" |
|
2312 |
! |
|
2313 |
||
2314 |
readSTLiteralsAttributeFor:aSmalltalkMethod |
|
2315 |
|attribute_length literal_table_length literal_table litIndex literal| |
|
2316 |
||
2317 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2318 |
||
2319 |
literal_table_length := inStream nextUnsignedShortMSB:msb. |
|
2320 |
literal_table_length ~~ 0 ifTrue:[ |
|
2321 |
literal_table := Array new:literal_table_length. |
|
2322 |
1 to:literal_table_length do:[:i | |
|
2323 |
litIndex := inStream nextUnsignedShortMSB:msb. |
|
2324 |
literal := (constants at:litIndex). |
|
2325 |
literal_table at:i put:literal. |
|
2326 |
]. |
|
2327 |
]. |
|
2328 |
Verbose ifTrue:[Transcript show:'literals: '; showCR:literal_table storeString.]. |
|
2329 |
||
2330 |
"Created: / 7.5.1998 / 11:52:28 / cg" |
|
2331 |
"Modified: / 16.5.1998 / 01:52:27 / cg" |
|
2332 |
! |
|
2333 |
||
2334 |
readSTMethodCategoryAttributeFor:aSmalltalkMethod |
|
2335 |
|attribute_length name_index name| |
|
2336 |
||
2337 |
attribute_length := inStream nextUnsignedLongMSB:msb. |
|
2338 |
||
2339 |
name_index := inStream nextUnsignedShortMSB:msb. |
|
2340 |
name := (constants at:name_index). |
|
2341 |
||
2342 |
aSmalltalkMethod category:name. |
|
2343 |
||
2344 |
"Modified: / 8.5.1998 / 20:39:59 / cg" |
|
2345 |
"Created: / 16.5.1998 / 01:04:19 / cg" |
|
2346 |
! ! |
|
2347 |
||
775 | 2348 |
!JavaClassReader methodsFor:'helpers'! |
2349 |
||
798
b534e73eaf7e
JavaClassReader2 now uses correct superclass loading
hlopkmar
parents:
797
diff
changeset
|
2350 |
loadSuperclassIdentifiedBy: something ignoring: classesBeingLoaded |
877 | 2351 |
"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
|
2352 |
|
877 | 2353 |
self assert: something isJavaRef |
2354 |
message: 'class identifier is not a java reference'. |
|
2355 |
self assert: something isJavaClassRef |
|
1033 | 2356 |
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
|
2357 |
(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
|
2358 |
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
|
2359 |
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
|
2360 |
]. |
5badd1d31864
introduced JavaClassRegistry, taken loading responsibilities from JavaClassReader, got rid of stringConstants and started using StringRefs.. Bugs very likely :)
hlopkmar
parents:
1025
diff
changeset
|
2361 |
"hint in case of bug - is parent of something set? surely jv will know more :)" "find out which classloader is used" |
1033 | 2362 |
^ JavaVM classForName: something name. |
877 | 2363 |
|
2364 |
"Created: / 18-05-2011 / 14:55:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
960 | 2365 |
"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
|
2366 |
! |
b534e73eaf7e
JavaClassReader2 now uses correct superclass loading
hlopkmar
parents:
797
diff
changeset
|
2367 |
|
775 | 2368 |
updateOwnerInCPItem: each |
2369 |
((each isJavaRef and: [ each isNewJavaRef ]) |
|
2370 |
or: [ each isJavaNameAndType and: [ each isNewJavaNameAndType ] ]) |
|
2371 |
ifTrue: [ each owner: classBeingLoaded ]. |
|
2372 |
||
2373 |
"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
|
2374 |
! |
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2375 |
|
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2376 |
updateOwnerInField: each |
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2377 |
|
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2378 |
each setClass: classBeingLoaded. |
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2379 |
|
9b3e00dd3196
Small fix, so JavaFields have their javaClass always set.
hlopkmar
parents:
784
diff
changeset
|
2380 |
"Created: / 18-05-2011 / 13:57:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
775 | 2381 |
! ! |
2382 |
||
799 | 2383 |
!JavaClassReader methodsFor:'logging'! |
2384 |
||
2385 |
info: message |
|
1000 | 2386 |
Verbose ifTrue: [ Logger log: message severity: #info facility: 'JVM' ]. |
799 | 2387 |
|
2388 |
"Created: / 18-05-2011 / 15:06:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1000 | 2389 |
"Modified (format): / 14-09-2011 / 21:39:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
799 | 2390 |
! ! |
2391 |
||
752 | 2392 |
!JavaClassReader class methodsFor:'documentation'! |
2393 |
||
2394 |
version |
|
1022 | 2395 |
^ '$Id$' |
752 | 2396 |
! |
2397 |
||
2398 |
version_CVS |
|
2399 |
^ '§Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaClassReader.st,v 1.92 2009/10/09 14:21:53 cg Exp §' |
|
2400 |
! |
|
2401 |
||
2402 |
version_SVN |
|
1022 | 2403 |
^ '$Id$' |
752 | 2404 |
! ! |
2405 |
||
959 | 2406 |
JavaClassReader initialize! |