Menu

[r691]: / branches / Release-5-1-2 / php-java-bridge / tests.php5 / nested_closure.php  Maximize  Restore  History

Download this file

39 lines (34 with data), 859 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
31
32
33
34
35
36
37
#!/usr/bin/php
<?php
if (!extension_loaded('java')) {
if (!(require_once("http://127.0.0.1:8080/JavaBridge/java/Java.inc"))) {
echo "java extension not installed.";
exit(2);
}
}
class c {
function toString() {
return "class c";
}
}
function toString() {
return "top-level";
}
function getClosure() {
$cl = java_closure(new c());
$res = java_cast($cl, "S");
if($res != "class c") throw new JavaException ("java.lang.Exception", "test failed");
return $cl;
}
try {
$cl = java_closure();
$Proxy = new JavaClass("java.lang.reflect.Proxy");
$proc = $Proxy->getInvocationHandler($cl);
$ncl = $proc->invoke($cl, "getClosure", array());
$res = java_cast($ncl, "S");
if($res != "class c") throw new Exception ("test failed");
echo "test okay<br>\n";
} catch (Exception $e) {
echo "test failed: $e<br>\n";
exit(1);
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.