[vtkusers] Catching VTK exceptions in Java

Mark Hünken mark.huenken at web.de
Fri Dec 5 12:08:38 EST 2003


I haven't tried it myself (yet), but shouldn't it be possible to catch
bad_allocs by setting up your own exception handler?

Something like
_set_new_handler(MyBadAllocHandler)

int MyBadAllocHandler(size_t size)
{
    throw the appropriate java exception
    and prevent VTK from running into memory access violations
}

Just an idea, but I would be interesting in any comments anyway.

Cheers,
Mark


----- Original Message -----
From: "Jeff Lee" <jeff at cdnorthamerica.com>
To: "Steve Joyce" <Steve.Joyce at sercoassurance.com>
Cc: <vtkusers at vtk.org>
Sent: Friday, December 05, 2003 1:36 PM
Subject: Re: [vtkusers] Catching VTK exceptions in Java


>
>
> 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
> >
> >
> >
> >
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list