跳过 Spot Bugs 堆栈跟踪,当功能需要 ASM8_EXPERIMENTAL 时。

huangapple go评论69阅读模式
英文:

Skip Spot Bugs stack traces when features require ASM8_EXPERIMENTAL

问题

我正在使用 spotbugs-maven-plugin 4.0.0(加上 spotbugs 4.0.2 依赖)。

问题是它无法识别 Java 14 的 records(记录类型)。

每次它发现一个记录类型或使用该记录类型的类时,它都会打印出一个长长的堆栈跟踪信息。

[INFO] >>> spotbugs-maven-plugin:4.0.0:check (default) > :spotbugs @ core >>>
[INFO] 
[INFO] --- spotbugs-maven-plugin:4.0.0:spotbugs (spotbugs) @ core ---
[INFO] Fork Value is true
     [java] The following errors occurred during analysis:
     [java]   Unable to get XClass for com/something/MyRecord
     [java]     java.lang.UnsupportedOperationException: This feature requires ASM8_EXPERIMENTAL
     ...
     [java]   Couldn't get class info for com/something/MyRecord
     ...
     [java]   Exception analyzing com.something.MyClassThatUsesMyRecord using detector edu.umd.cs.findbugs.detect.CalledMethods
     ...
     
[INFO] Done SpotBugs Analysis....

我该如何摆脱这些详细的异常信息呢?

英文:

I'm using spotbugs-maven-plugin 4.0.0 (+ spotbugs 4.0.2 dependency).

The problem is that it cannot recognize Java 14 records.

Every time when it finds a record or a class that uses that record, it prints a long stacktrace.

