Menu

[r312]: / trunk / php-java-bridge / tests.php4 / callBack.php  Maximize  Restore  History

Download this file

31 lines (25 with data), 809 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/php
<?php
if(!extension_loaded('java')) {
dl('java.' . PHP_SHLIB_SUFFIX);
}
$here=trim(`pwd`);
java_require("$here/callBack.jar");
class impl {// methods are called by index#, so their name is irrelevant.
function passX($Object) { echo $Object->hashCode(); return $Object; }
function pass2($o) { return $o; }
function pass3($s) { echo "pass3: $s\n"; }
function pass4() { echo "pass4\n"; }
function pass5($s, $a, $b, $c, $d) { return array($s, $a, $b, $c, $d); }
}
$impl = new impl();
$sig = new java("CallBack");
$closure = java_closure($impl, $sig);
$test = new java('CallBack$Impl', $closure);
$x=$test->test($sig);
echo $x->hashCode();
var_dump($test->test(array(1, 2, 3)));
$test->test("hello");
$test->test();
var_dump($test->test("hello", 1, true, 3, -998876));
?>