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