Is there any way to use annotations defined in Scala so they can work with Java code? I have a library with some annotations I would like to use in Java
Quotes from scaladocs:
A base class for annotations. Annotations extending this class directly are not preserved in the classfile. To enable storing annotations in the classfile's Scala signature and make it available to Scala reflection and other tools, the annotation needs to inherit from [[scala.annotation.StaticAnnotation]]. Annotation classes defined in Scala are not stored in classfiles in a Java-compatible manner and therefore not visible in Java reflection. In order to achieve this, the annotation has to be written in Java.
abstract class Annotation
https://github.com/scala/scala/blob/2.13.x/src/library/scala/annotation/Annotation.scala
A base class for static annotations. These are available to the Scala type checker or Scala reflection, even across different compilation units. Annotation classes defined in Scala are not stored in classfiles in a Java-compatible manner and therefore not visible in Java reflection. In order to achieve this, the annotation has to be written in Java.
trait StaticAnnotation extends Annotation
https://github.com/scala/scala/blob/2.13.x/src/library/scala/annotation/StaticAnnotation.scala