Skip to content

ArrayIndexOutOfBoundsException when serializing generic lambda written in Kotlin #864

@holgerbrandl

Description

@holgerbrandl

Describe the bug
When serializing an object in Kotlin it fails with an ArrayIndexOutOfBoundsException

Exception in thread "main" com.esotericsoftware.kryo.KryoException: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
Serialization trace:
definition (org.koin.core.definition.BeanDefinition)
	at com.esotericsoftware.kryo.serializers.ReflectField.write(ReflectField.java:101)
	at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:108)
	at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:711)
	at KryoBeanDefinitionKt.main(KryoBeanDefinition.kt:31)
	at KryoBeanDefinitionKt.main(KryoBeanDefinition.kt)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
	at com.esotericsoftware.kryo.util.DefaultGenerics.pushTypeVariables(DefaultGenerics.java:116)
	at com.esotericsoftware.kryo.serializers.FieldSerializer.pushTypeVariables(FieldSerializer.java:147)
	at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:102)
	at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:642)
	at com.esotericsoftware.kryo.serializers.ReflectField.write(ReflectField.java:70)
	... 4 more

Process finished with exit code 1

To Reproduce
I've created a minimal example in https://github.com/holgerbrandl/kryo-koin. The respective class to reproduce the stacktrace from above is KryoBeanDefinitionKt#main

Environment:

  • OS: Windows 10
  • JDK Version: 11
  • Kryo Version: 5.2.0

Analysis
It seems to be a mismatch between the array sizes of args and hierarchy in


image

I've tried, but did not manage to narrow down the problem any further.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions