我正在写一个应用程序一段时间,今天发生了一些变化后,当我尝试mvn clean install
时出现了这个错误:
An exception has occurred in the compiler (1.8.0_31). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diag nostic in your report. Thank you. java.lang.NullPointerException
at com.sun.tools.javac.code.Types.isConvertible(Types.java:290)
at com.sun.tools.javac.comp.Check.assertConvertible(Check.java:922)
at com.sun.tools.javac.comp.Check.checkMethod(Check.java:876)
at com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:3838)
at com.sun.tools.javac.comp.Attr.checkIdInternal(Attr.java:3615)
at com.sun.tools.javac.comp.Attr.checkMethodIdInternal(Attr.java:3522)
at com.sun.tools.javac.comp.Attr.checkMethodId(Attr.java:3501)
at com.sun.tools.javac.comp.Attr.checkId(Attr.java:3488)
at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3370)
at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1897)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:607)
at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1843)
at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:607)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:649)
at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1093)
at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:852)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:607)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:676)
at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:692)
at com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode$StructuralStuckChecker.canLambdaBodyCompleteNormally(DeferredAttr.java:704)
at com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode$StructuralStuckChecker.visitLambda(DeferredAttr.java:652)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode$StructuralStuckChecker.complete(DeferredAttr.java:605)
at com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:245)
at com.sun.tools.javac.comp.DeferredAttr$DeferredType.access$000(DeferredAttr.java:132)
at com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode.process(DeferredAttr.java:554)
at com.sun.tools.javac.comp.DeferredAttr$DeferredAttrContext.complete(DeferredAttr.java:479)
at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:578)
at com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1431)
at com.sun.tools.javac.comp.Resolve.findMethodInScope(Resolve.java:1618)
at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1689)
at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1662)
at com.sun.tools.javac.comp.Resolve.findConstructor(Resolve.java:2545)
at com.sun.tools.javac.comp.Resolve$11.doLookup(Resolve.java:2514)
at com.sun.tools.javac.comp.Resolve$BasicLookupHelper.lookup(Resolve.java:3074)
at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3325)
at com.sun.tools.javac.comp.Resolve.resolveConstructor(Resolve.java:2511)
at com.sun.tools.javac.comp.Resolve.resolveConstructor(Resolve.java:2502)
at com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:2097)
at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1516)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:607)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:649)
at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1093)
at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:852)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:607)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:676)
at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4342)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4252)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4181)
at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4156)
at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1248)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:785)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
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) [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO]
------------------------------------------------------------- [ERROR] An unknown compilation problem occurred [INFO] 1 error [INFO]
------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE
我以前从未见过这样的东西。我该如何解决这个问题?
答案 0 :(得分:3)
导致问题的原因:
int count = possibleCards.stream().reduce(0,
(cnt, c) -> cnt += (c.getTags().contains(tag) ? 1 : 0),
(cnt1, cnt2) -> cnt1 + cnt2);
这行代码应该计算所有具有特定标记的卡对象。 该错误是可重现的。更多细节可以在这里找到:https://bugs.openjdk.java.net/browse/JDK-8056038?page=com.atlassian.streams.streams-jira-plugin:activity-stream-issue-tab
答案 1 :(得分:1)
在某些平台上构建比u25更早的Java 8而在其他平台上构建u31通常会出现奇怪的问题,其中lambdas和拆箱可能不能很好地协同工作。解决方法可能是明确推断可能发生拆箱的一些lambda类型,例如:
(Integer count, c) -> count += c.getTags().contains(tag) ? 1 : 0)
但在这种特定情况下,您可以完全使用mapToInt()
和sum()
的组合来避免此问题,以便明显没有任何拆箱的恶作剧。
这个问题应该在u40中修复,但是在写这个答案时,不会发布。