You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Kevin Zhou (JIRA)" <ji...@apache.org> on 2008/09/09 10:13:44 UTC

[jira] Created: (HARMONY-5975) [classlib] [beans] XMLEncoder encodes the static field with customized persistence delegate

[classlib] [beans] XMLEncoder encodes the static field with customized persistence delegate
-------------------------------------------------------------------------------------------

                 Key: HARMONY-5975
                 URL: https://issues.apache.org/jira/browse/HARMONY-5975
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
    Affects Versions: 5.0M7
            Reporter: Kevin Zhou
             Fix For: 5.0M8


Consider test case [1], RI and Harmony's beans will generate different results [2] [3]. 
Using the given MockObjectPersistenceDelegate, RI will write the "inst" instance of MockObject as a field, 
while current Harmony's beans will write this instance by using reflection method Class.getField(...). 
This is due to the missing condition in the XMLEncoder.flushStatField(...) method.

[1]
public class XMLEncoderTest extends TestCase {
    public void test_WriteObject_StaticField() {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        XMLEncoder xmlEncoder = new XMLEncoder(bos);
        xmlEncoder.setPersistenceDelegate(MockObject.class,
                new MockObjectPersistenceDelegate());
        xmlEncoder.writeObject(MockObject.inst);
        xmlEncoder.close();
        System.out.println(bos.toString());
    }
    public static class MockObject {
        public static MockObject inst = new MockObject();
    }
    public static class MockObjectPersistenceDelegate extends
            PersistenceDelegate {
        protected Expression instantiate(Object oldInstance, Encoder enc) {
            Expression exp = null;
            try {
                exp = new Expression(MockObject.class.getField("inst"), "get",
                        new Object[] { null });
            } catch (Exception e) {
                e.printStackTrace();
            }
            return exp;
        }
    }
}

[2] RI's XML:
<?xml version="1.0" encoding="UTF-8"?> 
<java version="1.6.0_05" class="java.beans.XMLDecoder"> 
 <object class="tests.java.beans.XMLEncoderTest$MockObject" field="inst"/> 
</java> 

[3] Harmony's XML
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.5.0" class="java.beans.XMLDecoder">
 <object class="tests.java.beans.XMLEncoderTest$MockObject" method="getField">
  <string>inst</string>
 </object>
</java>

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


[jira] Commented: (HARMONY-5975) [classlib] [beans] XMLEncoder encodes the static field with customized persistence delegate

Posted by "Kevin Zhou (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5975?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12728579#action_12728579 ] 

Kevin Zhou commented on HARMONY-5975:
-------------------------------------

Hi Sean, 
I have already got a patch for this issue, and will apply that soon.
Thanks.

> [classlib] [beans] XMLEncoder encodes the static field with customized persistence delegate
> -------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5975
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5975
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M7
>            Reporter: Kevin Zhou
>            Assignee: Kevin Zhou
>             Fix For: 5.0M8
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> Consider test case [1], RI and Harmony's beans will generate different results [2] [3]. 
> Using the given MockObjectPersistenceDelegate, RI will write the "inst" instance of MockObject as a field, 
> while current Harmony's beans will write this instance by using reflection method Class.getField(...). 
> This is due to the missing condition in the XMLEncoder.flushStatField(...) method.
> [1]
> public class XMLEncoderTest extends TestCase {
>     public void test_WriteObject_StaticField() {
>         ByteArrayOutputStream bos = new ByteArrayOutputStream();
>         XMLEncoder xmlEncoder = new XMLEncoder(bos);
>         xmlEncoder.setPersistenceDelegate(MockObject.class,
>                 new MockObjectPersistenceDelegate());
>         xmlEncoder.writeObject(MockObject.inst);
>         xmlEncoder.close();
>         System.out.println(bos.toString());
>     }
>     public static class MockObject {
>         public static MockObject inst = new MockObject();
>     }
>     public static class MockObjectPersistenceDelegate extends
>             PersistenceDelegate {
>         protected Expression instantiate(Object oldInstance, Encoder enc) {
>             Expression exp = null;
>             try {
>                 exp = new Expression(MockObject.class.getField("inst"), "get",
>                         new Object[] { null });
>             } catch (Exception e) {
>                 e.printStackTrace();
>             }
>             return exp;
>         }
>     }
> }
> [2] RI's XML:
> <?xml version="1.0" encoding="UTF-8"?> 
> <java version="1.6.0_05" class="java.beans.XMLDecoder"> 
>  <object class="tests.java.beans.XMLEncoderTest$MockObject" field="inst"/> 
> </java> 
> [3] Harmony's XML
> <?xml version="1.0" encoding="UTF-8"?>
> <java version="1.5.0" class="java.beans.XMLDecoder">
>  <object class="tests.java.beans.XMLEncoderTest$MockObject" method="getField">
>   <string>inst</string>
>  </object>
> </java>

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


