Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Duplicate
-
Affects Version/s: None
-
Fix Version/s: 1.2.2
-
Component/s: Converters
-
Labels:None
-
JDK version and platform:Apache Harmony
Description
com.thoughtworks.xstream.converters.enums.EnumSetConverter, at its line 31 (rev. 538) uses reflection to address field elementType in class java.util.EnumSet.
That field is package private and is not covered by the Java API, and thus may be missing in implementations other than Sun's.
Thus, addressing this field limits the XStream's capability to run on Apache Harmony and other implementations lacking that Sun-implementation-specific field.
For example, this issue interferes with Apache Geronimo Unit Tests running on Apache Harmony.
The stack looks as follows:
com.thoughtworks.xstream.XStream$InitializationException: Could not instatiate converter : com.thoughtworks.xstream.converters.enums.EnumSetConverter : null
at com.thoughtworks.xstream.XStream.dynamicallyRegisterConverter(XStream.java:395)
at com.thoughtworks.xstream.XStream.setupConverters(XStream.java:378)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:196)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:181)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:156)
at org.apache.geronimo.timer.jdbc.JDBCWorkerPersistence.serialize(JDBCWorkerPersistence.java:305)
at org.apache.geronimo.timer.jdbc.JDBCWorkerPersistence.save(JDBCWorkerPersistence.java:118)
at org.apache.geronimo.timer.jdbc.JDBCWorkerPersistenceTestAbstract.testSaveCancel(JDBCWorkerPersistenceTestAbstract.java:66)
at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java)
at java.lang.reflect.Method.invoke(Method.java:317)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java)
at java.lang.reflect.Method.invoke(Method.java:317)
at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:210)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:135)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:122)
at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java)
at java.lang.reflect.Method.invoke(Method.java:317)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.VMReflection.newClassInstance(VMReflection.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:283)
at com.thoughtworks.xstream.XStream.dynamicallyRegisterConverter(XStream.java:392)
at com.thoughtworks.xstream.XStream.setupConverters(XStream.java:378)
... 26 more
Caused by: java.lang.RuntimeException: Could not access java.util.EnumSet.elementType field
at com.thoughtworks.xstream.core.util.Fields.find(Fields.java:18)
at com.thoughtworks.xstream.converters.enums.EnumSetConverter.<init>(EnumSetConverter.java:31)
at java.lang.reflect.VMReflection.newClassInstance(VMReflection.java)
... 29 more
Issue Links
- duplicates
-
XSTR-379 EnumSetConverter fails on Harmony
Here's the Apache Harmony effort to workaround this compatibility issue from its side: http://issues.apache.org/jira/browse/HARMONY-5196
However, the (potential) problem in XStream implementation remains.