fury
fury copied to clipboard
Map encoder derivation fails in Scala 3 LTS
Search before asking
- [x] I had searched in the issues and found no similar issues.
Version
Fory 0.11.1 (also tried with 0.11.2 and 0.10.3) Scala 3.3.6
Component(s)
Other
Minimal reproduce step
import scala.util.Try
import org.apache.fory.Fory
import org.apache.fory.format.encoder.Encoders
import org.apache.fory.serializer.scala.ScalaSerializers
object _ForyTest {
private class ExampleKLong(
val a: java.util.Map[java.lang.Long, java.lang.Long]
)
private class ExampleKString(
val a: java.util.Map[java.lang.String, java.lang.String]
)
def main(args: Array[String]): Unit = {
val fory = Fory
.builder()
.requireClassRegistration(false)
.withScalaOptimizationEnabled(true)
.build()
ScalaSerializers.registerSerializers(fory)
println(Try(Encoders.bean(classOf[ExampleKLong], fory)))
// Failure(java.lang.UnsupportedOperationException: Unsupported type K for field key, seen type set is [_ForyTest$ExampleKLong])
println(Try(Encoders.bean(classOf[ExampleKString], fory)))
// Failure(java.lang.UnsupportedOperationException: Unsupported type K for field key, seen type set is [_ForyTest$ExampleKString])
}
}
What did you expect to see?
Expected the encoder derivation to succeed (like it does in Scala version 3.6.4, for example).
What did you see instead?
[error] Exception in thread "main" java.lang.UnsupportedOperationException: Unsupported type K for field key, seen type set is [_ForyTest$ExampleKLong]
[error] at org.apache.fory.format.type.TypeInference.inferField(TypeInference.java:253)
[error] at org.apache.fory.format.type.TypeInference.inferField(TypeInference.java:233)
[error] at org.apache.fory.format.type.TypeInference.inferField(TypeInference.java:248)
[error] at org.apache.fory.format.type.TypeInference.inferField(TypeInference.java:134)
[error] at org.apache.fory.format.type.TypeInference.inferField(TypeInference.java:123)
[error] at org.apache.fory.format.type.TypeInference.inferSchema(TypeInference.java:76)
[error] at org.apache.fory.format.type.TypeInference.inferSchema(TypeInference.java:72)
[error] at org.apache.fory.format.type.TypeInference.inferSchema(TypeInference.java:62)
[error] at org.apache.fory.format.encoder.Encoders.bean(Encoders.java:76)
[error] at org.apache.fory.format.encoder.Encoders.bean(Encoders.java:72)
[error] at _ForyTest$.main(_ForyTest.scala:27)
[error] at _ForyTest.main(_ForyTest.scala)
Anything Else?
No response
Are you willing to submit a PR?
- [ ] I'm willing to submit a PR!
@rafaavc If I change private class ExampleKLong to public class ExampleKLong, everything will be fine. I fixed it in #2469
Hello! This example still fails in Scala LTS (3.3.6) and Fory 0.13.1 with the same error (even if we remove private). Can we reopen the issue? Thanks!