[jira] Commented: (HARMONY-5975) [classlib] [beans] XMLEncoder encodes the static field with customized persistence delegate

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5975?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12854373#action_12854373 ] 

Hudson commented on HARMONY-5975:
---------------------------------

Integrated in Harmony-1.5-head-linux-x86_64 #744 (See [http://hudson.zones.apache.org/hudson/job/Harmony-1.5-head-linux-x86_64/744/])
    Apply patch for : java.beans.XMLEncoder encodes the static field with customized persistence delegate.
Additionally, repeated invoking to XMLEncoder.writeObject(o) method should write the corresponding number of object before flush().


> [classlib] [beans] XMLEncoder encodes the static field with customized persistence delegate
> -------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5975
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5975
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M7
>            Reporter: Kevin Zhou
>            Assignee: Kevin Zhou
>             Fix For: 5.0M8
>
>         Attachments: HARMONY-5975.diff
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> Consider test case [1], RI and Harmony's beans will generate different results [2] [3]. 
> Using the given MockObjectPersistenceDelegate, RI will write the "inst" instance of MockObject as a field, 
> while current Harmony's beans will write this instance by using reflection method Class.getField(...). 
> This is due to the missing condition in the XMLEncoder.flushStatField(...) method.
> [1]
> public class XMLEncoderTest extends TestCase {
>     public void test_WriteObject_StaticField() {
>         ByteArrayOutputStream bos = new ByteArrayOutputStream();
>         XMLEncoder xmlEncoder = new XMLEncoder(bos);
>         xmlEncoder.setPersistenceDelegate(MockObject.class,
>                 new MockObjectPersistenceDelegate());
>         xmlEncoder.writeObject(MockObject.inst);
>         xmlEncoder.close();
>         System.out.println(bos.toString());
>     }
>     public static class MockObject {
>         public static MockObject inst = new MockObject();
>     }
>     public static class MockObjectPersistenceDelegate extends
>             PersistenceDelegate {
>         protected Expression instantiate(Object oldInstance, Encoder enc) {
>             Expression exp = null;
>             try {
>                 exp = new Expression(MockObject.class.getField("inst"), "get",
>                         new Object[] { null });
>             } catch (Exception e) {
>                 e.printStackTrace();
>             }
>             return exp;
>         }
>     }
> }
> [2] RI's XML:
> <?xml version="1.0" encoding="UTF-8"?> 
> <java version="1.6.0_05" class="java.beans.XMLDecoder"> 
>  <object class="tests.java.beans.XMLEncoderTest$MockObject" field="inst"/> 
> </java> 
> [3] Harmony's XML
> <?xml version="1.0" encoding="UTF-8"?>
> <java version="1.5.0" class="java.beans.XMLDecoder">
>  <object class="tests.java.beans.XMLEncoderTest$MockObject" method="getField">
>   <string>inst</string>
>  </object>
> </java>

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


[jira] Assigned: (HARMONY-5975) [classlib] [beans] XMLEncoder encodes the static field with customized persistence delegate

Posted by "Sean Qiu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5975?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sean Qiu reassigned HARMONY-5975:
---------------------------------

    Assignee: Sean Qiu

