On 2010-9-30 1:00, hindessm@apache.org wrote:
> Author: hindessm
> Date: Wed Sep 29 17:00:09 2010
> New Revision: 1002734
>
> URL: http://svn.apache.org/viewvc?rev=1002734&view=rev
> Log:
> Merge change from trunk@1002511:
>
> r1002511 | zhoukevin | 2010-09-29 09:10:27 +0100 (Wed, 29 Sep 2010) | 1 line
>
> Apply the patch for HARMONY-6664: Poor performance of
> java.beans.XMLEncoder.writeObject() method. This reduce the time of
> writing a list of 25000 integers from 30 seconds to 3 seconds, improve
> the performance of XMLEncoder.writeObject() to some extent.
>
> Removed:
> harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/ReferenceMap.java
> Modified:
> harmony/enhanced/java/branches/java6/ (props changed)
> harmony/enhanced/java/branches/java6/classlib/ (props changed)
> harmony/enhanced/java/branches/java6/classlib/depends/libs/ (props changed)
> harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/DefaultPersistenceDelegate.java
> harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/Encoder.java
> harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/PersistenceDelegate.java
> harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/XMLEncoder.java
> harmony/enhanced/java/branches/java6/drlvm/ (props changed)
> harmony/enhanced/java/branches/java6/jdktools/ (props changed)
>
> Propchange: harmony/enhanced/java/branches/java6/
> ------------------------------------------------------------------------------
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Wed Sep 29 17:00:09 2010
> @@ -1,4 +1,4 @@
> /harmony/enhanced/java/branches/mrh:935751-941490
> -/harmony/enhanced/java/trunk:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005,1000169,1000213,1000229,1000231,1000233,1000240,1000245,1000248,1000265,1000527,1000689,1000696,1000699-1000700,1000705,1000708,1001065,1001080,1001153,1001187,1001490,1001609,1001638,1001652,1001723,1001741,1001744-1001745,1001751,1002080,1002189,1002476,1002480,1002488,1002506
> +/harmony/enhanced/java/trunk:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005,1000169,1000213,1000229,1000231,1000233,1000240,1000245,1000248,1000265,1000527,1000689,1000696,1000699-1000700,1000705,1000708,1001065,1001080,1001153,1001187,1001490,1001609,1001638,1001652,1001723,1001741,1001744-1001745,1001751,1002080,1002189,1002476,1002480,1002488,1002506,1002511
> /harmony/enhanced/trunk:476395-929252
> /incubator/harmony/enhanced/trunk:292550-476394
>
> Propchange: harmony/enhanced/java/branches/java6/classlib/
> ------------------------------------------------------------------------------
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Wed Sep 29 17:00:09 2010
> @@ -1,7 +1,7 @@
> /harmony/enhanced/classlib/trunk:713674-735919,765923-926091,926318-926838
> /harmony/enhanced/classlib/trunk/working_classlib:884014-884286
> /harmony/enhanced/java/branches/mrh/classlib:935751-941490
> -/harmony/enhanced/java/trunk/classlib:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005,1000169,1000213,1000229,1000231,1000233,1000240,1000245,1000248,1000265,1000527,1000689,1000696,1000699-1000700,1000705,1000708,1001065,1001080,1001153,1001187,1001490,1001609,1001638,1001652,1001723,1001741,1001744-1001745,1001751,1002080,1002189,1002476,1002480,1002488,1002506
> +/harmony/enhanced/java/trunk/classlib:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005,1000169,1000213,1000229,1000231,1000233,1000240,1000245,1000248,1000265,1000527,1000689,1000696,1000699-1000700,1000705,1000708,1001065,1001080,1001153,1001187,1001490,1001609,1001638,1001652,1001723,1001741,1001744-1001745,1001751,1002080,1002189,1002476,1002480,1002488,1002506,1002511
> /harmony/enhanced/trunk/classlib:476395-929252
> /harmony/enhanced/trunk/working_classlib:476396-920147
> /incubator/harmony/enhanced/trunk/classlib:292550-476394
>
> Propchange: harmony/enhanced/java/branches/java6/classlib/depends/libs/
> ------------------------------------------------------------------------------
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Wed Sep 29 17:00:09 2010
> @@ -1,4 +1,4 @@
> /harmony/enhanced/classlib/trunk/depends/libs:544451-926091
> -/harmony/enhanced/java/trunk/classlib/depends/libs:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005,1000169,1000213,1000229,1000231,1000233,1000240,1000245,1000248,1000265,1000527,1000689,1000696,1000699-1000700,1000705,1000708,1001065,1001080,1001153,1001187,1001490,1001609,1001638,1001652,1001723,1001741,1001744-1001745,1001751,1002080,1002189,1002476,1002480,1002488,1002506
> +/harmony/enhanced/java/trunk/classlib/depends/libs:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005,1000169,1000213,1000229,1000231,1000233,1000240,1000245,1000248,1000265,1000527,1000689,1000696,1000699-1000700,1000705,1000708,1001065,1001080,1001153,1001187,1001490,1001609,1001638,1001652,1001723,1001741,1001744-1001745,1001751,1002080,1002189,1002476,1002480,1002488,1002506,1002511
> /harmony/enhanced/trunk/classlib/depends/libs:476395-929252
> /incubator/harmony/enhanced/trunk/classlib/depends/libs:292550-476394
>
> Modified: harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/DefaultPersistenceDelegate.java
> URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/DefaultPersistenceDelegate.java?rev=1002734&r1=1002733&r2=1002734&view=diff
> ==============================================================================
> --- harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/DefaultPersistenceDelegate.java (original)
> +++ harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/DefaultPersistenceDelegate.java Wed Sep 29 17:00:09 2010
> @@ -115,22 +115,23 @@ public class DefaultPersistenceDelegate
> return;
> }
> PropertyDescriptor[] pds = info.getPropertyDescriptors();
> -
> + Method getter, setter;
> // Initialize each found non-transient property
> for (int i = 0; i< pds.length; i++) {
> // Skip a property whose transient attribute is true
> if (Boolean.TRUE.equals(pds[i].getValue("transient"))) { //$NON-NLS-1$
> continue;
> }
> + getter = pds[i].getReadMethod();
> + setter = pds[i].getWriteMethod();
> // Skip a property having no setter or getter
> - if (null == pds[i].getWriteMethod()
> - || null == pds[i].getReadMethod()) {
> + if (getter == null || setter == null) {
> continue;
> }
>
> // Get the value of the property in the old instance
> - Expression getterExp = new Expression(oldInstance, pds[i]
> - .getReadMethod().getName(), null);
> + Expression getterExp = new Expression(oldInstance,
> + getter.getName(), null);
> try {
> // Calculate the old value of the property
> Object oldVal = getterExp.getValue();
> @@ -138,30 +139,14 @@ public class DefaultPersistenceDelegate
> enc.writeExpression(getterExp);
> // Get the target value that exists in the new environment
> Object targetVal = enc.get(oldVal);
> - // Get the current property value in the new environment
> - Object newVal = new Expression(newInstance, pds[i]
> - .getReadMethod().getName(), null).getValue();
> - /*
> - * Make the target value and current property value equivalent
> - * in the new environment
> - */
> - if (null == targetVal) {
> - if (null != newVal) {
> - // Set to null
> - Statement setterStm = new Statement(oldInstance, pds[i]
> - .getWriteMethod().getName(),
> - new Object[] { null });
> - enc.writeStatement(setterStm);
> - }
> - } else {
> - PersistenceDelegate pd = enc
> - .getPersistenceDelegate(targetVal.getClass());
> - if (!pd.mutatesTo(targetVal, newVal)) {
> - Statement setterStm = new Statement(oldInstance, pds[i]
> - .getWriteMethod().getName(),
> - new Object[] { oldVal });
> - enc.writeStatement(setterStm);
> - }
> + Object newVal = new Expression(newInstance, getter.getName(),
> + null).getValue();
> + boolean invokeSetter = targetVal == null ? (newVal != null&& oldVal == null)
> + : !enc.getPersistenceDelegate(targetVal.getClass())
> + .mutatesTo(targetVal, newVal);
> + if (invokeSetter) {
> + enc.writeStatement(new Statement(oldInstance, setter
> + .getName(), new Object[] { oldVal }));
> }
> } catch (Exception ex) {
> enc.getExceptionListener().exceptionThrown(ex);
>
> Modified: harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/Encoder.java
> URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/Encoder.java?rev=1002734&r1=1002733&r2=1002734&view=diff
> ==============================================================================
> --- harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/Encoder.java (original)
> +++ harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/Encoder.java Wed Sep 29 17:00:09 2010
> @@ -40,6 +40,7 @@ import java.lang.reflect.Proxy;
> import java.util.Collection;
> import java.util.Date;
> import java.util.Hashtable;
> +import java.util.IdentityHashMap;
> import java.util.Map;
>
> import javax.swing.Box;
> @@ -49,16 +50,16 @@ import javax.swing.JTabbedPane;
> import javax.swing.ToolTipManager;
>
> /**
> - * TheEncoder, together withPersistenceDelegate
> - * s, can encode an object into a series of java statements. By executing these
> + * TheEncoder, together withPersistenceDelegate s,
> + * can encode an object into a series of java statements. By executing these
> * statements, a new object can be created and it will has the same state as the
> * original object which has been passed to the encoder. Here "has the same
> * state" means the two objects are indistinguishable from their public API.
> *
> - * TheEncoder andPersistenceDelegate s do this
> - * by creating copies of the input object and all objects it references. The
> - * copy process continues recursively util every object in the object graph has
> - * its new copy and the new version has the same state as the old version. All
> + * TheEncoder andPersistenceDelegate s do this by
> + * creating copies of the input object and all objects it references. The copy
> + * process continues recursively util every object in the object graph has its
> + * new copy and the new version has the same state as the old version. All
> * statements used to create those new objects and executed on them during the
> * process form the result of encoding.
> *
> @@ -110,7 +111,7 @@ public class Encoder {
>
> private ExceptionListener listener = defaultExListener;
>
> - private ReferenceMap oldNewMap = new ReferenceMap();
> + private IdentityHashMap