You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "spark shen (JIRA)" <ji...@apache.org> on 2007/07/12 09:44:04 UTC

[jira] Updated: (HARMONY-4398) [classlib][luni]AbstractList does not handle expectedModCount correctly

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

spark shen updated HARMONY-4398:
--------------------------------

    Attachment: HY-4398.patch

Would you try my patch?

> [classlib][luni]AbstractList does not handle expectedModCount correctly
> -----------------------------------------------------------------------
>
>                 Key: HARMONY-4398
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4398
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: spark shen
>            Assignee: Leo Li
>         Attachments: HY-4398.patch
>
>
> The following test case will pass on RI, but fail on Harmony
> import java.util.AbstractList;
> import java.util.ArrayList;
> import java.util.ConcurrentModificationException;
> import java.util.Iterator;
> import java.util.NoSuchElementException;
> public class MyArrayList<E> extends AbstractList<E> {
> 	/**
> 	 * 
> 	 */
> 	private static final long serialVersionUID = 1L;
> 	
> 	ArrayList<E> list = new ArrayList<E>();
> 	public static void main(String args[]) {
> 		MyArrayList<String> t = new MyArrayList<String>();
> 		t.list.add("a");
> 		t.list.add("b");
> 		
> 		Iterator it = t.iterator();
> 		
> 		while (it.hasNext()) {
> 			it.next();
> 		}
> 		try {
> 			it.next();
> 		} catch (NoSuchElementException cme) {
> 		}
> 		
> 		t.add("c");
> 		try {
> 			it.remove();
> 		} catch (ConcurrentModificationException cme) {
> 		}
> 		
> 		it = t.iterator();
> 		try {
> 			it.remove();
> 			System.out.println("should throw IllegalStateException");
> 		} catch (IllegalStateException ise) {
> 		}
> 		try {
> 			it.next();
> 			System.out.println("Passed");
> 		} catch (ConcurrentModificationException ise) {
> 			System.out.println("Failed");
> 		}
> 	}
> 	
> 	public E remove(int idx) {
> 		modCount++;
> 		return list.remove(idx);
> 	}
> 	@Override
> 	public E get(int index) {
> 		return list.get(index);
> 	}
> 	@Override
> 	public int size() {
> 		return list.size();
> 	}
> 	
> 	public void add(int idx, E o) {
> 		modCount++;
> 		list.add(idx, o);
> 	}
> }

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