[vtkusers] Catching VTK exceptions in Java

Jeff Lee jeff at cdnorthamerica.com
Fri Dec 5 07:36:39 EST 2003


Steve Joyce wrote:

>I am using VTK 4.2.3 with Java wrapping.
>Is it possible to catch exceptions that are thrown in the VTK libraries
>within Java code?
>At the moment, if a VTK exception is thrown the Java application just
>exits.
>  
>
Hi,
vtk doesn't have an exception handling framework (the only try-catch 
stuff in the code base is either wrapper-language, or something JB 
wrote).  Anyway, if you actually were able to catch vtk c++ library 
exceptions with your own c++ exception handling code, you could 
theoretically propogate them through the jni interface up to the java 
code.  But for now, it would be useless to instrument the java cxx libs 
because no exceptions are thrown anyway.  Catching out-of-memory on c++ 
side would be tricky, because there is no global/centralized memory 
management in vtk (imagine doing a try-catch on every "new" in the 
code...).  Big job.  In short, you can't catch what isn't thrown.
-Jeff

>In particular, I'd like to catch out of memory errors, but catching any
>error would be useful.
>
>Thanks,
>Steve
>
>
>  
>




More information about the vtkusers mailing list