Menu

Custom Checkstyle plugins broken in Eclipse Oxygen

2017-07-30
2017-12-20
  • Innate Distress

    Innate Distress - 2017-07-30

    I have a plugin that extends Checkstyle with custom checks as described here:

    http://eclipse-cs.sourceforge.net/#!/custom-checks

    After upgrading to Eclipse Oxygen and eclipse-cs 8.0.0, my custom checks can no longer be instantiated by Checkstyle. I was able to reproduce this error using the SevNTU plugin as well (stack trace below). Any ideas?

    Checkstyle-Plugin: cannot initialize module TreeWalker - Unable to instantiate 'ForbidAnnotationCheck' class, it is also not possible to instantiate it as com.puppycrawl.tools.checkstyle.checks.annotationForbidAnnotationCheck, com.puppycrawl.tools.checkstyle.checks.blocksForbidAnnotationCheck, com.puppycrawl.tools.checkstyle.checks.codingForbidAnnotationCheck, com.puppycrawl.tools.checkstyle.checks.designForbidAnnotationCheck, com.puppycrawl.tools.checkstyle.checks.headerForbidAnnotationCheck, com.puppycrawl.tools.checkstyle.checks.importsForbidAnnotationCheck, com.puppycrawl.tools.checkstyle.checks.indentationForbidAnnotationCheck, com.puppycrawl.tools.checkstyle.checks.javadocForbidAnnotationCheck, com.puppycrawl.tools.checkstyle.checks.metricsForbidAnnotationCheck, com.puppycrawl.tools.checkstyle.checks.modifierForbidAnnotationCheck, com.puppycrawl.tools.checkstyle.checks.namingForbidAnnotationCheck, com.puppycrawl.tools.checkstyle.checks.regexpForbidAnnotationCheck, com.puppycrawl.tools.checkstyle.checks.sizesForbidAnnotationCheck, com.puppycrawl.tools.checkstyle.checks.whitespaceForbidAnnotationCheck, com.puppycrawl.tools.checkstyle.checksForbidAnnotationCheck, com.puppycrawl.tools.checkstyle.filefiltersForbidAnnotationCheck, com.puppycrawl.tools.checkstyle.filtersForbidAnnotationCheck, com.puppycrawl.tools.checkstyleForbidAnnotationCheck, com.github.sevntu.checkstyle.checks.annotationForbidAnnotationCheck, com.github.sevntu.checkstyle.checks.codingForbidAnnotationCheck, com.github.sevntu.checkstyle.checks.designForbidAnnotationCheck, com.github.sevntu.checkstyle.checks.namingForbidAnnotationCheck, com.github.sevntu.checkstyle.checks.sizesForbidAnnotationCheck, com.github.sevntu.checkstyle.checksForbidAnnotationCheck, com.github.sevntu.checkstyle.ForbidAnnotationCheck, ForbidAnnotationCheckCheck, com.puppycrawl.tools.checkstyle.checks.annotationForbidAnnotationCheckCheck, com.puppycrawl.tools.checkstyle.checks.blocksForbidAnnotationCheckCheck, com.puppycrawl.tools.checkstyle.checks.codingForbidAnnotationCheckCheck, com.puppycrawl.tools.checkstyle.checks.designForbidAnnotationCheckCheck, com.puppycrawl.tools.checkstyle.checks.headerForbidAnnotationCheckCheck, com.puppycrawl.tools.checkstyle.checks.importsForbidAnnotationCheckCheck, com.puppycrawl.tools.checkstyle.checks.indentationForbidAnnotationCheckCheck, com.puppycrawl.tools.checkstyle.checks.javadocForbidAnnotationCheckCheck, com.puppycrawl.tools.checkstyle.checks.metricsForbidAnnotationCheckCheck, com.puppycrawl.tools.checkstyle.checks.modifierForbidAnnotationCheckCheck, com.puppycrawl.tools.checkstyle.checks.namingForbidAnnotationCheckCheck, com.puppycrawl.tools.checkstyle.checks.regexpForbidAnnotationCheckCheck, com.puppycrawl.tools.checkstyle.checks.sizesForbidAnnotationCheckCheck, com.puppycrawl.tools.checkstyle.checks.whitespaceForbidAnnotationCheckCheck, com.puppycrawl.tools.checkstyle.checksForbidAnnotationCheckCheck, com.puppycrawl.tools.checkstyle.filefiltersForbidAnnotationCheckCheck, com.puppycrawl.tools.checkstyle.filtersForbidAnnotationCheckCheck, com.puppycrawl.tools.checkstyleForbidAnnotationCheckCheck, com.github.sevntu.checkstyle.checks.annotationForbidAnnotationCheckCheck, com.github.sevntu.checkstyle.checks.codingForbidAnnotationCheckCheck, com.github.sevntu.checkstyle.checks.designForbidAnnotationCheckCheck, com.github.sevntu.checkstyle.checks.namingForbidAnnotationCheckCheck, com.github.sevntu.checkstyle.checks.sizesForbidAnnotationCheckCheck, com.github.sevntu.checkstyle.checksForbidAnnotationCheckCheck, com.github.sevntu.checkstyle.ForbidAnnotationCheckCheck. Please recheck that class name is specified as canonical name or read how to configure short name usage http://checkstyle.sourceforge.net/config.html#Packages. Please also recheck that provided ClassLoader to Checker is configured correctly.
    
     
  • Jan Burkhardt

    Jan Burkhardt - 2017-07-31

    I can confirm this problem with another Plugin which was working before the upgrade to 8.0:

    https://github.com/bjrke/JSR305CheckstylePlugin

    !ENTRY net.sf.eclipsecs.core 4 0 2017-07-31 12:53:19.062
    !MESSAGE Checkstyle-Plugin: cannot initialize module TreeWalker - Unable to instantiate 'Jsr305Annotations' class, it is also not possible to instantiate it as com.puppycrawl.tools.checkstyle.checks.annotationJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.blocksJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.codingJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.designJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.headerJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.importsJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.indentationJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.javadocJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.metricsJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.modifierJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.namingJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.regexpJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.sizesJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.whitespaceJsr305Annotations, com.puppycrawl.tools.checkstyle.checksJsr305Annotations, com.puppycrawl.tools.checkstyle.filefiltersJsr305Annotations, com.puppycrawl.tools.checkstyle.filtersJsr305Annotations, com.puppycrawl.tools.checkstyle.Jsr305Annotations, Jsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.annotationJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.blocksJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.codingJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.designJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.headerJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.importsJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.indentationJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.javadocJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.metricsJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.modifierJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.namingJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.regexpJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.sizesJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.whitespaceJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checksJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.filefiltersJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.filtersJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.Jsr305AnnotationsCheck. Please recheck that class name is specified as canonical name or read how to configure short name usage http://checkstyle.sourceforge.net/config.html#Packages. Please also recheck that provided ClassLoader to Checker is configured correctly.
    !STACK 0
    com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module TreeWalker - Unable to instantiate 'Jsr305Annotations' class, it is also not possible to instantiate it as com.puppycrawl.tools.checkstyle.checks.annotationJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.blocksJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.codingJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.designJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.headerJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.importsJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.indentationJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.javadocJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.metricsJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.modifierJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.namingJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.regexpJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.sizesJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.whitespaceJsr305Annotations, com.puppycrawl.tools.checkstyle.checksJsr305Annotations, com.puppycrawl.tools.checkstyle.filefiltersJsr305Annotations, com.puppycrawl.tools.checkstyle.filtersJsr305Annotations, com.puppycrawl.tools.checkstyle.Jsr305Annotations, Jsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.annotationJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.blocksJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.codingJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.designJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.headerJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.importsJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.indentationJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.javadocJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.metricsJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.modifierJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.namingJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.regexpJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.sizesJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.whitespaceJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checksJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.filefiltersJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.filtersJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.Jsr305AnnotationsCheck. Please recheck that class name is specified as canonical name or read how to configure short name usage http://checkstyle.sourceforge.net/config.html#Packages. Please also recheck that provided ClassLoader to Checker is configured correctly.
        at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:457)
        at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:171)
        at net.sf.eclipsecs.core.builder.CheckerFactory.createCheckerInternal(CheckerFactory.java:290)
        at net.sf.eclipsecs.core.builder.CheckerFactory.createChecker(CheckerFactory.java:128)
        at net.sf.eclipsecs.core.builder.Auditor.runAudit(Auditor.java:141)
        at net.sf.eclipsecs.core.builder.CheckstyleBuilder.handleBuildSelection(CheckstyleBuilder.java:301)
        at net.sf.eclipsecs.core.jobs.RunCheckstyleOnFilesJob.runInWorkspace(RunCheckstyleOnFilesJob.java:119)
        at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:39)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
    Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Unable to instantiate 'Jsr305Annotations' class, it is also not possible to instantiate it as com.puppycrawl.tools.checkstyle.checks.annotationJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.blocksJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.codingJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.designJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.headerJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.importsJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.indentationJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.javadocJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.metricsJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.modifierJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.namingJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.regexpJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.sizesJsr305Annotations, com.puppycrawl.tools.checkstyle.checks.whitespaceJsr305Annotations, com.puppycrawl.tools.checkstyle.checksJsr305Annotations, com.puppycrawl.tools.checkstyle.filefiltersJsr305Annotations, com.puppycrawl.tools.checkstyle.filtersJsr305Annotations, com.puppycrawl.tools.checkstyle.Jsr305Annotations, Jsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.annotationJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.blocksJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.codingJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.designJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.headerJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.importsJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.indentationJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.javadocJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.metricsJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.modifierJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.namingJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.regexpJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.sizesJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checks.whitespaceJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.checksJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.filefiltersJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.filtersJsr305AnnotationsCheck, com.puppycrawl.tools.checkstyle.Jsr305AnnotationsCheck. Please recheck that class name is specified as canonical name or read how to configure short name usage http://checkstyle.sourceforge.net/config.html#Packages. Please also recheck that provided ClassLoader to Checker is configured correctly.
        at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createModule(PackageObjectFactory.java:184)
        at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java:153)
        at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:171)
        at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:452)
        ... 8 more
    
     
  • Lars Koedderitzsch

    Hi, I assume this to be related to a Checkstyle-internal change concerning the handling of checkstyle_packages.xml files.
    Please note in the Exception message that there is a dot missing between the package and class name which Checkstyle core constructs from the checkstyle_packages.xml and the check name from the loaded configuration, e.g. com.puppycrawl.tools.checkstyle.checks.annotationJsr305Annotations

    Please check with the Checkstyle core project where this change comes from. If my theory holds true, then custom checks will also not work with Checkstyle Ant/Maven tasks using Checkstyle 8.0.

    Regards,
    Lars

     
  • Jan Burkhardt

    Jan Burkhardt - 2017-08-01

    I've included tests against checkstyle 8 which are working well:
    https://travis-ci.org/bjrke/JSR305CheckstylePlugin
    When I upgrade the gradle build of our big project to Checkstyle 8.0 it is working with a dev version of the plugin, too.
    But I'll investigate the missing dot, perhaps there is a strange configuration issue.

     
  • Roman Ivanov

    Roman Ivanov - 2017-08-03

    I was able to reproduce this error using the SevNTU plugin as well (stack trace below).

    Sevntu plugin is not upgraded to checkstyle8.0 and eclipce-cs8.0.0 yet.
    It is rellay strange how me missed this as we run sevntu in CI.

     
  • Jan Burkhardt

    Jan Burkhardt - 2017-08-03

    I think the problem with loading is an eclipse-cs problem. Because as I already mentioned, I've upgraded the inheritance in https://github.com/bjrke/JSR305CheckstylePlugin/commit/e5fdf3c1340dbeb9bd5db79b9ad5448418b8dbb4 and I've tests against all known working checkstyle versions, including 8.0 and 8.1.
    But I didn't released yet since eclipse-cs is not working.
    To do more tests I need to setup a new environment because I need my eclipse for daily work.

     
  • Jan Burkhardt

    Jan Burkhardt - 2017-08-04

    I made some changes (i.e. adding plugin.xml) in the jar and now I get my package (with correct dots) in the error message, but it is still not loaded. So the checkstyle-metadata.xml is loading correct. Any ideas?

     
  • Innate Distress

    Innate Distress - 2017-08-04

    My custom check is also displayed with the correct dots in the error message but still is not loaded. Perhaps the incorrect dots in the error message was a red herring and not related to the class loading problem?

     
  • Lars Koedderitzsch

    Yes, indeed the error message was misleading.
    I did half an hour of debugging today and from what I can deduce there is something off with the classpath scanning for check class, introduced with https://github.com/checkstyle/checkstyle/issues/3607

    However, I couldn't get to the bottom of this just yet - will need more time

     
  • Lars Koedderitzsch

    Created https://github.com/checkstyle/checkstyle/issues/4916 - it appears as if a classpath scanning feature introduce in Checkstyle core recently cannot possibly work in Eclipse.

     
  • Jan Burkhardt

    Jan Burkhardt - 2017-08-09

    thank you for your effort debugging this issue!
    do you think eclipse-cs could workaround this issue or do we have to wait for a solution from the checkstyle maintainers?

     
  • Lars Koedderitzsch

    Unfortunately I don't think a workaround in eclipse-cs is feasible (or even possible).
    In my eyes the current classpath scanning implementation offers no practical benefit over the long standing previous implementation while adding serious drawbacks. I hope the points brought forward are sufficient to convince the Checkstyle team to revert this change.

     
  • Jan Burkhardt

    Jan Burkhardt - 2017-11-13

    I have seen a pull request which might fix the problem: https://github.com/checkstyle/checkstyle/pull/5245

     
  • Roman Ivanov

    Roman Ivanov - 2017-11-26

    Checkstyle released fix for https://github.com/checkstyle/checkstyle/issues/4916 .
    Lars, please upgrade to latest version of checkstyle to allow third-party checks.

     
  • Lars Koedderitzsch

    eclipse-cs 8.5.0 based on Checkstyle 8.5 has been released.

     
    • Vincent Privat

      Vincent Privat - 2017-12-20

      that's a nice Christmas gift, thanks Lars :)

       
    • Jan Burkhardt

      Jan Burkhardt - 2017-12-20

      I can confirm: It is working, thank you!

       

Log in to post a comment.