3

当我尝试使用dagger 2Kotlin Coroutines和 Java 8 构建我的项目时,我得到一个 ArrayIndexOutOfBoundsException。当我使用 Java 9 或 Java 10 时,问题不会出现(在 Java 11 上会出现另一个问题,但这是另一个问题)。我创建了一个示例项目,让其他人重现异常。

这是使用的框架之一中的已知错误吗?

毕业输出:

$ ./gradlew build
Downloading https://services.gradle.org/distributions/gradle-4.10.2-all.zip
...............................................................................................................

Welcome to Gradle 4.10.2!

Here are the highlights of this release:
 - Incremental Java compilation by default
 - Periodic Gradle caches cleanup
 - Gradle Kotlin DSL 1.0-RC6
 - Nested included builds
 - SNAPSHOT plugin versions in the `plugins {}` block

For more details see https://docs.gradle.org/4.10.2/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)
> Task :submodule:kaptGenerateStubsKotlin
> Task :submodule:kaptKotlin
> Task :submodule:compileKotlin
> Task :submodule:compileJava
> Task :submodule:processResources NO-SOURCE
> Task :submodule:classes
> Task :submodule:inspectClassesForKotlinIC
> Task :submodule:jar
> Task :app:kaptGenerateStubsKotlin
e: java.lang.IllegalStateException: failed to analyze: java.lang.ArrayIndexOutOfBoundsException: 21
    at org.jetbrains.kotlin.analyzer.AnalysisResult.throwIfError(AnalysisResult.kt:56)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:125)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:161)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:57)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:96)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:52)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:93)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$1$2.invoke(CompileServiceImpl.kt:441)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$1$2.invoke(CompileServiceImpl.kt:101)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:1020)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:101)
    at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:1062)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:1019)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:440)
    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:498)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
    at sun.rmi.transport.Transport$1.run(Transport.java:200)
    at sun.rmi.transport.Transport$1.run(Transport.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 21
    at com.sun.tools.javac.jvm.ClassReader$8.read(ClassReader.java:1072)
    at com.sun.tools.javac.jvm.ClassReader.readAttrs(ClassReader.java:1381)
    at com.sun.tools.javac.jvm.ClassReader.readMemberAttrs(ClassReader.java:1371)
    at com.sun.tools.javac.jvm.ClassReader.readCode(ClassReader.java:1408)
    at com.sun.tools.javac.jvm.ClassReader$3.read(ClassReader.java:1006)
    at com.sun.tools.javac.jvm.ClassReader.readAttrs(ClassReader.java:1381)
    at com.sun.tools.javac.jvm.ClassReader.readMemberAttrs(ClassReader.java:1371)
    at com.sun.tools.javac.jvm.ClassReader.readMethod(ClassReader.java:2044)
    at com.sun.tools.javac.jvm.ClassReader.readClass(ClassReader.java:2252)
    at com.sun.tools.javac.jvm.ClassReader.readClassFile(ClassReader.java:2324)
    at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:2511)
    at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:2442)
    at com.sun.tools.javac.jvm.ClassReader.access$000(ClassReader.java:76)
    at com.sun.tools.javac.jvm.ClassReader$1.complete(ClassReader.java:240)
    at com.sun.tools.javac.code.Symbol.complete(Symbol.java:574)
    at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1037)
    at com.sun.tools.javac.jvm.ClassReader.loadClass(ClassReader.java:2623)
    at com.sun.tools.javac.comp.Resolve.loadClass(Resolve.java:1907)
    at com.sun.tools.javac.comp.Resolve.findIdentInPackage(Resolve.java:2146)
    at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:3391)
    at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3278)
    at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1897)
    at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)
    at com.sun.tools.javac.comp.Attr.attribType(Attr.java:638)
    at com.sun.tools.javac.comp.Attr.attribType(Attr.java:631)
    at com.sun.tools.javac.comp.MemberEnter.signature(MemberEnter.java:390)
    at com.sun.tools.javac.comp.MemberEnter.visitMethodDef(MemberEnter.java:581)
    at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
    at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:437)
    at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:449)
    at com.sun.tools.javac.comp.MemberEnter.finishClass(MemberEnter.java:459)
    at com.sun.tools.javac.comp.MemberEnter.finish(MemberEnter.java:1404)
    at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:1199)
    at com.sun.tools.javac.code.Symbol.complete(Symbol.java:574)
    at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1037)
    at com.sun.tools.javac.comp.Enter.complete(Enter.java:493)
    at com.sun.tools.javac.comp.Enter.main(Enter.java:471)
    at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:982)
    at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:47)
    at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:27)
    at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.runAnnotationProcessing(Kapt3Extension.kt:213)
    at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:178)
    at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:96)
    at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:95)
    at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:105)
    at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:82)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:375)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:67)
    at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:107)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:366)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:120)
    ... 30 more


FAILURE: Build failed with an exception.> Task :app:kaptKotlin FAILED


* What went wrong:
Execution failed for task ':app:kaptKotlin'.
> Internal compiler error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 51s
8 actionable tasks: 8 executed
4

1 回答 1

1

There already is an issue: https://youtrack.jetbrains.com/issue/KT-27419

It should be resolved in Kotlin 1.3 (it's in release candidate for now though).

于 2018-10-25T14:59:40.163 回答