> [classlib] [beans] XMLEncoder encodes the static field with customized persistence delegate
> -------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5975
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5975
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M7
>            Reporter: Kevin Zhou
>            Assignee: Sean Qiu
>             Fix For: 5.0M8
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> Consider test case [1], RI and Harmony's beans will generate different results [2] [3]. 
> Using the given MockObjectPersistenceDelegate, RI will write the "inst" instance of MockObject as a field, 
> while current Harmony's beans will write this instance by using reflection method Class.getField(...). 
> This is due to the missing condition in the XMLEncoder.flushStatField(...) method.
> [1]
> public class XMLEncoderTest extends TestCase {
>     public void test_WriteObject_StaticField() {
>         ByteArrayOutputStream bos = new ByteArrayOutputStream();
>         XMLEncoder xmlEncoder = new XMLEncoder(bos);
>         xmlEncoder.setPersistenceDelegate(MockObject.class,
>                 new MockObjectPersistenceDelegate());
>         xmlEncoder.writeObject(MockObject.inst);
>         xmlEncoder.close();
>         System.out.println(bos.toString());
>     }
>     public static class MockObject {
>         public static MockObject inst = new MockObject();
>     }
>     public static class MockObjectPersistenceDelegate extends
>             PersistenceDelegate {
>         protected Expression instantiate(Object oldInstance, Encoder enc) {
>             Expression exp = null;
>             try {
>                 exp = new Expression(MockObject.class.getField("inst"), "get",
>                         new Object[] { null });
>             } catch (Exception e) {
>                 e.printStackTrace();
>             }
>             return exp;
>         }
>     }
> }
> [2] RI's XML:
> <?xml version="1.0" encoding="UTF-8"?> 
> <java version="1.6.0_05" class="java.beans.XMLDecoder"> 
>  <object class="tests.java.beans.XMLEncoderTest$MockObject" field="inst"/> 
> </java> 
> [3] Harmony's XML
> <?xml version="1.0" encoding="UTF-8"?>
> <java version="1.5.0" class="java.beans.XMLDecoder">
>  <object class="tests.java.beans.XMLEncoderTest$MockObject" method="getField">
>   <string>inst</string>
>  </object>
> </java>

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


[jira] Assigned: (HARMONY-5975) [classlib] [beans] XMLEncoder encodes the static field with customized persistence delegate

Posted by "Kevin Zhou (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5975?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kevin Zhou reassigned HARMONY-5975:
-----------------------------------

    Assignee: Kevin Zhou  (was: Sean Qiu)

> [classlib] [beans] XMLEncoder encodes the static field with customized persistence delegate
> -------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5975
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5975
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M7
>            Reporter: Kevin Zhou
>            Assignee: Kevin Zhou
>             Fix For: 5.0M8
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> Consider test case [1], RI and Harmony's beans will generate different results [2] [3]. 
> Using the given MockObjectPersistenceDelegate, RI will write the "inst" instance of MockObject as a field, 
> while current Harmony's beans will write this instance by using reflection method Class.getField(...). 
> This is due to the missing condition in the XMLEncoder.flushStatField(...) method.
> [1]
> public class XMLEncoderTest extends TestCase {
>     public void test_WriteObject_StaticField() {
>         ByteArrayOutputStream bos = new ByteArrayOutputStream();
>         XMLEncoder xmlEncoder = new XMLEncoder(bos);
>         xmlEncoder.setPersistenceDelegate(MockObject.class,
>                 new MockObjectPersistenceDelegate());
>         xmlEncoder.writeObject(MockObject.inst);
>         xmlEncoder.close();
>         System.out.println(bos.toString());
>     }
>     public static class MockObject {
>         public static MockObject inst = new MockObject();
>     }
>     public static class MockObjectPersistenceDelegate extends
>             PersistenceDelegate {
>         protected Expression instantiate(Object oldInstance, Encoder enc) {
>             Expression exp = null;
>             try {
>                 exp = new Expression(MockObject.class.getField("inst"), "get",
>                         new Object[] { null });
>             } catch (Exception e) {
>                 e.printStackTrace();
>             }
>             return exp;
>         }
>     }
> }
> [2] RI's XML:
> <?xml version="1.0" encoding="UTF-8"?> 
> <java version="1.6.0_05" class="java.beans.XMLDecoder"> 
>  <object class="tests.java.beans.XMLEncoderTest$MockObject" field="inst"/> 
> </java> 
> [3] Harmony's XML
> <?xml version="1.0" encoding="UTF-8"?>
> <java version="1.5.0" class="java.beans.XMLDecoder">
>  <object class="tests.java.beans.XMLEncoderTest$MockObject" method="getField">
>   <string>inst</string>
>  </object>
> </java>

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


