Skip to content

Kotlin parser failures on project without Kotlin sources #658

@Bananeweizen

Description

@Bananeweizen

The Maven plugin tries to run the Kotlin parser, and that fails. The project does not contain Kotlin sources, and there is no Kotlin tooling installed. I'm not sure if this is a Maven plugin issue or one for the project maintaining the Kotlin parser.

What version of OpenRewrite are you using?

I am using

  • Maven plugin 5.11.0

How are you running OpenRewrite?

I have quite some dependencies configured, because I'd like to use a lot of receipes. However, the issue occurs even with a single trivial Java recipe as the active recipe

				<plugin>
					<groupId>org.openrewrite.maven</groupId>
					<artifactId>rewrite-maven-plugin</artifactId>
					<version>${rewrite-maven-plugin-version}</version>
					<configuration>
						<activeRecipes>
							<recipe>org.openrewrite.java.RemoveObjectsIsNull</recipe>
						</activeRecipes>
					</configuration>
					<dependencies>
						<dependency>
							<groupId>org.openrewrite.recipe</groupId>
							<artifactId>rewrite-java-security</artifactId>
							<version>${rewrite-java-security-version}</version>
						</dependency>
						<dependency>
							<groupId>org.openrewrite.recipe</groupId>
							<artifactId>rewrite-java-security</artifactId>
							<version>${rewrite-java-security-version}</version>
						</dependency>
						<dependency>
							<groupId>org.openrewrite.recipe</groupId>
							<artifactId>rewrite-logging-frameworks</artifactId>
							<version>${rewrite-logging-frameworks-version}</version>
						</dependency>
						<dependency>
							<groupId>org.openrewrite.recipe</groupId>
							<artifactId>rewrite-static-analysis</artifactId>
							<version>${rewrite-static-analysis-version}</version>
						</dependency>
						<dependency>
							<groupId>org.openrewrite.recipe</groupId>
							<artifactId>rewrite-testing-frameworks</artifactId>
							<version>${rewrite-testing-frameworks-version}</version>
						</dependency>
					</dependencies>
				</plugin>

What is the full stack trace of any errors you encountered?

WARN: Error while reading zip file: C:\Users\myuserid\AppData\Local\Temp\file not yet available14437915253118885463.tmp: java.lang.IndexOutOfBoundsException
java.lang.IndexOutOfBoundsException
	at java.base/java.nio.Buffer.checkIndex(Buffer.java:749)
	at java.base/java.nio.DirectByteBuffer.getShort(DirectByteBuffer.java:599)
	at org.jetbrains.kotlin.cli.jvm.compiler.jarfs.ZipImplementationKt.getUnsignedShort(ZipImplementation.kt:165)
	at org.jetbrains.kotlin.cli.jvm.compiler.jarfs.ZipImplementationKt.parseCentralDirectoryRecordsNumberAndOffset(ZipImplementation.kt:134)
	at org.jetbrains.kotlin.cli.jvm.compiler.jarfs.ZipImplementationKt.parseCentralDirectory(ZipImplementation.kt:67)
	at org.jetbrains.kotlin.cli.jvm.compiler.jarfs.FastJarHandler.<init>(FastJarHandler.kt:28)
	at org.jetbrains.kotlin.cli.jvm.compiler.jarfs.FastJarFileSystem$myHandlers$1.fun(FastJarFileSystem.kt:24)
	at org.jetbrains.kotlin.cli.jvm.compiler.jarfs.FastJarFileSystem$myHandlers$1.fun(FastJarFileSystem.kt:22)
	at org.jetbrains.kotlin.com.intellij.util.containers.ConcurrentFactoryMap$2.create(ConcurrentFactoryMap.java:174)
	at org.jetbrains.kotlin.com.intellij.util.containers.ConcurrentFactoryMap.get(ConcurrentFactoryMap.java:40)
	at org.jetbrains.kotlin.cli.jvm.compiler.jarfs.FastJarFileSystem.findFileByPath(FastJarFileSystem.kt:51)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.findJarRoot(KotlinCoreEnvironment.kt:399)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.contentRootToVirtualFile(KotlinCoreEnvironment.kt:377)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.access$contentRootToVirtualFile(KotlinCoreEnvironment.kt:107)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$2.invoke(KotlinCoreEnvironment.kt:224)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$2.invoke(KotlinCoreEnvironment.kt:107)
	at org.jetbrains.kotlin.cli.jvm.compiler.ClasspathRootsResolver.convertClasspathRoots(ClasspathRootsResolver.kt:76)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:233)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:107)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:442)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.createForProduction(KotlinCoreEnvironment.kt)
	at org.openrewrite.kotlin.KotlinParser.parse(KotlinParser.java:362)
	at org.openrewrite.kotlin.KotlinParser.parseInputs(KotlinParser.java:162)
	at org.openrewrite.Parser.parse(Parser.java:59)
	at org.openrewrite.maven.MavenMojoProjectParser.lambda$processMainSources$5(MavenMojoProjectParser.java:332)

There are some things to note here:

  • There is no Kotlin code or anything Kotlin related in the sources being scanned.
  • There is no Kotlin tooling, compiler etc. on this machine.

I have no idea why OpenRewrite tries to use its Kotlin parser at all here.

Are you interested in contributing a fix to OpenRewrite?

Since I have no idea what's going on, I'm not sure that's possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions