Issue Details (XML | Word | Printable)

Key: HARMONY-5196
Type: Bug Bug
Status: Closed Closed
Resolution: Won't Fix
Priority: Major Major
Assignee: Unassigned
Reporter: Vasily Zakharov
Votes: 0
Watchers: 1
Operations

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

[classlib][luni][gut] EnumSet.elementType field doesn't exist

Created: 26/Nov/07 04:53 PM   Updated: 30/Nov/07 06:17 PM
Return to search
Component/s: App-Oriented Bug Reports, Classlib, Non-bug differences from RI
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works Harmony-5196.patch 2007-11-26 04:56 PM Vasily Zakharov 2 kB
Issue Links:
Reference
 

Patch Info: Patch Available
Resolution Date: 27/Nov/07 06:43 AM


 Description  « Hide
When running Geronimo Unit Tests v2.0.2, the following exception occurs:

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)

Here's the simple code to reproduce:

public class Test {
    public static void main(String[] args) {
        try {
            System.out.println("SUCCESS: " + java.util.EnumSet.class.getDeclaredField("elementType"));
        } catch (Exception e) {
            e.printStackTrace(System.out);
        }
    }
}

Output on RI:

SUCCESS: final java.lang.Class java.util.EnumSet.elementType

Output on Harmony:

java.lang.NoSuchFieldException: elementType
        at java.lang.Class.getDeclaredField(Class.java:373)
        at Test.main(Test.java:4)

Clearly enough, the mentioned field is package private, it's not covered by the spec, and probably it contains the element type of the EnumSet.

Addressing such a field in an application is clearly a bug, and it should be reported to XStream developers (http://xstream.codehaus.org).

However, as this issue occurred, I think it worths to behave compatibly. Harmony implementation of EnumSet has elementClass field that seems to be the equivalent of RI's elementType field. So my suggestion is to rename elementClass to elementType and thus become more compatible and move GUT v2.0 enabling forward.


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Vasily Zakharov added a comment - 26/Nov/07 04:56 PM
Attached a compatibility patch.

Vasily Zakharov added a comment - 26/Nov/07 05:18 PM
Here's the bug filed against XStream: http://jira.codehaus.org/browse/XSTR-452

Vasily Zakharov added a comment - 26/Nov/07 05:30 PM
Here's even older bug: http://jira.codehaus.org/browse/XSTR-379

The issue is already fixed in XStream 1.2.2 (GUT 2.0 uses old XStream 1.1.3), but I think applying a compatibility patch is still a good idea.

Vasily Zakharov added a comment - 27/Nov/07 06:43 AM
According to discussion in the mailing list, closing this issue as a non-bug difference.

http://thread.gmane.org/gmane.comp.java.harmony.devel/30655