harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Zhou (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (HARMONY-6221) [classlib][beans] java.beans.XMLEncoder.writeObject(obj) outputs different contents of the modified field of super class from RI
Date Thu, 08 Apr 2010 07:05:36 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-6221?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Kevin Zhou resolved HARMONY-6221.
---------------------------------

    Resolution: Fixed

Patch appied to r931796, Thanks

> [classlib][beans] java.beans.XMLEncoder.writeObject(obj) outputs different contents of
the modified field of super class from RI
> --------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-6221
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6221
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M9
>            Reporter: Kevin Zhou
>            Assignee: Kevin Zhou
>         Attachments: HARMONY-6221.diff
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> Given a test case [1], ChildClass extends ParentClass which contains a class field. If
we use java.beans.XMLEncoder to write a object of ChildClass after invoking super.setClazz()
method to modify the value of class field, (for example, from Collection.class to ChildClass.class)
the output will be different from RI's output. In fact, HARMONY creates an additional id for
the class object. I think it is unnecessary.
> HARMONY outputs:
> <?xml version="1.0" encoding="UTF-8"?>
> <java version="1.5.0" class="java.beans.XMLDecoder">
>  <object id="XMLEncoderTest$ChildClass0" class="hy.issue2.XMLEncoderTest$ChildClass">
>   <void property="clazz">
>    <class>hy.issue2.XMLEncoderTest$ChildClass</class>
>   </void>
>  </object>
> </java>
> RI outputs:
> <?xml version="1.0" encoding="UTF-8"?> 
> <java version="1.6.0_13" class="java.beans.XMLDecoder"> 
>  <object class="hy.issue2.XMLEncoderTest$ChildClass"> 
>   <void property="clazz"> 
>    <class>hy.issue2.XMLEncoderTest$ChildClass</class> 
>   </void> 
>  </object> 
> </java> 
> [1] Test Case:
> public static class ParentClass {
>     Class<?> clazz = Collection.class;
>     public Class<?> getClazz() {
>         return clazz;
>     }
>     public void setClazz(Class<?> clazz) {
>         this.clazz = clazz;
>     }
> }
> public static class ChildClass extends ParentClass {
> }
> public void test_XMLEncoder_writeObject() throws Exception {
>     ChildClass child = new ChildClass();
>     ByteArrayOutputStream bos = new ByteArrayOutputStream();
>     XMLEncoder xmlEncoder = new XMLEncoder(bos);
>     child.setClazz(ChildClass.class);
>     xmlEncoder.writeObject(child);
>     xmlEncoder.close();
>     System.out.println(bos.toString());
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message