Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin 1.4.30 Apache beam compilation error

I was trying to update to latest kotlin verion 1.4.30 an Apache Beam dataflow pipeline that is currently running with kotlin 1.4.21 but as soon as I upgrade build.gradle with version 1.4.30 the compilation fails with this exception:

java.lang.IllegalStateException: Could not read class: VirtualFile: /Users/stefanomassera/.gradle/caches/modules-2/files-2.1/org.apache.beam/beam-sdks-java-core/2.26.0/b57f8fa5ae66564c7ffafde34b690057f471bfa8/beam-sdks-java-core-2.26.0.jar!/org/apache/beam/sdk/options/PipelineOptions.class
    at org.jetbrains.kotlin.load.java.structure.impl.classFiles.BinaryJavaClass.<init>(BinaryJavaClass.kt:120)
    at org.jetbrains.kotlin.load.java.structure.impl.classFiles.BinaryJavaClass.<init>(BinaryJavaClass.kt:34)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl.findClass(KotlinCliJavaFileManagerImpl.kt:115)
    at org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade$CliFinder.findClass(KotlinJavaPsiFacade.java:484)
  ... omissis for brevity
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Wildcard mast have a bound for annotation of WILDCARD_BOUND position
    at org.jetbrains.kotlin.load.java.structure.impl.classFiles.BinaryJavaAnnotation$Companion.computeTargetType$resolution_common_jvm(Annotations.kt:188)
    at org.jetbrains.kotlin.load.java.structure.impl.classFiles.AnnotationsAndParameterCollectorMethodVisitor.visitTypeAnnotation$getTargetType(Annotations.kt:111)
    at org.jetbrains.kotlin.load.java.structure.impl.classFiles.AnnotationsAndParameterCollectorMethodVisitor.visitTypeAnnotation(Annotations.kt:117)
    at org.jetbrains.org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1427)
    at org.jetbrains.org.objectweb.asm.ClassReader.accept(ClassReader.java:719)
    at org.jetbrains.org.objectweb.asm.ClassReader.accept(ClassReader.java:402)
    at org.jetbrains.kotlin.load.java.structure.impl.classFiles.BinaryJavaClass.<init>(BinaryJavaClass.kt:115)
    ... 101 more

I've also tried with a blank dummy project just to verify if it is a compatibility error with current kotlin and apache beam and it seems a compatibility issue, here my dummy test

main.kt

package org.example

import org.apache.beam.sdk.Pipeline
import org.apache.beam.sdk.options.PipelineOptionsFactory

class DummyPipeline {
    fun main(args: Array<String>) {
        val options = PipelineOptionsFactory.fromArgs(*args)
            .withValidation()
            .`as`(DummyPipelineOptions::class.java)
        val pipeline = Pipeline.create(options)
        pipeline.run()
    }
}

build.gradle

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.4.30' //<-- do not build
    //id 'org.jetbrains.kotlin.jvm' version '1.4.21' // <-- correctly build
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib"
    implementation "org.apache.beam:beam-sdks-java-io-google-cloud-platform:2.26.0"
    runtimeOnly "org.apache.beam:beam-runners-direct-java:2.26.0"
}

Did anyone solved this compatibility issue?

like image 494
IlTera Avatar asked Jan 21 '26 10:01

IlTera


1 Answers

It causes by the Kotlin compiler.

Sorry for nuisance, I'm currently fixing that on the compiler's side. The fix will be available in Kotlin 1.5-M1.

Unfortunately, there are no normal workarounds here, since the problem occurs when reading class files (it's impossible to exclude the problematic logic in the mechanism for reading class files).

like image 98
Victor Petukhov Avatar answered Jan 23 '26 00:01

Victor Petukhov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!