Maven Checkstyle Plugin
  1. Maven Checkstyle Plugin
  2. MCHECKSTYLE-111

More information on issue: "Got an exception - java.lang.RuntimeException: Unable to get class information for [exception]"

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Blocker Blocker
    • Resolution: Not A Bug
    • Affects Version/s: 2.2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows Vista Business (x64), Windows XP (x86), Windows 2003 Server (x86)
      Apache Maven 2.1.0 (r755702; 2009-03-18 20:10:27+0100) and Maven 2.0.10
      Java version: 1.6.0_13
    • Testcase included:
      yes
    • Number of attachments :
      2

      Description

      This bug report provides more insight on the situations in which the maven-checkstyle-plugin is unable to get the class information for exceptions that are declared by the project. This report is, therefore, a refinement of prior bug reports such as MPCHECKSTYLE-1, MPCHECKSTYLE-20, or MCHECKSTYLE-54. We believe, however, that through a more in-depth study of the problem we can provide a narrower definition of the problem that, hopefully, will result in it resolution.

      Our experiments have shown that the maven-checkstyle-plugin fails for classes or interfaces that contain method signatures with a "throws" clause pointing to exception defined by both the project and elsewhere. This is demonstrated by the interface "ch.ethz.globis.demo.Demo" contained in the attached demo project.
      {{
      public interface Demo

      { void foo() throws DemoException, IOException, FileNotFoundException; void foofoo() throws DemoException; void bar() throws IOException, FileNotFoundException, IllegalArgumentException; }

      }}
      If the command "mvn checkstyle:check" is executed in the project, it will fail with one checkstyle violation. If, however, the method "foo()" is commented (or removed), everything works fine. Note that method "foofoo()" which only declares "ch.ethz.globis.demo.DemoException" is unproblematic as well as method "bar()" which declares a set of exceptions that are declared outside the project. Hence, the conclusion is that it is the combination of both project and outside-project exceptions that make the maven-checkstyle-plugin fail. Note that we have run maven on clean installation (where the local repository has been removed first) to produce a reproducible error.

      The attached zip file contains both the demo project that can be used to reproduce the error as well as the output of the "mvn checkstyle:check" command under "target". We also provide the file "output.txt" that documents the console output of the command. If further documentation is required, do not hesitate to contact me. We hope that by providing this information we can contribute to the resolution of said issue, once and for all.

      1. output.txt
        5 kB
        Michael Grossniklaus

        Issue Links

          Activity

          Hide
          Mark Hobson added a comment -
          Show
          Mark Hobson added a comment - This looks like an issue with checkstyle itself, see: https://sourceforge.net/tracker/index.php?func=detail&aid=2777291&group_id=29721&atid=397078
          Hide
          Aart added a comment -

          Is there some activity on this topic? I can find similar error reports from years back - it looks like either this bug is very hard to track down, or it's simply not worked on I, and I think many others, would be very grateful to see this issue removed
          Thanks

          Show
          Aart added a comment - Is there some activity on this topic? I can find similar error reports from years back - it looks like either this bug is very hard to track down, or it's simply not worked on I, and I think many others, would be very grateful to see this issue removed Thanks
          Hide
          Niraj Tolia added a comment -

          We ran into this at work too. Evidently checkstyle, if run on uncompiled code, will not be able to find your custom exceptions. With compiled code (what we usually do), it looks like things should be OK unless your error originates from a dependency that is marked with a test scope. In our project, junit currently is marked as being in the test scope but that is where the InitializationError Exception comes from and what triggered the bug for us. It should be possible to fix this by pointing checkstyle to the right dependency but I am not completely sure how.

          Show
          Niraj Tolia added a comment - We ran into this at work too. Evidently checkstyle, if run on uncompiled code, will not be able to find your custom exceptions. With compiled code (what we usually do), it looks like things should be OK unless your error originates from a dependency that is marked with a test scope. In our project, junit currently is marked as being in the test scope but that is where the InitializationError Exception comes from and what triggered the bug for us. It should be possible to fix this by pointing checkstyle to the right dependency but I am not completely sure how.
          Hide
          Mark Struberg added a comment -

          Closing, as this is not a problem of the maven-checkstyle-plugin itself.
          This happened to me as well when working with annotation processors, etc. In this case simply add the framework dependency in question to the <plugin><dependencies> worked for me.

          Show
          Mark Struberg added a comment - Closing, as this is not a problem of the maven-checkstyle-plugin itself. This happened to me as well when working with annotation processors, etc. In this case simply add the framework dependency in question to the <plugin><dependencies> worked for me.

            People

            • Assignee:
              Mark Struberg
              Reporter:
              Michael Grossniklaus
            • Votes:
              6 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: