diff --git a/CHANGES.current b/CHANGES.current index 6e6295378..25c5a80c3 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.40 (in progress) ============================ +2009-08-16: wsfulton + [Java] When %catches is used, fix so that any classes specified in the "throws" + attribute of the "throws" typemap are generated into the Java method's throws clause. + 2009-08-16: wsfulton [C#] Fix exception handling when %catches is used, reported by Juan Manuel Alvarez. diff --git a/Examples/test-suite/java/java_throws_runme.java b/Examples/test-suite/java/java_throws_runme.java index 6a73ea563..370173e50 100644 --- a/Examples/test-suite/java/java_throws_runme.java +++ b/Examples/test-suite/java/java_throws_runme.java @@ -40,6 +40,16 @@ public class java_throws_runme { if (!pass) throw new RuntimeException("Test 2 failed"); + // Check the exception class in the throw typemap + pass = false; + try { + java_throws.catches_function(100); + } + catch (IllegalAccessException e) { pass = true; } + + if (!pass) + throw new RuntimeException("Test 3 failed"); + // Check newfree typemap throws attribute try { TestClass tc = java_throws.makeTestClass(); diff --git a/Examples/test-suite/java_throws.i b/Examples/test-suite/java_throws.i index b020fefcb..48a0eeabc 100644 --- a/Examples/test-suite/java_throws.i +++ b/Examples/test-suite/java_throws.i @@ -42,12 +42,16 @@ short full_of_exceptions(int num) { #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif -void throw_spec_function(int value) throw (int) { throw (int)0; } +bool throw_spec_function(int value) throw (int) { throw (int)0; } #if defined(_MSC_VER) #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif %} +%catches(int) catches_function(int value); +%inline %{ +bool catches_function(int value) { throw (int)0; } +%} // Check newfree typemap throws attribute %newobject makeTestClass; diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 7ed4df636..9af6fc214 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -980,7 +980,7 @@ public: // Get any Java exception classes in the throws typemap ParmList *throw_parm_list = NULL; - if ((throw_parm_list = Getattr(n, "throws"))) { + if ((throw_parm_list = Getattr(n, "catchlist"))) { Swig_typemap_attach_parms("throws", throw_parm_list, f); for (p = throw_parm_list; p; p = nextSibling(p)) { if ((tm = Getattr(p, "tmap:throws"))) { @@ -3679,6 +3679,7 @@ public: Printf(declaration, " virtual %s", target); Delete(target); + // Add any exception specifications to the methods in the director class // Get any Java exception classes in the throws typemap ParmList *throw_parm_list = NULL; diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index b9eb840f6..b14dddd22 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -1404,7 +1404,7 @@ MODULA3(): // Get any Modula 3 exception classes in the throws typemap ParmList *throw_parm_list = NULL; - if ((throw_parm_list = Getattr(n, "throws"))) { + if ((throw_parm_list = Getattr(n, "catchlist"))) { Swig_typemap_attach_parms("throws", throw_parm_list, f); Parm *p; for (p = throw_parm_list; p; p = nextSibling(p)) {