magnolia icon indicating copy to clipboard operation
magnolia copied to clipboard

Derived typeclasses for types with Java annotations fail at runtime

Open espenhw opened this issue 6 years ago • 5 comments

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.

espenhw avatar Aug 24 '18 18:08 espenhw

Java annotations also hurts when you need the derived typeclass to be serializable. (Annotation are not serializable)

jto avatar Sep 06 '18 16:09 jto

AFAIK this is closed in #136

kubukoz avatar Nov 25 '19 15:11 kubukoz

It occurs in Scala 3 again as these test cases are skipped.

guersam avatar Dec 12 '23 05:12 guersam

@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? :)

adamw avatar Dec 12 '23 13:12 adamw

I took a workaround and now the data is not an enum, but I'll check it out when I get some free time.

guersam avatar Dec 13 '23 02:12 guersam