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

java.lang.IllegalArgumentException with Java 10? #47

Closed rbjorklin closed 6 years ago

rbjorklin commented 6 years ago

We are getting a lot of java.lang.IllegalArgumentException when trying to run this plugin with Java 10. But the changelog for Spotbugs gives me the impression it should be working. Are we missing --add-modules java.xml.bind or something of the likes somewhere?

EDIT: We're using maven 3.5.3 if it matters. //edit

Couldn't get class info for java/util/concurrent/Callable                                                                                                                                                        
 java.lang.IllegalArgumentException                                                                                                                                                                              
   At org.objectweb.asm.ClassReader.<init>(ClassReader.java:160)                                                                                                                                                 
   At org.objectweb.asm.ClassReader.<init>(ClassReader.java:143)                                      
   At edu.umd.cs.findbugs.asm.FBClassReader.<init>(FBClassReader.java:35)                             
   At edu.umd.cs.findbugs.classfile.engine.asm.ClassReaderAnalysisEngine.analyze(ClassReaderAnalysisEngine.java:48)                                                                                              
   At edu.umd.cs.findbugs.classfile.engine.asm.ClassReaderAnalysisEngine.analyze(ClassReaderAnalysisEngine.java:34)                                                                                              
   At edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getClassAnalysis(AnalysisCache.java:262)       
   At edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:75)                                                                                                      
   At edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:38)                                                                                                      
   At edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getClassAnalysis(AnalysisCache.java:262)       
   At edu.umd.cs.findbugs.ba.XFactory.getXClass(XFactory.java:687)                                    
   At edu.umd.cs.findbugs.ba.AnalysisContext.setAppClassList(AnalysisContext.java:970)                
   At edu.umd.cs.findbugs.FindBugs2.setAppClassList(FindBugs2.java:876)                               
   At edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:222)                                       
   At edu.umd.cs.findbugs.FindBugs.runMain(FindBugs.java:401)                                         
   At edu.umd.cs.findbugs.FindBugs2.main(FindBugs2.java:1187)                                         
Couldn't get class info for java/util/concurrent/ForkJoinPool                                         
 java.lang.IllegalArgumentException              
   At org.objectweb.asm.ClassReader.<init>(ClassReader.java:160)                                      
   At org.objectweb.asm.ClassReader.<init>(ClassReader.java:143)                                      
   At edu.umd.cs.findbugs.asm.FBClassReader.<init>(FBClassReader.java:35)                             
   At edu.umd.cs.findbugs.classfile.engine.asm.ClassReaderAnalysisEngine.analyze(ClassReaderAnalysisEngine.java:48)                                                                                              
   At edu.umd.cs.findbugs.classfile.engine.asm.ClassReaderAnalysisEngine.analyze(ClassReaderAnalysisEngine.java:34)                                                                                              
   At edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getClassAnalysis(AnalysisCache.java:262)       
   At edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:75)                                                                                                      
   At edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:38)                                                                                                      
   At edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getClassAnalysis(AnalysisCache.java:262)       
   At edu.umd.cs.findbugs.ba.XFactory.getXClass(XFactory.java:687)                                    
   At edu.umd.cs.findbugs.ba.AnalysisContext.setAppClassList(AnalysisContext.java:970)                
   At edu.umd.cs.findbugs.FindBugs2.setAppClassList(FindBugs2.java:876)                               
   At edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:222)                                       
   At edu.umd.cs.findbugs.FindBugs.runMain(FindBugs.java:401)                                         
   At edu.umd.cs.findbugs.FindBugs2.main(FindBugs2.java:1187)                                         
Couldn't get class info for javax/xml/bind/JAXBElement                                                
 java.lang.IllegalArgumentException              
   At org.objectweb.asm.ClassReader.<init>(ClassReader.java:160)                                      
   At org.objectweb.asm.ClassReader.<init>(ClassReader.java:143)                                      
   At edu.umd.cs.findbugs.asm.FBClassReader.<init>(FBClassReader.java:35)                             
   At edu.umd.cs.findbugs.classfile.engine.asm.ClassReaderAnalysisEngine.analyze(ClassReaderAnalysisEngine.java:48)                                                                                              
   At edu.umd.cs.findbugs.classfile.engine.asm.ClassReaderAnalysisEngine.analyze(ClassReaderAnalysisEngine.java:34)                                                                                              
   At edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getClassAnalysis(AnalysisCache.java:262)       
   At edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:75)                                                                                                      
   At edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:38)                                                                                                      
   At edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getClassAnalysis(AnalysisCache.java:262)       
   At edu.umd.cs.findbugs.ba.XFactory.getXClass(XFactory.java:687)                                    
   At edu.umd.cs.findbugs.ba.AnalysisContext.setAppClassList(AnalysisContext.java:970)                
   At edu.umd.cs.findbugs.FindBugs2.setAppClassList(FindBugs2.java:876)                               
   At edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:222)                                       
   At edu.umd.cs.findbugs.FindBugs.runMain(FindBugs.java:401)                                         
   At edu.umd.cs.findbugs.FindBugs2.main(FindBugs2.java:1187)