[jira] Resolved: (HARMONY-5975) [classlib] [beans] XMLEncoder encodes the static field with customized persistence delegate

Posted by "Kevin Zhou (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5975?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kevin Zhou resolved HARMONY-5975.
---------------------------------

    Resolution: Fixed

Patch applied to r931455


> [classlib] [beans] XMLEncoder encodes the static field with customized persistence delegate
> -------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5975
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5975
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M7
>            Reporter: Kevin Zhou
>            Assignee: Kevin Zhou
>             Fix For: 5.0M8
>
>         Attachments: HARMONY-5975.diff
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> Consider test case [1], RI and Harmony's beans will generate different results [2] [3]. 
> Using the given MockObjectPersistenceDelegate, RI will write the "inst" instance of MockObject as a field, 
> while current Harmony's beans will write this instance by using reflection method Class.getField(...). 
> This is due to the missing condition in the XMLEncoder.flushStatField(...) method.
> [1]
> public class XMLEncoderTest extends TestCase {
>     public void test_WriteObject_StaticField() {
>         ByteArrayOutputStream bos = new ByteArrayOutputStream();
>         XMLEncoder xmlEncoder = new XMLEncoder(bos);
>         xmlEncoder.setPersistenceDelegate(MockObject.class,
>                 new MockObjectPersistenceDelegate());
>         xmlEncoder.writeObject(MockObject.inst);
>         xmlEncoder.close();
>         System.out.println(bos.toString());
>     }
>     public static class MockObject {
>         public static MockObject inst = new MockObject();
>     }
>     public static class MockObjectPersistenceDelegate extends
>             PersistenceDelegate {
>         protected Expression instantiate(Object oldInstance, Encoder enc) {
>             Expression exp = null;
>             try {
>                 exp = new Expression(MockObject.class.getField("inst"), "get",
>                         new Object[] { null });
>             } catch (Exception e) {
>                 e.printStackTrace();
>             }
>             return exp;
>         }
>     }
> }
> [2] RI's XML:
> <?xml version="1.0" encoding="UTF-8"?> 
> <java version="1.6.0_05" class="java.beans.XMLDecoder"> 
>  <object class="tests.java.beans.XMLEncoderTest$MockObject" field="inst"/> 
> </java> 
> [3] Harmony's XML
> <?xml version="1.0" encoding="UTF-8"?>
> <java version="1.5.0" class="java.beans.XMLDecoder">
>  <object class="tests.java.beans.XMLEncoderTest$MockObject" method="getField">
>   <string>inst</string>
>  </object>
> </java>

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


[jira] Commented: (HARMONY-5975) [classlib] [beans] XMLEncoder encodes the static field with customized persistence delegate

Posted by "Sean Qiu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5975?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12728574#action_12728574 ] 

Sean Qiu commented on HARMONY-5975:
-----------------------------------

Hi, Kevin.
Are you going to supply for this issue?
Otherwise I can give the patch.

