owlike / genson

Genson a fast & modular Java <> Json library
http://owlike.github.io/genson/
219 stars 66 forks source link

Serialization/Deserialization of generics broken with java 10 #140

Open damnms opened 5 years ago

damnms commented 5 years ago

This code does not work. Can someone tell me why? I use Java10 with modules


import com.owlike.genson.GenericType;
import com.owlike.genson.Genson;
import com.owlike.genson.GensonBuilder;
import org.junit.jupiter.api.Test;

public class GensonTest {

    @Test
    void canSerializeDeserialize() {
        Genson genson = new GensonBuilder()
                .useConstructorWithArguments(true)
                .useRuntimeType(true)
                .useClassMetadata(true)
                .create();

        String serialize = genson.serialize(new RegisterXMLRequest(new RegisterXML()));
//        RegisterXMLRequest registerXMLRequest = genson.deserialize(serialize, RegisterXMLRequest.class);
        Object request = genson.deserialize(serialize, new GenericType<Request>(){});
    }
}

interface Request<T> extends Message<T> {

}

interface Response<T> extends Message<T>{

}

interface Message<T> {
    T getPayload();
}

class RegisterXML  {
    private final String xmlData = "someXMLhere...";
}

class RegisterXMLRequest implements Request<RegisterXML> {
    private final RegisterXML registerXML;

    public RegisterXMLRequest(RegisterXML registerXML) {
        this.registerXML = registerXML;
    }

    @Override
    public RegisterXML getPayload() {
        return registerXML;
    }
}

I created a java 8 Test-Project with the source above and it worked as expected. In that case, genson does not work with java 10, very sad. For me a show stopper. So i need to find something like genson which works with java 10 modules.

damnms commented 5 years ago
"C:\Program Files\Java\jdk-10.0.2\bin\java.exe" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2018.1.6\lib\idea_rt.jar=53791:C:\Program Files\JetBrains\IntelliJ IDEA 2018.1.6\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2018.1.6\lib\idea_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2018.1.6\plugins\junit\lib\junit-rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2018.1.6\plugins\junit\lib\junit5-rt.jar;C:\Users\gnah\.m2\repository\org\junit\platform\junit-platform-launcher\1.2.0\junit-platform-launcher-1.2.0.jar;C:\Users\gnah\.m2\repository\org\apiguardian\apiguardian-api\1.0.0\apiguardian-api-1.0.0.jar;C:\Users\gnah\.m2\repository\org\junit\platform\junit-platform-engine\1.2.0\junit-platform-engine-1.2.0.jar;C:\Users\gnah\.m2\repository\org\junit\platform\junit-platform-commons\1.2.0\junit-platform-commons-1.2.0.jar;C:\Users\gnah\.m2\repository\org\opentest4j\opentest4j\1.1.0\opentest4j-1.1.0.jar;C:\Users\gnah\.m2\repository\org\junit\jupiter\junit-jupiter-engine\5.2.0\junit-jupiter-engine-5.2.0.jar;C:\Users\gnah\.m2\repository\org\junit\jupiter\junit-jupiter-api\5.2.0\junit-jupiter-api-5.2.0.jar;C:\Users\gnah\IdeaProjects\GensonTest\target\classes;C:\Users\gnah\.m2\repository\com\owlike\genson\1.4\genson-1.4.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit5 TestTest,canSerializeDeserialize

