EnumerationSerializer fails for enumerations with attributes
ajaychandran opened this issue · 1 comments
ajaychandran commented
Input
object Planet extends Enumeration {
protected case class Val(mass: Double, radius: Double) extends super.Val {
def surfaceGravity: Double = Planet.G * mass / (radius * radius)
def surfaceWeight(otherMass: Double): Double = otherMass * surfaceGravity
}
implicit def valueToPlanetVal(x: Value): Val = x.asInstanceOf[Val]
val G: Double = 6.67300E-11
val Mercury = Val(3.303e+23, 2.4397e6)
val Venus = Val(4.869e+24, 6.0518e6)
val Earth = Val(5.976e+24, 6.37814e6)
val Mars = Val(6.421e+23, 3.3972e6)
val Jupiter = Val(1.9e+27, 7.1492e7)
val Saturn = Val(5.688e+26, 6.0268e7)
val Uranus = Val(8.686e+25, 2.5559e7)
val Neptune = Val(1.024e+26, 2.4746e7)
}
Error
$outer
java.lang.NoSuchFieldException: $outer
at java.lang.Class.getDeclaredField(Class.java:2070)
at com.romix.scala.serialization.kryo.EnumerationSerializer.write(EnumerationSerailizer.scala:35)
at com.romix.scala.serialization.kryo.EnumerationSerializer.write(EnumerationSerailizer.scala:32)
at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:651)
at com.romix.scala.serialization.kryo.EnumerationSerializationTest.$anonfun$new$1(EnumerationSerializationTest.scala:27)
nvollmar commented
The issue still applies to the current version.
@ajaychandran could you create a pull request against this repo? Or if you don't mind I could manually take over your fix.