commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <>
Subject Re: svn commit: r1030464 [1/3] - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/ main/java/org/apache/commons/math/analysis/ main/java/org/apache/commons/math/analysis/integration/ main/java/org/apache/commons/math/analysis/interpolat
Date Thu, 04 Nov 2010 16:03:28 GMT

> >public interface UnivariateRealFunction {
> >-
> >    /**
> >-     * Compute the value for the function.
> >-     * @param x the point for which the function value should be computed
> >-     * @return the value
> >-     * @throws FunctionEvaluationException if the function
> >evaluation fails
> >+     * Compute the value of the function.
> >+     *
> >+     * @param x Point at which the function value should be computed.
> >+     * @return the value.
> >     */
> >-    double value(double x) throws FunctionEvaluationException;
> >-
> >+    double value(double x);
> >}
> >
> IMHO we still need the @throws line in the javadoc.  Otherwise end
> users are going to get a nasty surprise when they get an unchecked
> exception thrown.

Using the "throws" clause for unchecked exception is misleading because it
can give the impression that it is necessary to propagate it (through a
clause for the enclosing method) or to isolate it (in a try/catch block).
Moreover, an equally false impression is that the code would be safe if
this specific exception is caught.
Adding the clause to the interface does not prevent an implementation to
from throwing another unchecked exception, so it does not provide any
information. And this is *no* change from the previous situation (where we
had a checked exception).
In the case where some code can continue even though the function evaluation
fails (for whatever reason, and whatever the exception thrown), the only
sure thing is that the call to "value" be enclosed in a "try" block that
"catch"es "RuntimeException".


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message