You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Sean Qiu (JIRA)" <ji...@apache.org> on 2008/01/30 09:26:35 UTC

[jira] Created: (HARMONY-5443) [java][util] Arrays.binarySearch(Object[],Object) will throw ClassCastException while RI won't

[java][util] Arrays.binarySearch(Object[],Object) will throw ClassCastException while RI won't
----------------------------------------------------------------------------------------------

                 Key: HARMONY-5443
                 URL: https://issues.apache.org/jira/browse/HARMONY-5443
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Sean Qiu


Harmony's Arrays.binarySearch(Object[],Object o) will throw ClassCastException when second parameter does not implement Comparable interface.
It means that RI will call compareTo from the first parameter rather than the second parameter.

Here is the test case   
---------------------------------
public class MethodTest extends TestCase {
	public void testMethod() throws Exception{
	    Object object = new Object();
	    Object[] objects = new MockComparable[] { new MockComparable() };
	    assertEquals("Should always return 0", 0, Arrays.binarySearch(objects, object));
	}
	
	static class MockComparable implements Comparable{
	    public int compareTo(Object o) {
	        return 0;
	    }
	}
}

------------------------------

Result:
RI passed
Harmony failed

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


[jira] Resolved: (HARMONY-5443) [java][util] Arrays.binarySearch(Object[],Object) will throw ClassCastException while RI won't

Posted by "Mark Hindess (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5443?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Hindess resolved HARMONY-5443.
-----------------------------------

    Resolution: Fixed

Thanks for the patch Sean.  Applied in r616719.  Please verify that it has been applied as expected.


> [java][util] Arrays.binarySearch(Object[],Object) will throw ClassCastException while RI won't
> ----------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5443
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5443
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Sean Qiu
>            Assignee: Mark Hindess
>         Attachments: Harmony-5443.diff
>
>
> Harmony's Arrays.binarySearch(Object[],Object o) will throw ClassCastException when second parameter does not implement Comparable interface.
> It means that RI will call compareTo from the first parameter rather than the second parameter.
> Here is the test case   
> ---------------------------------
> public class MethodTest extends TestCase {
> 	public void testMethod() throws Exception{
> 	    Object object = new Object();
> 	    Object[] objects = new MockComparable[] { new MockComparable() };
> 	    assertEquals("Should always return 0", 0, Arrays.binarySearch(objects, object));
> 	}
> 	
> 	static class MockComparable implements Comparable{
> 	    public int compareTo(Object o) {
> 	        return 0;
> 	    }
> 	}
> }
> ------------------------------
> Result:
> RI passed
> Harmony failed

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


[jira] Assigned: (HARMONY-5443) [java][util] Arrays.binarySearch(Object[],Object) will throw ClassCastException while RI won't

Posted by "Mark Hindess (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5443?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Hindess reassigned HARMONY-5443:
-------------------------------------

    Assignee: Mark Hindess

> [java][util] Arrays.binarySearch(Object[],Object) will throw ClassCastException while RI won't
> ----------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5443
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5443
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Sean Qiu
>            Assignee: Mark Hindess
>         Attachments: Harmony-5443.diff
>
>
> Harmony's Arrays.binarySearch(Object[],Object o) will throw ClassCastException when second parameter does not implement Comparable interface.
> It means that RI will call compareTo from the first parameter rather than the second parameter.
> Here is the test case   
> ---------------------------------
> public class MethodTest extends TestCase {
> 	public void testMethod() throws Exception{
> 	    Object object = new Object();
> 	    Object[] objects = new MockComparable[] { new MockComparable() };
> 	    assertEquals("Should always return 0", 0, Arrays.binarySearch(objects, object));
> 	}
> 	
> 	static class MockComparable implements Comparable{
> 	    public int compareTo(Object o) {
> 	        return 0;
> 	    }
> 	}
> }
> ------------------------------
> Result:
> RI passed
> Harmony failed

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


[jira] Updated: (HARMONY-5443) [java][util] Arrays.binarySearch(Object[],Object) will throw ClassCastException while RI won't

Posted by "Sean Qiu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5443?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sean Qiu updated HARMONY-5443:
------------------------------

    Attachment: Harmony-5443.diff

Could someone try this patch please?

> [java][util] Arrays.binarySearch(Object[],Object) will throw ClassCastException while RI won't
> ----------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5443
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5443
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Sean Qiu
>         Attachments: Harmony-5443.diff
>
>
> Harmony's Arrays.binarySearch(Object[],Object o) will throw ClassCastException when second parameter does not implement Comparable interface.
> It means that RI will call compareTo from the first parameter rather than the second parameter.
> Here is the test case   
> ---------------------------------
> public class MethodTest extends TestCase {
> 	public void testMethod() throws Exception{
> 	    Object object = new Object();
> 	    Object[] objects = new MockComparable[] { new MockComparable() };
> 	    assertEquals("Should always return 0", 0, Arrays.binarySearch(objects, object));
> 	}
> 	
> 	static class MockComparable implements Comparable{
> 	    public int compareTo(Object o) {
> 	        return 0;
> 	    }
> 	}
> }
> ------------------------------
> Result:
> RI passed
> Harmony failed

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


[jira] Closed: (HARMONY-5443) [java][util] Arrays.binarySearch(Object[],Object) will throw ClassCastException while RI won't

Posted by "Sean Qiu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5443?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sean Qiu closed HARMONY-5443.
-----------------------------


Verified by Sean at r616719.
Thanks

> [java][util] Arrays.binarySearch(Object[],Object) will throw ClassCastException while RI won't
> ----------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5443
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5443
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Sean Qiu
>            Assignee: Mark Hindess
>         Attachments: Harmony-5443.diff
>
>
> Harmony's Arrays.binarySearch(Object[],Object o) will throw ClassCastException when second parameter does not implement Comparable interface.
> It means that RI will call compareTo from the first parameter rather than the second parameter.
> Here is the test case   
> ---------------------------------
> public class MethodTest extends TestCase {
> 	public void testMethod() throws Exception{
> 	    Object object = new Object();
> 	    Object[] objects = new MockComparable[] { new MockComparable() };
> 	    assertEquals("Should always return 0", 0, Arrays.binarySearch(objects, object));
> 	}
> 	
> 	static class MockComparable implements Comparable{
> 	    public int compareTo(Object o) {
> 	        return 0;
> 	    }
> 	}
> }
> ------------------------------
> Result:
> RI passed
> Harmony failed

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