magnolia
magnolia copied to clipboard
Derived typeclasses for types with Java annotations fail at runtime
For instance, annotating a case class with javax.annotation.Resource produces
[error] java.lang.InstantiationError: javax.annotation.Resource
[error] at magnolia.tests.Tests$$anon$72.<init>(tests.scala:443)
[error] at magnolia.tests.Tests$.$anonfun$tests$439(tests.scala:443)
This happens because the derived tree includes new javax.annotation.Resource() which won't work.
I can't find a better fix than to filter out Java annotations from the type annotations; a pull request to that effect will follow shortly.
Java annotations also hurts when you need the derived typeclass to be serializable. (Annotation are not serializable)
AFAIK this is closed in #136
It occurs in Scala 3 again as these test cases are skipped.
@guersam not sure if there wasn't some Scala 3-specific problem ... maybe you can try enabling the tests & fixing the issue and letting us know here? :)
I took a workaround and now the data is not an enum, but I'll check it out when I get some free time.