spotbugs / spotbugs-maven-plugin

Maven Mojo Plug-In to generate reports based on the SpotBugs Analyzer
https://spotbugs.github.io/spotbugs-maven-plugin/
Apache License 2.0
69 stars 51 forks source link

Plugin fails on macOS 10.13 (High Sierra) with ArrayIndexOutOfBoundsException #9

Closed twohey closed 6 years ago

twohey commented 6 years ago

A minimal project with one class and no methods evidences this error. I've made a simple project which demonstrates this issue at https://github.com/twohey/spotbugs-bug

$ java -version
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)
$ uname -a
Darwin twohey-book.local 17.0.0 Darwin Kernel Version 17.0.0: Thu Aug 24 21:48:19 PDT 2017; root:xnu-4570.1.46~2/RELEASE_X86_64 x86_64
iloveeclipse commented 6 years ago

Can you please post the full stack trace, and also the version of spotbugs and plugin used? Thanks.

iloveeclipse commented 6 years ago

I can't reproduce neither with Java 8 nor with Java 9, but I'm using mingw on windows.

Andrey@Yoga MINGW64 /d/git/spotbugs-bug (master)
$ mvn -e verify
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SpotBugs 1 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ spotbugs-1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\git\spotbugs-bug\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ spotbugs-1 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ spotbugs-1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\git\spotbugs-bug\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ spotbugs-1 ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ spotbugs-1 ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ spotbugs-1 ---
[INFO]
[INFO] >>> spotbugs-maven-plugin:3.1.0-RC6:check (spotbugs-check) > :spotbugs @ spotbugs-1 >>>
[INFO]
[INFO] --- spotbugs-maven-plugin:3.1.0-RC6:spotbugs (spotbugs) @ spotbugs-1 ---
[INFO] Fork Value is true
[INFO] Done SpotBugs Analysis....
[INFO]
[INFO] <<< spotbugs-maven-plugin:3.1.0-RC6:check (spotbugs-check) < :spotbugs @ spotbugs-1 <<<
[INFO]
[INFO]
[INFO] --- spotbugs-maven-plugin:3.1.0-RC6:check (spotbugs-check) @ spotbugs-1 ---
[INFO] BugInstance size is 0
[INFO] Error size is 0
[INFO] No errors/warnings found
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.207 s
[INFO] Finished at: 2017-10-21T18:19:38+02:00
[INFO] Final Memory: 25M/213M
Andrey@Yoga MINGW64 /d/git/spotbugs-bug (master)
$ mvn -e verify
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SpotBugs 1 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ spotbugs-1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\git\spotbugs-bug\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ spotbugs-1 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ spotbugs-1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\git\spotbugs-bug\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ spotbugs-1 ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ spotbugs-1 ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ spotbugs-1 ---
[INFO]
[INFO] >>> spotbugs-maven-plugin:3.1.0-RC6:check (spotbugs-check) > :spotbugs @ spotbugs-1 >>>
[INFO]
[INFO] --- spotbugs-maven-plugin:3.1.0-RC6:spotbugs (spotbugs) @ spotbugs-1 ---
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/C:/Users/Andrey/.m2/repository/org/codehaus/groovy/groovy/2.4.12/groovy-2.4.12.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Fork Value is true
     [java] WARNING: An illegal reflective access operation has occurred
     [java] WARNING: Illegal reflective access by org.dom4j.io.SAXContentHandler (file:/C:/Users/Andrey/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar) to method com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser$LocatorProxy.getEncoding()
     [java] WARNING: Please consider reporting this to the maintainers of org.dom4j.io.SAXContentHandler
     [java] WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
     [java] WARNING: All illegal access operations will be denied in a future release
