JavaLookuo: code for Java-to-Java lookup moved to JavaLookuo::J2J
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 22 Mar 2016 23:42:40 +0000
changeset 3550 81ee3d2cc629
parent 3549 4a492755dd1f
child 3551 f8304e321df7
JavaLookuo: code for Java-to-Java lookup moved to JavaLookuo::J2J This is a preparation for implementing new Java 8 INVOKEINTERFACE semantics.
JavaLookup.st
--- a/JavaLookup.st	Tue Mar 22 22:34:35 2016 +0000
+++ b/JavaLookup.st	Tue Mar 22 23:42:40 2016 +0000
@@ -26,13 +26,22 @@
 "
 "{ Package: 'stx:libjava' }"
 
+"{ NameSpace: Smalltalk }"
+
 Lookup subclass:#JavaLookup
-	instanceVariableNames:'s2j j2s'
+	instanceVariableNames:'j2j j2s s2j'
 	classVariableNames:'Instance InvokeRSelectors'
 	poolDictionaries:''
 	category:'Languages-Java-Interop'
 !
 
+Lookup subclass:#J2J
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:JavaLookup
+!
+
 Lookup subclass:#J2S
 	instanceVariableNames:''
 	classVariableNames:''
@@ -157,39 +166,15 @@
 initialize
     "Invoked when a new instance is created."
 
+    j2j := J2J new.
+    j2s := J2S new. 
     s2j := S2J new.
-    j2s := J2S new.
 
-    "Modified: / 15-12-2011 / 23:06:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 22-03-2016 / 22:39:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !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.
@@ -259,21 +244,54 @@
         ].
         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.
-            ]
+            ^j2j lookupMethodForSelector:selector directedTo:initialSearchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext ilc: ilcCache.
         ].
+        self breakPoint: #jv.
     ].
 
     ^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>"
-    "Modified: / 20-01-2014 / 13:27:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 22-03-2016 / 22:44:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaLookup::J2J 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
+    | method |
+    method := self lookupMethodForSelector: selector directedTo: initialSearchClass.
+    ilcCache notNil ifTrue:[
+        ilcCache bindTo: method forClass: initialSearchClass.
+    ].
+    ^ method.
+
+    "Created: / 22-03-2016 / 22:43:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaLookup::J2S methodsFor:'lookup'!