Java <-> C

Matthew Fluet
Wed, 22 Aug 2001 11:33:40 -0700 (PDT)

> >This seems pretty scary, since all the C stuff misses its chance to do
> >cleanup.
> >I'd rather stick with return values for exceptional conditions (the C
> >way) for
> >now.
> I'm curious why you think this might cause problems.  There's an implicit
> assumption here that the C code is reasonable in its use of globals.  The
> issue of malloc'ed data is more problematic.  I suppose it would be possible
> for the Java/C interface to somehow communicate how much heap-allocated data
> was generated by C (e.g., when C calls back to Java) so that the handler can
> free this space prior to return, but I don't think we do this.

The problem I see is like the following:

Java method X.f calls C function g
f opens a file for output
f does some output
f calls Java method Y.h for some intermediate computation
Y.h raises an exception that is handled by the X.f handler

Now, there is an open, unflushed file that f should have gotten a chance
to deal with gracefully.