@@ -211,10 +211,6 @@ public static String bar(final String... s) {
211211 return "bar(String...)" ;
212212 }
213213
214- public static String intStringVarArg (final int intArg , final String ... args ) {
215- return "int, String..." ;
216- }
217-
218214 // This method is overloaded for the wrapper class for every numeric primitive type, plus the common
219215 // supertype Number
220216 public static String numOverload (final Byte ... args ) {
@@ -249,6 +245,10 @@ public static void oneParameterStatic(final String s) {
249245 // empty
250246 }
251247
248+ public static String staticIntStringVarArg (final int intArg , final String ... args ) {
249+ return "static int, String..." ;
250+ }
251+
252252 public static String varOverload (final Boolean ... args ) {
253253 return "Boolean..." ;
254254 }
@@ -374,6 +374,10 @@ public String foo(final String... s) {
374374 return "foo(String...)" ;
375375 }
376376
377+ public String intStringVarArg (final int intArg , final String ... args ) {
378+ return "int, String..." ;
379+ }
380+
377381 public void oneParameter (final String s ) {
378382 // empty
379383 }
@@ -1060,18 +1064,20 @@ void testInvokeMethod() throws Exception {
10601064 assertThrows (NoSuchMethodException .class , () -> MethodUtils .invokeMethod (testBean , null , 1 , 2 ));
10611065 }
10621066
1063- @ Test
1064- void testInvokeMethod_VarArgsNotUniqueResolvable () throws Exception {
1065- assertEquals ("Boolean..." , MethodUtils .invokeMethod (testBean , "varOverload" , new Object [] { null }));
1066- assertEquals ("Object..." , MethodUtils .invokeMethod (testBean , "varOverload" , (Object []) null ));
1067- }
1068-
10691067 @ Test
10701068 void testInvokeMethod_VarArgsWithNullValues () throws Exception {
10711069 assertEquals ("String..." , MethodUtils .invokeMethod (testBean , "varOverload" , "a" , null , "c" ));
10721070 assertEquals ("String..." , MethodUtils .invokeMethod (testBean , "varOverload" , "a" , "b" , null ));
10731071 }
10741072
1073+ @ Test
1074+ void testInvokeMethod1PlusVarArgs () throws Exception {
1075+ // assertEquals("int, String...", MethodUtils.invokeMethod(testBean, "intStringVarArg", 1));
1076+ assertEquals ("int, String..." , MethodUtils .invokeMethod (testBean , "intStringVarArg" , 1 , "s" ));
1077+ assertEquals ("int, String..." , MethodUtils .invokeMethod (testBean , "intStringVarArg" , 1 , "s1" , "s2" ));
1078+ assertThrows (NoSuchMethodException .class , () -> MethodUtils .invokeMethod (testBean , "intStringVarArg" , 1 , "s1" , 5 ));
1079+ }
1080+
10751081 @ Test
10761082 void testInvokeMethodForceAccessNoArgs () throws Exception {
10771083 assertEquals ("privateStringStuff()" , MethodUtils .invokeMethod (testBean , true , "privateStringStuff" ));
@@ -1087,6 +1093,12 @@ void testInvokeMethodForceAccessWithArgs() throws Exception {
10871093 assertNullPointerException (() -> MethodUtils .invokeMethod (testBean , true , null , "Hi There" ));
10881094 }
10891095
1096+ @ Test
1097+ void testInvokeMethodVarArgsNotUniqueResolvable () throws Exception {
1098+ assertEquals ("Boolean..." , MethodUtils .invokeMethod (testBean , "varOverload" , new Object [] { null }));
1099+ assertEquals ("Object..." , MethodUtils .invokeMethod (testBean , "varOverload" , (Object []) null ));
1100+ }
1101+
10901102 @ Test
10911103 void testInvokeMethodVarArgsUnboxingBooleanArray () throws Exception {
10921104 final TestBean testBean = new TestBean ();
@@ -1153,6 +1165,7 @@ void testInvokeMethodVarArgsUnboxingShortArray() throws Exception {
11531165
11541166 @ Test
11551167 void testInvokeStaticMethod () throws Exception {
1168+ assertEquals ("bar()" , MethodUtils .invokeStaticMethod (TestBean .class , "bar" ));
11561169 assertEquals ("bar()" , MethodUtils .invokeStaticMethod (TestBean .class , "bar" , (Object []) ArrayUtils .EMPTY_CLASS_ARRAY ));
11571170 assertEquals ("bar()" , MethodUtils .invokeStaticMethod (TestBean .class , "bar" , (Object []) null ));
11581171 assertEquals ("bar()" , MethodUtils .invokeStaticMethod (TestBean .class , "bar" , null , null ));
@@ -1176,6 +1189,14 @@ void testInvokeStaticMethod() throws Exception {
11761189 assertThrows (NoSuchMethodException .class , () -> MethodUtils .invokeStaticMethod (TestBean .class , "does_not_exist" ));
11771190 }
11781191
1192+ @ Test
1193+ void testInvokeStaticMethod1PlusVarArgs () throws Exception {
1194+ // assertEquals("static int, String...", MethodUtils.invokeStaticMethod(TestBean.class, "staticIntStringVarArg", 1));
1195+ assertEquals ("static int, String..." , MethodUtils .invokeStaticMethod (TestBean .class , "staticIntStringVarArg" , 1 , "s" ));
1196+ assertEquals ("static int, String..." , MethodUtils .invokeStaticMethod (TestBean .class , "staticIntStringVarArg" , 1 , "s1" , "s2" ));
1197+ assertThrows (NoSuchMethodException .class , () -> MethodUtils .invokeStaticMethod (TestBean .class , "staticIntStringVarArg" , 1 , "s1" , 5 ));
1198+ }
1199+
11791200 @ Test
11801201 void testNullArgument () {
11811202 expectMatchingAccessibleMethodParameterTypes (TestBean .class , "oneParameter" , singletonArray (null ), singletonArray (String .class ));
0 commit comments