Kotlin compilation bug: KotlinFrontEndException

My code:

// ... unimportant
companion object LineGetter {
 @JvmField
 val BUFFER_SIZE = 2048

// ... unimportant

It compiles fine, works fine.
But when I changed 2048 into 1024 and run gradle build, it gives me error:

e: org.jetbrains.kotlin.util.KotlinFrontEndException: Front-end Internal error: Failed to analyze declaration AudioPlayer
Cause: java.lang.ArrayIndexOutOfBoundsException: 0
File being compiled and position: (17,2) in /home/ice1000/git-repos/frice/FriceEngine/src/org/frice/utils/audio/AudioPlayer.kt
PsiElement: internal constructor(path: String) : this(File(path))
The root cause was thrown at: CompressedAppendableFile.java:209
	at org.jetbrains.kotlin.resolve.ExceptionWrappingKtVisitorVoid.visitDeclaration(ExceptionWrappingKtVisitorVoid.kt:47)
	at org.jetbrains.kotlin.psi.KtVisitorVoid.visitDeclaration(KtVisitorVoid.java:453)
	at org.jetbrains.kotlin.psi.KtVisitorVoid.visitDeclaration(KtVisitorVoid.java:21)
	at org.jetbrains.kotlin.psi.KtVisitor.visitSecondaryConstructor(KtVisitor.java:45)

The complete file can be found here:

I’m using Kotlin 1.2.0 with gradle 4.0.

It doesn’t affect much since I can rebuild it and no error appears.
Now I changed @JvmField into const and rerun gradle build, everything goes fine.

It’s just a rare bug.

This problem is caused by corrupt incremental compilation caches; a clean rebuild will solve it.

3 Likes