Index: src/test/api/common/tests/api/java/util/StackTest.java =================================================================== --- src/test/api/common/tests/api/java/util/StackTest.java (revision 561206) +++ src/test/api/common/tests/api/java/util/StackTest.java (working copy) @@ -155,7 +155,46 @@ assertEquals("Search returned incorrect value for search for null--wanted -1", -1, s.search(null)); } + + static class BugStack extends Stack{ + /** + * + */ + private static final long serialVersionUID = -9133762075342926141L; + /** + * + */ + public void setLength(int elementCount) + { + this.elementCount = elementCount; + } + + public int getLength() + { + return elementCount; + } + } + + //test for wrong exception threw by pop method + public void test_pop_modify_elementCount(){ + BugStack testStack = new BugStack(); + testStack.push("A"); + testStack.push("B"); + testStack.setLength(20); + try{ + testStack.pop(); + } + catch(ArrayIndexOutOfBoundsException e) + { + //Expected to throw ArrayIndexOutOfBoundsException here + } + catch(EmptyStackException e) + { + fail("Should throw ArrayIndexOutOfBoundsException here"); + } + } + /** * Sets up the fixture, for example, open a network connection. This method * is called before a test is executed.