cloudstateio / kotlin-support

Cloudstate Kotlin Support
https://cloudstate.io/docs/user/lang/kotlin/index.html
Apache License 2.0
8 stars 5 forks source link

Fix CRDT reflection support #47

Closed pvlugter closed 4 years ago

pvlugter commented 4 years ago

Should resolve #46.

Rather than being passed the java class for the entity, it was being passed the java class for kotlin's KClassImpl, which has a single java.lang.Class parameter for its constructor. Passing the correct java class seems to work fine.

And the chat example needs to use the java-support CommandHandler annotation, since the java-support AnnotationBasedCrdtSupport is being used, and the KotlinAnnotationBasedCrdt is not implemented yet.

sleipnir commented 4 years ago

In fact, annotations are performed with Kotlin with java support, as it is using a bytecode transformation recompiling for java annotations at Runtime. It was the old approach that will be replaced when KotlinAnnotationBasedCrdt is finished.

sleipnir commented 4 years ago

You have correctly concluded that the problem was related to the past type. But what caused the error was the fact that it was necessary to pass the transformed class instead of the real class as it was being used. I made the changes and the problem was fixed. Thanks for the insight at some point I changed something that broke it, I made the correction.

12:55:56.648 [main] DEBUG io.cloudstate.kotlinsupport.api.transcoding.CrdtTranscoder - Initializing ByteBuddy Agent....
12:55:57.439 [main] INFO io.cloudstate.kotlinsupport.api.transcoding.CrdtTranscoder - Executing Transformer...
12:55:57.443 [main] DEBUG io.cloudstate.kotlinsupport.ReflectionHelper - Found 2 methods to processing...
12:55:57.444 [main] DEBUG io.cloudstate.kotlinsupport.ReflectionHelper - Found Method connect annotated with CommandHandler. ReturnType void GenericReturnTYpe void
12:55:57.447 [main] DEBUG io.cloudstate.kotlinsupport.ReflectionHelper - Found Method monitor annotated with CommandHandler. ReturnType class io.cloudstate.examples.chat.presence.PresenceProtos$OnlineStatus GenericReturnTYpe class io.cloudstate.examples.chat.presence.PresenceProtos$OnlineStatus
12:55:57.447 [main] DEBUG io.cloudstate.kotlinsupport.ReflectionHelper - 2 Annotations of type CommandHandler found in PresenceEntity
12:55:57.678 [main] DEBUG io.cloudstate.javasupport.impl.AnySupport - Attempting to load com.google.protobuf.Message class io.cloudstate.examples.chat.presence.PresenceProtos$User
12:55:57.681 [main] DEBUG io.cloudstate.javasupport.impl.AnySupport - Attempting to load com.google.protobuf.Message class io.cloudstate.examples.chat.presence.PresenceProtos$Empty
12:55:57.684 [main] DEBUG io.cloudstate.javasupport.impl.AnySupport - Attempting to load com.google.protobuf.Message class io.cloudstate.examples.chat.presence.PresenceProtos$OnlineStatus
12:55:57.796 [main] INFO io.cloudstate.kotlinsupport.CloudStateRunner - Loading Config...
12:55:57.948 [main] DEBUG io.cloudstate.kotlinsupport.CloudStateRunner - Load config library.name: kotlin-support
12:55:57.948 [main] DEBUG io.cloudstate.kotlinsupport.CloudStateRunner - Load config library.version: 0.5.1
12:55:57.948 [main] DEBUG io.cloudstate.kotlinsupport.CloudStateRunner - Load config user-function-port: 8080
12:55:57.948 [main] DEBUG io.cloudstate.kotlinsupport.CloudStateRunner - Load config user-function-interface: 0.0.0.0
pvlugter commented 4 years ago

In fact, annotations are performed with Kotlin with java support, as it is using a bytecode transformation recompiling for java annotations at Runtime.

Okay, cool.

But what caused the error was the fact that it was necessary to pass the transformed class instead of the real class as it was being used.

Great to see it fixed properly.

sleipnir commented 4 years ago

Thanks Peter

Em terça-feira, 14 de julho de 2020, Peter Vlugter notifications@github.com escreveu:

In fact, annotations are performed with Kotlin with java support, as it is using a bytecode transformation recompiling for java annotations at Runtime.

Okay, cool.

But what caused the error was the fact that it was necessary to pass the transformed class instead of the real class as it was being used.

Great to see it fixed properly.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/cloudstateio/kotlin-support/pull/47#issuecomment-658461327, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACTTZXKIKLFLR7BHYGDXA3R3TSSZANCNFSM4OZCCORQ .

-- Adriano P. Santos

"O homem erudito é um descobridor de fatos que já existem - mas o homem sábio é um criador de valores que não existem e que ele faz existir." Albert Einstein