Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Issue with Kryo serialisation

Open afaucogney opened this issue 8 years ago • 12 comments

I'm working on android project, with paper (with the rxpaper2 wrapper). I have some object data with Time members.

I saw in the Kryo code, that such serializer shoud be added by default if Java8 is enable. This is my case

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

Here is the log :

E/dalvikvm: Could not find class 'sun.nio.ch.DirectBuffer', referenced from method com.esotericsoftware.kryo.util.UnsafeUtil.releaseBuffer
E/dalvikvm: Could not find class 'java.util.Optional', referenced from method com.esotericsoftware.kryo.serializers.OptionalSerializers.addDefaultSerializers
E/dalvikvm: Could not find class 'java.util.OptionalInt', referenced from method com.esotericsoftware.kryo.serializers.OptionalSerializers.addDefaultSerializers
E/dalvikvm: Could not find class 'java.util.OptionalLong', referenced from method com.esotericsoftware.kryo.serializers.OptionalSerializers.addDefaultSerializers
E/dalvikvm: Could not find class 'java.util.OptionalDouble', referenced from method com.esotericsoftware.kryo.serializers.OptionalSerializers.addDefaultSerializers
E/dalvikvm: Could not find class 'java.time.Duration', referenced from method com.esotericsoftware.kryo.serializers.TimeSerializers.addDefaultSerializers
E/dalvikvm: Could not find class 'java.time.Instant', referenced from method com.esotericsoftware.kryo.serializers.TimeSerializers.addDefaultSerializers
E/dalvikvm: Could not find class 'java.time.LocalDate', referenced from method com.esotericsoftware.kryo.serializers.TimeSerializers.addDefaultSerializers
E/dalvikvm: Could not find class 'java.time.LocalTime', referenced from method com.esotericsoftware.kryo.serializers.TimeSerializers.addDefaultSerializers
E/dalvikvm: Could not find class 'java.time.LocalDateTime', referenced from method com.esotericsoftware.kryo.serializers.TimeSerializers.addDefaultSerializers
E/dalvikvm: Could not find class 'java.time.ZoneOffset', referenced from method com.esotericsoftware.kryo.serializers.TimeSerializers.addDefaultSerializers
E/dalvikvm: Could not find class 'java.time.ZoneId', referenced from method com.esotericsoftware.kryo.serializers.TimeSerializers.addDefaultSerializers
E/dalvikvm: Could not find class 'java.time.OffsetTime', referenced from method com.esotericsoftware.kryo.serializers.TimeSerializers.addDefaultSerializers
E/dalvikvm: Could not find class 'java.time.OffsetDateTime', referenced from method com.esotericsoftware.kryo.serializers.TimeSerializers.addDefaultSerializers
E/dalvikvm: Could not find class 'java.time.ZonedDateTime', referenced from method com.esotericsoftware.kryo.serializers.TimeSerializers.addDefaultSerializers
E/dalvikvm: Could not find class 'java.time.Year', referenced from method com.esotericsoftware.kryo.serializers.TimeSerializers.addDefaultSerializers
E/dalvikvm: Could not find class 'java.time.YearMonth', referenced from method com.esotericsoftware.kryo.serializers.TimeSerializers.addDefaultSerializers
E/dalvikvm: Could not find class 'java.time.MonthDay', referenced from method com.esotericsoftware.kryo.serializers.TimeSerializers.addDefaultSerializers
E/dalvikvm: Could not find class 'java.time.Period', referenced from method com.esotericsoftware.kryo.serializers.TimeSerializers.addDefaultSerializers

How to solve this ?

How define a specific serializer as we do not get acces to kryo from paper (as far I read the doc)

afaucogney avatar Sep 01 '17 10:09 afaucogney

You can use Paper.addSerializer() to add custom serializers.

pilgr avatar Sep 01 '17 15:09 pilgr

@pilgr thanks for this, however, my issue is that Android does not hold such classes, and the serializer are added by default. So it triggers error. It seems to be more or less mapped to this Kryo issue https://github.com/EsotericSoftware/kryo/issues/410

afaucogney avatar Sep 04 '17 13:09 afaucogney

@pilgr any comment or advice on this point ?

afaucogney avatar Sep 11 '17 09:09 afaucogney

Do you include Time class with third-party dependency?

pilgr avatar Sep 11 '17 16:09 pilgr

@pilgr as far as I know the answer is no. I use JodaTime but that's different class as well as Date and Time classes from Android SDK What is strange, is that Kryo add the serializers even if I do not have the class in the project.

I overide the kryo version to 4.0.1 to get that commit

https://github.com/EsotericSoftware/kryo/commit/8fd3f891edac0c4f7c9f1d61e8e4ff769573e26c

Does I am the only one to get that bunch of exception ?

afaucogney avatar Sep 15 '17 13:09 afaucogney

@pilgr Please reopen the issue that I get visibiliy from community. thanks

afaucogney avatar Sep 15 '17 13:09 afaucogney

@afaucogney you're right, the fix should be to update Kryo dependency to version 4.0.1

pilgr avatar Sep 15 '17 16:09 pilgr

@pilgr fact is that I forced the kryo dependency to be at 4.0.1 level, and nothing changed...

afaucogney avatar Sep 16 '17 10:09 afaucogney

@afaucogney could you write a test case or class or small project so I could reproduce the issue?

pilgr avatar Sep 16 '17 16:09 pilgr

@afaucogney could you check out with latest paper 2.5? Forcing kryo dependency might not work for your experiment because of transitive dependency caused by "de.javakaffee:kryo-serializers" lib.

pilgr avatar Sep 22 '17 14:09 pilgr

Previously I also force the kryo-serializers. @pilgr I just updated paper to 2.5, from Android studio I have kryo 4.0.1 serializer 0.42 paper 2.5 But I still get exceptions in the trace. Nothing really changed up to now.

afaucogney avatar Sep 27 '17 13:09 afaucogney

Could you setup a basic project over Github to reproduce the issue? If it could be just a unit test for Paper - would be even coolleerr! :)

On Wednesday, September 27, 2017 at 16:16, Faucogney Anthony wrote:

Previously I also force the kryo-serializers. @pilgr (https://github.com/pilgr) I just updated paper to 2.5, from Android studio I have kryo 4.0.1 serializer 0.42 paper 2.5 But I still get exceptions in the trace. Nothing really changed up to now.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub (https://github.com/pilgr/Paper/issues/84#issuecomment-332516925), or mute the thread (https://github.com/notifications/unsubscribe-auth/AAaNIZpmGQjM92G9-TyrB9zYi4MiKwF1ks5smkqbgaJpZM4PJ9Pk).

pilgr avatar Sep 27 '17 21:09 pilgr