Issue Details (XML | Word | Printable)

Key: XSTR-379
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Assignee: Unassigned
Reporter: Robert Newson
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
XStream

EnumSetConverter fails on Harmony

Created: 05/Feb/07 04:30 PM   Updated: 26/Nov/07 03:32 PM   Resolved: 06/Feb/07 12:59 PM
Return to search
Component/s: None
Affects Version/s: None
Fix Version/s: 1.2.2

Issue Links:
Duplicate
 
Related
 

JDK version and platform: Harmony on Debian 386.


 Description  « Hide

After XFS-378 was fixed, the converters.extended testcases now fail in EnumSetConverter because of

"Could not access java.util.EnumSet.elementType field"

junit.framework.AssertionFailedError: Exception in constructor: testSupportsConstructor (com.thoughtworks.xstream.XStream$InitializationException: Could not instatiate converter : com.thoughtworks.xstream.converters.enums.EnumSetConverter : null
at com.thoughtworks.xstream.XStream.dynamicallyRegisterConverter(XStream.java:659)
at com.thoughtworks.xstream.XStream.setupConverters(XStream.java:630)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:374)
at com.thoughtworks.xstream.XStream.<init>(XStream.java)
at com.thoughtworks.acceptance.AbstractAcceptanceTest.createXStream(AbstractAcceptanceTest.java:29)
at com.thoughtworks.acceptance.AbstractAcceptanceTest.<init>(AbstractAcceptanceTest.java:24)
at com.thoughtworks.xstream.converters.extended.JavaMethodConverterTest.<init>(JavaMethodConverterTest.java)
at java.lang.reflect.VMReflection.newClassInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at junit.framework.TestSuite.createTest(TestSuite.java:131)
at junit.framework.TestSuite.addTestMethod(TestSuite.java:113)
at junit.framework.TestSuite.<init>(TestSuite.java:75)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.getTest(JUnit3TestLoader.java:102)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.loadTests(JUnit3TestLoader.java:58)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:385)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:195)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.VMReflection.newClassInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.thoughtworks.xstream.XStream.dynamicallyRegisterConverter(XStream.java:651)
at com.thoughtworks.xstream.XStream.setupConverters(XStream.java:630)
... 16 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(Native Method)
... 19 more
)
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.TestSuite$1.runTest(TestSuite.java)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java)
at junit.framework.TestResult.runProtected(TestResult.java)
at junit.framework.TestResult.run(TestResult.java:104)
at junit.framework.TestCase.run(TestCase.java)
at junit.framework.TestSuite.runTest(TestSuite.java)
at junit.framework.TestSuite.run(TestSuite.java:202)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:126)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:385)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:195)



Joerg Schaible made changes - 06/Feb/07 12:05 PM
Field Original Value New Value
Link This issue is related to XSTR-378 [ XSTR-378 ]
Joerg Schaible added a comment - 06/Feb/07 12:59 PM

Hi Robert,

I've committed a change, can you give it a try?

  • Jörg

Joerg Schaible made changes - 06/Feb/07 12:59 PM
Fix Version/s 1.x Maintenance [ 12873 ]
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Robert Newson added a comment - 12/Feb/07 12:39 PM

The latest trunk seems to have fixed this issue, thanks. It does appear that Xstream is quite intimately coupled to the Sun JDK as I do get another error because of assumptions about internal private variables. Testing against Harmony directly is a good strategy to find all of the places in Xstream that do this.

FYI: the next place that the test suite blows up is in StackTraceElementFactory;

private StackTraceElement create(String declaringClass, String methodName, String fileName, int lineNumber) {
StackTraceElement result = new Throwable().getStackTrace()[0];
setField(result, "declaringClass", declaringClass);

the setField line throws IllegalAccessException as, in Harmony, the declaringClass field is final. Specifically it's the setAccessible line in setField that throws.

I suspect there are many more bugs like this, so I'll leave it to you as to how much you want Xstream to work on Harmony (or, rather, non-Sun JDK's).

B.


Joerg Schaible added a comment - 13/Feb/07 01:05 AM

Hi Robert,

XStream runs on a lot of non-Sun-JDKs. I already tried to run Harmony myself, but since I am short on time and it was not clear to me (without further investigation) how to set up this dev snapshot as real JDK usable in Eclipse I stopped the effort.

The problem with the StackTraceElement is because Harmony is not conforming to the spec. A JDK 5 implementation must allow a program to set even final fields: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Field.html#set(java.lang.Object,%20java.lang.Object)

We are interested in Harmony as platform, but it seems not ready for production also.

  • Jörg

Joerg Schaible made changes - 24/May/07 12:36 AM
Fix Version/s 1.x Maintenance [ 12873 ]
Fix Version/s 1.2.2 [ 13038 ]
Joerg Schaible made changes - 24/May/07 12:38 AM
Status Resolved [ 5 ] Closed [ 6 ]
Vasily Zakharov added a comment - 26/Nov/07 03:14 PM

Joerg,

Thank you very much for pointing this out! Just in case, here are the corresponding issues on this problem in Harmony:

http://issues.apache.org/jira/browse/HARMONY-5196 [classlib][luni][gut] EnumSet.elementType field doesn't exist
http://issues.apache.org/jira/browse/HARMONY-5199 [drlvm][kernel] final fields cannot be set accessible
http://issues.apache.org/jira/browse/HARMONY-5200 [ibm vme] final fields cannot be set accessible

Vasily


Joerg Schaible made changes - 26/Nov/07 03:29 PM
Link This issue is duplicated by XSTR-452 [ XSTR-452 ]
Joerg Schaible added a comment - 26/Nov/07 03:32 PM

I'll give Harmony a shot, once a new version exists, where HARMONY-5199 is fixed.