diff options
author | Zack Weinberg <zackw@stanford.edu> | 2001-05-13 01:28:18 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2001-05-13 01:28:18 +0000 |
commit | 1f730ff7b674c4309a3684f9e7f901ccf01da9c7 (patch) | |
tree | 49246e78a7ee8c4a59b8982faf4c2837e13775cb /gcc/extend.texi | |
parent | c9ec8f321f955dd9750f73d6957afbb0bac842e5 (diff) | |
download | gcc-1f730ff7b674c4309a3684f9e7f901ccf01da9c7.zip gcc-1f730ff7b674c4309a3684f9e7f901ccf01da9c7.tar.gz gcc-1f730ff7b674c4309a3684f9e7f901ccf01da9c7.tar.bz2 |
except.c (choose_personality_routine): Export.
gcc/cp:
* except.c (choose_personality_routine): Export. Add
explanatory comment. Take an enum languages, not a boolean.
(initialize_handler_parm): Adjust to match.
* cp-tree.h: Prototype choose_personality_routine.
* lex.c (handle_pragma_java_exceptions): New function.
(init_cp_pragma): Register #pragma GCC java_exceptions.
gcc:
* extend.texi: Document #pragma GCC java_exceptions.
libjava:
* Makefile.am (libgcj_la_OBJECTS): Remove libsupc++convenience.la.
* Makefile.in: Regenerate (by hand).
* include/jvm.h: Add #pragma GCC java_exceptions at top of file.
* doc/cni.sgml: Document #pragma GCC java_exceptions.
From-SVN: r42027
Diffstat (limited to 'gcc/extend.texi')
-rw-r--r-- | gcc/extend.texi | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/extend.texi b/gcc/extend.texi index 5c52fcb..6b08843 100644 --- a/gcc/extend.texi +++ b/gcc/extend.texi @@ -3811,6 +3811,7 @@ Predefined Macros,cpp.info,The C Preprocessor}). * Bound member functions:: You can extract a function pointer to the method denoted by a @samp{->*} or @samp{.*} expression. * C++ Attributes:: Variable, function, and type attributes for C++ only. +* Java Exceptions:: Tweaking exception handling to work with Java. * Deprecated Features:: Things might disappear from g++. * Backwards Compatibility:: Compatibilities with earlier definitions of C++. @end menu @@ -4380,6 +4381,41 @@ interface table mechanism, instead of regular virtual table dispatch. @end table +@node Java Exceptions +@section Java Exceptions + +The Java language uses a slightly different exception handling model +from C++. Normally, GNU C++ will automatically detect when you are +writing C++ code that uses Java exceptions, and handle them +appropriately. However, if C++ code only needs to execute destructors +when Java exceptions are thrown through it, GCC will guess incorrectly. +Sample problematic code: + +@example + struct S @{ ~S(); @}; + extern void bar(); // is implemented in Java and may throw exceptions + void foo() + @{ + S s; + bar(); + @} +@end example + +@noindent +The usual effect of an incorrect guess is a link failure, complaining of +a missing routine called @samp{__gxx_personality_v0}. + +You can inform the compiler that Java exceptions are to be used in a +translation unit, irrespective of what it might think, by writing +@samp{@w{#pragma GCC java_exceptions}} at the head of the file. This +@samp{#pragma} must appear before any functions that throw or catch +exceptions, or run destructors when exceptions are thrown through them. + +You cannot mix Java and C++ exceptions in the same translation unit. It +is believed to be safe to throw a C++ exception from one file through +another file compiled for the for the Java exception model, or vice +versa, but there may be bugs in this area. + @node Deprecated Features @section Deprecated Features |