You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Leo Li (JIRA)" <ji...@apache.org> on 2006/10/09 10:46:20 UTC

[jira] Updated: (HARMONY-1770) [classlib][math]BigInteger has an unexpected "protected clone()" method

     [ http://issues.apache.org/jira/browse/HARMONY-1770?page=all ]

Leo Li updated HARMONY-1770:
----------------------------

    Attachment: patch.diff

Is there someone willing to try this?

> [classlib][math]BigInteger has an unexpected "protected clone()" method
> -----------------------------------------------------------------------
>
>                 Key: HARMONY-1770
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1770
>             Project: Harmony
>          Issue Type: Bug
>            Reporter: Leo Li
>         Attachments: patch.diff
>
>
> BigInteger have a protected clone() method while as the spec says BigInteger itself does not implement Cloneable. The clone() method just new an instance of itself instead of super().clone.Although it is not public, the Clone() method might lead to side-effect if some Object extends from it and implements Cloneable. 
>  
> Here is an testcase:
> public class TestCloneable extends TestCase {
>  public void testClone()
>  {
>   MyBigInteger myBigInteger = new MyBigInteger("12345");
>   myBigInteger = (MyBigInteger)myBigInteger.clone();
>  }
> }
>  class MyBigInteger extends BigInteger implements Cloneable { 
>  public MyBigInteger(String val) {
>   super(val);  
>  }
>  
>  public Object clone()
>  {
>   try {
>    return super.clone();
>   } catch (CloneNotSupportedException e) {
>    return null;
>   }
>  } 
>  }
> Result:
> RI passes.
> Harmony Fails.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira