diff options
Diffstat (limited to 'Examples/test-suite/java_throws.i')
-rw-r--r-- | Examples/test-suite/java_throws.i | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/Examples/test-suite/java_throws.i b/Examples/test-suite/java_throws.i index 48a0eeabc..6cd47b448 100644 --- a/Examples/test-suite/java_throws.i +++ b/Examples/test-suite/java_throws.i @@ -2,6 +2,12 @@ %module java_throws +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW1(T1) throw(T1) +%{ +#define TESTCASE_THROW1(T1) +%} + // Exceptions are chosen at random but are ones which have to have a try catch block to compile %typemap(in, throws=" ClassNotFoundException") int num { $1 = (int)$input; @@ -39,13 +45,7 @@ short full_of_exceptions(int num) { return $null; } %inline %{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -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 +bool throw_spec_function(int value) TESTCASE_THROW1(int) { throw (int)0; } %} %catches(int) catches_function(int value); @@ -126,6 +126,24 @@ JAVAEXCEPTION(FeatureTest::staticMethod) }; %} +%include <swiginterface.i> +%interface_impl(InterfaceTest); +JAVAEXCEPTION(imethod) + +%inline %{ + struct InterfaceTest { + virtual void imethod(bool raise) = 0; + virtual ~InterfaceTest() {} + }; + + struct InterfaceTestImpl : InterfaceTest { + void imethod(bool raise) { + if (raise) + throw MyException("raise message"); + } + }; +%} + // Mixing except feature and typemaps when both generate a class for the throws clause %typemap(in, throws="ClassNotFoundException") int both { $1 = (int)$input; @@ -165,6 +183,7 @@ try { // Need to handle the checked exception in NoExceptTest.delete() %typemap(javafinalize) SWIGTYPE %{ + @SuppressWarnings("deprecation") protected void finalize() { try { delete(); |