harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "spark shen (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-4577) [classlib][luni] Stack.pop method of harmony throws EmptyStackException, while RI throws ArrayIndexOutOfBoundsException
Date Tue, 31 Jul 2007 08:19:53 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-4577?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

spark shen updated HARMONY-4577:
--------------------------------

    Attachment: Stack-Patch.txt

> [classlib][luni] Stack.pop method of harmony throws EmptyStackException, while RI throws
ArrayIndexOutOfBoundsException
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4577
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4577
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: spark shen
>         Attachments: Stack-Patch.txt, StackTest-Patch.txt
>
>
> The protected field  elementCount can be modified by its subclass. And if this
> field is modified to a value which exceeds the array boundry, and invoke the pop() method,
> RI will throw an ArrayIndexOutOfBoundsException but trunk5 will throw an EmptyStackException.
> The following test case will show:
> tatic class BugStack<E> extends Stack<E>{
> 		/**
> 		 * 
> 		 */
> 		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<String> testStack = new BugStack<String>();
> 		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");
> 		}
> 	}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message