Commons Math
  1. Commons Math
  2. MATH-458

Interpolators: Remove "MathException" from the signature of the "interpolate" method

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0
    • Labels:
      None

      Description

      The interfaces for the interpolators contain a "throws" clause that should be removed.
      E.g.

      public interface UnivariateRealInterpolator {
      
          /**
           * Computes an interpolating function for the data set.
           * @param xval the arguments for the interpolation points
           * @param yval the values for the interpolation points
           * @return a function which interpolates the data set
           * @throws MathException if arguments violate assumptions made by the
           *         interpolation algorithm
           */
          UnivariateRealFunction interpolate(double xval[], double yval[])
              throws MathException;
      }
      

      Assumptions violation should be dealt with by throwing appropriate unchecked exceptions.

        Activity

        Hide
        Michael Yannakopoulos added a comment -

        Excuse me, but why interfaces for the interpolators shoudn't contain a "throws" clause? The appropriate unchecked exceptions are shown by the stack trace... Sorry for not understanding what would you like to be done...

        Show
        Michael Yannakopoulos added a comment - Excuse me, but why interfaces for the interpolators shoudn't contain a "throws" clause? The appropriate unchecked exceptions are shown by the stack trace... Sorry for not understanding what would you like to be done...
        Hide
        Gilles added a comment -

        One of the changes we set to implement in 3.0 is that all exceptions in Commons-Math will be unchecked. And in fact they will all inherit from a single MathRuntimeException base class (defined in the package exception).
        The checked MathException will be removed.

        Show
        Gilles added a comment - One of the changes we set to implement in 3.0 is that all exceptions in Commons-Math will be unchecked. And in fact they will all inherit from a single MathRuntimeException base class (defined in the package exception ). The checked MathException will be removed.
        Hide
        Michael Yannakopoulos added a comment -

        So if we just changed the "throws MathException" statement with "throws MathRuntimeException" statement then the new implementation would be compatible with the new standards? Thanks in advance Gilles!

        Show
        Michael Yannakopoulos added a comment - So if we just changed the "throws MathException" statement with "throws MathRuntimeException" statement then the new implementation would be compatible with the new standards? Thanks in advance Gilles!
        Hide
        Gilles added a comment -

        Yes but it's unnecessary. Some would argue that having runtime exceptions declared in the "throws" clause is confusing because
        it is not guaranteed that only those exceptions listed there will be thrown, and not even that these exceptions will be thrown at all.

        Show
        Gilles added a comment - Yes but it's unnecessary. Some would argue that having runtime exceptions declared in the "throws" clause is confusing because it is not guaranteed that only those exceptions listed there will be thrown, and not even that these exceptions will be thrown at all.
        Hide
        Gilles added a comment -

        Revision 1055931.

        Show
        Gilles added a comment - Revision 1055931.
        Hide
        Michael Yannakopoulos added a comment - - edited

        Just if you are interested i have modified the classes that were affected by this exception and i have changed the exception to "MathRuntimeException"... If you need them i would gladly attached these files...

        Show
        Michael Yannakopoulos added a comment - - edited Just if you are interested i have modified the classes that were affected by this exception and i have changed the exception to "MathRuntimeException"... If you need them i would gladly attached these files...
        Hide
        Gilles added a comment -

        I'm not sure of what you mean and what need to be changed. Please attach the "diff" files.

        Show
        Gilles added a comment - I'm not sure of what you mean and what need to be changed. Please attach the "diff" files.

          People

          • Assignee:
            Gilles
            Reporter:
            Gilles
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development