commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruno P. Kinoshita (JIRA)" <>
Subject [jira] [Commented] (MATH-1406) official support for compiling on GWT 2.8
Date Tue, 04 Apr 2017 09:35:42 GMT


Bruno P. Kinoshita commented on MATH-1406:

Hi Michael,

Thanks a lot for the pointers and for the explanation. I do not contribute to Math, but my
concerns are only around implementing something in order to get the GWT framework to work,
while we could break something else and have to undo it, or if another framework needs clone
back again, for instance. So will leave the decision to more active contributors of Math :-)

>re Clone:

The SO answer points to old issues that contain workarounds for applications, implementing
a naive version looping through attributes, with a special case for arrays I think. There's
also the [issue migrated to GitHub|].

Would it be possible, perhaps, to use a similar workaround as in the issue, or maybe ping
GWT developers to see what's the status of the fix for that? This way we would basically get
everything that uses #clone() to work with GWT I think.

>simply don't throw an Exception in GWT so lead to runtime rather than compile-time errors

I believe this is then [an example of CCE being used in Math|].
Here's the except as example from ArrayFieldVector.

    public FieldVector<T> add(FieldVector<T> v)
        throws DimensionMismatchException {
        try {
            return add((ArrayFieldVector<T>) v);
        } catch (ClassCastException cce) {
            T[] out = MathArrays.buildArray(field, data.length);
            for (int i = 0; i < data.length; i++) {
                out[i] = data[i].add(v.getEntry(i));
            return new ArrayFieldVector<>(field, out, false);

Looks like the code in Math may handle the case where there is a different type then expected,
but instead of throwing an exception, it builds the desired object. So - correct me if I didn't
understand it - the second part of the flow (i.e. the inner block of the catch) would never
be executed in GWT, and instead there would be an runtime error.

This seems a bit trickier. Looks like there are [quite a few places to fix it in Math|].
We would have to update the code to use instanceof, and update test cases, unless there is
some other workaround in GWT.

> official support for compiling on GWT 2.8
> -----------------------------------------
>                 Key: MATH-1406
>                 URL:
>             Project: Commons Math
>          Issue Type: Improvement
>            Reporter: Michael Borcherds
>   Original Estimate: 168h
>  Remaining Estimate: 168h
> Context: at the moment Apache Commons Math can't be compiled using GWT (to allow it to
be made into a JavaScript library for example)
> Is there any interest in allowing Apache Commons Math to be officially supported on GWT?
> With GWT 2.8.0 the changes needed aren't too hard to get most of it to compile
> You can see the diff from 3.6.1 here:

This message was sent by Atlassian JIRA

View raw message