|
From: <php...@li...> - 2009-01-11 19:34:03
|
Hi Jost,
o.k., we're coming closer:
Your proposal is about the same I had already described in the attached file of my very first email.
I've now aligned it with your example.
-----------------------------------------------------------
Java looks like:
package php.java.bridge;
import java.lang.reflect.Proxy;
import php.java.bridge.Request.AbortException;
public class Test2 {
public void call(Object $cca, Object $ccb) {
PhpProcedure cca = (PhpProcedure)Proxy.getInvocationHandler($cca);
PhpProcedure ccb = (PhpProcedure)Proxy.getInvocationHandler($ccb);
try {
cca.invoke( $cca, "invokeA", new Object[]{ ccb } );
} catch (AbortException ae) {
} catch (Throwable e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
final String[] initArgs = {"LOCAL", "6", "javabridge_simple_callback.log"};
try {
(new Standalone()).init(initArgs);
} catch (Throwable t) {
t.printStackTrace();
System.exit(9);
}
}
}
-----------------------------------------------------------
PHP looks about this:
class a {
function invokeA($b) {
echo $b->invokeB();
}
}
class b {
function invokeB() {
echo "class b";
}
}
$c = new Java("php.java.bridge.Test2");
$a = java_closure(new a());
$b = java_closure(new b());
$c->call($a, $b)
-----------------------------------------------------------
If I run this then the log-file shows:
1. new Java("php.java.bridge.Test2"):
--> <C v="php.java.bridge.Test2" p="I" ></C>
<-- <O v="1" m="php.java.bridge.Test2" p="O" n="T"/>
=> $c has Java-ID="1"
2. java_closure(new a()):
--> <I v="0" m="makeClosure" p="I" />
--> <L v="2513895" p="O" />
--> </I>
<-- <O v="2" m="php.java.bridge.PhpProcedureProxy" p="O" n="T"/>
=> $a has Java-ID="2"
3. java_closure(new b()):
--> <I v="0" m="makeClosure" p="I" />
--> <L v="2513278" p="O" />
--> </I>
<-- <O v="3" m="php.java.bridge.PhpProcedureProxy" p="O" n="T"/>
=> $b has Java-ID="3"
4. call($a, $b):
--> <I v="1" m="call" p="I" />
--> <O v="2" />
--> <O v="3" />
--> </I>
=> calling the method with the correct IDs ("2" and "3")
5. invokeA():
<-- <A v="2513895" p="aW52b2tlQSgp" m="aW52b2tlQSgp" n="1"><P><O v="4" m="php.java.bridge.PhpProcedure" p="O" n="T"/></P></A>
=> ID now passed back is "4" instead of "3"!
So, the PhpProcedure passed to invokeA() is a new one.
(which in turn causes invokeB() to fail...)
Did I find a bug here?
Regards Jürgen
|