[INFO] Done SpotBugs Analysis....
[INFO]
[INFO] <<< spotbugs-maven-plugin:3.1.0-RC6:check (spotbugs-check) < :spotbugs @ spotbugs-1 <<<
[INFO]
[INFO]
[INFO] --- spotbugs-maven-plugin:3.1.0-RC6:check (spotbugs-check) @ spotbugs-1 ---
[INFO] BugInstance size is 0
[INFO] Error size is 0
[INFO] No errors/warnings found
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.505 s
[INFO] Finished at: 2017-10-21T18:29:53+02:00
[INFO] Final Memory: 26M/87M
[INFO] ------------------------------------------------------------------------

Andrey@Yoga MINGW64 /d/git/spotbugs-bug (master)
hazendaz commented 6 years ago

Possibly local configuration is bad. While reported differently, this claims that similar issue when pom or maven settings files are not properly tagged with UTF-8. See here

twohey commented 6 years ago

The full stack trace is:

[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ spotbugs-1 ---
[INFO] Building jar: /Users/twohey/code/spotbugs-bug/target/spotbugs-1-1.0-SNAPSHOT.jar
[INFO] 
[INFO] >>> spotbugs-maven-plugin:3.1.0-RC6:check (spotbugs-check) > :spotbugs @ spotbugs-1 >>>
[INFO] 
[INFO] --- spotbugs-maven-plugin:3.1.0-RC6:spotbugs (spotbugs) @ spotbugs-1 ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.343 s
[INFO] Finished at: 2017-10-23T22:13:45-04:00
[INFO] Final Memory: 16M/53M
[INFO] ------------------------------------------------------------------------
[ERROR] 9897
java.lang.ArrayIndexOutOfBoundsException: 9897
    at org.codehaus.plexus.util.xml.pull.MXParser.parsePI(MXParser.java:2502)
    at org.codehaus.plexus.util.xml.pull.MXParser.parseEpilog(MXParser.java:1604)
    at org.codehaus.plexus.util.xml.pull.MXParser.nextImpl(MXParser.java:1434)
    at org.codehaus.plexus.util.xml.pull.MXParser.next(MXParser.java:1131)
    at org.apache.maven.model.io.xpp3.MavenXpp3Reader.read(MavenXpp3Reader.java:3856)
    at org.apache.maven.model.io.xpp3.MavenXpp3Reader.read(MavenXpp3Reader.java:595)
    at org.apache.maven.model.io.DefaultModelReader.read(DefaultModelReader.java:109)
    at org.apache.maven.model.io.DefaultModelReader.read(DefaultModelReader.java:82)
    at org.apache.maven.model.building.DefaultModelProcessor.read(DefaultModelProcessor.java:81)
    at org.apache.maven.model.building.DefaultModelBuilder.readModel(DefaultModelBuilder.java:535)
    at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally(DefaultModelBuilder.java:1097)
    at org.apache.maven.model.building.DefaultModelBuilder.readParent(DefaultModelBuilder.java:829)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:331)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:321)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:199)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.resolveCachedArtifactDescriptor(DefaultDependencyCollector.java:544)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.getArtifactDescriptorResult(DefaultDependencyCollector.java:528)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:418)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:372)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.process(DefaultDependencyCollector.java:360)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.doRecurse(DefaultDependencyCollector.java:513)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:467)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:372)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.process(DefaultDependencyCollector.java:360)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.doRecurse(DefaultDependencyCollector.java:513)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:467)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:372)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.process(DefaultDependencyCollector.java:360)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:263)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies(DefaultRepositorySystem.java:325)
    at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolveInternal(DefaultPluginDependenciesResolver.java:202)
    at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:149)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.createPluginRealm(DefaultMavenPluginManager.java:402)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.setupPluginRealm(DefaultMavenPluginManager.java:374)
    at org.apache.maven.plugin.DefaultBuildPluginManager.getPluginRealm(DefaultBuildPluginManager.java:231)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:102)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:353)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:198)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
twohey commented 6 years ago

@iloveeclipse the version is that specified in the pom.xml of the example project: 3.1.0-RC6

twohey commented 6 years ago