[INFO] >>> spotbugs-maven-plugin:4.0.0:check (default) > :spotbugs @ core >>>
[INFO] 
[INFO] --- spotbugs-maven-plugin:4.0.0:spotbugs (spotbugs) @ core ---
[INFO] Fork Value is true
     [java] The following errors occurred during analysis:
     [java]   Unable to get XClass for com/something/MyRecord
     [java]     java.lang.UnsupportedOperationException: This feature requires ASM8_EXPERIMENTAL
     [java]       At org.objectweb.asm.ClassVisitor.visitRecordComponentExperimental(ClassVisitor.java:304)
     [java]       At org.objectweb.asm.ClassReader.readRecordComponent(ClassReader.java:929)
     [java]       At org.objectweb.asm.ClassReader.accept(ClassReader.java:704)
     [java]       At edu.umd.cs.findbugs.asm.FBClassReader.accept(FBClassReader.java:44)
     [java]       At org.objectweb.asm.ClassReader.accept(ClassReader.java:401)
     [java]       At edu.umd.cs.findbugs.classfile.engine.ClassParserUsingASM.parse(ClassParserUsingASM.java:552)
     [java]       At edu.umd.cs.findbugs.classfile.engine.ClassParserUsingASM.parse(ClassParserUsingASM.java:736)
     [java]       At edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:79)
     [java]       At edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:38)
     [java]       At edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getClassAnalysis(AnalysisCache.java:261)
     [java]       At edu.umd.cs.findbugs.ba.XFactory.getXClass(XFactory.java:685)
     [java]       At edu.umd.cs.findbugs.ba.AnalysisContext.setAppClassList(AnalysisContext.java:975)
     [java]       At edu.umd.cs.findbugs.FindBugs2.setAppClassList(FindBugs2.java:909)
     [java]       At edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:252)
     [java]       At edu.umd.cs.findbugs.FindBugs.runMain(FindBugs.java:395)
     [java]       At edu.umd.cs.findbugs.FindBugs2.main(FindBugs2.java:1231)
     [java]   Couldn't get class info for com/something/MyRecord
     [java]     java.lang.UnsupportedOperationException: This feature requires ASM8_EXPERIMENTAL
     [java]       At org.objectweb.asm.ClassVisitor.visitRecordComponentExperimental(ClassVisitor.java:304)
     [java]       At org.objectweb.asm.ClassReader.readRecordComponent(ClassReader.java:929)
     [java]       At org.objectweb.asm.ClassReader.accept(ClassReader.java:704)
     [java]       At edu.umd.cs.findbugs.asm.FBClassReader.accept(FBClassReader.java:44)
     [java]       At org.objectweb.asm.ClassReader.accept(ClassReader.java:401)
     [java]       At edu.umd.cs.findbugs.classfile.engine.ClassParserUsingASM.parse(ClassParserUsingASM.java:552)
     [java]       At edu.umd.cs.findbugs.classfile.engine.ClassParserUsingASM.parse(ClassParserUsingASM.java:736)
     [java]       At edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:79)
     [java]       At edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:38)
     [java]       At edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getClassAnalysis(AnalysisCache.java:261)
     [java]       At edu.umd.cs.findbugs.ba.XFactory.getXClass(XFactory.java:685)
     [java]       At edu.umd.cs.findbugs.ba.AnalysisContext.setAppClassList(AnalysisContext.java:975)
     [java]       At edu.umd.cs.findbugs.FindBugs2.setAppClassList(FindBugs2.java:909)
     [java]       At edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:252)
     [java]       At edu.umd.cs.findbugs.FindBugs.runMain(FindBugs.java:395)
     [java]       At edu.umd.cs.findbugs.FindBugs2.main(FindBugs2.java:1231)
     [java]   Exception analyzing com.something.MyClassThatUsesMyRecord using detector edu.umd.cs.findbugs.detect.CalledMethods
     [java]     java.lang.UnsupportedOperationException: This feature requires ASM8_EXPERIMENTAL
     [java]       At org.objectweb.asm.ClassVisitor.visitRecordComponentExperimental(ClassVisitor.java:304)
     [java]       At org.objectweb.asm.ClassReader.readRecordComponent(ClassReader.java:929)
     [java]       At org.objectweb.asm.ClassReader.accept(ClassReader.java:704)
     [java]       At edu.umd.cs.findbugs.asm.FBClassReader.accept(FBClassReader.java:44)
     [java]       At org.objectweb.asm.ClassReader.accept(ClassReader.java:401)
     [java]       At edu.umd.cs.findbugs.classfile.engine.ClassParserUsingASM.parse(ClassParserUsingASM.java:552)
     [java]       At edu.umd.cs.findbugs.classfile.engine.ClassParserUsingASM.parse(ClassParserUsingASM.java:736)
     [java]       At edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:79)
     [java]       At edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:38)
     [java]       At edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getClassAnalysis(AnalysisCache.java:261)
     [java]       At edu.umd.cs.findbugs.ba.XFactory.getXClass(XFactory.java:685)
     [java]       At edu.umd.cs.findbugs.ba.AnalysisContext.setAppClassList(AnalysisContext.java:975)
     [java]       At edu.umd.cs.findbugs.FindBugs2.setAppClassList(FindBugs2.java:909)
     [java]       At edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:252)
     [java]       At edu.umd.cs.findbugs.FindBugs.runMain(FindBugs.java:395)
     [java]       At edu.umd.cs.findbugs.FindBugs2.main(FindBugs2.java:1231)
     ...
     
[INFO] Done SpotBugs Analysis....

How can I get rid of these detailed exceptions?

答案1

得分: 3

虽然该插件的最新发布已经支持 JDK-15,但是对于预览特性的 ASM 支持需要 8.0+ 版本,而该库目前仍然是 7.3.1

话虽如此,对于他们可部署分支的更改应该可以修复这个问题。具体来说,区别在于:

- <asm.version>7.3.1</asm.version>
+ <asm.version>8.0.1</asm.version>

所以只需等待下一个版本,同时请求他们尽快发布。 跳过 Spot Bugs 堆栈跟踪,当功能需要 ASM8_EXPERIMENTAL 时。

英文:

Though the plugin's latest release read the support through JDK-15, the ASM support for preview features require 8.0+ version while the library is still on 7.3.1.

That said, the changes to their deployable branch should fix this. Specifically the difference in:

- <asm.version>7.3.1</asm.version>
+ <asm.version>8.0.1</asm.version>

So just wait for the next version while requesting them to release soon. 跳过 Spot Bugs 堆栈跟踪,当功能需要 ASM8_EXPERIMENTAL 时。

huangapple
  • 本文由 发表于 2020年5月5日 07:56:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/61603586.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定