1
|
1 |
JavaRef subclass:#JavaMethodref
|
29
|
2 |
instanceVariableNames:'method sel'
|
1
|
3 |
classVariableNames:''
|
|
4 |
poolDictionaries:''
|
4
|
5 |
category:'Java-Reader-Support'
|
1
|
6 |
!
|
|
7 |
|
|
8 |
|
41
|
9 |
!JavaMethodref methodsFor:'accessing'!
|
|
10 |
|
|
11 |
name
|
|
12 |
^ nameandType name.
|
|
13 |
!
|
|
14 |
|
|
15 |
selector
|
|
16 |
sel isNil ifTrue:[
|
|
17 |
sel := (nameandType name , nameandType signature) asSymbol.
|
|
18 |
].
|
|
19 |
^ sel
|
|
20 |
!
|
|
21 |
|
|
22 |
signature
|
|
23 |
^ nameandType signature.
|
|
24 |
! !
|
|
25 |
|
|
26 |
!JavaMethodref methodsFor:'printing & storing'!
|
|
27 |
|
|
28 |
displayString
|
|
29 |
^ 'JavaMethodRef (' , class displayString , ' '
|
|
30 |
, '''' , nameandType name , '''' , nameandType signature , ')'
|
|
31 |
! !
|
|
32 |
|
27
|
33 |
!JavaMethodref methodsFor:'resolving'!
|
|
34 |
|
|
35 |
method
|
87
|
36 |
|nm sig mthd cls|
|
27
|
37 |
|
|
38 |
method notNil ifTrue:[^ method].
|
|
39 |
|
90
|
40 |
cls := class javaClass.
|
|
41 |
cls ~~ class ifTrue:[
|
|
42 |
class := cls.
|
27
|
43 |
].
|
90
|
44 |
|
|
45 |
"/ (class isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
|
|
46 |
"/ cls := class resolve.
|
|
47 |
"/ cls notNil ifTrue:[
|
|
48 |
"/ class := cls
|
|
49 |
"/ ]
|
|
50 |
"/ ].
|
|
51 |
"/ (class isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
|
|
52 |
"/ self halt:'unresolved class'.
|
|
53 |
"/ ].
|
27
|
54 |
|
29
|
55 |
sel isNil ifTrue:[
|
|
56 |
nm := nameandType name asSymbol.
|
|
57 |
sig := nameandType signature.
|
|
58 |
sel := (nm , sig) asSymbol.
|
|
59 |
].
|
27
|
60 |
|
29
|
61 |
"/ 'search in: ' print. class fullName print. ' for ' print. nm print. ' sig: ' print. sig printNL.
|
41
|
62 |
|
63
|
63 |
mthd := class compiledMethodAt:sel.
|
|
64 |
mthd notNil ifTrue:[^ mthd].
|
|
65 |
self halt:'no such method found'.
|
29
|
66 |
!
|
|
67 |
|
|
68 |
methodFor:aClass
|
|
69 |
|nm sig mthd cls|
|
|
70 |
|
|
71 |
cls := aClass.
|
|
72 |
|
71
|
73 |
cls == Array ifTrue:[
|
|
74 |
cls := Java classNamed:'java.lang.Object'.
|
90
|
75 |
] ifFalse:[
|
100
|
76 |
cls == UndefinedObject ifTrue:[
|
|
77 |
cls := Java classNamed:'java.lang.Object'.
|
|
78 |
] ifFalse:[
|
|
79 |
cls isBehavior ifTrue:[
|
|
80 |
cls isMeta ifTrue:[
|
|
81 |
cls := cls soleInstance.
|
|
82 |
].
|
|
83 |
(cls isKindOf:JavaClass) ifFalse:[
|
|
84 |
self halt:'not a javaClass'.
|
|
85 |
self internalError:'not a javaClass'.
|
|
86 |
]
|
90
|
87 |
].
|
100
|
88 |
"/ cls := cls javaClass.
|
90
|
89 |
].
|
71
|
90 |
].
|
|
91 |
|
90
|
92 |
cls isUnresolved ifTrue:[
|
87
|
93 |
self halt:'unresolved class'.
|
29
|
94 |
].
|
|
95 |
|
|
96 |
sel isNil ifTrue:[
|
|
97 |
nm := nameandType name asSymbol.
|
|
98 |
sig := nameandType signature.
|
|
99 |
sel := (nm , sig) asSymbol.
|
|
100 |
].
|
|
101 |
|
|
102 |
[cls notNil] whileTrue:[
|
63
|
103 |
mthd := cls compiledMethodAt:sel.
|
|
104 |
mthd notNil ifTrue:[^ mthd].
|
41
|
105 |
|
29
|
106 |
cls := cls superclass
|
27
|
107 |
].
|
71
|
108 |
|
41
|
109 |
^ nil
|
27
|
110 |
! !
|
|
111 |
|
63
|
112 |
!JavaMethodref class methodsFor:'documentation'!
|
1
|
113 |
|
|
114 |
version
|
114
|
115 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethodref.st,v 1.14 1996/07/03 16:15:50 cg Exp $'
|
1
|
116 |
! !
|