You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why are enums with anonymous classes are not supported? I have an enum which is composed of constants, some of which are anonymous classes, which I would like to serialise. Even with a custom encoder this is not possible. It should be incredibly easy to serialise an enum, i.e. it just needs to be a string in the serialisation, surely?
Enums constants without an anonymous class work fine on the same class (x.y.z.Symbol)
The exception:
com.jsoniter.spi.JsonException: anonymous class not supported: class x.y.z.Symbol$2
at com.jsoniter.spi.TypeLiteral.generateCacheKey(TypeLiteral.java:96)
at com.jsoniter.spi.TypeLiteral.generateDecoderCacheKey(TypeLiteral.java:84)
at com.jsoniter.spi.TypeLiteral.createNew(TypeLiteral.java:180)
at com.jsoniter.spi.TypeLiteral.create(TypeLiteral.java:170)
at com.jsoniter.spi.Config.getEncoderCacheKey(Config.java:65)
at com.jsoniter.output.JsonStream.writeVal(JsonStream.java:361)
at com.jsoniter.output.ReflectionObjectEncoder.writeEncodeTo(ReflectionObjectEncoder.java:121)
at com.jsoniter.output.ReflectionObjectEncoder.enocde_(ReflectionObjectEncoder.java:78)
at com.jsoniter.output.ReflectionObjectEncoder.encode(ReflectionObjectEncoder.java:37)
at com.jsoniter.output.JsonStream.writeVal(JsonStream.java:381)
at com.jsoniter.output.JsonStream.serialize(JsonStream.java:490)
at com.jsoniter.output.JsonStream.serialize(JsonStream.java:470)
at io.temperley.backtest.ParamsSerDe.serialize(ParamsSerDe.java:45)
at io.temperley.backtest.ParamsSerDeTest.serialize(ParamsSerDeTest.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
The text was updated successfully, but these errors were encountered:
OK I figured out how to do this, I simply needed a class-specific property decoder which simply encodes/decodes the enum as a string. As it's a very simple operation I feel like there should be an easier way to do this, but this works.
Why are enums with anonymous classes are not supported? I have an enum which is composed of constants, some of which are anonymous classes, which I would like to serialise. Even with a custom encoder this is not possible. It should be incredibly easy to serialise an enum, i.e. it just needs to be a string in the serialisation, surely?
Enums constants without an anonymous class work fine on the same class (x.y.z.Symbol)
The exception:
The text was updated successfully, but these errors were encountered: