Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#488 @throws tag checking - unexpected error

_release_4.3
closed
nobody
Other (70)
5
2013-12-15
2007-07-18
waysider
No

Grateful for any help on this :-)

Trying to resolve a problem with Checkstyle where, if a method's javadoc declares a method to be thrown and treewalker cannot load
info for the Exception class it performs no further analysis on the class (as documented). So added what I believe to be the correct options to the appropriate Checkstyle rules (i.e 'logLoadErrors' and 'suppressLoadErrors') but now I get a different error.

The following Java code (a very simple maven plugin) :-

    /**
     * Execute method (entry point).
     * @throws MojoFailureException if an error occurs
     * @throws MojoExecutionException if an error occurs
     */
    public void execute()
        throws MojoFailureException, MojoExecutionException

Produces no violations in the Eclipse checkstyle plugin but in Maven checkstyle plugin report I get:-

        JavadocMethodCheck          Expected @throws tag for 'MojoExecutionException'. 
        RedundantThrowsCheck    Redundant throws: 'MojoExecutionException' listed more then one time.

The relevant checkstyle config entries (same in both environments) are:-

<module name="JavadocMethod">
        <property name="severity" value="error"/>
        <property name="logLoadErrors" value="true"/>
        <property name="suppressLoadErrors" value="true"/>
</module>

<module name="RedundantThrows">
         <property name="logLoadErrors" value="true"/>
         <property name="suppressLoadErrors" value="true"/>
</module>

I have tried various combinations of the above without success. Can anyone shed any light on why Checkstyle says it wants a @throws tag when its got one ?

TIA

Discussion

  • Joseph Cruz
    Joseph Cruz
    2007-09-05

    Logged In: YES
    user_id=1883800
    Originator: NO

    I also got the Expected @throws error described in this issue. In my case, Checkstyle could not load the exception classes because they did not exist. I was executing Checkstyle during the 'validate' phase, before compile. Executing Checkstyle during the 'test' phase resolved this problem for me.

    Solution:
    <executions>
    <execution>
    <phase>test</phase>
    <goals>
    <goal>checkstyle</goal>
    </goals>
    </execution>
    </executions>

     
  • Joseph Cruz
    Joseph Cruz
    2007-09-05

    Logged In: YES
    user_id=1883800
    Originator: NO

    I recommend executing Checkstyle in the 'verify' phase to work-around this issue.

     
  • McCloud
    McCloud
    2007-10-01

    Logged In: YES
    user_id=1169258
    Originator: NO

    I've got exactly the same error using the Checkstyle Eclipse plugin v.4.3.2 on Rational Application Developer 6.0. I also have to use the logLoadErrors and suppressLoadErrors set to to 'true' due to the IBM JVM bug. I'm also developing a Maven plugin and got the exact same errors as the submitter of this bug ('RedundantThrow' and 'expected @throws tag' messages).

     
  • chetankjain
    chetankjain
    2007-12-14

    Logged In: YES
    user_id=1959910
    Originator: NO

    Hi,
    Even I'm running into this problem

    Expected @throws tag for 'SomeException'.
    Redundant throws: 'SomeException' listed more then one time.

     
  • Roman Ivanov
    Roman Ivanov
    2013-11-27

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -5,6 +5,7 @@
    
     The following Java code (a very simple maven plugin) :-
    
    +~~~~~~
         /**
          * Execute method (entry point).
          * @throws MojoFailureException if an error occurs
    @@ -12,14 +13,18 @@
          */
         public void execute()
             throws MojoFailureException, MojoExecutionException
    +~~~~~~
    
     Produces no violations in the Eclipse checkstyle plugin but in Maven checkstyle plugin report I get:-
    
    +~~~~~~
            JavadocMethodCheck          Expected @throws tag for 'MojoExecutionException'. 
            RedundantThrowsCheck    Redundant throws: 'MojoExecutionException' listed more then one time. 
    +~~~~~~
    
     The relevant checkstyle config entries (same in both environments) are:-
    
    +~~~~~~
     <module name="JavadocMethod">
                <property name="severity" value="error"/>
             <property name="logLoadErrors" value="true"/>
    @@ -30,6 +35,8 @@
              <property name="logLoadErrors" value="true"/>
              <property name="suppressLoadErrors" value="true"/>
     </module>
    +~~~~~~
    +
    
     I have tried various combinations of the above without success. Can anyone shed any light on why Checkstyle says it wants a @throws tag when its got one ?
    
     
  • Roman Ivanov
    Roman Ivanov
    2013-11-27

    • status: open --> closed