rbjorklin commented 6 years ago

My colleague have probably found the solution: https://github.com/spotbugs/spotbugs/issues/593#issuecomment-385904884

spotbugs-maven-plugin 3.1.3 depends on spotbugs 3.1.2.

rbjorklin commented 6 years ago

This issue has already been resolved on spotbugs branch in commit: https://github.com/spotbugs/spotbugs-maven-plugin/commit/56eaed1a002289e6f9cf7bc36c1c2a3b1fd53466

Is there a new release on the way?

hazendaz commented 6 years ago

There is a patch to asm that is needed and latest spotbugs has it. Release on this repo has not been pushed yet. I'll get a release out tonight.

Thanks

Jeremy

Get Outlook for Androidhttps://aka.ms/ghei36


From: Robin notifications@github.com Sent: Wednesday, May 2, 2018 4:47:38 AM To: spotbugs/spotbugs-maven-plugin Cc: Subscribed Subject: Re: [spotbugs/spotbugs-maven-plugin] java.lang.IllegalArgumentException with Java 10? (#47)

This issue has already been resolved on spotbugs branch: 56eaed1https://github.com/spotbugs/spotbugs-maven-plugin/commit/56eaed1a002289e6f9cf7bc36c1c2a3b1fd53466

Is there a new release on the way?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/spotbugs/spotbugs-maven-plugin/issues/47#issuecomment-385907569, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AA7ho5H_4EEv5j_XwA2KW9TwJmq-0ibXks5tuXKqgaJpZM4Tu3qO.

hazendaz commented 6 years ago

Work around for now, just include spotbugs 3.1.3 in the plugin dependencies section in your pom. I cannot otherwise release tonight as I have 2 integration tests failing on jdk 10 I need to work out details on. When I do release, I'm going to re-align to spotbugs numbering to avoid confusion. So release when I push it will become 3.1.3-1. Thanks.

hazendaz commented 6 years ago

Release 3.1.3.1 will be out shortly and has patch for this. Please note jdk11 support is not possible on any maven plugin right now due to what they are doing under the hood. I've verified that across multiple plugins so jdk11 support will need to wait.

PascalSchumacher commented 6 years ago

Thanks for fixing this! 👍

Please note jdk11 support is not possible on any maven plugin right now due to what they are doing under the hood.

No sure what you are referring to, but a lot of maven plugins already work on java 11. For example the Apache Commons Text build works fine (with just skipping Jacoco) (see: https://travis-ci.org/apache/commons-text/builds).

Edit: I guess currently it is not possible to run SpotBugs on Java 12 because SpotBugs requires ASM and there is no ASM version with support for the Java 11 class file format yet.

hazendaz commented 6 years ago

Plugin issue only. Normal artifacts are fine. It's a module issue.

Get Outlook for Androidhttps://aka.ms/ghei36


From: Pascal Schumacher notifications@github.com Sent: Thursday, May 10, 2018 9:21:38 AM To: spotbugs/spotbugs-maven-plugin Cc: Jeremy Landis; State change Subject: Re: [spotbugs/spotbugs-maven-plugin] java.lang.IllegalArgumentException with Java 10? (#47)

Please note jdk11 support is not possible on any maven plugin right now due to what they are doing under the hood.

No sure what you are referring to?, but a lot of maven plugin already work on java 11. For example the whole Apache Commons Text Build works fine (see: https://travis-ci.org/apache/commons-text/builds).

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/spotbugs/spotbugs-maven-plugin/issues/47#issuecomment-388051336, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AA7ho1aedVGWVY42YydZPL6NcOyUUSD0ks5txD7igaJpZM4Tu3qO.

hazendaz commented 6 years ago

To clarify, jdk11 issue is building of the plugin itself. This was confirmed with other maven plugins as well.

[ERROR] spotbugs-maven-plugin\target\generated-sources\groovy-stubs\main\org\codehaus\mojo\spotbugs\SpotBugsMojo.java:[10,195] cannot access java.lang.Object
  bad class file: /modules/java.base/java/lang/Object.class
    class file has wrong version 55.0, should be 53.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.
PascalSchumacher commented 6 years ago

You probably already know this, but just to clarify:

The error occurs because Groovy 2.4.15 contains a repackaged ASM 6.1, which supports the class file format up to version 53.0 (Java 9). ASM 6.1.1 supports the class file format up to version 54.0 (Java 10). No ASM version with support of 55.0 (Java 11) has been released yet.

hazendaz commented 6 years ago

@PascalSchumacher Thanks for heads up on that. I didn't realize groovy had that embedded like that. That also gives me something to pinpoint on another maven plugin which doesn't use groovy but probably has ASM in there somewhere. After you pointed that out I looked around some and see that is a problem for a lot of projects. Thanks.