|
From: <php...@li...> - 2008-05-18 11:31:21
|
Hi,
> "getMessage()" in the cause, however, when we go
> to access the method
> directly, we get nothing.
that's because PHP's Exception::getMessage() shadows java.lang.Throwable.getMessage().
Please either use getLocalizedMessage() or access "message" directly (which invokes the Java Bean getter "getMessage") or pass the Java message to PHP's exception constructor.
> **note, we tried to override
> Java_Exception_Proxy::getMessage()
> directly, we received:
>
> [16-May-2008 20:55:17] PHP Fatal error: Cannot override
> final method
> Exception::getMessage() in .../java_exception_proxy.obj
That's why the bridge did not provide a resonable default for it.
However, if you extend from Exception, you can access the $message property directly. The following code creates a new Exception and fills PHP's exception property with the exception obtained from Java:
<?php
require_once("java/Java.inc");
class my_JavaException extends java_InternalException {
function __construct ($proxy, $message) {
$this->message = $message;
parent::__construct($proxy->__delegate);
}
}
class my_ThrowExceptionProxyFactory extends java_ThrowExceptionProxyFactory {
function checkResult($result) {
throw new my_JavaException ($result, $result->getCause()->message);
}
}
$client = __javaproxy_Client_getClient();
$client->throwExceptionProxyFactory =
new my_ThrowExceptionProxyFactory($client);
// test
java_autoload("/home/jost/Test.jar");
try {
$test = new Test(true);
} catch (Exception $e) {
echo $e->getMessage();
}
Regards,
Jost Boekemeier
__________________________________________________________
Gesendet von Yahoo! Mail.
Dem pfiffigeren Posteingang.
http://de.overview.mail.yahoo.com
|