Question about EH

Martin v. Loewis
Wed Feb 23 13:44:00 GMT 2000

> Mike> Well, this is a java issue.  If you want to find the g++
> Mike> entries, you will need to figure out a mapping between C++ and
> Mike> Java that you like, and extend the Java matcher to handle the
> Mike> union case better.
> If I have a pointer to a random collection of bits (which is what I
> have in the type matcher, I think), I don't think that there is a way
> to determine whether it is a C++ object or a Java object.

The C++ EH part at the moment works by processing 'type_info' objects.
If you have a generic C++ object, you cannot find out at run-time what
its type is - which you have to do for exception handling.

Therefore, the C++ EH passes a separate typeinfo object along with the
exception object, and performs type matching based on that. The exact
processing varies whether old or new EH is used, but in general, the
matcher knows the typeinfo of the expected exception, and requires the
typeinfo of the thrown exception in eh_info().

Therefore, to catch exceptions thrown in Java, you need to put a C++
typeinfo into the exception info. I'm not sure whether the C++
compiler generates proper typeinfos for 'extern "Java"' classes; that
also may need some work.

> This is the start of the impossible things.  In Java it is only
> possible to throw a Java object derived from java.lang.Throwable.  (In
> C++ terms this is the same as throwing a pointer to that object -- in
> Java you can only have object references.)

That's one of the things to decide. If you throw a Java exception in
Java, would you expect to catch that as java::lang::Throwable& or
java::lang::Throwable*? Depending on that decision, you need to pass
object or pointer typeinfos.

Of course, it may be possible to adjust everything the other way
'round, ie. treat throw and catch in C++ specially if that is an
extern "Java" type.


More information about the Gcc mailing list