想编写一个映射的Spliterator
类:
public abstract class MappedSpliterator implements Spliterator {}
经过尝试,即使是如上所示的空类,也会导致 javac 报错StackOverflowError
。
这可能是什么原因造成的呢?
根据评论的提醒,我新建了工程单独创建该类,竟然没报错。
而我将该类加入原工程,仍然报错,现添加描述希望能够提供更多信息。
在 IDEA 里 build 报错截图:
使用 Maven 编译并把异常输出:
[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.222 s [INFO] Finished at: 2017-04-16T10:40:58+08:00 [INFO] Final Memory: 26M/143M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project oshuu: Fatal error compiling: java.lang.StackOverflowError -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project oshuu: Fatal error compiling at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213) 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 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) Caused by: org.apache.maven.plugin.MojoExecutionException: Fatal error compiling at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:796) at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 20 more Caused by: org.codehaus.plexus.compiler.CompilerException: java.lang.StackOverflowError at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:191) at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169) at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:785) ... 23 more Caused by: java.lang.RuntimeException: java.lang.StackOverflowError at com.sun.tools.javac.main.Main.compile(Main.java:553) 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) ... 25 more Caused by: java.lang.StackOverflowError at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:4481) at com.sun.tools.javac.code.Types$Subst.subst(Types.java:2906) at com.sun.tools.javac.code.Types$Subst.visitWildcardType(Types.java:2976) at com.sun.tools.javac.code.Types$Subst.visitWildcardType(Types.java:2883) at com.sun.tools.javac.code.Type$WildcardType.accept(Type.java:600) at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:4481) at com.sun.tools.javac.code.Types$Subst.subst(Types.java:2906) at com.sun.tools.javac.code.Types$Subst.subst(Types.java:2914) at com.sun.tools.javac.code.Types$Subst.visitClassType(Types.java:2955) at com.sun.tools.javac.code.Types$Subst.visitClassType(Types.java:2883) at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:763) at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:4481) at com.sun.tools.javac.code.Types$Subst.subst(Types.java:2906) at com.sun.tools.javac.code.Types$Subst.subst(Types.java:2914) at com.sun.tools.javac.code.Types$Subst.visitMethodType(Types.java:2928) at com.sun.tools.javac.code.Types$Subst.visitMethodType(Types.java:2883) at com.sun.tools.javac.code.Type$MethodType.accept(Type.java:1132) at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:4481) at com.sun.tools.javac.code.Types$Subst.subst(Types.java:2906) at com.sun.tools.javac.code.Types.subst(Types.java:2880) at com.sun.tools.javac.code.Types$16.visitClassType(Types.java:2088) at com.sun.tools.javac.code.Types$16.visitClassType(Types.java:2059) at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:763) at com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:4400) at com.sun.tools.javac.code.Types.memberType(Types.java:2056) at com.sun.tools.javac.code.Symbol$MethodSymbol.overrides(Symbol.java:1443) at com.sun.tools.javac.model.JavacElements.overrides(JavacElements.java:503) at com.sun.tools.javac.model.JavacElements.addMembers(JavacElements.java:382) at com.sun.tools.javac.model.JavacElements.getAllMembers(JavacElements.java:369) at com.sun.tools.javac.model.JavacElements.getAllMembers(JavacElements.java:61) at org.hibernate.validator.ap.ClassVisitor.visitAllMyElements(ClassVisitor.java:104) at org.hibernate.validator.ap.ClassVisitor.visitTypeAsInterface(ClassVisitor.java:80) at org.hibernate.validator.ap.ClassVisitor.visitTypeAsInterface(ClassVisitor.java:34) at javax.lang.model.util.ElementKindVisitor6.visitType(ElementKindVisitor6.java:153) at com.sun.tools.javac.code.Symbol$ClassSymbol.accept(Symbol.java:1137) at javax.lang.model.util.AbstractElementVisitor6.visit(AbstractElementVisitor6.java:111)
截取文本的最后是重复的栈“循环节”,再往前均为该循环节:
at org.hibernate.validator.ap.ClassVisitor.visitAllMyElements(ClassVisitor.java:105) at org.hibernate.validator.ap.ClassVisitor.visitTypeAsInterface(ClassVisitor.java:80) at org.hibernate.validator.ap.ClassVisitor.visitTypeAsInterface(ClassVisitor.java:34) at javax.lang.model.util.ElementKindVisitor6.visitType(ElementKindVisitor6.java:153) at com.sun.tools.javac.code.Symbol$ClassSymbol.accept(Symbol.java:1137) at javax.lang.model.util.AbstractElementVisitor6.visit(AbstractElementVisitor6.java:111)
现在还是很困惑,希望得到指教。
认证0级讲师