Menu

[r123]: / trunk / php-java-bridge / tests.php5 / exception.php  Maximize  Restore  History

Download this file

35 lines (28 with data), 717 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
#!/usr/bin/php
<?php
if(!extension_loaded('java')) {
dl('java.' . PHP_SHLIB_SUFFIX);
}
try {
$here=trim(`pwd`);
java_set_library_path("$here/exception.jar");
$e = new java("Exception");
// trigger ID=42
$i = $e->inner;
$i->o = new java("java.lang.Integer", 42);
// should return 33
$e->inner->meth(33);
try {
// should throw exception "Exception$Ex"
$e->inner->meth(42);
return 2;
} catch (java_exception $exception) {
echo "An exception occured: $exception\n";
$cause = $exception->getCause();
echo "exception ". $cause ." --> " . $cause->getID() . "\n";
return ($cause->getID() == 42) ? 0 : 3;
}
} catch (exception $err) {
print "$err \n";
return 4;
}