softwaremill / magnolia

Easy, fast, transparent generic derivation of typeclass instances
https://softwaremill.com/open-source/
Apache License 2.0
765 stars 116 forks source link

Derived typeclasses for types with Java annotations fail at runtime #135

Open espenhw opened 6 years ago

espenhw commented 6 years ago

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.

jto commented 6 years ago

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

kubukoz commented 4 years ago

AFAIK this is closed in #136

guersam commented 10 months ago

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

adamw commented 10 months ago

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

guersam commented 10 months ago

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