java.lang.IllegalArgumentException
    at com.owlike.genson.internal.asm.ClassReader.<init>(Unknown Source)
    at com.owlike.genson.internal.asm.ClassReader.<init>(Unknown Source)
    at com.owlike.genson.internal.asm.ClassReader.<init>(Unknown Source)
    at com.owlike.genson.reflect.ASMCreatorParameterNameResolver.read(ASMCreatorParameterNameResolver.java:64)
    at com.owlike.genson.reflect.ASMCreatorParameterNameResolver.resolve(ASMCreatorParameterNameResolver.java:81)
    at com.owlike.genson.reflect.PropertyNameResolver$CompositePropertyNameResolver.resolve(PropertyNameResolver.java:82)
    at com.owlike.genson.reflect.BaseBeanDescriptorProvider.provideConstructorCreators(BaseBeanDescriptorProvider.java:133)
    at com.owlike.genson.reflect.BaseBeanDescriptorProvider.provideBeanCreators(BaseBeanDescriptorProvider.java:77)
    at com.owlike.genson.reflect.AbstractBeanDescriptorProvider.provide(AbstractBeanDescriptorProvider.java:95)
    at com.owlike.genson.reflect.BeanDescriptorProvider$CompositeBeanDescriptorProvider.provide(BeanDescriptorProvider.java:60)
    at com.owlike.genson.convert.BasicConvertersFactory.provide(BasicConvertersFactory.java:104)
    at com.owlike.genson.convert.BasicConvertersFactory.create(BasicConvertersFactory.java:69)
    at com.owlike.genson.convert.BasicConvertersFactory.create(BasicConvertersFactory.java:51)
    at com.owlike.genson.reflect.AbstractBeanDescriptorProvider$ContextualFactoryDecorator.create(AbstractBeanDescriptorProvider.java:75)
    at com.owlike.genson.reflect.AbstractBeanDescriptorProvider$ContextualFactoryDecorator.create(AbstractBeanDescriptorProvider.java:64)
    at com.owlike.genson.convert.ChainedFactory.create(ChainedFactory.java:88)
    at com.owlike.genson.convert.ChainedFactory.create(ChainedFactory.java:75)
    at com.owlike.genson.convert.ChainedFactory.create(ChainedFactory.java:88)
    at com.owlike.genson.convert.ChainedFactory.create(ChainedFactory.java:75)
    at com.owlike.genson.convert.ChainedFactory.create(ChainedFactory.java:88)
    at com.owlike.genson.convert.ChainedFactory.create(ChainedFactory.java:75)
    at com.owlike.genson.convert.CircularClassReferenceConverterFactory.create(CircularClassReferenceConverterFactory.java:55)
    at com.owlike.genson.convert.CircularClassReferenceConverterFactory.create(CircularClassReferenceConverterFactory.java:19)
    at com.owlike.genson.Genson.provideConverter(Genson.java:148)
    at com.owlike.genson.Genson.serialize(Genson.java:272)
    at com.owlike.genson.Genson.serialize(Genson.java:170)
    at TestTest.canSerializeDeserialize(TestTest.java:17)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:513)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:115)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:170)
    at org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:166)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:113)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:58)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:113)
    at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:121)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
    at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
    at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:121)
    at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:121)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
    at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
    at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:121)
    at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:55)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:43)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:74)
    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)
EugenCepoi commented 5 years ago

Could you try to configuring Genson slightly differently by disabling: useConstructorWithArguments(false). The stacktrace above seems to be specific to the code in Genson that does resolution of constructors with arguments and uses ASM which does bytecode manipulation. I'm not too surprised that the bytecode isn't compatible in java 10. Note that you will need to provide empty argument constructors however if this option is disabled.

EugenCepoi commented 5 years ago

@damnms could you try out this branch https://github.com/owlike/genson/pull/141 and see if this solves your problem?

damnms commented 5 years ago

I can not test #141 as it does not compile on my machine. I checked out the genson-parent, applied the change of the ASM version and tried to mvn install, which lead to a lot of errors.

