Closed sortega closed 6 years ago
FYI, if you do not extend AnyVal (but only WrappedValue) it seems to work just fine. I am not sure why though, the combination of Java reflection + Scala value classes seems to be pretty complex to handle.
In that case, is it still a value class (with no runtime impact)?
I suggested this because none of the examples of WrappedValue's included in Finatra extend AnyVal. But good point, although WrappedValue is a universal trait, I am afraid extending it does not automatically create a value class… I cannot find any reliable documentation about that topic though.
@pvcnt @sortega https://docs.scala-lang.org/overviews/core/value-classes.html. WrappedValue is only a universal trait, it does not create a value class. It is meant to be mixable into a value class and other classes.
@sortega the solution is as mentioned by @pvcnt you only need to extend the universal trait, not AnyVal
.
Cannot deserialize case classes with wrapped primitives (those that extend
Wrapped[_]
Expected behavior
You should be able to deserialize them.
Actual behavior
You get a nasty error in which a constructor that is being called by reflection gets arguments of the wrong type.
Steps to reproduce the behavior
Just run the only test in this minimal example (full repo):
Test: