author | mawalch |
Mon, 22 May 2017 14:18:31 +0200 | |
branch | cvs_MAIN |
changeset 3713 | 68c63bd08343 |
parent 3522 | d22b680e8ab0 |
permissions | -rw-r--r-- |
2624 | 1 |
" |
3324
a58245c0e83a
Updated copyright notices.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2966
diff
changeset
|
2 |
COPYRIGHT (c) 1996-2015 by Claus Gittinger |
2624 | 3 |
|
4 |
New code and modifications done at SWING Research Group [1]: |
|
5 |
||
3324
a58245c0e83a
Updated copyright notices.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2966
diff
changeset
|
6 |
COPYRIGHT (c) 2010-2015 by Jan Vrany, Jan Kurs and Marcel Hlopko |
2624 | 7 |
SWING Research Group, Czech Technical University in Prague |
8 |
||
9 |
This software is furnished under a license and may be used |
|
10 |
only in accordance with the terms of that license and with the |
|
11 |
inclusion of the above copyright notice. This software may not |
|
12 |
be provided or otherwise made available to, or used by, any |
|
13 |
other person. No title to or ownership of the software is |
|
14 |
hereby transferred. |
|
15 |
||
16 |
[1] Code written at SWING Research Group contains a signature |
|
17 |
of one of the above copright owners. For exact set of such code, |
|
18 |
see the differences between this version and version stx:libjava |
|
19 |
as of 1.9.2010 |
|
20 |
" |
|
21 |
"{ Package: 'stx:libjava' }" |
|
22 |
||
3522 | 23 |
"{ NameSpace: Smalltalk }" |
24 |
||
2624 | 25 |
JavaMirror subclass:#JavaClassMirror |
26 |
instanceVariableNames:'' |
|
27 |
classVariableNames:'' |
|
2625
a91a1db9718e
Make JavaMirror to access classes through pool vars.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2624
diff
changeset
|
28 |
poolDictionaries:'JavaVMData' |
2624 | 29 |
category:'Languages-Java-Classes' |
30 |
! |
|
31 |
||
32 |
!JavaClassMirror class methodsFor:'documentation'! |
|
33 |
||
34 |
copyright |
|
35 |
" |
|
3324
a58245c0e83a
Updated copyright notices.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2966
diff
changeset
|
36 |
COPYRIGHT (c) 1996-2015 by Claus Gittinger |
2624 | 37 |
|
38 |
New code and modifications done at SWING Research Group [1]: |
|
39 |
||
3324
a58245c0e83a
Updated copyright notices.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2966
diff
changeset
|
40 |
COPYRIGHT (c) 2010-2015 by Jan Vrany, Jan Kurs and Marcel Hlopko |
2624 | 41 |
SWING Research Group, Czech Technical University in Prague |
42 |
||
43 |
This software is furnished under a license and may be used |
|
44 |
only in accordance with the terms of that license and with the |
|
45 |
inclusion of the above copyright notice. This software may not |
|
46 |
be provided or otherwise made available to, or used by, any |
|
47 |
other person. No title to or ownership of the software is |
|
48 |
hereby transferred. |
|
49 |
||
50 |
[1] Code written at SWING Research Group contains a signature |
|
51 |
of one of the above copright owners. For exact set of such code, |
|
52 |
see the differences between this version and version stx:libjava |
|
53 |
as of 1.9.2010 |
|
54 |
||
55 |
" |
|
56 |
! |
|
57 |
||
58 |
documentation |
|
59 |
" |
|
60 |
A specialized mirror for all Java classes |
|
61 |
||
62 |
[author:] |
|
63 |
Jan Vrany <jan.vrany@fit.cvut.cz> |
|
64 |
||
65 |
[instance variables:] |
|
66 |
||
67 |
[class variables:] |
|
68 |
||
69 |
[see also:] |
|
70 |
||
71 |
" |
|
72 |
! ! |
|
73 |
||
74 |
!JavaClassMirror methodsFor:'accessing'! |
|
75 |
||
76 |
getClassLoader |
|
77 |
"Returns a class loader that loaded this class" |
|
78 |
||
79 |
^ klass classLoader |
|
80 |
||
81 |
"Modified: / 31-07-2012 / 18:26:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
82 |
! |
|
83 |
||
84 |
getDeclaredConstructors:publicOnly |
|
2966 | 85 |
"Returns an java.lang.reflect.Constructor[] with all constructors |
2624 | 86 |
declared by this class" |
87 |
||
88 |
| ctors | |
|
89 |
||
90 |
ctors := OrderedCollection new. |
|
91 |
klass selectorsAndMethodsDo:[:sel :mthd| |
|
92 |
(mthd isJavaConstructor and:[publicOnly not or:[mthd isPublic]]) ifTrue:[ |
|
93 |
ctors add: (self getDeclaredConstructorFor: mthd). |
|
94 |
]. |
|
95 |
]. |
|
2966 | 96 |
^_java_lang_reflect_Constructor_CLASS javaArrayClass withAll: ctors |
2624 | 97 |
|
98 |
"Modified: / 18-05-2013 / 10:56:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
99 |
! |
|
100 |
||
101 |
getDeclaredFields:publicOnly |
|
2966 | 102 |
"Returns an java.lang.reflect.Field[] with all constructors |
2624 | 103 |
declared by this class." |
104 |
||
2966 | 105 |
| fields | |
2624 | 106 |
|
107 |
fields := klass fields , klass staticFields. |
|
108 |
publicOnly ifTrue:[ fields := fields select:[:f | f isPublic ] ]. |
|
109 |
JavaClassReader classLoaderQuerySignal answer: klass classLoader do:[ |
|
110 |
fields := fields collect:[:f | self createFieldFor:f ]. |
|
111 |
]. |
|
2966 | 112 |
^ _java_lang_reflect_Field_CLASS javaArrayClass |
2624 | 113 |
withAll:fields |
114 |
||
115 |
"Modified: / 18-05-2013 / 10:57:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
116 |
! |
|
117 |
||
118 |
getDeclaredMethods:publicOnly |
|
2966 | 119 |
"Returns an java.lang.reflect.Constructor[] with all constructors |
2624 | 120 |
declared by this class" |
121 |
||
122 |
| methods | |
|
123 |
||
124 |
methods := OrderedCollection new. |
|
125 |
klass selectorsAndMethodsDo:[:sel :mthd| |
|
126 |
mthd isJavaMethod and:[ |
|
2966 | 127 |
(mthd isJavaConstructor not |
2624 | 128 |
and:[mthd isJavaStaticInitializer not |
129 |
and:[publicOnly not or:[mthd isPublic]]]) ifTrue:[ |
|
130 |
methods add: (self getDeclaredMethodFor: mthd). |
|
131 |
] |
|
132 |
]. |
|
133 |
]. |
|
2966 | 134 |
^_java_lang_reflect_Method_CLASS javaArrayClass withAll: methods |
2624 | 135 |
|
136 |
"Modified: / 18-05-2013 / 10:57:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
137 |
! |
|
138 |
||
139 |
getGenericSignature |
|
140 |
"Returns Java generic signature (if a generic class) or nil" |
|
141 |
||
142 |
^klass signatureJ |
|
143 |
||
144 |
"Created: / 22-08-2012 / 11:58:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
145 |
! |
|
146 |
||
147 |
getInterfaces |
|
148 |
"Return a list if interfaces" |
|
149 |
||
150 |
^ klass interfaces |
|
151 |
||
152 |
"Modified: / 22-08-2012 / 11:08:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
153 |
! |
|
154 |
||
155 |
getModifiers |
|
156 |
"Return class modifiers (public/abstract/final...)" |
|
157 |
||
2966 | 158 |
| modifiers | |
2624 | 159 |
|
160 |
"According to OpenJDK JVM, strip ACC_SUPER" |
|
3522 | 161 |
modifiers := (klass accessFlags bitAnd: JavaConstants ACC_SUPER bitInvert) bitAnd: 16r7FFF. |
2624 | 162 |
"JV@2011-10-30: It seems that private inner classes has no |
163 |
private bit set, sigh" |
|
3522 | 164 |
(modifiers bitAnd: 16r0007) == 0 ifTrue:[ |
165 |
modifiers := modifiers bitOr: JavaConstants ACC_PRIVATE. |
|
2624 | 166 |
]. |
167 |
^modifiers |
|
168 |
||
169 |
"Modified: / 22-08-2012 / 11:03:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
170 |
! |
|
171 |
||
172 |
getProtectionDomain |
|
173 |
^klass protectionDomain |
|
174 |
||
175 |
"Created: / 22-08-2012 / 12:56:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
176 |
! ! |
|
177 |
||
178 |
!JavaClassMirror methodsFor:'accessing-private'! |
|
179 |
||
180 |
getDeclaredConstructorFor: method |
|
181 |
||
182 |
^self createConstructorFor: method javaClass |
|
183 |
method: method |
|
184 |
signature: method signature |
|
185 |
modifiers: method accessFlags |
|
186 |
parameterTyoes: (method descriptor parameterClassesUsingClassLoader: method javaClass classLoader) |
|
187 |
exceptionTypes: method exceptionClasses |
|
188 |
annotations: method method annotations. |
|
189 |
||
190 |
"Created: / 01-08-2012 / 00:46:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
191 |
! |
|
192 |
||
193 |
getDeclaredMethodFor: method |
|
194 |
||
195 |
^self createMethodFor: method javaClass |
|
196 |
method: method |
|
197 |
name: (method selector upTo: $() |
|
198 |
signature: method signature |
|
199 |
modifiers: method accessFlags |
|
200 |
parameterTyoes: (method descriptor parameterClassesUsingClassLoader: method javaClass classLoader) |
|
201 |
returnType: (method descriptor returnClassUsingClassLoader: method javaClass classLoader) |
|
202 |
exceptionTypes: method exceptionClasses |
|
203 |
annotations: method method annotations. |
|
204 |
||
205 |
"Created: / 01-08-2012 / 11:11:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
206 |
! ! |
|
207 |
||
208 |
!JavaClassMirror class methodsFor:'documentation'! |
|
209 |
||
3522 | 210 |
version |
211 |
^ '$Header$' |
|
212 |
! |
|
213 |
||
214 |
version_CVS |
|
215 |
^ '$Header$' |
|
216 |
! |
|
217 |
||
2624 | 218 |
version_HG |
219 |
||
220 |
^ '$Changeset: <not expanded> $' |
|
221 |
! ! |
|
222 |