Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transformation failure in objects #118

Closed
ReneeVandervelde opened this issue Jan 24, 2020 · 1 comment
Closed

Transformation failure in objects #118

ReneeVandervelde opened this issue Jan 24, 2020 · 1 comment
Assignees
Labels

Comments

@ReneeVandervelde
Copy link

getAndUpdate Seems to fail when the parent class is an object:

object Example {
    private val atomic = atomic("test")

    fun update() {
        atomic.getAndUpdate { "$it !" }
    }
}

Results in the following compilation error:

Failed to transform: java.lang.ArrayIndexOutOfBoundsException: -1
java.lang.ArrayIndexOutOfBoundsException: -1
        at org.objectweb.asm.Frame.getConcreteOutputType(Frame.java:1139)
        at org.objectweb.asm.Frame.merge(Frame.java:1184)
        at org.objectweb.asm.MethodWriter.computeAllFrames(MethodWriter.java:1610)
        at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1546)
        at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:767)
        at kotlinx.atomicfu.transformer.AtomicFUTransformer$TransformerMV.visitEnd(AtomicFUTransformer.kt:616)
        at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1288)
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:688)
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:400)
        at kotlinx.atomicfu.transformer.AtomicFUTransformer.transformFile(AtomicFUTransformer.kt:238)
        at kotlinx.atomicfu.transformer.AtomicFUTransformer.transform(AtomicFUTransformer.kt:172)
        at kotlinx.atomicfu.plugin.gradle.AtomicFUTransformTask.transform(AtomicFUGradlePlugin.kt:406)

Changing the declaration to class will compile successfully.

This seems to have been reported before in #94 as a problem with companion objects, which was closed but never resolved.

Kotlin Version: 1.3.61
atomicfu version: 0.14.1

@LikhanovMaxim
Copy link

LikhanovMaxim commented Mar 26, 2020

Hi,
I have the same error with a bit different code:

private val top = atomic<Int?>(null)

fun main() {
    top.update { 0 }
}

Error log: error_atomic.txt
kotlinVersion=1.3.70
atomicFuVersion=0.14.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants