Add missing Java throws clause for interfaces when using the %interface family of macros.
Fixes #1156.
This commit is contained in:
parent
c44adff7b9
commit
49af1907b8
4 changed files with 48 additions and 2 deletions
|
|
@ -93,6 +93,28 @@ public class java_throws_runme {
|
|||
if (!pass)
|
||||
throw new RuntimeException("Test 6 failed");
|
||||
|
||||
// Interface function
|
||||
pass = false;
|
||||
try {
|
||||
InterfaceTestImpl iti = new InterfaceTestImpl();
|
||||
iti.imethod(true);
|
||||
}
|
||||
catch (MyException e) { pass = true; }
|
||||
|
||||
if (!pass)
|
||||
throw new RuntimeException("Test interface 1 failed");
|
||||
|
||||
pass = false;
|
||||
try {
|
||||
InterfaceTestImpl iti = new InterfaceTestImpl();
|
||||
iti.imethod(false);
|
||||
pass = true;
|
||||
}
|
||||
catch (MyException e) { pass = false; }
|
||||
|
||||
if (!pass)
|
||||
throw new RuntimeException("Test interface 2 failed");
|
||||
|
||||
// Global function
|
||||
pass = false;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -135,6 +135,23 @@ JAVAEXCEPTION(FeatureTest::staticMethod)
|
|||
};
|
||||
%}
|
||||
|
||||
%include <swiginterface.i>
|
||||
%interface_impl(InterfaceTest);
|
||||
JAVAEXCEPTION(imethod)
|
||||
|
||||
%inline %{
|
||||
struct InterfaceTest {
|
||||
virtual void imethod(bool raise) = 0;
|
||||
};
|
||||
|
||||
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue