Skip to main content
1-Visitor
April 25, 2013
Question

Java exception handling in ACL

  • April 25, 2013
  • 2 replies
  • 1100 views

If I call some Java code from ACL and the Java code throws an exception, I see a message in the status bar, but the ACL script continues.

I tried this:
if ( 0 != catch("java_instance( $myObj, 'myMethod' )") ) {
response( "Barfed." )
}
The message wasn't displayed.

Is there another way to handle the exception?


Jonathan Reeve
Practical Law Company
19 Hatfields
London SE1 8DJ
T +44 (0)20 3423 6586
E jonathan.reeve@practicallaw.com
W http://www.practicallaw.com/

    2 replies

    1-Visitor
    April 25, 2013
    The best design for calling Java from ACL is to create a class with a bunch of static methods meant to be the interface to ACL, and call using java_static(). It's the easiest way to limit the risk of memory leaks in the passthrough (if you don't call java_delete() on the java instances used in your ACL code, their reference counts never get decremented, and the JVM's garbage collector never picks them up).

    So your best bet would be to write a static method that calls your instance method and handles any exceptions that come up.

    Chris

    1-Visitor
    May 8, 2013

    You can handle the exception in the java code and call Acl.func("response","error") in the java code to response the error message