avro-kotlin / avro4k

Avro format support for Kotlin
Apache License 2.0
188 stars 36 forks source link

Native image issue #147

Closed rafalg closed 2 months ago

rafalg commented 1 year ago

Hi,

Trying to run my app as an native image. However get this issue:

java.lang.NoSuchFieldException: original at java.base@17.0.5/java.lang.Class.getDeclaredField(DynamicHub.java:961) at com.github.avrokotlin.avro4k.schema.SchemaForKt.schemaFor(SchemaFor.kt:170) Is it a must for avro4k to use reflection?

Chuckame commented 1 year ago

Hello, It's a good question. In fact, we should not use reflection since the core of using kotlinx serialization is to not have reflection. This line is about a tricks that unwrap a nullable field serializer to maybe get an internal avro serializer.

We are currently re thinking about the schema generation by fully using kotlinx serialization features.

It won't be that quick, so the quick answer is yes, and let's see in the future to not have reflection anymore.

Chuckame commented 1 year ago

See https://github.com/avro-kotlin/avro4k/issues/148

Chuckame commented 2 months ago

Still using reflection with AvroSchema and AvroLogicalType. Waiting for the next kotlinx-serialization release that will include this PR to allow accessing the descriptor without reflection: https://github.com/Kotlin/kotlinx.serialization/pull/2633

Chuckame commented 2 months ago

Duplicate of #199