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

Close

#470 Unable to get class information for @throws tag

_release_4.3
closed
5
2012-10-10
2007-02-09
Maarten Coene
No

Hi,

I've just upgraded from checkstyle 3.5 to version 4.3 to have support for Java 5.

I didn't change anything to the configuration, but I now receive a lot of new validation errors: Unable to get class information for @throws tag... These errors weren't there when running the checks with version 3.5.

The error occurs when my method throws one of my own exceptions (which are also checked by checkstyle). If I throw an exception from a 3th-party library, checkstyle doesn't complain because I've added all my dependencies to the checkstyle classpath. But since I run checkstyle before I compile my sources, I cannot add my own .class files to the checkstyle classpath.

regards,
Maarten

Discussion

  • Logged In: YES
    user_id=746148
    Originator: NO

    most likely you need to add classes for your exceptions to classpath which Checkstyle uses.

     
  • Maarten Coene
    Maarten Coene
    2007-02-12

    Logged In: YES
    user_id=178745
    Originator: YES

    Hi,

    I cannot add the classes containing the exception because I do a stylecheck before I compile my code. The exception is in the same source folder as my other class.

    For instance, I have the following directory structure:
    $project/src/my/package/MyObject.java
    $project/src/my/package/MyException.java
    The MyObject class uses MyException.

    With checkstyle 3.5, I could verify my sources without having to compile them first.
    With checkstyle 4.3, I get this 'unable to get class information' error.

    Compiling the sources first and adding the classes to the classpath will probably solve the problem.
    Can you confirm that this isn't supported anymore in checkstyle 4.3, or is this a bug?
    If this is the new way checkstyle works, I'll change my build process to compile the sources first...

    regards,
    Maarten

     
  • Logged In: YES
    user_id=746148
    Originator: NO

    Well, some checks (like RedundantThrows and JavadocMethod) always required class information (perhaps not for all classes).
    So, it is expected that they have these classes in classpath.
    Also, I need to warn you that Checkstyle is supposed to work well with compilable sources only (it may provide wrong results
    if you have bug in your sources). So it is better to un Checkstyle after building sources.

    So, could you, please verify if adding classes to classpath resolve the problem.

     
  • Maarten Coene
    Maarten Coene
    2007-02-13

    Logged In: YES
    user_id=178745
    Originator: YES

    I've just tested it with adding the classes of my project to the classpath and it works as expected.
    Thanks for the feedback.

    regards,
    Maarten

     
  • Logged In: YES
    user_id=746148
    Originator: NO

    Great. I'm closing this bug.