WARNING: HK2 service reification failed for [org.glassfish.jersey.message.internal.XmlCollectionJaxbProvider$Text] with an exception:
MultiException stack 1 of 2
java.lang.NoClassDefFoundError: javax/xml/bind/PropertyException
    at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3090)
    at java.base/java.lang.Class.getDeclaredConstructors(Class.java:2316)
    at org.jvnet.hk2.internal.Utilities$3.run(Utilities.java:1334)
    at org.jvnet.hk2.internal.Utilities$3.run(Utilities.java:1330)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at org.jvnet.hk2.internal.Utilities.getAllConstructors(Utilities.java:1330)
    at org.jvnet.hk2.internal.Utilities.findProducerConstructor(Utilities.java:1251)
    at org.jvnet.hk2.internal.DefaultClassAnalyzer.getConstructor(DefaultClassAnalyzer.java:78)
    at org.glassfish.jersey.internal.inject.JerseyClassAnalyzer.getConstructor(JerseyClassAnalyzer.java:143)
    at org.jvnet.hk2.internal.Utilities.getConstructor(Utilities.java:186)
    at org.jvnet.hk2.internal.ClazzCreator.initialize(ClazzCreator.java:129)
    at org.jvnet.hk2.internal.ClazzCreator.initialize(ClazzCreator.java:182)
    at org.jvnet.hk2.internal.SystemDescriptor.internalReify(SystemDescriptor.java:713)
    at org.jvnet.hk2.internal.SystemDescriptor.reify(SystemDescriptor.java:668)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.reifyDescriptor(ServiceLocatorImpl.java:418)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.narrow(ServiceLocatorImpl.java:2120)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.access$900(ServiceLocatorImpl.java:119)
    at org.jvnet.hk2.internal.ServiceLocatorImpl$10.compute(ServiceLocatorImpl.java:1260)
    at org.jvnet.hk2.internal.ServiceLocatorImpl$10.compute(ServiceLocatorImpl.java:1255)
    at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture$1.call(LRUHybridCache.java:115)
    at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture$1.call(LRUHybridCache.java:111)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture.run(LRUHybridCache.java:173)
    at org.glassfish.hk2.utilities.cache.LRUHybridCache.compute(LRUHybridCache.java:292)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetAllServiceHandles(ServiceLocatorImpl.java:1333)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.getAllServiceHandles(ServiceLocatorImpl.java:1242)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.getAllServiceHandles(ServiceLocatorImpl.java:1231)
    at org.glassfish.jersey.internal.inject.Providers.getServiceHandles(Providers.java:340)
    at org.glassfish.jersey.internal.inject.Providers.getCustomProviders(Providers.java:199)
    at org.glassfish.jersey.message.internal.MessageBodyFactory.<init>(MessageBodyFactory.java:303)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
    at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1107)
    at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:274)
    at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:368)
    at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:461)
    at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:114)
    at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:102)
    at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture$1.call(Cache.java:97)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture.run(Cache.java:154)
    at org.glassfish.hk2.utilities.cache.Cache.compute(Cache.java:199)
    at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:153)
    at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2268)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:690)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:663)
    at org.jvnet.hk2.internal.IterableProviderImpl.get(IterableProviderImpl.java:107)
    at org.glassfish.jersey.client.RequestProcessingInitializationStage.apply(RequestProcessingInitializationStage.java:97)
    at org.glassfish.jersey.client.RequestProcessingInitializationStage.apply(RequestProcessingInitializationStage.java:67)
    at org.glassfish.jersey.process.internal.Stages$LinkedStage.apply(Stages.java:308)
    at org.glassfish.jersey.process.internal.Stages.process(Stages.java:171)
    at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:246)
    at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:683)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:424)
    at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:679)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:408)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:308)
    at com.owlike.genson.ext.JaxRSIntegrationTest.testDisableGenson(JaxRSIntegrationTest.java:154)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.PropertyException
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
    ... 87 more
MultiException stack 2 of 2
java.lang.IllegalArgumentException: Errors were discovered while reifying SystemDescriptor(
    implementation=org.glassfish.jersey.message.internal.XmlCollectionJaxbProvider$Text
    contracts={javax.ws.rs.ext.MessageBodyWriter,javax.ws.rs.ext.MessageBodyReader}
    scope=javax.inject.Singleton
    qualifiers={}
    descriptorType=CLASS
    descriptorVisibility=NORMAL
    metadata=
    rank=0
    loader=org.glassfish.hk2.utilities.binding.AbstractBinder$2@503fbbc6
    proxiable=null
    proxyForSameScope=null
    analysisName=null
    id=24
    locatorId=9
    identityHashCode=200744172
    reified=false)
    at org.jvnet.hk2.internal.SystemDescriptor.reify(SystemDescriptor.java:679)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.reifyDescriptor(ServiceLocatorImpl.java:418)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.narrow(ServiceLocatorImpl.java:2120)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.access$900(ServiceLocatorImpl.java:119)
    at org.jvnet.hk2.internal.ServiceLocatorImpl$10.compute(ServiceLocatorImpl.java:1260)
    at org.jvnet.hk2.internal.ServiceLocatorImpl$10.compute(ServiceLocatorImpl.java:1255)
    at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture$1.call(LRUHybridCache.java:115)
    at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture$1.call(LRUHybridCache.java:111)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture.run(LRUHybridCache.java:173)
    at org.glassfish.hk2.utilities.cache.LRUHybridCache.compute(LRUHybridCache.java:292)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetAllServiceHandles(ServiceLocatorImpl.java:1333)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.getAllServiceHandles(ServiceLocatorImpl.java:1242)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.getAllServiceHandles(ServiceLocatorImpl.java:1231)
    at org.glassfish.jersey.internal.inject.Providers.getServiceHandles(Providers.java:340)
    at org.glassfish.jersey.internal.inject.Providers.getCustomProviders(Providers.java:199)
    at org.glassfish.jersey.message.internal.MessageBodyFactory.<init>(MessageBodyFactory.java:303)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
    at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1107)
    at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:274)
    at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:368)
    at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:461)
    at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:114)
    at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:102)
    at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture$1.call(Cache.java:97)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture.run(Cache.java:154)
    at org.glassfish.hk2.utilities.cache.Cache.compute(Cache.java:199)
    at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:153)
    at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2268)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:690)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:663)
    at org.jvnet.hk2.internal.IterableProviderImpl.get(IterableProviderImpl.java:107)
    at org.glassfish.jersey.client.RequestProcessingInitializationStage.apply(RequestProcessingInitializationStage.java:97)
    at org.glassfish.jersey.client.RequestProcessingInitializationStage.apply(RequestProcessingInitializationStage.java:67)
    at org.glassfish.jersey.process.internal.Stages$LinkedStage.apply(Stages.java:308)
    at org.glassfish.jersey.process.internal.Stages.process(Stages.java:171)
    at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:246)
    at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:683)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:424)
    at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:679)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:408)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:308)
    at com.owlike.genson.ext.JaxRSIntegrationTest.testDisableGenson(JaxRSIntegrationTest.java:154)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
