author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Tue, 29 Jan 2013 15:15:51 +0000 | |
branch | development |
changeset 2006 | c0598cab5f15 |
parent 1864 | 60a8dc26c8c6 |
child 2069 | 75d40b7b986f |
permissions | -rw-r--r-- |
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
1 |
" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
3 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
4 |
New code and modifications done at SWING Research Group [1]: |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
5 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
6 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
7 |
SWING Research Group, Czech Technical University in Prague |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
8 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
9 |
This software is furnished under a license and may be used |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
10 |
only in accordance with the terms of that license and with the |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
11 |
inclusion of the above copyright notice. This software may not |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
12 |
be provided or otherwise made available to, or used by, any |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
13 |
other person. No title to or ownership of the software is |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
14 |
hereby transferred. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
15 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
16 |
[1] Code written at SWING Research Group contains a signature |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
17 |
of one of the above copright owners. For exact set of such code, |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
18 |
see the differences between this version and version stx:libjava |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
19 |
as of 1.9.2010 |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
20 |
" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
21 |
"{ Package: 'stx:libjava' }" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
22 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
23 |
Object subclass:#JavaMirror |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
24 |
instanceVariableNames:'klass reflection' |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
25 |
classVariableNames:'' |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
26 |
poolDictionaries:'' |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
27 |
category:'Languages-Java-Classes' |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
28 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
29 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
30 |
JavaMirror subclass:#AlienClassMirror |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
31 |
instanceVariableNames:'' |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
32 |
classVariableNames:'' |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
33 |
poolDictionaries:'' |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
34 |
privateIn:JavaMirror |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
35 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
36 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
37 |
JavaMirror subclass:#JavaArrayMirror |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
38 |
instanceVariableNames:'' |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
39 |
classVariableNames:'' |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
40 |
poolDictionaries:'' |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
41 |
privateIn:JavaMirror |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
42 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
43 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
44 |
JavaMirror subclass:#JavaClassMirror |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
45 |
instanceVariableNames:'' |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
46 |
classVariableNames:'' |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
47 |
poolDictionaries:'' |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
48 |
privateIn:JavaMirror |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
49 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
50 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
51 |
JavaMirror subclass:#JavaPrimitiveMirror |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
52 |
instanceVariableNames:'' |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
53 |
classVariableNames:'' |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
54 |
poolDictionaries:'' |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
55 |
privateIn:JavaMirror |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
56 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
57 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
58 |
!JavaMirror class methodsFor:'documentation'! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
59 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
60 |
copyright |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
61 |
" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
62 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
63 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
64 |
New code and modifications done at SWING Research Group [1]: |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
65 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
66 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
67 |
SWING Research Group, Czech Technical University in Prague |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
68 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
69 |
This software is furnished under a license and may be used |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
70 |
only in accordance with the terms of that license and with the |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
71 |
inclusion of the above copyright notice. This software may not |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
72 |
be provided or otherwise made available to, or used by, any |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
73 |
other person. No title to or ownership of the software is |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
74 |
hereby transferred. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
75 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
76 |
[1] Code written at SWING Research Group contains a signature |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
77 |
of one of the above copright owners. For exact set of such code, |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
78 |
see the differences between this version and version stx:libjava |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
79 |
as of 1.9.2010 |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
80 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
81 |
" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
82 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
83 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
84 |
documentation |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
85 |
" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
86 |
Instances of a JavaCassMirror provide unified access to |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
87 |
Java reflective data (expeccially to methods, constructors and |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
88 |
fields) as required by Java reflection API. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
89 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
90 |
Different classes may use different mirrors - for example, |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
91 |
Smalltalk classes use a special mirror so non-Smalltalk classes |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
92 |
and instances could be introspected and manipulated by standard |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
93 |
Java code. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
94 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
95 |
[author:] |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
96 |
Jan Vrany <jan.vrany@fit.cvut.cz> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
97 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
98 |
[instance variables:] |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
99 |
klass ........ the real class on which receiver reflects |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
100 |
reflection ... now always a JavaVM reflection. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
101 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
102 |
[class variables:] |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
103 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
104 |
[see also:] |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
105 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
106 |
" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
107 |
! ! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
108 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
109 |
!JavaMirror class methodsFor:'instance creation'! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
110 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
111 |
forClass: aClass |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
112 |
^self new setKlass: aClass. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
113 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
114 |
"Created: / 31-07-2012 / 17:54:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
115 |
! ! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
116 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
117 |
!JavaMirror class methodsFor:'accessing'! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
118 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
119 |
mirrorClassForAlienClass |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
120 |
^ AlienClassMirror |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
121 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
122 |
"Created: / 31-07-2012 / 17:36:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
123 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
124 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
125 |
mirrorClassForJavaArray |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
126 |
^ JavaArrayMirror |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
127 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
128 |
"Created: / 31-07-2012 / 18:26:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
129 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
130 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
131 |
mirrorClassForJavaClass |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
132 |
^ JavaClassMirror |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
133 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
134 |
"Created: / 31-07-2012 / 17:36:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
135 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
136 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
137 |
mirrorClassForJavaPrimitive |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
138 |
^ JavaPrimitiveMirror |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
139 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
140 |
"Created: / 31-07-2012 / 18:27:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
141 |
! ! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
142 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
143 |
!JavaMirror methodsFor:'accessing'! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
144 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
145 |
getClassLoader |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
146 |
"Returns a class loader that loaded this class" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
147 |
^self subclassResponsibility |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
148 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
149 |
"Created: / 31-07-2012 / 18:25:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
150 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
151 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
152 |
getDeclaredConstructors: publicOnly |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
153 |
"Returns an java.lang.reflect.Constructor[] with all constructors |
1648 | 154 |
declared by this class. " |
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
155 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
156 |
^self subclassResponsibility |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
157 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
158 |
"Created: / 31-07-2012 / 18:39:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
159 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
160 |
|
1648 | 161 |
getDeclaredFields: publicOnly |
162 |
"Returns an java.lang.reflect.Field[] with all constructors |
|
163 |
declared by this class." |
|
164 |
||
165 |
^self subclassResponsibility |
|
166 |
||
167 |
"Created: / 22-08-2012 / 12:03:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
168 |
! |
|
169 |
||
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
170 |
getDeclaredMethods:publicOnly |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
171 |
"Returns an java.lang.reflect.Method[] with all methods |
1648 | 172 |
declared by this class." |
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
173 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
174 |
^ self subclassResponsibility |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
175 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
176 |
"Created: / 01-08-2012 / 11:07:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1648 | 177 |
! |
178 |
||
179 |
getGenericSignature |
|
180 |
"Returns Java generic signature (if a generic class) or nil" |
|
181 |
||
182 |
^nil |
|
183 |
||
184 |
"Created: / 22-08-2012 / 11:57:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
185 |
! |
|
186 |
||
187 |
getInterfaces |
|
188 |
"Return a list if interfaces" |
|
189 |
||
190 |
^self subclassResponsibility |
|
191 |
||
192 |
"Created: / 22-08-2012 / 11:05:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
193 |
! |
|
194 |
||
195 |
getModifiers |
|
196 |
"Return class modifiers (public/abstract/final...)" |
|
197 |
||
198 |
^self subclassResponsibility |
|
199 |
||
200 |
"Created: / 22-08-2012 / 10:49:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
201 |
! |
|
202 |
||
203 |
getName |
|
204 |
"Returns name of the class" |
|
205 |
^klass javaName |
|
206 |
||
207 |
"Created: / 22-08-2012 / 10:46:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1649
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
208 |
! |
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
209 |
|
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
210 |
getProtectionDomain |
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
211 |
^nil |
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
212 |
|
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
213 |
"Created: / 22-08-2012 / 12:56:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
214 |
! ! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
215 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
216 |
!JavaMirror methodsFor:'initialization'! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
217 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
218 |
setKlass: aClass |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
219 |
klass := aClass. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
220 |
reflection := JavaVM reflection |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
221 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
222 |
"Created: / 31-07-2012 / 17:40:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
223 |
! ! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
224 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
225 |
!JavaMirror methodsFor:'instance creation-java.lang.reflect.*'! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
226 |
|
1848 | 227 |
create: ctorOrMethodClass for: class method: method signature: signature modifiers: modifiers parameterTyoes: parameterClasses exceptionTypes: exceptionClasses annotations: annotations |
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
228 |
"Creates a new java.lang.Constructor. Arguments: |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
229 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
230 |
ctorOrMethodClass <java.lang.reflect.Constructor|java.lang.reflect.Method> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
231 |
class <Class> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
232 |
method <Method> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
233 |
signature <String> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
234 |
modifiers <SmallInteger> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
235 |
parameterClasses <Collection of Class> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
236 |
exceptionClasses <Collection of Class> |
1848 | 237 |
annotations <JavaAnnotationContainer>" |
238 |
||
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
239 |
| ctorOrMethod | |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
240 |
ctorOrMethod := ctorOrMethodClass new. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
241 |
ctorOrMethod |
1848 | 242 |
instVarNamed: #clazz |
243 |
put: (reflection "method m" javaClassObjectForClass: class); |
|
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
244 |
instVarNamed: #slot put: method; |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
245 |
instVarNamed: #modifiers put: modifiers; |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
246 |
instVarNamed: #parameterTypes |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
247 |
put: (reflection javaClassObjectArrayForClasses: parameterClasses); |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
248 |
instVarNamed: #exceptionTypes |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
249 |
put: (reflection javaClassObjectArrayForClasses: exceptionClasses); |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
250 |
instVarNamed: #annotations put: annotations runtimeVisible bytes; |
1848 | 251 |
instVarNamed: #parameterAnnotations |
1850 | 252 |
put: annotations rawParamAnnotations. |
1848 | 253 |
(method isJavaMethod and: [ method signature notNil ]) ifTrue: [ |
254 |
ctorOrMethod instVarNamed: #signature |
|
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
255 |
put: (reflection javaStringObjectForString: method signature interned: true) |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
256 |
]. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
257 |
^ ctorOrMethod |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
258 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
259 |
"Created: / 01-08-2012 / 10:24:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1850 | 260 |
"Modified: / 01-12-2012 / 22:55:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
261 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
262 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
263 |
createConstructorFor: class method: method signature: signature modifiers: modifiers parameterTyoes: parameterClasses exceptionTypes: exceptionClasses annotations: annotations |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
264 |
"Creates a new java.lang.Constructor. Arguments: |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
265 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
266 |
class <Class> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
267 |
method <Method> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
268 |
signature <String> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
269 |
modifiers <SmallInteger> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
270 |
parameterClasses <Collection of Class> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
271 |
exceptionClasses <Collection of Class> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
272 |
annotations <JavaAnnotationContainer> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
273 |
" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
274 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
275 |
| ctor | |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
276 |
ctor := self create: (JavaVM classForName:'java.lang.reflect.Constructor') |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
277 |
for: class |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
278 |
method: method |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
279 |
signature: signature |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
280 |
modifiers: modifiers |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
281 |
parameterTyoes: parameterClasses |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
282 |
exceptionTypes: exceptionClasses |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
283 |
annotations: annotations. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
284 |
^ctor |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
285 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
286 |
"Created: / 01-08-2012 / 10:20:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
287 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
288 |
|
1648 | 289 |
createFieldFor: javaField |
290 |
"given a java field, return the corresponding java.lang.Field |
|
291 |
instance for it." |
|
292 |
" |
|
293 |
See OpenJDK7 source: |
|
294 |
jdk7/hotspot/src/share/vm/runtime/reflection.cpp, |
|
295 |
oop Reflection::new_field" |
|
296 |
||
297 |
| field clazz name slot type modifiers | |
|
298 |
||
299 |
clazz := reflection javaClassObjectForClass: klass. |
|
300 |
name := JavaVM reflection javaStringObjectForString: javaField name |
|
301 |
interned: true. |
|
302 |
slot := javaField index. |
|
303 |
type := JavaVM javaClassObjectForClass: javaField typeClass. |
|
304 |
modifiers := javaField accessFlags. |
|
305 |
field := (JavaVM classForName: 'java.lang.reflect.Field') new. |
|
306 |
field |
|
307 |
instVarNamed: #clazz put: clazz; |
|
308 |
instVarNamed: #name put: name; |
|
309 |
instVarNamed: #slot put: slot; |
|
310 |
instVarNamed: #type put: type; |
|
311 |
instVarNamed: #modifiers put: modifiers; |
|
312 |
yourself. |
|
313 |
javaField annotations |
|
314 |
ifNotNil: [ |
|
315 |
field instVarNamed: #annotations |
|
316 |
put: javaField annotations runtimeVisible rawAnnotations |
|
317 |
]. |
|
318 |
^ field. |
|
319 |
||
320 |
"Created: / 22-08-2012 / 12:09:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
321 |
! |
|
322 |
||
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
323 |
createMethodFor: class method: method name: name signature: signature modifiers: modifiers parameterTyoes: parameterClasses returnType: returnClass exceptionTypes: exceptionClasses annotations: annotations |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
324 |
"Creates a new java.lang.Constructor. Arguments: |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
325 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
326 |
class <Class> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
327 |
method <Method> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
328 |
name <String> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
329 |
signature <String> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
330 |
modifiers <SmallInteger> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
331 |
parameterClasses <Collection of Class> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
332 |
returnClass <Class> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
333 |
exceptionClasses <Collection of Class> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
334 |
annotations <JavaAnnotationContainer> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
335 |
" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
336 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
337 |
| mthd | |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
338 |
mthd := self create: (JavaVM classForName:'java.lang.reflect.Method') |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
339 |
for: class |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
340 |
method: method |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
341 |
signature: signature |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
342 |
modifiers: modifiers |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
343 |
parameterTyoes: parameterClasses |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
344 |
exceptionTypes: exceptionClasses |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
345 |
annotations: annotations. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
346 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
347 |
mthd |
1649
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
348 |
instVarNamed: #name put: (reflection javaStringObjectForString: name interned: true); |
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
349 |
instVarNamed: #returnType put: (reflection javaClassObjectForClass: returnClass); |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
350 |
instVarNamed: #annotationDefault put: (annotations default bytes). |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
351 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
352 |
^mthd |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
353 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
354 |
"Created: / 01-08-2012 / 10:46:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
355 |
! ! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
356 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
357 |
!JavaMirror::AlienClassMirror class methodsFor:'documentation'! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
358 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
359 |
documentation |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
360 |
" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
361 |
Specialized mirror for Smalltalk (and all other |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
362 |
non-Java classes) |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
363 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
364 |
[author:] |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
365 |
Jan Vrany <jan.vrany@fit.cvut.cz> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
366 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
367 |
[instance variables:] |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
368 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
369 |
[class variables:] |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
370 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
371 |
[see also:] |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
372 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
373 |
" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
374 |
! ! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
375 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
376 |
!JavaMirror::AlienClassMirror methodsFor:'accessing'! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
377 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
378 |
getClassLoader |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
379 |
"Returns a class loader that loaded this class" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
380 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
381 |
^ (Java classForName:'stx.libjava.ClassLoader') instVarNamed: #scl. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
382 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
383 |
"Modified: / 31-07-2012 / 18:34:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
384 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
385 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
386 |
getDeclaredConstructors:publicOnly |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
387 |
"Returns an java.lang.reflect.Constructor[] with all constructors |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
388 |
declared by this class" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
389 |
|
1648 | 390 |
"Here, return onlu default constructor. Later, all methods annotated |
391 |
with <jsignature: #'<init>(...)V'> wil be returned as well" |
|
392 |
||
393 |
| ctors | |
|
394 |
||
395 |
ctors := OrderedCollection new. |
|
396 |
klass selectorsAndMethodsDo:[:sel :mthd| |
|
397 |
(self isJavaConstructor: mthd selector: sel) ifTrue:[ |
|
398 |
ctors add: (self getDeclaredConstructorFor: mthd). |
|
399 |
]. |
|
400 |
]. |
|
401 |
||
402 |
ctors isEmpty ifTrue:[ |
|
403 |
"/If no constructor is found, fake default one... |
|
404 |
ctors add: (self getDeclaredConstructorFor: (klass lookupMethodFor: #initialize)). |
|
405 |
]. |
|
406 |
||
407 |
^(JavaVM classForName:'java.lang.reflect.Constructor') javaArrayClass withAll: ctors |
|
408 |
||
409 |
"Modified: / 22-08-2012 / 11:37:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
410 |
! |
|
411 |
||
412 |
getDeclaredFields:publicOnly |
|
413 |
"Returns an java.lang.reflect.Field[] with all constructors |
|
414 |
declared by this class." |
|
415 |
||
416 |
| fields | |
|
417 |
||
418 |
fields := OrderedCollection new. |
|
419 |
||
420 |
klass instVarNames withIndexDo:[:nm :index| |
|
421 |
| field | |
|
422 |
||
423 |
field := JavaField new. |
|
424 |
field |
|
425 |
setAccessFlags: JavaConstants ACC_PROTECTED; |
|
426 |
setClass: klass; |
|
427 |
setIndex: klass superclass instSize + index; |
|
428 |
setDescriptor: #'Ljava/lang/Object;'; |
|
429 |
setName: nm. |
|
430 |
||
431 |
fields add: (self createFieldFor: field) |
|
432 |
]. |
|
433 |
||
434 |
^ (JavaVM classForName:'java.lang.reflect.Field') javaArrayClass |
|
435 |
withAll:fields |
|
436 |
||
437 |
"Modified: / 22-08-2012 / 12:19:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
438 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
439 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
440 |
getDeclaredMethods:publicOnly |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
441 |
"Returns an java.lang.reflect.Method[] with all methods |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
442 |
declared by this class" |
1648 | 443 |
|
444 |
| methods | |
|
445 |
||
446 |
methods := OrderedCollection new. |
|
447 |
klass selectorsAndMethodsDo:[:sel :mthd| |
|
448 |
(self isJavaMethod: mthd selector: sel) ifTrue:[ |
|
449 |
methods add: (self getDeclaredMethodFor: mthd). |
|
450 |
]. |
|
451 |
]. |
|
452 |
^(JavaVM classForName:'java.lang.reflect.Method') javaArrayClass withAll: methods |
|
453 |
||
454 |
"Modified: / 22-08-2012 / 11:36:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
455 |
! |
|
456 |
||
457 |
getInterfaces |
|
458 |
"Return a list if interfaces" |
|
459 |
||
460 |
^ Array with: (JavaVM classForName: 'java.lang.Cloneable') |
|
461 |
||
462 |
"Modified: / 22-08-2012 / 11:06:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
463 |
! |
|
464 |
||
465 |
getModifiers |
|
466 |
"Return class modifiers (public/abstract/final...)" |
|
467 |
||
468 |
^ JavaConstants ACC_PUBLIC |
|
469 |
||
470 |
"Modified: / 22-08-2012 / 11:01:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
471 |
! |
|
472 |
||
473 |
getName |
|
474 |
"Returns name of the class" |
|
475 |
^'SMALLTALK.' , klass name |
|
476 |
||
477 |
"Created: / 22-08-2012 / 10:47:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
478 |
! ! |
|
479 |
||
480 |
!JavaMirror::AlienClassMirror methodsFor:'accessing-private'! |
|
481 |
||
482 |
getDeclaredConstructorFor: method |
|
483 |
^ self |
|
484 |
createConstructorFor: klass |
|
485 |
method: method |
|
486 |
signature: (self getSignatureForConstructor: method) |
|
487 |
modifiers: JavaConstants ACC_PUBLIC |
|
488 |
parameterTyoes: #() |
|
489 |
exceptionTypes: #() |
|
490 |
annotations: JavaMethodAnnotationContainer new |
|
491 |
||
492 |
"Created: / 22-08-2012 / 11:36:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
493 |
! |
|
494 |
||
495 |
getDeclaredMethodFor:method |
|
1649
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
496 |
| signature name java_lang_Object | |
1648 | 497 |
|
498 |
signature := self getSignatureForMethod: method short: false. |
|
499 |
name := signature upTo: $(. |
|
1649
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
500 |
java_lang_Object := JavaVM classNamed: 'java.lang.Object'. |
1648 | 501 |
^ self |
502 |
createMethodFor: klass |
|
503 |
method: method |
|
504 |
name: name |
|
505 |
signature: signature |
|
506 |
modifiers: JavaConstants ACC_PUBLIC |
|
1649
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
507 |
parameterTyoes: ((1 to: method selector numArgs) collect:[:i|java_lang_Object]) |
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
508 |
returnType: java_lang_Object |
1648 | 509 |
exceptionTypes: #() |
510 |
annotations: JavaMethodAnnotationContainer new |
|
511 |
||
512 |
"Created: / 22-08-2012 / 11:36:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
513 |
! |
|
514 |
||
515 |
getSignatureForConstructor: method |
|
516 |
| signature | |
|
517 |
||
518 |
signature := |
|
519 |
(String streamContents:[:s| |
|
520 |
s nextPutAll: '<init>('. |
|
521 |
method selector numArgs timesRepeat:[ |
|
522 |
s nextPutAll:'Ljava/lang/Object;'. |
|
523 |
]. |
|
524 |
s nextPutAll: ')V'. |
|
525 |
]) asSymbol. |
|
526 |
^signature |
|
527 |
||
528 |
"Created: / 22-08-2012 / 11:40:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
529 |
! |
|
530 |
||
531 |
getSignatureForMethod: method short: short |
|
532 |
| selector signature | |
|
533 |
||
534 |
selector := method selector. |
|
535 |
signature := |
|
536 |
(String streamContents:[:s| |
|
537 |
short ifTrue:[ |
|
538 |
s nextPutAll: (selector upTo: $:) |
|
539 |
] ifFalse:[ |
|
1649
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
540 |
selector numArgs == 1 ifTrue:[ |
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
541 |
s nextPutAll: (selector copyTo: selector size - 1) |
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
542 |
] ifFalse:[ |
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
543 |
s nextPutAll: (selector copyReplaceAll: $: with: $_) |
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
544 |
] |
1648 | 545 |
]. |
1649
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
546 |
s nextPut: $(. |
1648 | 547 |
method selector numArgs timesRepeat:[ |
548 |
s nextPutAll:'Ljava/lang/Object;'. |
|
549 |
]. |
|
550 |
s nextPutAll: ')'. |
|
551 |
s nextPutAll:'Ljava/lang/Object;'. |
|
552 |
]) asSymbol. |
|
553 |
^signature |
|
554 |
||
555 |
"Created: / 22-08-2012 / 11:46:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
556 |
! ! |
|
557 |
||
558 |
!JavaMirror::AlienClassMirror methodsFor:'testing-private'! |
|
559 |
||
560 |
isJavaConstructor: mthd selector: sel |
|
561 |
||
562 |
^sel startsWith: #initialize |
|
563 |
||
564 |
"Created: / 22-08-2012 / 11:47:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
565 |
! |
|
566 |
||
567 |
isJavaMethod: mthd selector: sel |
|
568 |
||
569 |
^sel isBinarySelector not |
|
570 |
and:[(self isJavaConstructor: mthd selector: sel) not] |
|
571 |
||
572 |
"Created: / 22-08-2012 / 11:47:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
573 |
! ! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
574 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
575 |
!JavaMirror::JavaArrayMirror methodsFor:'accessing'! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
576 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
577 |
getClassLoader |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
578 |
"Returns a class loader that loaded this class" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
579 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
580 |
^ klass javaComponentClass javaMirror getClassLoader |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
581 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
582 |
"Modified: / 31-07-2012 / 18:35:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
583 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
584 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
585 |
getDeclaredConstructors:publicOnly |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
586 |
"Returns an java.lang.reflect.Constructor[] with all constructors |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
587 |
declared by this class" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
588 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
589 |
^ (JavaVM classForName:'java.lang.reflect.Constructor') javaArrayClass new:0. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
590 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
591 |
"Modified: / 31-07-2012 / 18:41:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
592 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
593 |
|
1648 | 594 |
getDeclaredFields:publicOnly |
595 |
"Returns an java.lang.reflect.Field[] with all constructors |
|
596 |
declared by this class." |
|
597 |
||
598 |
^(JavaVM classForName:'java.lang.reflect.Field') javaArrayClass new:0. |
|
599 |
||
600 |
"Modified: / 22-08-2012 / 12:03:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
601 |
! |
|
602 |
||
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
603 |
getDeclaredMethods:publicOnly |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
604 |
"Returns an java.lang.reflect.Method[] with all methods |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
605 |
declared by this class" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
606 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
607 |
^ (JavaVM classForName:'java.lang.reflect.Method') javaArrayClass new:0. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
608 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
609 |
"Modified: / 01-08-2012 / 11:08:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1648 | 610 |
! |
611 |
||
612 |
getInterfaces |
|
613 |
"Return a list if interfaces" |
|
614 |
||
615 |
^ Array |
|
616 |
with: (JavaVM classForName: 'java.lang.Cloneable') |
|
617 |
with: (JavaVM classForName: 'java.io.Serializable') |
|
618 |
||
619 |
"Modified: / 22-08-2012 / 11:06:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
620 |
! |
|
621 |
||
622 |
getModifiers |
|
623 |
"Return class modifiers (public/abstract/final...)" |
|
624 |
||
625 |
^ JavaConstants ACC_ABSTRACT | JavaConstants ACC_FINAL | JavaConstants ACC_PUBLIC |
|
626 |
||
627 |
"Modified: / 22-08-2012 / 11:02:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
628 |
! ! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
629 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
630 |
!JavaMirror::JavaClassMirror class methodsFor:'documentation'! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
631 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
632 |
documentation |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
633 |
" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
634 |
A specialized mirror for all Java classes |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
635 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
636 |
[author:] |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
637 |
Jan Vrany <jan.vrany@fit.cvut.cz> |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
638 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
639 |
[instance variables:] |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
640 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
641 |
[class variables:] |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
642 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
643 |
[see also:] |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
644 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
645 |
" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
646 |
! ! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
647 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
648 |
!JavaMirror::JavaClassMirror methodsFor:'accessing'! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
649 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
650 |
getClassLoader |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
651 |
"Returns a class loader that loaded this class" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
652 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
653 |
^ klass classLoader |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
654 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
655 |
"Modified: / 31-07-2012 / 18:26:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
656 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
657 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
658 |
getDeclaredConstructors:publicOnly |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
659 |
"Returns an java.lang.reflect.Constructor[] with all constructors |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
660 |
declared by this class" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
661 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
662 |
| ctors | |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
663 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
664 |
ctors := OrderedCollection new. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
665 |
klass selectorsAndMethodsDo:[:sel :mthd| |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
666 |
(mthd isJavaConstructor and:[publicOnly not or:[mthd isPublic]]) ifTrue:[ |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
667 |
ctors add: (self getDeclaredConstructorFor: mthd). |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
668 |
]. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
669 |
]. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
670 |
^(JavaVM classForName:'java.lang.reflect.Constructor') javaArrayClass withAll: ctors |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
671 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
672 |
"Modified: / 01-08-2012 / 11:04:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
673 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
674 |
|
1648 | 675 |
getDeclaredFields:publicOnly |
676 |
"Returns an java.lang.reflect.Field[] with all constructors |
|
677 |
declared by this class." |
|
678 |
||
679 |
| fields | |
|
680 |
||
681 |
fields := klass fields , klass staticFields. |
|
682 |
publicOnly ifTrue:[ fields := fields select:[:f | f isPublic ] ]. |
|
683 |
JavaClassReader classLoaderQuerySignal answer: klass classLoader do:[ |
|
684 |
fields := fields collect:[:f | self createFieldFor:f ]. |
|
685 |
]. |
|
686 |
^ (JavaVM classForName:'java.lang.reflect.Field') javaArrayClass |
|
687 |
withAll:fields |
|
688 |
||
689 |
"Modified: / 22-08-2012 / 12:10:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
690 |
! |
|
691 |
||
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
692 |
getDeclaredMethods:publicOnly |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
693 |
"Returns an java.lang.reflect.Constructor[] with all constructors |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
694 |
declared by this class" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
695 |
|
1648 | 696 |
| methods | |
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
697 |
|
1648 | 698 |
methods := OrderedCollection new. |
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
699 |
klass selectorsAndMethodsDo:[:sel :mthd| |
1699
73003b9f58fc
- Support for extension methods finished (ready for testing)
vranyj1
parents:
1677
diff
changeset
|
700 |
mthd isJavaMethod and:[ |
1708 | 701 |
(mthd isJavaConstructor not |
702 |
and:[mthd isJavaStaticInitializer not |
|
703 |
and:[publicOnly not or:[mthd isPublic]]]) ifTrue:[ |
|
1699
73003b9f58fc
- Support for extension methods finished (ready for testing)
vranyj1
parents:
1677
diff
changeset
|
704 |
methods add: (self getDeclaredMethodFor: mthd). |
73003b9f58fc
- Support for extension methods finished (ready for testing)
vranyj1
parents:
1677
diff
changeset
|
705 |
] |
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
706 |
]. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
707 |
]. |
1648 | 708 |
^(JavaVM classForName:'java.lang.reflect.Method') javaArrayClass withAll: methods |
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
709 |
|
1708 | 710 |
"Modified: / 19-09-2012 / 16:26:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1648 | 711 |
! |
712 |
||
713 |
getGenericSignature |
|
714 |
"Returns Java generic signature (if a generic class) or nil" |
|
715 |
||
716 |
^klass signatureJ |
|
717 |
||
718 |
"Created: / 22-08-2012 / 11:58:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
719 |
! |
|
720 |
||
721 |
getInterfaces |
|
722 |
"Return a list if interfaces" |
|
723 |
||
724 |
^ klass interfaces |
|
725 |
||
726 |
"Modified: / 22-08-2012 / 11:08:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
727 |
! |
|
728 |
||
729 |
getModifiers |
|
730 |
"Return class modifiers (public/abstract/final...)" |
|
731 |
||
732 |
| modifiers | |
|
733 |
||
734 |
"According to OpenJDK JVM, strip ACC_SUPER" |
|
735 |
modifiers := (klass accessFlags & JavaConstants ACC_SUPER bitInvert) & 16r7FFF. |
|
736 |
"JV@2011-10-30: It seems that private inner classes has no |
|
737 |
private bit set, sigh" |
|
738 |
(modifiers & 16r0007) == 0 ifTrue:[ |
|
739 |
modifiers := modifiers | JavaConstants ACC_PRIVATE. |
|
740 |
]. |
|
741 |
^modifiers |
|
742 |
||
743 |
"Modified: / 22-08-2012 / 11:03:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1649
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
744 |
! |
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
745 |
|
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
746 |
getProtectionDomain |
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
747 |
^klass protectionDomain |
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
748 |
|
0af82006c0b2
- some more support for calling Smalltalk from Groovy. Crashes VM now :-)
vranyj1
parents:
1648
diff
changeset
|
749 |
"Created: / 22-08-2012 / 12:56:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
750 |
! ! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
751 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
752 |
!JavaMirror::JavaClassMirror methodsFor:'accessing-private'! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
753 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
754 |
getDeclaredConstructorFor: method |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
755 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
756 |
^self createConstructorFor: method javaClass |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
757 |
method: method |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
758 |
signature: method signature |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
759 |
modifiers: method accessFlags |
1609
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1581
diff
changeset
|
760 |
parameterTyoes: (method descriptor parameterClassesUsingClassLoader: method javaClass classLoader) |
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
761 |
exceptionTypes: method exceptionClasses |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
762 |
annotations: method method annotations. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
763 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
764 |
"Created: / 01-08-2012 / 00:46:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
765 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
766 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
767 |
getDeclaredMethodFor: method |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
768 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
769 |
^self createMethodFor: method javaClass |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
770 |
method: method |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
771 |
name: (method selector upTo: $() |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
772 |
signature: method signature |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
773 |
modifiers: method accessFlags |
1609
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1581
diff
changeset
|
774 |
parameterTyoes: (method descriptor parameterClassesUsingClassLoader: method javaClass classLoader) |
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1581
diff
changeset
|
775 |
returnType: (method descriptor returnClassUsingClassLoader: method javaClass classLoader) |
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
776 |
exceptionTypes: method exceptionClasses |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
777 |
annotations: method method annotations. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
778 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
779 |
"Created: / 01-08-2012 / 11:11:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
780 |
! ! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
781 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
782 |
!JavaMirror::JavaPrimitiveMirror methodsFor:'accessing'! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
783 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
784 |
getClassLoader |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
785 |
"Returns a class loader that loaded this class" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
786 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
787 |
^ nil |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
788 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
789 |
"Modified: / 31-07-2012 / 18:35:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
790 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
791 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
792 |
getDeclaredConstructors:publicOnly |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
793 |
"Returns an java.lang.reflect.Constructor[] with all constructors |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
794 |
declared by this class" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
795 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
796 |
^ (JavaVM classForName:'java.lang.reflect.Constructor') javaArrayClass new:0. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
797 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
798 |
"Modified: / 31-07-2012 / 18:41:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
799 |
! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
800 |
|
1648 | 801 |
getDeclaredFields:publicOnly |
802 |
"Returns an java.lang.reflect.Field[] with all constructors |
|
803 |
declared by this class." |
|
804 |
||
805 |
^(JavaVM classForName:'java.lang.reflect.Field') javaArrayClass new:0. |
|
806 |
||
807 |
"Modified: / 22-08-2012 / 12:03:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
808 |
! |
|
809 |
||
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
810 |
getDeclaredMethods:publicOnly |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
811 |
"Returns an java.lang.reflect.Method[] with all methods |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
812 |
declared by this class" |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
813 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
814 |
^ (JavaVM classForName:'java.lang.reflect.Method') javaArrayClass new:0. |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
815 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
816 |
"Modified: / 01-08-2012 / 11:08:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1648 | 817 |
! |
818 |
||
819 |
getInterfaces |
|
820 |
"Return a list if interfaces" |
|
821 |
||
822 |
^ #() |
|
823 |
||
824 |
"Modified: / 22-08-2012 / 11:07:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
825 |
! |
|
826 |
||
827 |
getModifiers |
|
828 |
"Return class modifiers (public/abstract/final...)" |
|
829 |
||
830 |
^ JavaConstants ACC_ABSTRACT | JavaConstants ACC_FINAL | JavaConstants ACC_PUBLIC |
|
831 |
||
832 |
"Modified: / 22-08-2012 / 11:02:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
833 |
! ! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
834 |
|
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
835 |
!JavaMirror class methodsFor:'documentation'! |
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
836 |
|
1864 | 837 |
version_HG |
838 |
||
839 |
^ '$Changeset: <not expanded> $' |
|
840 |
! |
|
841 |
||
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
842 |
version_SVN |
1864 | 843 |
^ '§Id:: §' |
1581
70fbc03d2d82
Java reflection support refactoring - moved to use JavaMirrors
vranyj1
parents:
diff
changeset
|
844 |
! ! |