Robert Scholte created MWAR-397:
-----------------------------------

             Summary: Replace XStream with Modello to merge overlays
                 Key: MWAR-397
                 URL: https://issues.apache.org/jira/browse/MWAR-397
             Project: Maven WAR Plugin
          Issue Type: Improvement
            Reporter: Robert Scholte


When packaging a war with most recent jigsaw-jdk9-ea releases you will get the 
following exception:
{noformat}
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 "exports private java.util" to unnamed module 
@17088b23
    at jdk.internal.reflect.Reflection.throwInaccessibleObjectException 
(Reflection.java:414)
    at java.lang.reflect.AccessibleObject.checkCanSetAccessible 
(AccessibleObject.java:198)
    at java.lang.reflect.Field.checkCanSetAccessible (Field.java:171)
    at java.lang.reflect.Field.setAccessible (Field.java:165)
    at com.thoughtworks.xstream.core.util.Fields.locate (Fields.java:40)
    at 
com.thoughtworks.xstream.converters.collections.TreeMapConverter.<clinit> 
(TreeMapConverter.java:50)
    at com.thoughtworks.xstream.XStream.setupConverters (XStream.java:832)
    at com.thoughtworks.xstream.XStream.<init> (XStream.java:574)
    at com.thoughtworks.xstream.XStream.<init> (XStream.java:496)
    at com.thoughtworks.xstream.XStream.<init> (XStream.java:465)
    at com.thoughtworks.xstream.XStream.<init> (XStream.java:411)
    at com.thoughtworks.xstream.XStream.<init> (XStream.java:378)
    at org.apache.maven.plugins.war.util.WebappStructureSerializer.<clinit> 
(WebappStructureSerializer.java:47)
{noformat}
Root cause is the change is the 
[jigsaw-jdk-9-ea+135|http://mail.openjdk.java.net/pipermail/jigsaw-dev/2016-September/009404.html]

{quote}
The changes to setAccessible in #AwkwardStrongEncapsulation is going to 
be disruptive and will no doubt expose hacks in many areas. We've run 
into several of these already. The command line option to allow existing 
code to break into non-public types/members is --add-exports-private. 
The format of the value passed to this option is the same--add-exports. 
With #AddExportsInManifest then there are equivalents in the application 
JAR main manifest to try out too.
{quote}

The stacktrace exposes that the issue is caused by XStream. It seems that 
XStream is used to be able to merge overlays. Maven and most other plugins use 
Modello for these kind of things.

There's still a lot of discussion about #ReflectiveAccessToNonExportedTypes and 
#AwkwardStrongEncapsulation and but I think we can avoid this issue by simply 
switching to the well known Modello solution.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to