damnms commented 5 years ago

If there is a build system where i can download an pre-built artifact, i could try to use that.

EugenCepoi commented 5 years ago

Eh Looks like other libs that are being used during testing might not be compatible with java 10 :/ I'll need to dig further.

damnms commented 5 years ago

If you use intellij, its quite easy to get a java10-compatible project. Just create a module-info.java in src/main/java with content like this: module genson {} Intellij will complain about missing modules and tell you what to add. Unfortunately, it requires a lot of dependencies to be updated to be able to use the build with java 10 (at least thats what i guess)

damnms commented 5 years ago

any news on that? a binary (.jar etc.) with the new asm version as dependency could maybe help to use it at least as unnamed module. unfortunately, i can not build it with java 11. i get many errors

EugenCepoi commented 5 years ago

I didn't have the time to look more into that for now. I deployed a snapshot version here https://oss.sonatype.org/content/repositories/snapshots/com/owlike/genson/1.5-SNAPSHOT/. You should be able to refer to it just as you would do with any other dependency.

Note that it was built using java 8. Let me know if this works for you.

damnms commented 5 years ago

I got it working with some modifications. I will create a fork of the repo so you can maybe work with that. Whats now missing (did not get it working) was the maven-bundle-plugin, something wrong with the MANIFEST.MF

The local installed version seem now to work with java10/11, but required asm7-beta

damnms commented 5 years ago

I didn't have the time to look more into that for now. I deployed a snapshot version here https://oss.sonatype.org/content/repositories/snapshots/com/owlike/genson/1.5-SNAPSHOT/. You should be able to refer to it just as you would do with any other dependency.

Note that it was built using java 8. Let me know if this works for you.

only changing the asm version in the pom did not work, see https://github.com/owlike/genson/pull/142

EugenCepoi commented 5 years ago

So you tried depending on this snapshot version of Genson and you got some errors? If so what error did you get?

I'd imagine that there are high chances that code compiled for Java 8 should be compatible with Java 11.

damnms commented 5 years ago

Thats really wierd now. I recieved an error yesterday evening something with: "This feature requires ASM6", checked the changelog of asm7 (support of JDK 11 features now official (was experimental) - so i thought i just go to 7-beta to see what happens.

I checked the file ASMCreatorParameterNameResolver.java which has a nested class which extends ClassVisitor. With your pull request, the API version of that class (first parameter) is 5. In ClassVisitor there is a method called visitModule which checks for ASM6 or higher, otherwise throws an exception. So i bumped that to 7 too.

At the moment it makes no sense to me why it should work with only updating the module, but i deleted my .m2 cache and it still works. Also checked the source of the .jar i use now, this also initializes the class with ASM5.

martin-petzold commented 4 years ago

I also ran into this problem using Java 11. Jetty updated to ASM 7.0 [1] in order to run on Java 11

@EugenCepoi IMHO this is a very important feature for Genson. Any update on Java 11 support?

[1] https://www.eclipse.org/lists/jetty-announce/msg00125.html

martin-petzold commented 4 years ago

How could I test? Any development build available?

EugenCepoi commented 4 years ago

Hey @martin-petzold, I've somewhat stopped investing time in Genson. But if you had the desire to work on a fix and submit a PR, I could do a release with it.