Index: modules/beans/src/main/java/java/beans/Statement.java =================================================================== --- modules/beans/src/main/java/java/beans/Statement.java (revision 420769) +++ modules/beans/src/main/java/java/beans/Statement.java (working copy) @@ -184,25 +184,29 @@ } private Method findArrayMethod() throws NoSuchMethodException { + // the code below reproduces exact RI exception throwing behavior if (!methodName.equals("set") && !methodName.equals("get")) { throw new NoSuchMethodException("Unknown method name for array"); + } else if (arguments.length > 0 && + arguments[0].getClass() != Integer.class) { + throw new ClassCastException( + "First parameter in array getter(setter) is not of " + + "Integer type"); } else if (methodName.equals("get") && (arguments.length != 1)) { - throw new NoSuchMethodException( + throw new ArrayIndexOutOfBoundsException( "Illegal number of arguments in array getter"); } else if (methodName.equals("set") && (arguments.length != 2)) { - throw new NoSuchMethodException( + throw new ArrayIndexOutOfBoundsException( "Illegal number of arguments in array setter"); - } else if (arguments[0].getClass() != Integer.class) { - throw new NoSuchMethodException( - "First parameter in array getter(setter) is not of " - + "Integer type"); + } + + if (methodName.equals("get")) { + return Array.class.getMethod("get", + new Class[] { Object.class, int.class } ); + } else { + return Array.class.getMethod("set", + new Class[] { Object.class, int.class, Object.class } ); } - - Class[] argClasses = methodName.equals("get") ? new Class[] { - Object.class, int.class } : new Class[] { Object.class, - int.class, Object.class }; - - return Array.class.getMethod(methodName, argClasses); } private Object[] getArrayMethodArguments() { Index: modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java =================================================================== --- modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java (revision 420769) +++ modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java (working copy) @@ -612,7 +612,7 @@ public void testExecute_ArrayGet() throws Exception { Object[] array = new Object[] { "test" }; Statement t = new Statement(array, "get", new Object[] { - new Integer(0), new Object() }); + new Integer(0)}); t.execute(); array = new Object[] { "test" }; @@ -660,7 +660,7 @@ public void testExecute_ArrayInvalidSet() throws Exception { Object[] array = new Object[] { "test" }; Statement t = new Statement(array, "set", new Object[] { - new Integer(0), "test2", new Object() }); + new Integer(0), "test2"}); t.execute(); assertEquals("test2", array[0]);