Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java 9 + jigsaw compatibility #74

Closed
ndeloof opened this issue Oct 17, 2016 · 6 comments
Closed

java 9 + jigsaw compatibility #74

ndeloof opened this issue Oct 17, 2016 · 6 comments
Assignees

Comments

@ndeloof
Copy link

ndeloof commented Oct 17, 2016

I tried to build xstream using JDK9 jigsaw preview. For this purpose I used this dockerfile :

FROM ubuntu

RUN apt-get -y update && apt-get install -y git curl

WORKDIR /tmp
RUN curl 'http://download.java.net/java/jigsaw/archive/139/binaries/jigsaw-jdk-9-ea+139_linux-x64_bin.tar.gz' -H 'Cookie: __unam=6cb5566-1578ee6046c-2d0982a0-1' | tar xvz

RUN ln -s /tmp/jdk-9/bin/* /usr/local/bin
ENV JAVA_HOME=/tmp/jdk-9

RUN curl 'http://apache.mirrors.ovh.net/ftp.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz' | tar xvz
RUN ln -s /tmp/apache-maven-3.3.9/bin/* /usr/local/bin


RUN git clone https://github.com/x-stream/xstream

WORKDIR /tmp/xstream
RUN mvn install

Such a build fails running tests. This seems to demonstrate xstream won't be compatible with Java 9 when released (on March 2017). I suggest to run some tests with preview so any isssue with JDK 9 . JDK APIs / Jigsaw can be reported to JDK development team.

@joehni
Copy link
Member

joehni commented Oct 19, 2016

I know, it breaks, since Jigsaw was integrated. But I had no time to work on it. Most problems are caused by the tests itself, because when serializing JDK types, it will also use reflection to access the internals. And currently these internals are neither accessible anymore and they are moved every second week (my gut's telling). For people serializing their own stuff, it will make no difference, but it will have implications for XStream users that serialize these types also.

@joehni joehni self-assigned this Oct 19, 2016
@AlanBateman
Copy link

From what I can tell then XStream has several issues when running on JDK 9.

One is that it seems to have a couple of hacks where it attempts to use setAccessible to get a non-public members of JDK classes, e.g. the protected getName method on AttributedCharacterIterator.Attribute.

The bigger issue is that it's a custom serialization library and so will not be able to use setAccessible to break into non-exported packages or non-public elements in exported packages. There is an updated sun.reflect.ReflectionFactory in JDK 9 (and in jdk8u-dev for a future JDK 8 update) to help custom serialization libraries invoke non-public readObject/writeObject/etc. methods. It may be that XStream will need to use these.

@jerboaa
Copy link

jerboaa commented Feb 8, 2017

FWIW, this is breaking the maven-war-plugin. See also https://cwiki.apache.org/confluence/display/MAVEN/Java+9+-+Jigsaw in section "Third party components".

For me the exception looks like this (JDK 9 b154 from https://copr.fedorainfracloud.org/coprs/omajid/openjdk9/):

Caused by: java.lang.ExceptionInInitializerError
        at com.thoughtworks.xstream.XStream.setupConverters(XStream.java:679)
        at com.thoughtworks.xstream.XStream.<init>(XStream.java:456)
        at com.thoughtworks.xstream.XStream.<init>(XStream.java:381)
        at com.thoughtworks.xstream.XStream.<init>(XStream.java:356)
        at org.apache.maven.plugin.war.util.WebappStructureSerializer.<clinit>(WebappStructureSerializer.java:47)
        at org.apache.maven.plugin.war.AbstractWarMojo.<init>(AbstractWarMojo.java:324)
        at org.apache.maven.plugin.war.WarMojo.<init>(WarMojo.java:53)
        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:466)
        at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:86)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105)
        at com.google.inject.internal.ConstructorInjector.access$000(ConstructorInjector.java:32)
        at com.google.inject.internal.ConstructorInjector$1.call(ConstructorInjector.java:89)
        at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:115)
        at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:133)
        at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68)
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:87)
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
        at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1015)
        at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1102)
        at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1011)
        at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1050)
        at org.eclipse.sisu.space.AbstractDeferredClass.get(AbstractDeferredClass.java:48)
        at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
        at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:53)
        at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:65)
        at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:115)
        at org.eclipse.sisu.bean.BeanScheduler$Activator.onProvision(BeanScheduler.java:176)
        at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:126)
        at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68)
        at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:63)
        at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
        at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1015)
        at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1091)
        at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1011)
        at org.eclipse.sisu.inject.Guice4$1.get(Guice4.java:162)
        at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:81)
        at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51)
        at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263)
        at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255)
        at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:517)
        ... 22 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module @1c76b2fe
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:207)
        at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:171)
        at java.base/java.lang.reflect.Field.setAccessible(Field.java:165)
        at com.thoughtworks.xstream.converters.collections.TreeMapConverter.<clinit>(TreeMapConverter.java:59)
        ... 65 more

@AlanBateman
Copy link

@pmouawad
Copy link

pmouawad commented Nov 3, 2017

Hello @joehni ,
Is there any update on this issue ?

Thank you
Regards

@joehni
Copy link
Member

joehni commented Dec 21, 2017

I am closing this, since it is a duplicate of #101 which reflects the situation with the final release of Java 9.

@joehni joehni closed this as completed Dec 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants