Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#227 Minor problem with RedundantThrows and nested exceptions

release_3.5
closed
ANT Task (45)
5
2012-10-10
2004-04-30
David Whitmore
No

Hi,
I've been trying out the latest version (3.4) of
checkstyle, and unfortunately, I think I've found
another minor problem with the RedundantThrows check:
Sometimes, it doesn't seem able to find information for
exception classes.

This is actually related to a previous issue (925263)
that I reported with RedundantThrows and nested
exceptions.
Bizarrely, this new problem seems to be more specific.

Specifically, it doesn't seem able to find the
information in the following scenario:
Class A is defined in its own file.
Class B is a nested exception defined in Class B.

Here's a small example file that illustrates the problem:

package test;
public class Test1 {
void doStuff1() throws TestException1 {
throw new Test1().new TestException1("");
}
void doStuff2() throws TestException2 {
throw new TestException2("");
}
class TestException1 extends Exception {
TestException1(String messg) {
super(messg);
}
}
static class TestException2 extends Exception {
TestException2(String messg) {
super(messg);
}
}
}

I've set up a small demonstration, using the
checkstyle/ant integration, and can provide this if you
want it.

When I check the above class, I get the following
reports from the ant checkstyle task:
<error line="3" column="26" severity="error" message="Unable to get class information for TestException1." source="com.puppycrawl.tools.checkstyle.checks.coding.RedundantThrowsCheck"/>
<error line="6" column="26" severity="error" message="Unable to get class information for TestException2." source="com.puppycrawl.tools.checkstyle.checks.coding.RedundantThrowsCheck"/>

I know that you get a lot of cases where users forget
to specify the correct classpath argument to the ant
checkstyle task, but I promise you - I have correctly
specified the classpath argument!

Thanks for all your hard work, and such an incredibly
useful project!

Regards,

David

Discussion

  • Oliver Burn
    Oliver Burn
    2004-08-19

    Logged In: YES
    user_id=218824

    likely to be a bug in ClassResolver.

     
  • Logged In: YES
    user_id=746148

    Fix committed to CVS for 3.5