cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Java exception handling in ACL

jonathan.reeve
1-Visitor

Java exception handling in ACL

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 2

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

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

Announcements

Top Tags