--- a/src/JavaLookup.st Thu Jul 05 08:35:23 2012 +0000
+++ b/src/JavaLookup.st Thu Jul 05 10:35:31 2012 +0000
@@ -122,6 +122,31 @@
!JavaLookup methodsFor:'lookup'!
+lookupMethodForSelector: selector directedTo: initialSearchClass
+ "This method performs standard Java lookup as required JVM spec. See
+ - JVM spec, 5.4.2.1 Method overriding
+ - JVM spec, 6.4 invokevirtual
+
+ This is hacky because of those stupid package-private methods. Sigh."
+
+ | method superMethod |
+
+ method := super lookupMethodForSelector: selector directedTo: initialSearchClass.
+ method isNil ifTrue:[ ^ nil ].
+
+ superMethod := super lookupMethodForSelector: selector directedTo: method mclass superclass.
+ [ superMethod notNil ] whileTrue:[
+ (method overrides: superMethod) ifFalse:[
+ method := superMethod
+ ].
+ superMethod := super lookupMethodForSelector: selector directedTo: superMethod mclass superclass.
+ ].
+
+ ^method
+
+ "Created: / 05-07-2012 / 11:06:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
lookupMethodForSelector:selector directedTo:initialSearchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext ilc: ilcCache
"Invoked by the VM to ask me for a method to call.
@@ -130,23 +155,30 @@
the sending context and the inline/poly cache (instance of
PolymorphicInlineCache). "
- | m |
- m := super lookupMethodForSelector:selector directedTo:initialSearchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext ilc: ilcCache.
- m notNil ifTrue: [ ^ m ].
-
sendingContext programmingLanguage isSmalltalk ifTrue:[
aReceiver class theNonMetaclass programmingLanguage isJavaLike ifTrue:[
^s2j lookupMethodForSelector:selector directedTo:initialSearchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext ilc: ilcCache.
- ]
+ ].
].
- sendingContext programmingLanguage isJava ifTrue:[
- aReceiver class programmingLanguage isSmalltalk ifTrue:[
+ sendingContext programmingLanguage isJavaLike ifTrue:[
+ initialSearchClass programmingLanguage isSmalltalk ifTrue:[
+ "Java to Smalltalk send"
^j2s lookupMethodForSelector:selector directedTo:initialSearchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext ilc: ilcCache.
- ]
+ ].
+ initialSearchClass programmingLanguage isJavaLike ifTrue:[
+ "Java to Java send"
+ | m |
+
+ m := self lookupMethodForSelector: selector directedTo: initialSearchClass.
+ m notNil ifTrue:[
+ ilcCache notNil ifTrue:[ ilcCache bindTo: m forClass: aReceiver class ].
+ ^m.
+ ]
+ ].
].
- ^nil
+ ^super lookupMethodForSelector:selector directedTo:initialSearchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext ilc: ilcCache.
"Created: / 01-10-2011 / 13:18:40 / Jan Kurs <kursjan@fit.cvut.cz>"
"Created: / 15-12-2011 / 23:11:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"