[
https://issues.apache.org/jira/browse/MATH-1406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15954913#comment-15954913
]
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:
>http://stackoverflow.com/questions/7577865/gwt-linkedhashmap-clone-issue
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|https://github.com/gwtproject/gwt/issues/5067].
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 (nasty!)
>https://dev.geogebra.org/trac/changeset/32007
I believe this is then [an example of CCE being used in
Math|https://github.com/apache/commons-math/blob/d9e43edd13d55224fabc9a65b75884a77a3d56b7/src/main/java/org/apache/commons/math4/linear/ArrayFieldVector.java#L396].
Here's the except as example from ArrayFieldVector.
{code}
@Override
public FieldVector<T> add(FieldVector<T> v)
throws DimensionMismatchException {
try {
return add((ArrayFieldVector<T>) v);
} catch (ClassCastException cce) {
checkVectorDimensions(v);
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);
}
}
{code}
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|https://github.com/apache/commons-math/search?utf8=%E2%9C%93&q=ClassCastException&type=].
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: https://issues.apache.org/jira/browse/MATH-1406
> 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)
> http://www.gwtproject.org/
> 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:
> https://github.com/murkle/commons-math/issues/1
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)