PMDException: Error while processing Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 65

573 views Asked by At
  • What I am trying to achieve:

Use org.apache.maven.plugins maven-pmd-plugin 3.21.2 to perform PMD scan on a project

  • What did I try:

With this pom:

 <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>3.21.2</version>
                <configuration>
                    <outputDirectory>target/reports/pmd</outputDirectory>
                </configuration>
            </plugin>

I am running this mvn command mvn clean install pmd:cpd pmd:pmd

  • Issue

Reproducible 100%, I am getting this:

 There are X PMD processing errors:
C:\Users\SomeFile.java: PMDException: Error while processing 

With further debugging, this is what I am seeing:

net.sourceforge.pmd.PMDException: Error while processing
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCodeWithoutCache(SourceCodeProcessor.java:128)
    at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:100)
    at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:62)
    at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:89)
    at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:30)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 65
    at org.objectweb.asm.ClassReader.(ClassReader.java:199)
    at org.objectweb.asm.ClassReader.(ClassReader.java:180)
    at org.objectweb.asm.ClassReader.(ClassReader.java:166)
    at org.objectweb.asm.ClassReader.(ClassReader.java:287)
    at net.sourceforge.pmd.lang.java.typeresolution.PMDASMClassLoader.getImportedClasses(PMDASMClassLoader.java:118)
    at net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver.populateClassName(ClassTypeResolver.java:1643)
    at net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver.visit(ClassTypeResolver.java:216)
    at net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit.jjtAccept(ASTCompilationUnit.java:44)
    at net.sourceforge.pmd.lang.java.typeresolution.TypeResolutionFacade.initializeWith(TypeResolutionFacade.java:21)
    at net.sourceforge.pmd.lang.java.AbstractJavaHandler$5.start(AbstractJavaHandler.java:121)
    at net.sourceforge.pmd.SourceCodeProcessor.usesTypeResolution(SourceCodeProcessor.java:178)
    at net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:205)
    at net.sourceforge.pmd.SourceCodeProcessor.processSourceCodeWithoutCache(SourceCodeProcessor.java:118)
    ... 10 more
  • Question

What could cause this PMDException? How can I get more logs to troubleshoot this?

1

There are 1 answers

1
adangel On

The processing errors are part of the report, the maven-pmd-plugin creates. If you look at the report at target/reports/pmd/pmd.html you should see the processing error including the stacktrace for further analysis. The same info is also added to the XML-based report in target/pmd.xml.

The maven-pmd-plugin contains a couple of configuration options, which are interesting in this matter:

  • renderProcessingErrors - this is by default enabled, and it is the reason, why the processing errors end up in the HTML report.
  • skipPmdError - this is enabled by default. But you might want to disable this, so that the build breaks, if PMD can't analyze the code for whatever reason. However, with this option disabled, the maven-pmd-plugin doesn't create a report with the processing error stacktrace anymore. In order to see the errors, you'd need to run maven with the -X flag, to see debug outputs.