> [classlib] [beans] XMLEncoder encodes the static field with customized persistence delegate
> -------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5975
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5975
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M7
>            Reporter: Kevin Zhou
>            Assignee: Sean Qiu
>             Fix For: 5.0M8
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> Consider test case [1], RI and Harmony's beans will generate different results [2] [3]. 
> Using the given MockObjectPersistenceDelegate, RI will write the "inst" instance of MockObject as a field, 
> while current Harmony's beans will write this instance by using reflection method Class.getField(...). 
> This is due to the missing condition in the XMLEncoder.flushStatField(...) method.
> [1]
> public class XMLEncoderTest extends TestCase {
>     public void test_WriteObject_StaticField() {
>         ByteArrayOutputStream bos = new ByteArrayOutputStream();
>         XMLEncoder xmlEncoder = new XMLEncoder(bos);
>         xmlEncoder.setPersistenceDelegate(MockObject.class,
>                 new MockObjectPersistenceDelegate());
>         xmlEncoder.writeObject(MockObject.inst);
>         xmlEncoder.close();
>         System.out.println(bos.toString());
>     }
>     public static class MockObject {
>         public static MockObject inst = new MockObject();
>     }
>     public static class MockObjectPersistenceDelegate extends
>             PersistenceDelegate {
>         protected Expression instantiate(Object oldInstance, Encoder enc) {
>             Expression exp = null;
>             try {
>                 exp = new Expression(MockObject.class.getField("inst"), "get",
>                         new Object[] { null });
>             } catch (Exception e) {
>                 e.printStackTrace();
>             }
>             return exp;
>         }
>     }
> }
> [2] RI's XML:
> <?xml version="1.0" encoding="UTF-8"?> 
> <java version="1.6.0_05" class="java.beans.XMLDecoder"> 
>  <object class="tests.java.beans.XMLEncoderTest$MockObject" field="inst"/> 
> </java> 
> [3] Harmony's XML
> <?xml version="1.0" encoding="UTF-8"?>
> <java version="1.5.0" class="java.beans.XMLDecoder">
>  <object class="tests.java.beans.XMLEncoderTest$MockObject" method="getField">
>   <string>inst</string>
>  </object>
> </java>

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


[jira] Updated: (HARMONY-5975) [classlib] [beans] XMLEncoder encodes the static field with customized persistence delegate

Posted by "Kevin Zhou (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5975?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kevin Zhou updated HARMONY-5975:
--------------------------------

    Attachment: HARMONY-5975.diff

Would you please help to tested it ?

> [classlib] [beans] XMLEncoder encodes the static field with customized persistence delegate
> -------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5975
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5975
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M7
>            Reporter: Kevin Zhou
>            Assignee: Kevin Zhou
>             Fix For: 5.0M8
>
>         Attachments: HARMONY-5975.diff
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> Consider test case [1], RI and Harmony's beans will generate different results [2] [3]. 
> Using the given MockObjectPersistenceDelegate, RI will write the "inst" instance of MockObject as a field, 
> while current Harmony's beans will write this instance by using reflection method Class.getField(...). 
> This is due to the missing condition in the XMLEncoder.flushStatField(...) method.
> [1]
> public class XMLEncoderTest extends TestCase {
>     public void test_WriteObject_StaticField() {
>         ByteArrayOutputStream bos = new ByteArrayOutputStream();
>         XMLEncoder xmlEncoder = new XMLEncoder(bos);
>         xmlEncoder.setPersistenceDelegate(MockObject.class,
>                 new MockObjectPersistenceDelegate());
>         xmlEncoder.writeObject(MockObject.inst);
>         xmlEncoder.close();
>         System.out.println(bos.toString());
>     }
>     public static class MockObject {
>         public static MockObject inst = new MockObject();
>     }
>     public static class MockObjectPersistenceDelegate extends
>             PersistenceDelegate {
>         protected Expression instantiate(Object oldInstance, Encoder enc) {
>             Expression exp = null;
>             try {
>                 exp = new Expression(MockObject.class.getField("inst"), "get",
>                         new Object[] { null });
>             } catch (Exception e) {
>                 e.printStackTrace();
>             }
>             return exp;
>         }
>     }
> }
> [2] RI's XML:
> <?xml version="1.0" encoding="UTF-8"?> 
> <java version="1.6.0_05" class="java.beans.XMLDecoder"> 
>  <object class="tests.java.beans.XMLEncoderTest$MockObject" field="inst"/> 
> </java> 
> [3] Harmony's XML
> <?xml version="1.0" encoding="UTF-8"?>
> <java version="1.5.0" class="java.beans.XMLDecoder">
>  <object class="tests.java.beans.XMLEncoderTest$MockObject" method="getField">
>   <string>inst</string>
>  </object>
> </java>

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