Checkstyle not getting compiled classes on classpath in 1.0 milestone 6

Since upgrading from M3 to M6 I have started getting these warnings when running checkstyle with the ‘code-quality’ plugin:

Unable to get class information for <custom exception in the same package>

I get this as part of the RedundantThrowsCheck. It seems that the problem has to do with the classpath given to checkstyle. The RedundantThrowsCheck itself includes the note that “The classpath should be configured to locate the class information. The classpath configuration is dependent on the mechanism used to invoke Checkstyle.”

The problem seems to be that I need to include the compiled classes to the checkstyle classpath. This seems to sum up the solution:

How can I put the compiled classes in the checkstyle classpath?

Thanks, David


I am having the same issue, have you been able to resolve this?

I believe that the only fix required was this change in my checkstyle.xml:

<module name="RedundantThrows">
       <property name="allowUnchecked" value="true"/>
       <property name="allowSubclasses" value="true"/>
    <property name="suppressLoadErrors" value="true"/>
  • David

Thanks, that worked. It would be nice if it worked correctly and didn’t require a supression.

Please let us know if the new Checkstyle plugin that will ship with m8 solves the problem.

Right, after posting I realized that suppression of the error is not exactly a fix.

Does the checkstyle task require the compiled classes of the source it is analyzing?

Yes, for some checks it does.

Not always. I am in the process of converting our projects to gradle. Any project that uses an Exception that is defined in that project fails on the RedundantThrows check.

The solution to this for anyone seeing RedundantThrows errors:

checkstyleMain {
  classpath += configurations.compile
 checkstyleTest {
  classpath += configurations.compile

You can’t change the checkstyle classpath from checkstyle {}, but modifying it per-task works.