|
From: <php...@li...> - 2009-09-24 18:30:57
|
Hi,
Version 5.5.3 let's you handle RuntimeException and java.lang.Error. If
JAVA_PREFER_VALUES is set, RuntimeException/Errors are reported as
Exceptions.
If JAVA_PREFER_VALUES is not set, you can use java_last_exception_get() to
retrieve the unchecked exception. For example:
<?php
define ("JAVA_PREFER_VALUES", false);
require_once("http://localhost:8080/JavaBridge/java/Java.inc");
try {
@new java("java.lang.String", null);
if ($ex = java_last_exception_get()) {
echo "OOPS, ";
java_last_exception_clear();
throw $ex;
}
} catch (Exception $e) {
echo "OK {$e->message}";
}
?>
=>
http://sourceforge.net/projects/php-java-bridge/files/Binary%20package/php-java-bridge_5.5.3/JavaBridgeTemplate553.war/download
Regards,
Jost Boekemeier
On Sep 24, 2009 3:45 PM, "Jost Bekemeier" <jos...@go...>
wrote:
> a the log on the Java side.
Or via last_exception_get(), which returns the first exception not cleared
via last_exception_clear().
> Are my assumptions correct
Yes, correct.
If you add a throw java_last_exception_get();
java_last_exception_clear(); at the bottom of your try/catch block, you will
receive all exceptions with their stack traces from the back end.
The only problem is that the current Java.inc turns all undeclared
exceptions into fatal errors (see checkResult() in
java_ThrowExceptionProxyFactory) and that java_last_exception is currently
deprecated.
Regards,
Jost Boekemeier
On Sep 24, 2009 3:21 PM, <php...@li...>
wrote:
Jost Bekemeier wrote: > I think you'll have to bite the bullet and always
throw checked > exceptions...
> > Ok, I'll look into that as well. My main issue with this is that almost
all > of what I'm goin...
Jost Bekemeier wrote: >> Would you mind explaining why? > > If you call a
procedure or method that ...
> > Ok, thanks for the explanation.
Michael
------------------------------------------------------------------------------
Come build...
is the only developer event you need to attend this year. Jumpstart your
developing skills, take Bla...
> > php...@li... > >
https://lists.sourceforge.net/lists/listinfo/ph...
|