diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 52ae78563..1bd4b0261 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -46,18 +46,9 @@ JAVA_PACKAGE = $* JAVA_PACKAGEOPT = -package $(JAVA_PACKAGE) SWIGOPT += $(JAVA_PACKAGEOPT) -RUNME_CLASSPATH = -classpath . -ifeq (Cygwin,$(shell uname -o 2>/dev/null)) -SEP=; -else -SEP=: -endif - # Custom tests - tests with additional commandline options java_nspacewithoutpackage.%: JAVA_PACKAGEOPT = -java_director_exception_feature_nspace.%: JAVA_PACKAGEOPT = -java_director_exception_feature_nspace.%: RUNME_CLASSPATH = -classpath .$(SEP)./java_director_exception_feature_nspace - +java_director_exception_feature_nspace.%: JAVA_PACKAGE = $*Package nspace.%: JAVA_PACKAGE = $*Package nspace_extend.%: JAVA_PACKAGE = $*Package director_nspace.%: JAVA_PACKAGE = $*Package @@ -96,8 +87,8 @@ setup = \ run_testcase = \ cd $(JAVA_PACKAGE) && $(COMPILETOOL) $(JAVAC) -classpath . `find . -name "*.java"` && cd .. && \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - $(COMPILETOOL) $(JAVAC) $(RUNME_CLASSPATH) -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ - env LD_LIBRARY_PATH="$(JAVA_PACKAGE):$$LD_LIBRARY_PATH" PATH="$(JAVA_PACKAGE):$$PATH" SHLIB_PATH="$(JAVA_PACKAGE):$$SHLIB_PATH" DYLD_LIBRARY_PATH="$(JAVA_PACKAGE):$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) $(JAVAFLAGS) $(RUNME_CLASSPATH) $*_runme; \ + $(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ + env LD_LIBRARY_PATH="$(JAVA_PACKAGE):$$LD_LIBRARY_PATH" PATH="$(JAVA_PACKAGE):$$PATH" SHLIB_PATH="$(JAVA_PACKAGE):$$SHLIB_PATH" DYLD_LIBRARY_PATH="$(JAVA_PACKAGE):$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) $(JAVAFLAGS) -classpath . $*_runme; \ fi # Clean: remove testcase directories diff --git a/Examples/test-suite/java/java_director_exception_feature_nspace_runme.java b/Examples/test-suite/java/java_director_exception_feature_nspace_runme.java index 0cde36953..ea7da5c1a 100644 --- a/Examples/test-suite/java/java_director_exception_feature_nspace_runme.java +++ b/Examples/test-suite/java/java_director_exception_feature_nspace_runme.java @@ -1,5 +1,5 @@ -import MyNS.*; -import MyNS_JNI.*; +import java_director_exception_feature_nspacePackage.*; +import java_director_exception_feature_nspacePackage.MyNS.*; class java_director_exception_feature_nspace_Consts { public static final String PINGEXCP1 = "Ping MyJavaException1"; // should get translated through an int on ping @@ -18,25 +18,25 @@ class java_director_exception_feature_nspace_Consts { // an exception not mentioned or wrapped by the swig interface, // to reconstruct using generic DirectorException handling -class NewCheckedException extends Exception { - public NewCheckedException(String s) { +class java_director_exception_feature_nspace_NewCheckedException extends Exception { + public java_director_exception_feature_nspace_NewCheckedException(String s) { super(s); } } // an exception not mentioned or wrapped by the swig interface, // to reconstruct using generic DirectorException handling -class NewUncheckedException extends RuntimeException { - public NewUncheckedException(String s) { +class java_director_exception_feature_nspace_NewUncheckedException extends RuntimeException { + public java_director_exception_feature_nspace_NewUncheckedException(String s) { super(s); } } -// an exception not constructable from a string, +// an exception not constructible from a string, // to test DirectorException fallback reconstruction -class UnconstructableException extends Exception { +class java_director_exception_feature_nspace_UnconstructibleException extends Exception { private int extrastate; - public UnconstructableException(int a, String s) { + public java_director_exception_feature_nspace_UnconstructibleException(int a, String s) { super(s); extrastate = a; } @@ -62,15 +62,15 @@ class java_director_exception_feature_nspace_MyFooDirectorImpl extends Foo { } @Override - public String genericpong(int excp) throws MyJavaException1, NewCheckedException, UnconstructableException { + public String genericpong(int excp) throws MyJavaException1, java_director_exception_feature_nspace_NewCheckedException, java_director_exception_feature_nspace_UnconstructibleException { if (excp == 1) throw new MyJavaException1(java_director_exception_feature_nspace_Consts.GENERICPONGEXCP1); if (excp == 2) - throw new NewCheckedException(java_director_exception_feature_nspace_Consts.GENERICPONGEXCP2); + throw new java_director_exception_feature_nspace_NewCheckedException(java_director_exception_feature_nspace_Consts.GENERICPONGEXCP2); if (excp == 3) - throw new NewUncheckedException(java_director_exception_feature_nspace_Consts.GENERICPONGEXCP3); + throw new java_director_exception_feature_nspace_NewUncheckedException(java_director_exception_feature_nspace_Consts.GENERICPONGEXCP3); if (excp == 4) - throw new UnconstructableException(1, java_director_exception_feature_nspace_Consts.GENERICPONGEXCP4); + throw new java_director_exception_feature_nspace_UnconstructibleException(1, java_director_exception_feature_nspace_Consts.GENERICPONGEXCP4); return "GenericPong director returned"; } } @@ -128,11 +128,11 @@ public class java_director_exception_feature_nspace_runme { failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP1.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); } try { b.genericpong(2); fail("No exception thrown in genericpong(2)");} - catch (NewCheckedException e) { + catch (java_director_exception_feature_nspace_NewCheckedException e) { failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP2.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); } try { b.genericpong(3); fail("No exception thrown in genericpong(3)");} - catch (NewUncheckedException e) { + catch (java_director_exception_feature_nspace_NewUncheckedException e) { failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP3.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); } try { b.genericpong(4); fail("No exception thrown in genericpong(4)");} diff --git a/Examples/test-suite/java_director_exception_feature.i b/Examples/test-suite/java_director_exception_feature.i index fc1af7a96..1552454dc 100644 --- a/Examples/test-suite/java_director_exception_feature.i +++ b/Examples/test-suite/java_director_exception_feature.i @@ -138,26 +138,26 @@ %feature("director") Foo; // Rename exceptions on java side to make translation of exceptions more clear -%rename(MyJavaException1,fullname=1) MyNS::Exception1; -%rename(MyJavaException2,fullname=1) MyNS::Exception2; -%rename(MyJavaUnexpected,fullname=1) MyNS::Unexpected; +%rename(MyJavaException1) MyNS::Exception1; +%rename(MyJavaException2) MyNS::Exception2; +%rename(MyJavaUnexpected) MyNS::Unexpected; %typemap(javabase) ::MyNS::Exception1,::MyNS::Exception2,::MyNS::Unexpected "java.lang.Exception"; -%rename(getMessage) what(); // Rename all what() methods +%rename(getMessage) what() const; // Rename all what() methods namespace MyNS { struct Exception1 { Exception1(const std::string& what); - const char * what(); + const char * what() const; }; struct Exception2 { Exception2(const std::string& what); - const char * what(); + const char * what() const; }; struct Unexpected { Unexpected(const std::string& what); - const char * what(); + const char * what() const; }; } diff --git a/Examples/test-suite/java_director_exception_feature_nspace.i b/Examples/test-suite/java_director_exception_feature_nspace.i index 1f3d97ad3..aea362905 100644 --- a/Examples/test-suite/java_director_exception_feature_nspace.i +++ b/Examples/test-suite/java_director_exception_feature_nspace.i @@ -4,9 +4,12 @@ %nspace; // turn namespace feature on for everything. -// When using namespaces with no -package, must put JNI classes into a namespace -%pragma(java) jniclasspackage=%{MyNS_JNI%} -%warnfilter(SWIGWARN_JAVA_NSPACE_WITHOUT_PACKAGE); +#define PACKAGEDOT "java_director_exception_feature_nspacePackage." +#define PACKAGESLASH "java_director_exception_feature_nspacePackage/" +%{ +#define PACKAGEDOT "java_director_exception_feature_nspacePackage." +#define PACKAGESLASH "java_director_exception_feature_nspacePackage/" +%} %{ #if defined(_MSC_VER) @@ -83,24 +86,24 @@ // $javaclassname or $packagepath ("java_director_exception_feature" here) // throws typemaps for c++->java exception conversions -%typemap(throws,throws="MyNS.MyJavaException1") MyNS::Exception1 %{ - jclass excpcls = jenv->FindClass("MyNS/MyJavaException1"); +%typemap(throws,throws=PACKAGEDOT"MyNS.MyJavaException1") MyNS::Exception1 %{ + jclass excpcls = jenv->FindClass(PACKAGESLASH"MyNS/MyJavaException1"); if (excpcls) { jenv->ThrowNew(excpcls, $1.what()); } return $null; %} -%typemap(throws,throws="MyNS.MyJavaException1") int %{ - jclass excpcls = jenv->FindClass("MyNS/MyJavaException1"); +%typemap(throws,throws=PACKAGEDOT"MyNS.MyJavaException1") int %{ + jclass excpcls = jenv->FindClass(PACKAGESLASH"MyNS/MyJavaException1"); if (excpcls) { jenv->ThrowNew(excpcls, "Threw some integer"); } return $null; %} -%typemap(throws,throws="MyNS.MyJavaException2") MyNS::Exception2 %{ - jclass excpcls = jenv->FindClass("MyNS/MyJavaException2"); +%typemap(throws,throws=PACKAGEDOT"MyNS.MyJavaException2") MyNS::Exception2 %{ + jclass excpcls = jenv->FindClass(PACKAGESLASH"MyNS/MyJavaException2"); if (excpcls) { jenv->ThrowNew(excpcls, $1.what()); } @@ -108,8 +111,8 @@ %} -%typemap(throws,throws="MyNS.MyJavaUnexpected") MyNS::Unexpected %{ - jclass excpcls = jenv->FindClass("MyNS/MyJavaUnexpected"); +%typemap(throws,throws=PACKAGEDOT"MyNS.MyJavaUnexpected") MyNS::Unexpected %{ + jclass excpcls = jenv->FindClass(PACKAGESLASH"MyNS/MyJavaUnexpected"); if (excpcls) { jenv->ThrowNew(excpcls, $1.what()); } @@ -143,26 +146,26 @@ %feature("director") Foo; // Rename exceptions on java side to make translation of exceptions more clear -%rename(MyJavaException1,fullname=1) MyNS::Exception1; -%rename(MyJavaException2,fullname=1) MyNS::Exception2; -%rename(MyJavaUnexpected,fullname=1) MyNS::Unexpected; +%rename(MyJavaException1) MyNS::Exception1; +%rename(MyJavaException2) MyNS::Exception2; +%rename(MyJavaUnexpected) MyNS::Unexpected; %typemap(javabase) ::MyNS::Exception1,::MyNS::Exception2,::MyNS::Unexpected "java.lang.Exception"; -%rename(getMessage) what(); // Rename all what() methods +%rename(getMessage) what() const; // Rename all what() methods namespace MyNS { struct Exception1 { Exception1(const std::string& what); - const char * what(); + const char * what() const; }; struct Exception2 { Exception2(const std::string& what); - const char * what(); + const char * what() const; }; struct Unexpected { Unexpected(const std::string& what); - const char * what(); + const char * what() const; }; }