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

Luc Maisonobe updated MATH-284:
-------------------------------

    Attachment: math-284.patch

The patch file above corresponds to your suggested change.
Could you check if this solves the problem in your case ?

I would like to wait a little before commiting it as it breaks compatibility 
(we add a method to a public interface). However, this interface is a new one 
and very few people are likely to implement it (in fact, I'm surprised someone 
used it so quickly). The compatibility break is easy to solve for users as they 
mainly have to create a one line method like:
{code}
public Class SomeTypeField implements Field<SomeType>, Serializable  {

    ...

    /** {...@inheritdoc} */
    public Class<? extends FieldElement<SomeType>> getRuntimeClass() {
        return SomeType.class;
    }

}
{code}

Since the change you suggest is an interesting improvement and the 
compatibility break is easy to solve, I think it is worth adding it and 
breaking compatibility.

What do other people think ?

> Avoid ArrayStoreException
> -------------------------
>
>                 Key: MATH-284
>                 URL: https://issues.apache.org/jira/browse/MATH-284
>             Project: Commons Math
>          Issue Type: Improvement
>    Affects Versions: 2.0
>            Reporter: Klaus Hartlage
>            Priority: Minor
>         Attachments: math-284.patch
>
>
> Add a new method
> org.apache.commons.math,Field#getRuntimeClass():
> ...
>     /**
>      * Returns the runtime class of the FieldElement. 
>      * 
>      * @return The {...@code Class} object that represents the runtime
>      *         class of this object.
>      */
>     Class<? extends FieldElement> getRuntimeClass();
> ...
> and replace all occurrences of 
>   Array.newInstance(field.getZero().getClass(),....)
> with
>   Array.newInstance(field.getRuntimeClass(),....)
> to avoid the throwing of ArrayStoreException in the case you have a type 
> hierachy of Fields with a common interface
> and the array should have the interface type at runtime.

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

Reply via email to