commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (MATH-793) OrderedTuple#hashCode() uses casting instead of boxing
Date Tue, 29 May 2012 15:02:23 GMT

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

Sebb updated MATH-793:
----------------------

    Environment: 
OrderedTuple#hashCode() is as follows:

{code}
public int hashCode() {
    return Arrays.hashCode(components)   ^
           ((Integer) offset).hashCode() ^
           ((Integer) lsb).hashCode()    ^
           ((Boolean) posInf).hashCode() ^
           ((Boolean) negInf).hashCode() ^
           ((Boolean) nan).hashCode();
}
{code}

This is not the correct way to convert primitives to their object equivalents.

{code}
((Integer) x).hashCode() == x

Boolean#hashCode() is defined as

value ? 1231 : 1237
{code}

Note that this error won't be found unless the compiler emits warnings for boxing.

  was:
OrderedTuple#hashCode() is as follows:

{code}
public int hashCode() {
    return Arrays.hashCode(components)   ^
           ((Integer) offset).hashCode() ^
           ((Integer) lsb).hashCode()    ^
           ((Boolean) posInf).hashCode() ^
           ((Boolean) negInf).hashCode() ^
           ((Boolean) nan).hashCode();
}
{code}

This is not the correct way to convert primitives to their object equivalents.

((Integer) x).hashCode() == x
Boolean#hashCode() is defined as

value ? 1231 : 1237

Note that this error won't be found unless the compiler emits warnings for boxing.

    
> OrderedTuple#hashCode() uses casting instead of boxing
> ------------------------------------------------------
>
>                 Key: MATH-793
>                 URL: https://issues.apache.org/jira/browse/MATH-793
>             Project: Commons Math
>          Issue Type: Bug
>         Environment: OrderedTuple#hashCode() is as follows:
> {code}
> public int hashCode() {
>     return Arrays.hashCode(components)   ^
>            ((Integer) offset).hashCode() ^
>            ((Integer) lsb).hashCode()    ^
>            ((Boolean) posInf).hashCode() ^
>            ((Boolean) negInf).hashCode() ^
>            ((Boolean) nan).hashCode();
> }
> {code}
> This is not the correct way to convert primitives to their object equivalents.
> {code}
> ((Integer) x).hashCode() == x
> Boolean#hashCode() is defined as
> value ? 1231 : 1237
> {code}
> Note that this error won't be found unless the compiler emits warnings for boxing.
>            Reporter: Sebb
>             Fix For: 3.1
>
>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message