@hazendaz I do not think it is a maven issue as I have neither $M2_HOME set nor a ~/.m2/settings.xml file.

$ ls -al ~/.m2
total 0
drwxr-xr-x   3 twohey  staff    96 Jun 11  2016 .
drwxr-xr-x+ 37 twohey  staff  1184 Oct 11 14:12 ..
drwxr-xr-x  53 twohey  staff  1696 Oct  8 15:14 repository
$ echo $M2_HOME

$ 
hazendaz commented 6 years ago

@twohey What maven version are you using?

twohey commented 6 years ago

@hazendaz

I was using maven 3.5.0

$ mvn -v
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T15:39:06-04:00)
Maven home: /usr/local/Cellar/maven/3.5.0/libexec
Java version: 9, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.1", arch: "x86_64", family: "mac"

Your question got me thinking and I upgraded my maven to 3.5.2

$ mvn -v
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T03:58:13-04:00)
Maven home: /usr/local/Cellar/maven/3.5.2/libexec
Java version: 9, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.1", arch: "x86_64", family: "mac"

Now the build is successful, but does warn about illegal groovy method accesses, which I'm happy to file a separate bug report on.

[INFO] >>> spotbugs-maven-plugin:3.1.0-RC7:check (spotbugs-check) > :spotbugs @ spotbugs-1 >>>
[INFO] 
[INFO] --- spotbugs-maven-plugin:3.1.0-RC7:spotbugs (spotbugs) @ spotbugs-1 ---
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/Users/twohey/.m2/repository/org/codehaus/groovy/groovy/2.4.12/groovy-2.4.12.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Fork Value is true
     [java] WARNING: An illegal reflective access operation has occurred
     [java] WARNING: Illegal reflective access by org.dom4j.io.SAXContentHandler (file:/Users/twohey/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar) to method com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser$LocatorProxy.getEncoding()
     [java] WARNING: Please consider reporting this to the maintainers of org.dom4j.io.SAXContentHandler
     [java] WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
     [java] WARNING: All illegal access operations will be denied in a future release
[INFO] Done SpotBugs Analysis....
[INFO] 
[INFO] <<< spotbugs-maven-plugin:3.1.0-RC7:check (spotbugs-check) < :spotbugs @ spotbugs-1 <<<
[INFO] 
[INFO] 
[INFO] --- spotbugs-maven-plugin:3.1.0-RC7:check (spotbugs-check) @ spotbugs-1 ---
[INFO] BugInstance size is 0
[INFO] Error size is 0
[INFO] No errors/warnings found
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.400 s
[INFO] Finished at: 2017-11-11T14:34:41-05:00
[INFO] Final Memory: 24M/79M
[INFO] ------------------------------------------------------------------------
hazendaz commented 6 years ago

@iloveeclipse Do you think that issue is in spotbugs itself since it is using dom4j or do you think its the plugin usage?

iloveeclipse commented 6 years ago

Tjere are two issues, caused by using Java 9 as JVM: 1) Groovy illegal reflection use warning: that is from plugin 2) dom4j warning: that is from spotbugs (there is a ticket to update dom4j already)

Both are thanks to the Java 9 paranoia.

hazendaz commented 6 years ago

Groovy issue is not even fixed on their alpha 3.0.0-alpha-1 which supports java 9 fully per their release notes. It's a warning at best so safe to ignore that.

hazendaz commented 6 years ago

Closing this issue as not applicable to this plugin itself. The groovy issue seems to be known after some google searches. However, given groovy is only 3.0.0-alpha-1 right now they do not have it yet fixed. We will stick to 2.4.13 at this point in time and those are effectively warnings that means it might break later (possibly in java 10). The dom4j thing has a ticket already. Given both are outside of scope here, going to close this.

As a side note, this plugin now effectively builds with proper java 9 setup (where java 8 isn't getting mixed under the hood) without issues. That took a lot of digging to figure out but travis now has clean builds.