0

Due to a third-party library requirement I have to do some finagling with annotations.

Using Kotlin, is there a way to dynamically add an annotation to class metadata at runtime like you can in Java?

e.g. something like:

clazz.annotations.set(idx, myAnnotation)
dnault
  • 8,340
  • 1
  • 34
  • 53
thinice
  • 700
  • 5
  • 19
  • What is the third-party library, and what kind of annotations do you need to add? – dnault Sep 02 '21 at 18:01
  • In this case, it's the Dapr Java SDK. It registers actors by name, by default - the class name (non FQ). The Dapr actor runtime makes these addressable by the name it extracts within a k8s cluster. The problem is, I want to have different actor versions running on the cluster - so I'm attempting to use Dapr's annotation: `@ActorType` which has a name attribute. I'm attempting to set that name attribute on the actors that are being registered at runtime based on an environment variable/prefix to provide that isolation. – thinice Sep 02 '21 at 18:03
  • Should actually be possible, at least based on this response: https://stackoverflow.com/a/30287201/2135888 – Lubos Mudrak Sep 02 '21 at 20:35

0 Answers0