json-iterator / java

jsoniter (json-iterator) is fast and flexible JSON parser available in Java and Go
http://jsoniter.com/
MIT License
1.51k stars 518 forks source link

java.lang.ClassFormatError: class com.jsoniter.IterImpl cannot access its superclass com.jsoniter.IterImplForStreaming #225

Open mferretti opened 5 years ago

mferretti commented 5 years ago

Hi, I am facing an odd issue running tests for my app with arquillian: whenever I try to parse a json (stream) with JSonIterator the test fails with the following exception : ` ... Caused by: javassist.CannotCompileException: by java.lang.ClassFormatError: class com.jsoniter.IterImpl cannot access its superclass com.jsoniter.IterImplForStreaming at javassist.util.proxy.DefineClassHelper.toClass(DefineClassHelper.java:274) at javassist.ClassPool.toClass(ClassPool.java:1232) at javassist.ClassPool.toClass(ClassPool.java:1090) at javassist.ClassPool.toClass(ClassPool.java:1048) at javassist.CtClass.toClass(CtClass.java:1290) at com.jsoniter.DynamicCodegen.enableStreamingSupport(DynamicCodegen.java:32) at com.jsoniter.JsonIterator.enableStreamingSupport(JsonIterator.java:546) ... 141 more Caused by: java.lang.ClassFormatError: class com.jsoniter.IterImpl cannot access its superclass com.jsoniter.IterImplForStreaming at javassist.util.proxy.DefineClassHelper$Java7.defineClass(DefineClassHelper.java:182) at javassist.util.proxy.DefineClassHelper.toClass(DefineClassHelper.java:263) ... 147 more

`

Looking at the code (DynamicCodegen) I see public static void enableStreamingSupport() throws Exception { CtClass ctClass = pool.makeClass("com.jsoniter.IterImpl"); ctClass.setSuperclass(pool.get(IterImplForStreaming.class.getName())); ctClass.toClass(); }

Following the stack trace it seems that the exception is thrown in ` public Class toClass(CtClass ct, Class<?> neighbor, ClassLoader loader, ProtectionDomain domain)

`

Where

` ct =IterImplForStreaming

neighbor=null

loader = org.jboss.shrinkwrap.api.classloader.ShrinkWrapClassLoader

domain = null

`

Could you please shed some light into this ?

jsonIter : 0.9.23 javaassist : 3.24.1-GA shrinkwrap: 1.2.6 arquillian: 1.4.1

Cheers

ingomueller-net commented 3 years ago

@mferretti Have you found a solution for your problem in the meantime?

mferretti commented 3 years ago

@mferretti Have you found a solution for your problem in the meantime?

nope. Since there was no coming back on this, and due to the fact that arquillian was a mandatory requirement for the project, we simply moved to jackson.