mirror of https://github.com/swig/swig
Java compiler lint warnings fixes in test code
Fixes: [cast] redundant cast [rawtypes] found raw type [serial] serializable class has no definition of serialVersionUID Also suppress warning: auxiliary class TargetLanguageBase in ./inherit_target_language.java should not be accessed from outside its own source file
This commit is contained in:
parent
a16e3cb8ce
commit
c2ad64d0a8
|
@ -46,7 +46,7 @@ public class runme {
|
|||
System.out.println( "ucvar =" + example.getUcvar() );
|
||||
System.out.println( "fvar =" + example.getFvar() );
|
||||
System.out.println( "dvar =" + example.getDvar() );
|
||||
System.out.println( "cvar =" + (char)example.getCvar() );
|
||||
System.out.println( "cvar =" + example.getCvar() );
|
||||
System.out.println( "strvar =" + example.getStrvar() );
|
||||
System.out.println( "cstrvar =" + example.getCstrvar() );
|
||||
System.out.println( "iptrvar =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(example.getIptrvar())) );
|
||||
|
@ -62,7 +62,7 @@ public class runme {
|
|||
|
||||
System.out.println( " Trying to set 'path'" );
|
||||
try {
|
||||
Method m = example.class.getDeclaredMethod("setPath", new Class[] {String.class});
|
||||
Method m = example.class.getDeclaredMethod("setPath", String.class);
|
||||
m.invoke(example.class, new Object[] {"Whoa!"} );
|
||||
System.out.println( "Hey, what's going on?!?! This shouldn't work" );
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class runme {
|
|||
|
||||
System.out.println( " Trying to set 'status'" );
|
||||
try {
|
||||
Method m = example.class.getDeclaredMethod("setStatus", new Class[] {Integer.class});
|
||||
Method m = example.class.getDeclaredMethod("setStatus", int.class);
|
||||
m.invoke(example.class, new Object[] {Integer.valueOf(0)} );
|
||||
System.out.println( "Hey, what's going on?!?! This shouldn't work" );
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ public class CommentParser implements Doclet {
|
|||
|
||||
while (it.hasNext()) {
|
||||
|
||||
Entry<String, String> e = (Entry<String, String>) it.next();
|
||||
Entry<String, String> e = it.next();
|
||||
String actualStr = e.getValue();
|
||||
String wantedStr = wantedComments.get(e.getKey());
|
||||
// this may be weird, but I don't know any more effective solution
|
||||
|
@ -222,7 +222,7 @@ public class CommentParser implements Doclet {
|
|||
|
||||
while (it.hasNext()) {
|
||||
|
||||
Entry<String, String> e = (Entry<String, String>) it.next();
|
||||
Entry<String, String> e = it.next();
|
||||
String commentText = e.getValue();
|
||||
commentText = commentText.replace("\\", "\\\\");
|
||||
commentText = commentText.replace("\"", "\\\"");
|
||||
|
|
|
@ -82,6 +82,9 @@ SWIGOPT += $(JAVA_PACKAGEOPT)
|
|||
# Ensure testsuite remains free from SWIG warnings.
|
||||
SWIGOPT += -Werror
|
||||
|
||||
# Suppress -Xlint
|
||||
inherit_target_language.%: JAVAC_OPTIONS=
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
cpp17_nspace_nested_namespaces.%: JAVA_PACKAGE = $*Package
|
||||
director_nspace.%: JAVA_PACKAGE = $*Package
|
||||
|
|
|
@ -12,45 +12,43 @@ public class argcargvtest_runme {
|
|||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
argcargvtest test = new argcargvtest();
|
||||
|
||||
String[] largs = {"hi", "hola", "hello"};
|
||||
if (test.mainc(largs) != 3)
|
||||
if (argcargvtest.mainc(largs) != 3)
|
||||
throw new RuntimeException("bad main typemap");
|
||||
|
||||
String[] targs = {"hi", "hola"};
|
||||
if (!test.mainv(targs, 0).equals("hi"))
|
||||
if (!argcargvtest.mainv(targs, 0).equals("hi"))
|
||||
throw new RuntimeException("bad main typemap");
|
||||
if (!test.mainv(targs, 1).equals("hola"))
|
||||
if (!argcargvtest.mainv(targs, 1).equals("hola"))
|
||||
throw new RuntimeException("bad main typemap");
|
||||
if (!test.mainv(targs, 2).equals("<<NULL>>"))
|
||||
if (!argcargvtest.mainv(targs, 2).equals("<<NULL>>"))
|
||||
throw new RuntimeException("bad main typemap");
|
||||
|
||||
// For dynamically typed languages we test this throws an exception or similar
|
||||
// at runtime, but for Java this doesn't even compile (but we can't easily
|
||||
// test for that here).
|
||||
// test.mainv("hello", 1);
|
||||
// argcargvtest.mainv("hello", 1);
|
||||
|
||||
test.initializeApp(largs);
|
||||
argcargvtest.initializeApp(largs);
|
||||
|
||||
// Check that an empty array works.
|
||||
String[] empty_args = {};
|
||||
if (test.mainc(empty_args) != 0)
|
||||
if (argcargvtest.mainc(empty_args) != 0)
|
||||
throw new RuntimeException("bad main typemap");
|
||||
if (!test.mainv(empty_args, 0).equals("<<NULL>>"))
|
||||
if (!argcargvtest.mainv(empty_args, 0).equals("<<NULL>>"))
|
||||
throw new RuntimeException("bad main typemap");
|
||||
|
||||
// Check that empty strings are handled.
|
||||
String[] empty_string = {"hello", "", "world"};
|
||||
if (test.mainc(empty_string) != 3)
|
||||
if (argcargvtest.mainc(empty_string) != 3)
|
||||
throw new RuntimeException("bad main typemap");
|
||||
if (!test.mainv(empty_string, 0).equals("hello"))
|
||||
if (!argcargvtest.mainv(empty_string, 0).equals("hello"))
|
||||
throw new RuntimeException("bad main typemap");
|
||||
if (!test.mainv(empty_string, 1).equals(""))
|
||||
if (!argcargvtest.mainv(empty_string, 1).equals(""))
|
||||
throw new RuntimeException("bad main typemap");
|
||||
if (!test.mainv(empty_string, 2).equals("world"))
|
||||
if (!argcargvtest.mainv(empty_string, 2).equals("world"))
|
||||
throw new RuntimeException("bad main typemap");
|
||||
if (!test.mainv(empty_string, 3).equals("<<NULL>>"))
|
||||
if (!argcargvtest.mainv(empty_string, 3).equals("<<NULL>>"))
|
||||
throw new RuntimeException("bad main typemap");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,9 +24,9 @@ public class cpp11_constexpr_runme {
|
|||
check(cpp11_constexpr.DDD(), 40);
|
||||
|
||||
ConstExpressions ce = new ConstExpressions(0);
|
||||
check(ce.JJJ, 100);
|
||||
check(ce.KKK, 200);
|
||||
check(ce.LLL, 300);
|
||||
check(ConstExpressions.JJJ, 100);
|
||||
check(ConstExpressions.KKK, 200);
|
||||
check(ConstExpressions.LLL, 300);
|
||||
check(ce.MMM(), 400);
|
||||
check(ce.NNN(), 500);
|
||||
}
|
||||
|
|
|
@ -156,8 +156,8 @@ public class cpp11_director_using_constructor_runme {
|
|||
// Introspection to make sure these are actually generated in the derived class
|
||||
try {
|
||||
TemplateConstructor1Derived.class.getDeclaredMethod("normal_method", (java.lang.Class[])null);
|
||||
TemplateConstructor1Derived.class.getDeclaredMethod("template_method", new java.lang.Class[]{String.class, String.class});
|
||||
TemplateConstructor1Derived.class.getDeclaredMethod("template_method", new java.lang.Class[]{int.class, String.class});
|
||||
TemplateConstructor1Derived.class.getDeclaredMethod("template_method", String.class, String.class);
|
||||
TemplateConstructor1Derived.class.getDeclaredMethod("template_method", int.class, String.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class cpp11_std_array_runme {
|
|||
|
||||
// out of range errors
|
||||
try {
|
||||
ai.set((int)ai.size(), 0);
|
||||
ai.set(ai.size(), 0);
|
||||
throw new RuntimeException("Out of range exception not caught");
|
||||
} catch(IndexOutOfBoundsException e) {
|
||||
}
|
||||
|
|
|
@ -155,8 +155,8 @@ public class cpp11_using_constructor_runme {
|
|||
// Introspection to make sure these are actually generated in the derived class
|
||||
try {
|
||||
TemplateConstructor1Derived.class.getDeclaredMethod("normal_method", (java.lang.Class[])null);
|
||||
TemplateConstructor1Derived.class.getDeclaredMethod("template_method", new java.lang.Class[]{String.class, String.class});
|
||||
TemplateConstructor1Derived.class.getDeclaredMethod("template_method", new java.lang.Class[]{int.class, String.class});
|
||||
TemplateConstructor1Derived.class.getDeclaredMethod("template_method", String.class, String.class);
|
||||
TemplateConstructor1Derived.class.getDeclaredMethod("template_method", int.class, String.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ public class director_classes_runme {
|
|||
}
|
||||
|
||||
// Same as Class.getSimpleName() which is not present in all jdks
|
||||
static String getSimpleName(Class klass) {
|
||||
static String getSimpleName(Class<?> klass) {
|
||||
String fullName = klass.getName();
|
||||
Package packag = klass.getPackage();
|
||||
String simpleName = null;
|
||||
|
|
|
@ -28,8 +28,8 @@ public class java_constants_runme {
|
|||
}
|
||||
|
||||
// Check the altered constants interface access modifier
|
||||
Class[] cls = java_constants.class.getInterfaces();
|
||||
Class constantsInterface = cls[0];
|
||||
Class<?>[] cls = java_constants.class.getInterfaces();
|
||||
Class<?> constantsInterface = cls[0];
|
||||
int modifiers = constantsInterface.getModifiers();
|
||||
boolean isDefaultAccessModifier = !(Modifier.isPublic(modifiers) || Modifier.isProtected(modifiers) || Modifier.isPrivate(modifiers));
|
||||
if (!isDefaultAccessModifier)
|
||||
|
|
|
@ -18,6 +18,7 @@ class java_director_exception_feature_nspace_Consts {
|
|||
|
||||
// an exception not mentioned or wrapped by the swig interface,
|
||||
// to reconstruct using generic DirectorException handling
|
||||
@SuppressWarnings("serial")
|
||||
class java_director_exception_feature_nspace_NewCheckedException extends Exception {
|
||||
public java_director_exception_feature_nspace_NewCheckedException(String s) {
|
||||
super(s);
|
||||
|
@ -26,6 +27,7 @@ class java_director_exception_feature_nspace_NewCheckedException extends Excepti
|
|||
|
||||
// an exception not mentioned or wrapped by the swig interface,
|
||||
// to reconstruct using generic DirectorException handling
|
||||
@SuppressWarnings("serial")
|
||||
class java_director_exception_feature_nspace_NewUncheckedException extends RuntimeException {
|
||||
public java_director_exception_feature_nspace_NewUncheckedException(String s) {
|
||||
super(s);
|
||||
|
@ -34,6 +36,7 @@ class java_director_exception_feature_nspace_NewUncheckedException extends Runti
|
|||
|
||||
// an exception not constructible from a string,
|
||||
// to test DirectorException fallback reconstruction
|
||||
@SuppressWarnings("serial")
|
||||
class java_director_exception_feature_nspace_UnconstructibleException extends Exception {
|
||||
private int extrastate;
|
||||
public java_director_exception_feature_nspace_UnconstructibleException(int a, String s) {
|
||||
|
|
|
@ -19,6 +19,7 @@ class java_director_exception_feature_Consts {
|
|||
|
||||
// an exception not mentioned or wrapped by the swig interface,
|
||||
// to reconstruct using generic DirectorException handling
|
||||
@SuppressWarnings("serial")
|
||||
class NewCheckedException extends Exception {
|
||||
public NewCheckedException(String s) {
|
||||
super(s);
|
||||
|
@ -27,6 +28,7 @@ class NewCheckedException extends Exception {
|
|||
|
||||
// an exception not mentioned or wrapped by the swig interface,
|
||||
// to reconstruct using generic DirectorException handling
|
||||
@SuppressWarnings("serial")
|
||||
class NewUncheckedException extends RuntimeException {
|
||||
public NewUncheckedException(String s) {
|
||||
super(s);
|
||||
|
@ -35,6 +37,7 @@ class NewUncheckedException extends RuntimeException {
|
|||
|
||||
// an exception not constructable from a string,
|
||||
// to test DirectorException fallback reconstruction
|
||||
@SuppressWarnings("serial")
|
||||
class UnconstructableException extends Exception {
|
||||
private int extrastate;
|
||||
public UnconstructableException(int a, String s) {
|
||||
|
|
|
@ -609,7 +609,7 @@ public class li_boost_shared_ptr_runme {
|
|||
throw new RuntimeException("verify value failed. Expected: " + expected + " Got: " + got);
|
||||
}
|
||||
private void verifyCount(int expected, Klass k) {
|
||||
int got = (int)li_boost_shared_ptr.use_count(k);
|
||||
int got = li_boost_shared_ptr.use_count(k);
|
||||
if (expected != got)
|
||||
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ public class long_long_runme {
|
|||
|
||||
boolean failed = false;
|
||||
for (int i=0; i<bigIntegers.size(); ++i) {
|
||||
BigInteger bi = (BigInteger)bigIntegers.get(i);
|
||||
BigInteger bi = bigIntegers.get(i);
|
||||
long longReturn = long_long.UnsignedToSigned(bi);
|
||||
if (bi.longValue() != longReturn) {
|
||||
System.err.println("Conversion to long failed, in:" + bi + " out:" + longReturn);
|
||||
|
|
|
@ -12,11 +12,11 @@ public class multiple_inheritance_interfaces_runme {
|
|||
}
|
||||
}
|
||||
|
||||
private static void checkBaseAndInterfaces(Class cls, boolean interfaceExpected, String base, String[] interfaces) {
|
||||
private static void checkBaseAndInterfaces(Class<?> cls, boolean interfaceExpected, String base, String[] interfaces) {
|
||||
String[] expectedInterfaces = new String[interfaces.length];
|
||||
for (int i=0; i<interfaces.length; ++i)
|
||||
expectedInterfaces[i] = "interface multiple_inheritance_interfaces." + interfaces[i];
|
||||
Class[] actualInterfaces = cls.getInterfaces();
|
||||
Class<?>[] actualInterfaces = cls.getInterfaces();
|
||||
String expectedInterfacesString = Arrays.toString(expectedInterfaces);
|
||||
String actualInterfacesString = Arrays.toString(actualInterfaces);
|
||||
if (!expectedInterfacesString.equals(actualInterfacesString))
|
||||
|
|
|
@ -16,7 +16,7 @@ public class nested_inheritance_interface_runme {
|
|||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
Class[] BNInterfaces = B.N.class.getInterfaces();
|
||||
Class<?>[] BNInterfaces = B.N.class.getInterfaces();
|
||||
String expectedInterfacesString = "[interface nested_inheritance_interface.IASwigInterface]";
|
||||
String actualInterfacesString = Arrays.toString(BNInterfaces);
|
||||
if (!expectedInterfacesString.equals(actualInterfacesString))
|
||||
|
|
|
@ -134,6 +134,9 @@
|
|||
|
||||
%feature("director") Foo;
|
||||
|
||||
%typemap(javaclassmodifiers) MyNS::Exception1, MyNS::Exception2, MyNS::Unexpected %{@SuppressWarnings("serial")
|
||||
public class%}
|
||||
|
||||
// Rename exceptions on java side to make translation of exceptions more clear
|
||||
%rename(MyJavaException1) MyNS::Exception1;
|
||||
%rename(MyJavaException2) MyNS::Exception2;
|
||||
|
|
|
@ -141,6 +141,9 @@
|
|||
|
||||
%feature("director") Foo;
|
||||
|
||||
%typemap(javaclassmodifiers) MyNS::Exception1, MyNS::Exception2, MyNS::Unexpected %{@SuppressWarnings("serial")
|
||||
public class%}
|
||||
|
||||
// Rename exceptions on java side to make translation of exceptions more clear
|
||||
%rename(MyJavaException1) MyNS::Exception1;
|
||||
%rename(MyJavaException2) MyNS::Exception2;
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
$result = bar::Ptr< bar::Baz >(*( bar::Baz**)&$input);
|
||||
}
|
||||
%typemap(javadirectorin) bar::Ptr< bar::Baz > %{
|
||||
((long)$jniinput == 0) ? null : new $typemap(jstype, bar::Baz)($jniinput, false)
|
||||
($jniinput == 0) ? null : new $typemap(jstype, bar::Baz)($jniinput, false)
|
||||
%}
|
||||
%typemap(javadirectorout) bar::Ptr< bar::Baz > "$typemap(jstype, bar::Baz).getCPtr($javacall)"
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
%include "std_vector.i"
|
||||
|
||||
%define VECTOR_DOUBLE_JAVAIN_POST
|
||||
" int count$javainput = (int)d$javainput.size();
|
||||
" int count$javainput = d$javainput.size();
|
||||
$javainput = new double[count$javainput];
|
||||
for (int i=0; i<count$javainput; ++i) {
|
||||
$javainput[i] = d$javainput.get(i);
|
||||
|
@ -27,7 +27,7 @@
|
|||
"$javaclassname.getCPtr(d$javainput)"
|
||||
|
||||
// post only in javain typemap
|
||||
%typemap(javain, post=" int size = (int)$javainput.size();\n for (int i=0; i<size; ++i) {\n $javainput.set(i, $javainput.get(i)/100);\n }") std::vector<double> &vpost
|
||||
%typemap(javain, post=" int size = $javainput.size();\n for (int i=0; i<size; ++i) {\n $javainput.set(i, $javainput.get(i)/100);\n }") std::vector<double> &vpost
|
||||
"$javaclassname.getCPtr($javainput)"
|
||||
|
||||
%inline %{
|
||||
|
|
Loading…
Reference in New Issue