[
https://issues.apache.org/jira/browse/MATH-261?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12698879#action_12698879
]
Luc Maisonobe commented on MATH-261:
------------------------------------
A first minor comment about the patch content. Wouldn't it be simpler to remove
the @SuppressWarnings and replace the two casts by a direct use of the v
parameter ?
Now a more important comment. The test don't run under eclipse ganymede with
OpenJDK on a 64 bits Linux machine. They fail without any explanation, with
just red crosses and no message at all. Trying to compile using maven rather
than eclipse fail even earlier: maven does not compile the Frequency.java file
with error messages like:
{noformat}
/home/luc/.../Frequency.java:[109,12] inconvertible types
found : T
required: java.lang.Integer
/home/luc/.../Frequency.java:[110,41] inconvertible types
found : T
required: java.lang.Integer
/home/luc/.../Frequency.java:[202,12] inconvertible types
found : T
required: java.lang.Integer
/home/luc/.../Frequency.java:[203,39] inconvertible types
found : T
required: java.lang.Integer
/home/luc/.../Frequency.java:[312,12] inconvertible types
found : T
required: java.lang.Integer
/home/luc/.../Frequency.java:[313,41] inconvertible types
found : T
required: java.lang.Integer
{noformat}
So it seems some compilers do not like constructs like
{code}
if (v instanceof Integer) {
obj = Long.valueOf(((Integer) v).longValue());
}
{code}
when v is a parameterized type.
Last a comment on the general idea of the patch. It tries to preserve the fact
several integral types can be added while restricting the Object to one
specific class. On one hand if people do not want to add any object but want
only int, long ... they still have to select one Comparable type to avoid a
warning about Frequency being a raw type. On the other hand, if they want the
previous behavior allowing almost anything, they cannot do it.
I am uncomfortable with this. I am also umconfortable with the previous
behavior. Would'nt it be better to completely change the API and don't allow
mixing types at all ?
> Add generics to Frequency
> -------------------------
>
> Key: MATH-261
> URL: https://issues.apache.org/jira/browse/MATH-261
> Project: Commons Math
> Issue Type: Improvement
> Reporter: Sebb
> Fix For: 2.0
>
> Attachments: Frequency.patch
>
>
> I've attempted to add generics to Frequency.
> This requires a minor change to the API, in that Objects to be used with the
> class need to be Comparable.
> This will break some code, e.g. one change was needed to the test cases.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.