harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r932673 [1/2] - in /harmony/enhanced/java/branches/java6: ./ classlib/ classlib/depends/libs/ classlib/modules/beans/src/main/java/java/beans/ classlib/modules/beans/src/test/java-internal/java/beans/ classlib/modules/beans/src/test/java/or...
Date Sat, 10 Apr 2010 06:54:15 GMT
Author: hindessm
Date: Sat Apr 10 06:54:13 2010
New Revision: 932673

URL: http://svn.apache.org/viewvc?rev=932673&view=rev
Log:
Merging from trunk@932581.

Added:
    harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/resources/xml/ChangedObject.xml
      - copied unchanged from r932581, harmony/enhanced/java/trunk/classlib/modules/beans/src/test/resources/xml/ChangedObject.xml
    harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/resources/xml/ClassID.xml
      - copied unchanged from r932581, harmony/enhanced/java/trunk/classlib/modules/beans/src/test/resources/xml/ClassID.xml
    harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/resources/xml/ObjectID.xml
      - copied unchanged from r932581, harmony/enhanced/java/trunk/classlib/modules/beans/src/test/resources/xml/ObjectID.xml
    harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/resources/xml/StaticField.xml
      - copied unchanged from r932581, harmony/enhanced/java/trunk/classlib/modules/beans/src/test/resources/xml/StaticField.xml
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/ArrayPersistenceDelegate.java
    harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/Statement.java
    harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/XMLEncoder.java
    harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java-internal/java/beans/ArrayPersistenceDelegateTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/ExpressionTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/resources/xml/MockBean4Codec_ManyChanges.xml
    harmony/enhanced/java/branches/java6/classlib/modules/lang-management/src/main/java/java/lang/management/ThreadInfo.java
    harmony/enhanced/java/branches/java6/classlib/modules/lang-management/src/test/impl/java/org/apache/harmony/lang/management/ThreadInfoTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/DatagramSocket.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramSocketTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/HttpURLConnectionTest.java
    harmony/enhanced/java/branches/java6/common_resources/   (props changed)
    harmony/enhanced/java/branches/java6/drlvm/   (props changed)
    harmony/enhanced/java/branches/java6/drlvm/make/depends.properties
    harmony/enhanced/java/branches/java6/drlvm/vm/port/src/crash_handler/stack_dump.cpp
    harmony/enhanced/java/branches/java6/drlvm/vm/port/src/modules/unix/freebsd/native_modules_procmap.c
    harmony/enhanced/java/branches/java6/drlvm/vm/vmcore/src/util/crash_dump.cpp
    harmony/enhanced/java/branches/java6/drlvm/vm/vmcore/src/util/em64t/base/ini_em64t.cpp
    harmony/enhanced/java/branches/java6/drlvm/vm/vmcore/src/util/ia32/base/ini_iA32.cpp
    harmony/enhanced/java/branches/java6/jdktools/   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/.classpath   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/.project   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/.settings/org.eclipse.jdt.core.prefs   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/.settings/org.eclipse.jdt.ui.prefs   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/META-INF/MANIFEST.MF   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/build.xml   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/internal/nls/Messages.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/internal/nls/messages.properties   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/ArgumentsParser.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/CRLManager.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/CSRGenerator.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/CertChainVerifier.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/CertExporter.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/CertImporter.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/CertReader.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/Command.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/EntryManager.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/HelpPrinter.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/KeyCertGenerator.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/KeyStoreCertPrinter.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/KeyStoreConverter.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/KeytoolException.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/KeytoolKSLoaderSaver.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/KeytoolParameters.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/keytool/Main.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/Consts.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/Main.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/control/Controller.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/control/InvalidPolicyTextException.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/control/PolicyFileHandler.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/control/PolicyTextParser.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/model/CommentEntry.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/model/GrantEntry.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/model/KeystoreEntry.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/model/KeystorePasswordURLEntry.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/model/Permission.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/model/PolicyEntry.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/model/Principal.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/view/BaseFormDialog.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/view/DirectTextEditorPanel.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/view/EditorPanel.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/view/GrantEntryEditFormDialog.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/view/GraphicalEditorPanel.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/view/KeystoreEntryEditFormDialog.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/view/LAEFormDialog.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/view/ListAndEditPanel.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/view/MainFrame.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/view/PermissionEditFormDialog.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/view/PrincipalEditFormDialog.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/view/WarningLogDialog.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/view/apache.gif   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/toolutils/KeyStoreLoaderSaver.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/toolutils/Util.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/main/java/org/apache/harmony/jretools/unpack200/Main.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/test/java/org/apache/harmony/jretools/tests/keytool/GenKeyTest.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/test/java/org/apache/harmony/jretools/tests/keytool/TestUtils.java   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/modules/jretools/src/test/java/org/apache/harmony/jretools/tests/toolutils/KeyStoreLoaderSaverTest.java   (props changed)

Propchange: harmony/enhanced/java/branches/java6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Apr 10 06:54:13 2010
@@ -1,2 +1,2 @@
-/harmony/enhanced/java/trunk:929253-930072
+/harmony/enhanced/java/trunk:929253-932581
 /harmony/enhanced/trunk:810871-929252

Propchange: harmony/enhanced/java/branches/java6/classlib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Apr 10 06:54:13 2010
@@ -1,6 +1,6 @@
 /harmony/enhanced/classlib/trunk:713674-735919,765923-926091,926318-926838
 /harmony/enhanced/classlib/trunk/working_classlib:884014-884286
-/harmony/enhanced/java/trunk/classlib:929253-930072
+/harmony/enhanced/java/trunk/classlib:929253-932581
 /harmony/enhanced/trunk/classlib:810871-929252
 /harmony/enhanced/trunk/working_classlib:476396-920147
 /incubator/harmony/enhanced/trunk/working_classlib:423974-476394

Propchange: harmony/enhanced/java/branches/java6/classlib/depends/libs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Apr 10 06:54:13 2010
@@ -1,3 +1,3 @@
 /harmony/enhanced/classlib/trunk/depends/libs:544451-926091
-/harmony/enhanced/java/trunk/classlib/depends/libs:929253-930072
+/harmony/enhanced/java/trunk/classlib/depends/libs:929253-932581
 /harmony/enhanced/trunk/classlib/depends/libs:810871-929252

Modified: harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/ArrayPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/ArrayPersistenceDelegate.java?rev=932673&r1=932672&r2=932673&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/ArrayPersistenceDelegate.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/ArrayPersistenceDelegate.java Sat Apr 10 06:54:13 2010
@@ -49,11 +49,8 @@ class ArrayPersistenceDelegate extends P
         assert newInstance != null && newInstance.getClass().isArray() : newInstance;
 
         int length = Array.getLength(oldInstance);
-        Class<?> componentType = type.getComponentType();
-        Object nullValue = Array.get(Array.newInstance(componentType, 1), 0);
 
         for (int i = 0; i < length; ++i) {
-
             Object oldValue = Array.get(oldInstance, i);
             Object newValue = Array.get(newInstance, i);
             if (!deepEquals(oldValue, newValue)) {
@@ -72,11 +69,17 @@ class ArrayPersistenceDelegate extends P
             return false;
         }
         // oldInstnace != newInstance
-        if (oldInstance.equals(newInstance)) {
+        if (oldInstance.getClass().isAssignableFrom(newInstance.getClass())
+                && oldInstance.equals(newInstance)) {
             return true;
-        } else if (oldInstance.getClass().isArray() && newInstance.getClass().isArray()) {
-            int length = Array.getLength(oldInstance);
-            for (int i = 0; i < length; ++i) {
+        } else if (oldInstance.getClass().isArray()
+                && newInstance.getClass().isArray()) {
+            int length1 = Array.getLength(oldInstance);
+            int length2 = Array.getLength(newInstance);
+            if (length1 != length2) {
+                return false;
+            }
+            for (int i = 0; i < length1; i++) {
                 Object oldValue = Array.get(oldInstance, i);
                 Object newValue = Array.get(newInstance, i);
                 if (!deepEquals(oldValue, newValue)) {

Modified: harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/Statement.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/Statement.java?rev=932673&r1=932672&r2=932673&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/Statement.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/Statement.java Sat Apr 10 06:54:13 2010
@@ -322,8 +322,30 @@ public class Statement {
                     }
                 }
                 if (found) {
-                    result = constructor;
-                    break;
+                    if (result == null) {
+                        // first time, set constructor
+                        result = constructor;
+                        continue;
+                    }
+                    // find out more suitable constructor
+                    Class<?>[] resultParameterTypes = result
+                            .getParameterTypes();
+                    boolean isAssignable = true;
+                    for (int j = 0; j < parameterTypes.length; ++j) {
+                        if (theArguments[j] != null
+                                && !(isAssignable &= resultParameterTypes[j]
+                                        .isAssignableFrom(parameterTypes[j]))) {
+                            break;
+                        }
+                        if (theArguments[j] == null
+                                && !(isAssignable &= parameterTypes[j]
+                                        .isAssignableFrom(resultParameterTypes[j]))) {
+                            break;
+                        }
+                    }
+                    if (isAssignable) {
+                        result = constructor;
+                    }
                 }
             }
         }

Modified: harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/XMLEncoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/XMLEncoder.java?rev=932673&r1=932672&r2=932673&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/XMLEncoder.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/beans/src/main/java/java/beans/XMLEncoder.java Sat Apr 10 06:54:13 2010
@@ -15,23 +15,22 @@
  *  limitations under the License.
  */
 
-
 package java.beans;
 
-import java.awt.SystemColor;
-import java.awt.font.TextAttribute;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
 import java.lang.reflect.Proxy;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.harmony.awt.internal.nls.Messages;
+import org.apache.harmony.beans.internal.nls.Messages;
 
 /**
  * <code>XMLEncoder</code> extends <code>Encoder</code> to write out the
@@ -78,8 +77,6 @@ public class XMLEncoder extends Encoder 
 
 	private boolean hasXmlHeader = false;
 
-	private int idSerialNo = 0;
-
 	/*
 	 * if any expression or statement references owner, it is set true in method
 	 * recordStatement() or recordExpressions(), and, at the first time
@@ -96,6 +93,10 @@ public class XMLEncoder extends Encoder 
 
 	private ReferenceMap records = new ReferenceMap();
 
+    private ReferenceMap objPrePendingCache = new ReferenceMap();
+
+    private ReferenceMap clazzCounterMap = new ReferenceMap();
+
 	private boolean writingObject = false;
 
 	/**
@@ -132,6 +133,15 @@ public class XMLEncoder extends Encoder 
 		return buf;
 	}
 
+    private String idSerialNoOfObject(Object obj) {
+        Class<?> clazz = obj.getClass();
+        Integer serialNo = (Integer) clazzCounterMap.get(clazz);
+        serialNo = serialNo == null ? 0 : serialNo;
+        String id = nameForClass(obj.getClass()) + serialNo;
+        clazzCounterMap.put(clazz, ++serialNo);
+        return id;
+    }
+
 	/**
 	 * Writes out all objects since last flush to the output stream.
 	 * <p>
@@ -170,7 +180,9 @@ public class XMLEncoder extends Encoder 
 
 			// clear statement records
 			records.clear();
-			flushPendingStat.clear();
+            flushPendingStat.clear();
+            objPrePendingCache.clear();
+            clazzCounterMap.clear();
 
 			// remove all old->new mappings
 			super.clear();
@@ -198,9 +210,9 @@ public class XMLEncoder extends Encoder 
 			out.print("<string>");
 			flushString((String) obj);
 			out.println("</string>");
-		} else if (obj instanceof Class) {
+		} else if (obj instanceof Class<?>) {
 			out.print("<class>");
-			out.print(((Class) obj).getName());
+			out.print(((Class<?>) obj).getName());
 			out.println("</class>");
 		} else if (obj instanceof Boolean) {
 			out.print("<boolean>");
@@ -242,27 +254,33 @@ public class XMLEncoder extends Encoder 
 
 	@SuppressWarnings("nls")
     private void flushExpression(Object obj, Record rec, int indent,
-			boolean asStatement) {
-		// not first time, use idref
-		if (rec.id != null) {
-			flushIndent(indent);
-			out.print("<object idref=\"");
-			out.print(rec.id);
-			out.println("\" />");
-			return;
-		}
+            boolean asStatement) {
+        // flush
+        Statement stat = asStatement ? new Statement(rec.exp.getTarget(),
+                rec.exp.getMethodName(), rec.exp.getArguments()) : rec.exp;
+        if (isStaticConstantsSupported
+                && "getField".equals(stat.getMethodName())) {
+            flushStatField(stat, indent);
+            return;
+        }
 
-		// generate id, if necessary
-		if (rec.refCount > 1) {
-			rec.id = nameForClass(obj.getClass()) + idSerialNo;
-			idSerialNo++;
-		}
+        // not first time, use idref
+        if (rec.id != null) {
+            flushIndent(indent);
+            out.print("<object idref=\"");
+            out.print(rec.id);
+            out.println("\" />");
+            return;
+        }
 
-		// flush
-		Statement stat = asStatement ? new Statement(rec.exp.getTarget(),
-				rec.exp.getMethodName(), rec.exp.getArguments()) : rec.exp;
-		flushStatement(stat, rec.id, rec.stats, indent);
-	}
+        // generate id, if necessary
+        if (rec.refCount > 1 && rec.id == null) {
+            rec.id = idSerialNoOfObject(obj);
+        }
+
+        // flush
+        flushStatement(stat, rec.id, rec.stats, indent);
+    }
 
 	private void flushIndent(int indent) {
 		for (int i = 0; i < indent; i++) {
@@ -294,10 +312,9 @@ public class XMLEncoder extends Encoder 
 
 	@SuppressWarnings("nls")
     private void flushOwner(Object obj, Record rec, int indent) {
-		if (rec.refCount > 1) {
-			rec.id = nameForClass(obj.getClass()) + idSerialNo;
-			idSerialNo++;
-		}
+        if (rec.refCount > 1 && rec.id == null) {
+            rec.id = idSerialNoOfObject(obj);
+        }
 
 		flushIndent(indent);
 		String tagName = "void";
@@ -351,7 +368,7 @@ public class XMLEncoder extends Encoder 
 
 		// class & length
 		out.print(" class=\"");
-		out.print(((Class) stat.getArguments()[0]).getName());
+		out.print(((Class<?>) stat.getArguments()[0]).getName());
 		out.print("\" length=\"");
 		out.print(stat.getArguments()[1]);
 		out.print("\"");
@@ -388,9 +405,9 @@ public class XMLEncoder extends Encoder 
 		}
 
 		// special class attribute
-		if (stat.getTarget() instanceof Class) {
+		if (stat.getTarget() instanceof Class<?>) {
 			out.print(" class=\"");
-			out.print(((Class) stat.getTarget()).getName());
+			out.print(((Class<?>) stat.getTarget()).getName());
 			out.print("\"");
 		}
 
@@ -449,7 +466,7 @@ public class XMLEncoder extends Encoder 
 
 		if (isStaticConstantsSupported
 				&& "getField".equals(stat.getMethodName())) {
-			flushStatField(stat, id, indent);
+            flushStatField(stat, indent);
 			return;
 		}
 
@@ -457,48 +474,46 @@ public class XMLEncoder extends Encoder 
 		flushStatCommon(stat, id, subStats, indent);
 	}
 
-	@SuppressWarnings("nls")
-    private void flushStatField(Statement stat, String id, 
-			int indent) {
-		// open tag, begin
-		flushIndent(indent);
-		String tagName = "object";
-		out.print("<");
-		out.print(tagName);
-
-		// id attribute
-		if (id != null) {
-			out.print(" id=\"");
-			out.print(id);
-			out.print("\"");
-		}
-
-		// special class attribute
-		if (stat.getTarget() instanceof Class) {
-			out.print(" class=\"");
-			out.print(((Class) stat.getTarget()).getName());
-			out.print("\"");
-		}
+    @SuppressWarnings("nls")
+    private void flushStatField(Statement stat, int indent) {
+        // open tag, begin
+        flushIndent(indent);
+        out.print("<object");
+
+        // special class attribute
+        Object target = stat.getTarget();
+        if (target instanceof Class<?>) {
+            out.print(" class=\"");
+            out.print(((Class<?>) target).getName());
+            out.print("\"");
+        }
 
-		Object target = stat.getTarget();
-		if(target == SystemColor.class || target == TextAttribute.class) {
-			out.print(" field=\"");
-			out.print(stat.getArguments()[0]);
-			out.print("\"");
-			out.println("/>");
+        Field field = null;
+        if (target instanceof Class<?> && stat.getArguments().length == 1
+                && stat.getArguments()[0] instanceof String) {
+            try {
+                field = ((Class<?>) target).getField((String) stat
+                        .getArguments()[0]);
+            } catch (Exception e) {
+                // ignored
+            }
+        }
 
-		}
-		else {
-			out.print(" method=\"");
-			out.print(stat.getMethodName());
-			out.print("\"");
-			out.println(">");
-			Object fieldName = stat.getArguments()[0];
-			flushObject(fieldName, indent + INDENT_UNIT);
-			flushIndent(indent);
-			out.println("</object>");
-		}
-	}
+        if (field != null && Modifier.isStatic(field.getModifiers())) {
+            out.print(" field=\"");
+            out.print(stat.getArguments()[0]);
+            out.print("\"");
+            out.println("/>");
+        } else {
+            out.print(" method=\"");
+            out.print(stat.getMethodName());
+            out.print("\"");
+            out.println(">");
+            flushObject(stat.getArguments()[0], indent + INDENT_UNIT);
+            flushIndent(indent);
+            out.println("</object>");
+        }
+    }
 
 	@SuppressWarnings("nls")
     private void flushStatGetterSetter(Statement stat, String id,
@@ -517,9 +532,9 @@ public class XMLEncoder extends Encoder 
 		}
 
 		// special class attribute
-		if (stat.getTarget() instanceof Class) {
+		if (stat.getTarget() instanceof Class<?>) {
 			out.print(" class=\"");
-			out.print(((Class) stat.getTarget()).getName());
+			out.print(((Class<?>) stat.getTarget()).getName());
 			out.print("\"");
 		}
 
@@ -567,9 +582,9 @@ public class XMLEncoder extends Encoder 
 		}
 
 		// special class attribute
-		if (stat.getTarget() instanceof Class) {
+		if (stat.getTarget() instanceof Class<?>) {
 			out.print(" class=\"");
-			out.print(((Class) stat.getTarget()).getName());
+			out.print(((Class<?>) stat.getTarget()).getName());
 			out.print("\"");
 		}
 
@@ -653,7 +668,7 @@ public class XMLEncoder extends Encoder 
 	private boolean isBasicType(Object value) {
 		return value == null || value instanceof Boolean
 				|| value instanceof Byte || value instanceof Character
-				|| value instanceof Class || value instanceof Double
+				|| value instanceof Class<?> || value instanceof Double
 				|| value instanceof Float || value instanceof Integer
 				|| value instanceof Long || value instanceof Short
 				|| value instanceof String || value instanceof Proxy;
@@ -689,44 +704,44 @@ public class XMLEncoder extends Encoder 
         return name.substring(i + 1);
 	}
 
-	/*
-	 * The preprocess removes unused statements and counts references of every
-	 * object
-	 */
-	private void preprocess(Object obj, Record rec) {
-		if (isBasicType(obj) && writingObject) {
-			return;
-		}
+    /*
+     * The preprocess removes unused statements and counts references of every
+     * object
+     */
+    private void preprocess(Object obj, Record rec) {
+        if (writingObject && isBasicType(obj)) {
+            return;
+        }
 
-		// count reference
-		rec.refCount++;
+        if (obj instanceof Class<?>) {
+            return;
+        }
 
-		// do things only one time for each record
-		if (rec.refCount > 1) {
-			return;
-		}
+        // count reference
+        rec.refCount++;
 
-		// deal with 'field' property
-		try {
-			if (isStaticConstantsSupported
-					&& "getField".equals(((Record) records.get(rec.exp //$NON-NLS-1$
-							.getTarget())).exp.getMethodName())) {
-				records.remove(obj);
-			}
-		} catch (NullPointerException e) {
-			// do nothing, safely
-		}
+        // do things only one time for each record
+        if (rec.refCount > 1) {
+            return;
+        }
 
-		// do it recursively
-		if (null != rec.exp) {
-			Object args[] = rec.exp.getArguments();
-			for (int i = 0; i < args.length; i++) {
-				Record argRec = (Record) records.get(args[i]);
-				if (argRec != null) {
-					preprocess(args[i], argRec);
-				}
-			}
-		}
+        // do it recursively
+        if (null != rec.exp) {
+            // deal with 'field' property
+            Record targetRec = (Record) records.get(rec.exp.getTarget());
+            if (targetRec != null && targetRec.exp != null
+                    && "getField".equals(targetRec.exp.getMethodName())) {
+                records.remove(obj);
+            }
+
+            Object args[] = rec.exp.getArguments();
+            for (int i = 0; i < args.length; i++) {
+                Record argRec = (Record) records.get(args[i]);
+                if (argRec != null) {
+                    preprocess(args[i], argRec);
+                }
+            }
+        }
 
 		for (Iterator<?> iter = rec.stats.iterator(); iter.hasNext();) {
 			Statement subStat = (Statement) iter.next();
@@ -909,36 +924,52 @@ public class XMLEncoder extends Encoder 
 	 * Records the object so that it can be written out later, then calls super
 	 * implementation.
 	 */
-	@Override
+    @SuppressWarnings("unchecked")
+    @Override
     public void writeObject(Object o) {
-		synchronized (this) {
-			boolean oldWritingObject = writingObject;
-			writingObject = true;
-			try {
-				super.writeObject(o);
-			} finally {
-				writingObject = oldWritingObject;
-			}
+        synchronized (this) {
+            ArrayList<Object> prePending = (ArrayList<Object>) objPrePendingCache
+                    .get(o);
+            if (prePending == null) {
+                boolean oldWritingObject = writingObject;
+                writingObject = true;
+                try {
+                    super.writeObject(o);
+                } finally {
+                    writingObject = oldWritingObject;
+                }
+            } else {
+                flushPrePending.clear();
+                flushPrePending.addAll(prePending);
+            }
 
-			// root object?
-			if (!writingObject) {
-				// add to pending
-				flushPending.addAll(flushPrePending);
-				flushPendingStat.addAll(flushPrePending);
-				flushPrePending.clear();
-				if (flushPending.contains(o)) {
-					flushPrePending.remove(o);
-					flushPendingStat.remove(o);
-				} else {
-					flushPending.add(o);
-				}
-				if (needOwner) {
-					this.flushPending.remove(owner);
-					this.flushPending.add(0, owner);
-				}
-			}
-		}
-	}
+            // root object
+            if (!writingObject) {
+                boolean isNotCached = prePending == null;
+                // is not cached, add to cache
+                if (isNotCached && o != null) {
+                    prePending = new ArrayList<Object>();
+                    prePending.addAll(flushPrePending);
+                    objPrePendingCache.put(o, prePending);
+                }
+
+                // add to pending
+                flushPending.addAll(flushPrePending);
+                flushPendingStat.addAll(flushPrePending);
+                flushPrePending.clear();
+
+                if (isNotCached && flushPending.contains(o)) {
+                    flushPendingStat.remove(o);
+                } else {
+                    flushPending.add(o);
+                }
+                if (needOwner) {
+                    this.flushPending.remove(owner);
+                    this.flushPending.add(0, owner);
+                }
+            }
+        }
+    }
 
 	/**
 	 * Records the statement so that it can be written out later, then calls

Modified: harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java-internal/java/beans/ArrayPersistenceDelegateTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java-internal/java/beans/ArrayPersistenceDelegateTest.java?rev=932673&r1=932672&r2=932673&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java-internal/java/beans/ArrayPersistenceDelegateTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java-internal/java/beans/ArrayPersistenceDelegateTest.java Sat Apr 10 06:54:13 2010
@@ -17,9 +17,7 @@
 
 package java.beans;
 
-import java.beans.ArrayPersistenceDelegate;
-import java.beans.Encoder;
-import java.beans.Expression;
+import java.io.ByteArrayOutputStream;
 import java.lang.reflect.Array;
 
 import junit.framework.TestCase;
@@ -166,4 +164,39 @@ public class ArrayPersistenceDelegateTes
         }
     }
 
+    public static class ParentClass {
+
+        String multiArray[][][] = { { { "1", "2" } }, { { "3", "4", "5" } },
+                { { "1", "2" }, { "3", "4", "5" } } };
+
+        public ParentClass() {
+        }
+
+        public String[][][] getMultiArray() {
+            return multiArray;
+        }
+
+        public void setMultiArray(String[][][] array) {
+            multiArray = array;
+        }
+
+    }
+
+    public static class ChildClass extends ParentClass {
+
+        public ChildClass() {
+
+        }
+
+    }
+
+    public void testInitialize_MultiArray() throws Exception {
+        ChildClass child = new ChildClass();
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        XMLEncoder xmlEncoder = new XMLEncoder(bos);
+        xmlEncoder.writeObject(child);
+        xmlEncoder.close();
+        assertFalse(bos.toString("UTF-8").contains("multiArray"));
+    }
+
 }

Modified: harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/ExpressionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/ExpressionTest.java?rev=932673&r1=932672&r2=932673&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/ExpressionTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/ExpressionTest.java Sat Apr 10 06:54:13 2010
@@ -19,6 +19,7 @@ package org.apache.harmony.beans.tests.j
 
 import java.beans.DefaultPersistenceDelegate;
 import java.beans.Expression;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Vector;
 
@@ -1201,4 +1202,176 @@ public class ExpressionTest extends Test
             return "haha";
         }
     }
+
+    public void test_Expression_Constructor_OneArgument_senario1()
+            throws Exception {
+        Object[] arguments = new Object[] { "test" };
+        Expression expression = new Expression(SampleObject.class, "new",
+                arguments);
+        assertTrue(expression.getValue() instanceof SampleObject);
+        SampleObject.assertCalled("string", arguments);
+    }
+
+    public void test_Expression_Constructor_OneArgument_senario2()
+            throws Exception {
+        Object[] arguments = new Object[] { new Integer(1) };
+        Expression expression = new Expression(SampleObject.class, "new",
+                arguments);
+        assertTrue(expression.getValue() instanceof SampleObject);
+        SampleObject.assertCalled("integer", arguments);
+    }
+
+    public void test_Expression_Constructor_OneArgument_senario3()
+            throws Exception {
+        Object[] arguments = new Object[] { new Object() };
+        Expression expression = new Expression(SampleObject.class, "new",
+                arguments);
+        assertTrue(expression.getValue() instanceof SampleObject);
+        SampleObject.assertCalled("object", arguments);
+    }
+
+    public void test_Expression_Constructor_OneArgument_senario4()
+            throws Exception {
+        Object[] arguments = new Object[] { null };
+        Expression expression = new Expression(SampleObject.class, "new",
+                arguments);
+        assertTrue(expression.getValue() instanceof SampleObject);
+        SampleObject.assertCalled("object", arguments);
+    }
+
+    public void test_Expression_Constructor_twoArguments_senario1()
+            throws Exception {
+        Object[] arguments = new Object[] { null, null };
+        Expression expression = new Expression(SampleObject.class, "new",
+                arguments);
+        assertTrue(expression.getValue() instanceof SampleObject);
+        SampleObject.assertCalled("object_object", arguments);
+    }
+
+    public void test_Expression_Constructor_twoArguments_senario2()
+            throws Exception {
+        Object[] arguments = new Object[] { null, "test" };
+        Expression expression = new Expression(SampleObject.class, "new",
+                arguments);
+        assertTrue(expression.getValue() instanceof SampleObject);
+        SampleObject.assertCalled("object_string", arguments);
+    }
+
+    public void test_Expression_Constructor_twoArguments_senario3()
+            throws Exception {
+        Object[] arguments = new Object[] { new Object(), "test" };
+        Expression expression = new Expression(SampleObject.class, "new",
+                arguments);
+        assertTrue(expression.getValue() instanceof SampleObject);
+        SampleObject.assertCalled("object_string", arguments);
+    }
+
+    public void test_Expression_Constructor_twoArguments_senario4()
+            throws Exception {
+        Object[] arguments = new Object[] { "test1", "test2" };
+        Expression expression = new Expression(SampleObject.class, "new",
+                arguments);
+        assertTrue(expression.getValue() instanceof SampleObject);
+        SampleObject.assertCalled("string_string", arguments);
+    }
+
+    public void test_Expression_Constructor_twoArguments_senario5()
+            throws Exception {
+        Object[] arguments = new Object[] { "test", new Integer(1) };
+        Expression expression = new Expression(SampleObject.class, "new",
+                arguments);
+        assertTrue(expression.getValue() instanceof SampleObject);
+        SampleObject.assertCalled("string_integer", arguments);
+    }
+
+    public void test_Expression_Constructor_twoArguments_senario6()
+            throws Exception {
+        Object[] arguments = new Object[] { "test", (String) null };
+        Expression expression = new Expression(SampleObject.class, "new",
+                arguments);
+        assertTrue(expression.getValue() instanceof SampleObject);
+        SampleObject.assertCalled("object_object", arguments);
+    }
+
+    public void test_Expression_Constructor_twoArguments_senario7()
+            throws Exception {
+        Object[] arguments = new Object[] { new Integer(1), "test" };
+        Expression expression = new Expression(SampleObject.class, "new",
+                arguments);
+        assertTrue(expression.getValue() instanceof SampleObject);
+        SampleObject.assertCalled("object_string", arguments);
+    }
+
+    public void test_Expression_Constructor_twoArguments_senario8()
+            throws Exception {
+        Object[] arguments = new Object[] { new Integer(1), new Integer(2) };
+        Expression expression = new Expression(SampleObject.class, "new",
+                arguments);
+        assertTrue(expression.getValue() instanceof SampleObject);
+        SampleObject.assertCalled("object_object", arguments);
+    }
+
+    public static class SampleObject {
+
+        public static String calledMethod = null;
+
+        public static ArrayList<Object> receivedArguments = new ArrayList<Object>();
+
+        public SampleObject(String o) {
+            reset();
+            calledMethod = "string";
+            receivedArguments.add(o);
+        }
+
+        public SampleObject(Object o) {
+            reset();
+            calledMethod = "object";
+            receivedArguments.add(o);
+        }
+
+        public SampleObject(Integer o) {
+            reset();
+            calledMethod = "integer";
+            receivedArguments.add(o);
+        }
+
+        public SampleObject(Object arg1, Object arg2) {
+            reset();
+            calledMethod = "object_object";
+            receivedArguments.add(arg1);
+            receivedArguments.add(arg2);
+        }
+
+        public SampleObject(Object arg1, String arg2) {
+            reset();
+            calledMethod = "object_string";
+            receivedArguments.add(arg1);
+            receivedArguments.add(arg2);
+        }
+
+        public SampleObject(String arg1, String arg2) {
+            reset();
+            calledMethod = "string_string";
+            receivedArguments.add(arg1);
+            receivedArguments.add(arg2);
+        }
+
+        public SampleObject(String arg1, Integer arg2) {
+            reset();
+            calledMethod = "string_integer";
+            receivedArguments.add(arg1);
+            receivedArguments.add(arg2);
+        }
+
+        public static void assertCalled(String methodName, Object[] arguments) {
+            assertEquals(methodName, calledMethod);
+            assertTrue(Arrays.equals(arguments, receivedArguments.toArray()));
+            reset();
+        }
+
+        public static void reset() {
+            receivedArguments.clear();
+            calledMethod = null;
+        }
+    }
 }

Modified: harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java?rev=932673&r1=932672&r2=932673&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java Sat Apr 10 06:54:13 2010
@@ -17,6 +17,8 @@
 
 package org.apache.harmony.beans.tests.java.beans;
 
+import java.awt.SystemColor;
+import java.awt.font.TextAttribute;
 import java.beans.DefaultPersistenceDelegate;
 import java.beans.Encoder;
 import java.beans.ExceptionListener;
@@ -33,6 +35,7 @@ import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.io.StringReader;
+import java.util.Collection;
 import java.util.Date;
 import java.util.Map;
 import java.util.TreeMap;
@@ -46,8 +49,6 @@ import org.apache.harmony.beans.tests.su
 import org.apache.harmony.beans.tests.support.mock.MockBean4Codec;
 import org.apache.harmony.beans.tests.support.mock.MockBean4Owner_Owner;
 import org.apache.harmony.beans.tests.support.mock.MockBean4Owner_Target;
-import org.apache.harmony.beans.tests.support.mock.MockBean4StaticField;
-import org.apache.harmony.beans.tests.support.mock.MockBean4StaticField_PD;
 import org.apache.harmony.beans.tests.support.mock.MockTreeMapClass;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
@@ -410,7 +411,18 @@ public class XMLEncoderTest extends Test
 
     private void assertCodedXML(Object obj, String xmlFile,
             ByteArrayOutputStream temp, XMLEncoder enc) throws Exception {
+        if (enc == null || temp == null) {
+            temp = new ByteArrayOutputStream();
+            enc = new XMLEncoder(temp);
+        }
+        enc.writeObject(obj);
+        enc.close();
+        
+        assertXMLContent(obj, temp.toByteArray(), xmlFile);
+            
+    }
 
+    private void assertXMLContent(Object obj, byte[] bytes, String xmlFile) throws Exception {
         InputStream refIn;
         InputStreamReader xml;
 
@@ -420,14 +432,6 @@ public class XMLEncoderTest extends Test
         TestEventHandler refHandler = new TestEventHandler();
         String saxParserClassName = System.getProperty("org.xml.sax.driver");
         String version = System.getProperty("java.version");
-
-        if (enc == null || temp == null) {
-            temp = new ByteArrayOutputStream();
-            enc = new XMLEncoder(temp);
-        }
-        enc.writeObject(obj);
-        enc.close();
-        byte bytes[] = temp.toByteArray();
         xml = new InputStreamReader(new ByteArrayInputStream(bytes), "UTF-8");
         refIn = XMLEncoderTest.class.getResourceAsStream(xmlFile);
         if (refIn == null) {
@@ -834,6 +838,188 @@ public class XMLEncoderTest extends Test
 
             return false;
         }
+    }
+
+    public void testWriteObject_StaticFields() throws Exception {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        XMLEncoder xmlEncoder = new XMLEncoder(bos);
+        xmlEncoder.setPersistenceDelegate(MockObject.class,
+                new MockObjectPersistenceDelegate());
+        xmlEncoder.writeObject(MockObject.inst);
+        xmlEncoder.writeObject(MockObject.inst);
+        xmlEncoder.writeObject(SystemColor.activeCaption);
+        xmlEncoder.writeObject(SystemColor.activeCaption);
+        xmlEncoder.writeObject(TextAttribute.FAMILY);
+        xmlEncoder.writeObject(TextAttribute.FAMILY);
+        xmlEncoder.close();
+        assertXMLContent(null, bos.toByteArray(), "/xml/StaticField.xml");
+    }
+
+    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;
+        }
+    }
+
+    public void testWriteObject_ChangedObject() throws Exception {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        XMLEncoder xmlEncoder = new XMLEncoder(bos);
+        Sample sample = new Sample("oldName");
+        xmlEncoder.writeObject(sample);
+        sample.setName("newName");
+        xmlEncoder.writeObject(sample);
+        xmlEncoder.close();
+        assertXMLContent(null, bos.toByteArray(), "/xml/ChangedObject.xml");
+    }
+
+    public static class Sample {
+
+        String name;
+
+        public Sample() {
+            name = null;
+        }
+
+        public Sample(String n) {
+            name = n;
+        }
+
+        public String getName() {
+            return name;
+        }
 
+        public void setName(String name) {
+            this.name = name;
+        }
+    }
+
+    public void testWriteObject_ClassID() throws Exception {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        XMLEncoder xmlEncoder = new XMLEncoder(bos);
+        ChildClass childClazz = new ChildClass();
+        childClazz.setClazz(ChildClass.class);
+        xmlEncoder.writeObject(childClazz);
+        xmlEncoder.close();
+        assertXMLContent(null, bos.toByteArray(), "/xml/ClassID.xml");
+    }
+
+    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 testWriteObject_ObjectID() throws Exception {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        XMLEncoder xmlEncoder = new XMLEncoder(bos);
+        ExampleA exampleAI = new ExampleA("exampleAI");
+        xmlEncoder.writeObject(exampleAI);
+        xmlEncoder.writeObject(exampleAI);
+        ExampleA exampleAII = new ExampleA("exampleAI");
+        xmlEncoder.writeObject(exampleAII);
+        xmlEncoder.writeObject(exampleAII);
+
+        ExampleB exampleBI = new ExampleB("exampleBI");
+        xmlEncoder.writeObject(exampleBI);
+        xmlEncoder.writeObject(exampleBI);
+        ExampleB exampleBII = new ExampleB("exampleBII");
+        xmlEncoder.writeObject(exampleBII);
+        xmlEncoder.writeObject(exampleBII);
+
+        ExampleC exampleCI = new ExampleC("exampleCI");
+        xmlEncoder.writeObject(exampleCI);
+        xmlEncoder.writeObject(exampleCI);
+        ExampleC exampleCII = new ExampleC("exampleCII");
+        xmlEncoder.writeObject(exampleCII);
+        xmlEncoder.writeObject(exampleCII);
+
+        xmlEncoder.close();
+
+        assertXMLContent(null, bos.toByteArray(), "/xml/ObjectID.xml");
+    }
+
+    public static class ExampleA {
+
+        private String name;
+
+        public ExampleA() {
+
+        }
+
+        public ExampleA(String name) {
+            this.name = name;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+    }
+
+    public static class ExampleB {
+
+        private String name;
+
+        public ExampleB() {
+
+        }
+
+        public ExampleB(String name) {
+            this.name = name;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+    }
+
+    public static class ExampleC {
+
+        private String name;
+
+        public ExampleC() {
+
+        }
+
+        public ExampleC(String name) {
+            this.name = name;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
     }
-}
+}
\ No newline at end of file

Modified: harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/resources/xml/MockBean4Codec_ManyChanges.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/resources/xml/MockBean4Codec_ManyChanges.xml?rev=932673&r1=932672&r2=932673&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/resources/xml/MockBean4Codec_ManyChanges.xml (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/beans/src/test/resources/xml/MockBean4Codec_ManyChanges.xml Sat Apr 10 06:54:13 2010
@@ -48,7 +48,7 @@
    <float>12.34</float> 
   </void> 
   <void property="friend"> 
-   <object class="${classname}" id="MockBean4Codec1">
+   <object class="${classname}">
     <void property="clazz"> 
     <class>${classname}</class>
     </void> 

Modified: harmony/enhanced/java/branches/java6/classlib/modules/lang-management/src/main/java/java/lang/management/ThreadInfo.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/lang-management/src/main/java/java/lang/management/ThreadInfo.java?rev=932673&r1=932672&r2=932673&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/lang-management/src/main/java/java/lang/management/ThreadInfo.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/lang-management/src/main/java/java/lang/management/ThreadInfo.java Sat Apr 10 06:54:13 2010
@@ -101,6 +101,10 @@ public class ThreadInfo {
             Object[] attributeVals = cd.getAll(attributeNames);
             long threadIdVal = ((Long) attributeVals[0]).longValue();
             String threadNameVal = (String) attributeVals[1];
+            if (threadNameVal == null) {
+                throw new IllegalArgumentException(
+                        "Invalid composite data: Attribute threadName has null value"); //$NON-NLS-1$
+            }
             String threadStateStringVal = (String) attributeVals[2];
 
             // Verify that threadStateStringVal contains a string that can be
@@ -126,8 +130,10 @@ public class ThreadInfo {
             String lockOwnerNameVal = attributeVals[11] != null ? (String) attributeVals[11]
                     : null;
             CompositeData[] stackTraceDataVal = (CompositeData[]) attributeVals[12];
+            if (stackTraceDataVal == null) {
+                throw new IllegalArgumentException("StackTraceElement[] is missing"); //$NON-NLS-1$
+            }
             StackTraceElement[] stackTraceVals = getStackTracesFromCompositeData(stackTraceDataVal);
-
             result = new ThreadInfo(threadIdVal, threadNameVal, threadStateVal,
                     suspendedVal, inNativeVal, blockedCountVal, blockedTimeVal,
                     waitedCountVal, waitedTimeVal, lockNameVal, lockOwnerIdVal,

Modified: harmony/enhanced/java/branches/java6/classlib/modules/lang-management/src/test/impl/java/org/apache/harmony/lang/management/ThreadInfoTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/lang-management/src/test/impl/java/org/apache/harmony/lang/management/ThreadInfoTest.java?rev=932673&r1=932672&r2=932673&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/lang-management/src/test/impl/java/org/apache/harmony/lang/management/ThreadInfoTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/lang-management/src/test/impl/java/org/apache/harmony/lang/management/ThreadInfoTest.java Sat Apr 10 06:54:13 2010
@@ -88,6 +88,8 @@ public class ThreadInfoTest extends Test
 
     private static final String GOOD_LOCK_NAME = "foo.Bar@1234567";
 
+    private static final String GOOD_THREADINFO_CLASSNAME = ThreadInfo.class.getName();
+
     private CompositeData tiCD;
 
     private ThreadInfo ti;
@@ -364,6 +366,393 @@ public class ThreadInfoTest extends Test
         }
     }
 
+    private static final Object stackTraceElementData = createGoodStackTraceCompositeData();
+
+    private static final CompositeType stackTraceElementType = createGoodStackTraceElementCompositeType();
+
+    private String[] initialNames = { "threadId", "threadName", "threadState",
+            "suspended", "inNative", "blockedCount", "blockedTime",
+            "waitedCount", "waitedTime", "lockName", "lockOwnerId",
+            "lockOwnerName", "stackTrace", "additionalName" };
+
+    private Object[] initialValues = { 1L, "threadName",
+            GOOD_THREAD_STATE.toString(), true, false, 1L, 500L, 1L, 1L,
+            "lock", 2L, "lockOwner", stackTraceElementData, "additionalValue" };
+
+    public void test_from_scenario1() throws Exception {
+        ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
+        OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
+                SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
+                SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+                SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
+                SimpleType.STRING, stackTraceArray, SimpleType.STRING };
+        CompositeType compositeType = getCompositeType(initialNames, types);
+        CompositeData data = new CompositeDataSupport(compositeType,
+                initialNames, initialValues);
+        ThreadInfo threadInfo = ThreadInfo.from(data);
+        assertEquals(initialValues[0], threadInfo.getThreadId());
+        assertEquals(initialValues[1], threadInfo.getThreadName());
+        assertEquals(GOOD_THREAD_STATE, threadInfo.getThreadState());
+        assertEquals(initialValues[3], threadInfo.isSuspended());
+        assertEquals(initialValues[4], threadInfo.isInNative());
+        assertEquals(initialValues[5], threadInfo.getBlockedCount());
+        assertEquals(initialValues[6], threadInfo.getBlockedTime());
+        assertEquals(initialValues[7], threadInfo.getWaitedCount());
+        assertEquals(initialValues[8], threadInfo.getWaitedTime());
+        assertEquals(initialValues[9], threadInfo.getLockName());
+        assertEquals(initialValues[10], threadInfo.getLockOwnerId());
+        assertEquals(initialValues[11], threadInfo.getLockOwnerName());
+        StackTraceElement[] stackElements = threadInfo.getStackTrace();
+        assertEquals(GOOD_STACK_SIZE, stackElements.length);
+        for (StackTraceElement element : stackElements) {
+            assertEquals(GOOD_STACK_CLASSNAME, element.getClassName());
+            assertEquals(GOOD_STACK_NATIVEMETHOD, element.isNativeMethod());
+            assertEquals(GOOD_STACK_FILENAME, element.getFileName());
+            assertEquals(GOOD_STACK_LINENUMBER, element.getLineNumber());
+            assertEquals(GOOD_STACK_METHODNAME, element.getMethodName());
+        }
+    }
+
+    public void test_from_scenario2() throws Exception {
+        initialValues[0] = "1";
+        ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
+        OpenType[] types = { SimpleType.STRING, SimpleType.STRING,
+                SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
+                SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+                SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
+                SimpleType.STRING, stackTraceArray, SimpleType.STRING };
+        CompositeType compositeType = getCompositeType(initialNames, types);
+        CompositeData data = new CompositeDataSupport(compositeType,
+                initialNames, initialValues);
+        try {
+            ThreadInfo.from(data);
+            fail("should throw IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // Expected
+        }
+    }
+
+    public void test_from_scenario3() throws Exception {
+        int length = 10;
+        String[] names = new String[length];
+        for (int index = 0; index < length; index++) {
+            names[index] = initialNames[index];
+        }
+        Object[] values = new Object[length];
+        for (int index = 0; index < length; index++) {
+            values[index] = initialValues[index];
+        }
+        OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
+                SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
+                SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+                SimpleType.LONG, SimpleType.STRING };
+        CompositeType compositeType = getCompositeType(names, types);
+        CompositeData data = new CompositeDataSupport(compositeType, names,
+                values);
+        try {
+            ThreadInfo.from(data);
+            fail("should throw IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // Expected
+        }
+
+        values[0] = null;
+        compositeType = getCompositeType(names, types);
+        data = new CompositeDataSupport(compositeType, names, values);
+        try {
+            ThreadInfo.from(data);
+            fail("should throw IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // Expected
+        }
+    }
+
+    public void test_from_scenario4() throws Exception {
+        initialValues[0] = null;
+        ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
+        OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
+                SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
+                SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+                SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
+                SimpleType.STRING, stackTraceArray, SimpleType.STRING };
+        CompositeType compositeType = getCompositeType(initialNames, types);
+        CompositeData data = new CompositeDataSupport(compositeType,
+                initialNames, initialValues);
+        try {
+            ThreadInfo.from(data);
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    public void test_from_scenario5() throws Exception {
+        initialValues[1] = null;
+        ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
+        OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
+                SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
+                SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+                SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
+                SimpleType.STRING, stackTraceArray, SimpleType.STRING };
+        CompositeType compositeType = getCompositeType(initialNames, types);
+        CompositeData data = new CompositeDataSupport(compositeType,
+                initialNames, initialValues);
+        try {
+            ThreadInfo.from(data);
+            fail("should throw IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // Expected
+        }
+    }
+
+    public void test_from_scenario6() throws Exception {
+        initialValues[2] = null;
+        ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
+        OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
+                SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
+                SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+                SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
+                SimpleType.STRING, stackTraceArray, SimpleType.STRING };
+        CompositeType compositeType = getCompositeType(initialNames, types);
+        CompositeData data = new CompositeDataSupport(compositeType,
+                initialNames, initialValues);
+        try {
+            ThreadInfo.from(data);
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    public void test_from_scenario7() throws Exception {
+        initialValues[3] = null;
+        ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
+        OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
+                SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
+                SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+                SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
+                SimpleType.STRING, stackTraceArray, SimpleType.STRING };
+        CompositeType compositeType = getCompositeType(initialNames, types);
+        CompositeData data = new CompositeDataSupport(compositeType,
+                initialNames, initialValues);
+        try {
+            ThreadInfo.from(data);
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    public void test_from_scenario8() throws Exception {
+        initialValues[4] = null;
+        ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
+        OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
+                SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
+                SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+                SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
+                SimpleType.STRING, stackTraceArray, SimpleType.STRING };
+        CompositeType compositeType = getCompositeType(initialNames, types);
+        CompositeData data = new CompositeDataSupport(compositeType,
+                initialNames, initialValues);
+        try {
+            ThreadInfo.from(data);
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    public void test_from_scenario9() throws Exception {
+        initialValues[5] = null;
+        ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
+        OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
+                SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
+                SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+                SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
+                SimpleType.STRING, stackTraceArray, SimpleType.STRING };
+        CompositeType compositeType = getCompositeType(initialNames, types);
+        CompositeData data = new CompositeDataSupport(compositeType,
+                initialNames, initialValues);
+        try {
+            ThreadInfo.from(data);
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    public void test_from_scenario10() throws Exception {
+        initialValues[6] = null;
+        ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
+        OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
+                SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
+                SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+                SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
+                SimpleType.STRING, stackTraceArray, SimpleType.STRING };
+        CompositeType compositeType = getCompositeType(initialNames, types);
+        CompositeData data = new CompositeDataSupport(compositeType,
+                initialNames, initialValues);
+        try {
+            ThreadInfo.from(data);
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    public void test_from_scenario11() throws Exception {
+        initialValues[7] = null;
+        ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
+        OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
+                SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
+                SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+                SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
+                SimpleType.STRING, stackTraceArray, SimpleType.STRING };
+        CompositeType compositeType = getCompositeType(initialNames, types);
+        CompositeData data = new CompositeDataSupport(compositeType,
+                initialNames, initialValues);
+        try {
+            ThreadInfo.from(data);
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    public void test_from_scenario12() throws Exception {
+        initialValues[8] = null;
+        ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
+        OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
+                SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
+                SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+                SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
+                SimpleType.STRING, stackTraceArray, SimpleType.STRING };
+        CompositeType compositeType = getCompositeType(initialNames, types);
+        CompositeData data = new CompositeDataSupport(compositeType,
+                initialNames, initialValues);
+        try {
+            ThreadInfo.from(data);
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    public void test_from_scenario13() throws Exception {
+        initialValues[9] = null;
+        ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
+        OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
+                SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
+                SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+                SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
+                SimpleType.STRING, stackTraceArray, SimpleType.STRING };
+        CompositeType compositeType = getCompositeType(initialNames, types);
+        CompositeData data = new CompositeDataSupport(compositeType,
+                initialNames, initialValues);
+        ThreadInfo threadInfo = ThreadInfo.from(data);
+        assertEquals(initialValues[0], threadInfo.getThreadId());
+        assertEquals(initialValues[1], threadInfo.getThreadName());
+        assertEquals(GOOD_THREAD_STATE, threadInfo.getThreadState());
+        assertEquals(initialValues[3], threadInfo.isSuspended());
+        assertEquals(initialValues[4], threadInfo.isInNative());
+        assertEquals(initialValues[5], threadInfo.getBlockedCount());
+        assertEquals(initialValues[6], threadInfo.getBlockedTime());
+        assertEquals(initialValues[7], threadInfo.getWaitedCount());
+        assertEquals(initialValues[8], threadInfo.getWaitedTime());
+        assertNull(threadInfo.getLockName());
+        assertEquals(initialValues[10], threadInfo.getLockOwnerId());
+        assertEquals(initialValues[11], threadInfo.getLockOwnerName());
+        StackTraceElement[] stackElements = threadInfo.getStackTrace();
+        assertEquals(GOOD_STACK_SIZE, stackElements.length);
+        for (StackTraceElement element : stackElements) {
+            assertEquals(GOOD_STACK_CLASSNAME, element.getClassName());
+            assertEquals(GOOD_STACK_NATIVEMETHOD, element.isNativeMethod());
+            assertEquals(GOOD_STACK_FILENAME, element.getFileName());
+            assertEquals(GOOD_STACK_LINENUMBER, element.getLineNumber());
+            assertEquals(GOOD_STACK_METHODNAME, element.getMethodName());
+        }
+    }
+
+    public void test_from_scenario14() throws Exception {
+        initialValues[10] = null;
+        ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
+        OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
+                SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
+                SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+                SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
+                SimpleType.STRING, stackTraceArray, SimpleType.STRING };
+        CompositeType compositeType = getCompositeType(initialNames, types);
+        CompositeData data = new CompositeDataSupport(compositeType,
+                initialNames, initialValues);
+        try {
+            ThreadInfo.from(data);
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    public void test_from_scenario15() throws Exception {
+        initialValues[11] = null;
+        ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
+        OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
+                SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
+                SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+                SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
+                SimpleType.STRING, stackTraceArray, SimpleType.STRING };
+        CompositeType compositeType = getCompositeType(initialNames, types);
+        CompositeData data = new CompositeDataSupport(compositeType,
+                initialNames, initialValues);
+        ThreadInfo.from(data);
+        ThreadInfo threadInfo = ThreadInfo.from(data);
+        assertEquals(initialValues[0], threadInfo.getThreadId());
+        assertEquals(initialValues[1], threadInfo.getThreadName());
+        assertEquals(GOOD_THREAD_STATE, threadInfo.getThreadState());
+        assertEquals(initialValues[3], threadInfo.isSuspended());
+        assertEquals(initialValues[4], threadInfo.isInNative());
+        assertEquals(initialValues[5], threadInfo.getBlockedCount());
+        assertEquals(initialValues[6], threadInfo.getBlockedTime());
+        assertEquals(initialValues[7], threadInfo.getWaitedCount());
+        assertEquals(initialValues[8], threadInfo.getWaitedTime());
+        assertEquals(initialValues[9], threadInfo.getLockName());
+        assertEquals(initialValues[10], threadInfo.getLockOwnerId());
+        assertNull(threadInfo.getLockOwnerName());
+        StackTraceElement[] stackElements = threadInfo.getStackTrace();
+        assertEquals(GOOD_STACK_SIZE, stackElements.length);
+        for (StackTraceElement element : stackElements) {
+            assertEquals(GOOD_STACK_CLASSNAME, element.getClassName());
+            assertEquals(GOOD_STACK_NATIVEMETHOD, element.isNativeMethod());
+            assertEquals(GOOD_STACK_FILENAME, element.getFileName());
+            assertEquals(GOOD_STACK_LINENUMBER, element.getLineNumber());
+            assertEquals(GOOD_STACK_METHODNAME, element.getMethodName());
+        }
+    }
+
+    public void test_from_scenario16() throws Exception {
+        initialValues[12] = null;
+        ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
+        OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
+                SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
+                SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
+                SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
+                SimpleType.STRING, stackTraceArray, SimpleType.STRING };
+        CompositeType compositeType = getCompositeType(initialNames, types);
+        CompositeData data = new CompositeDataSupport(compositeType,
+                initialNames, initialValues);
+        try {
+            ThreadInfo.from(data);
+            fail("should throw IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // Expected
+        }
+    }
+
+    protected CompositeType getCompositeType(String[] typeNames,
+            OpenType[] typeTypes) throws Exception {
+        return new CompositeType(GOOD_THREADINFO_CLASSNAME,
+                GOOD_THREADINFO_CLASSNAME, typeNames, typeNames, typeTypes);
+    }
+
     String getGoodToStringVal() {
         StringBuilder result = new StringBuilder();
         result.append("Thread " + GOOD_THREAD_NAME + " (Id = " + GOOD_THREAD_ID

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/DatagramSocket.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/DatagramSocket.java?rev=932673&r1=932672&r2=932673&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/DatagramSocket.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/net/DatagramSocket.java Sat Apr 10 06:54:13 2010
@@ -442,11 +442,8 @@ public class DatagramSocket {
         } else {
             // not connected so the target address is not allowed to be null
             if (packAddr == null) {
-                if (pack.getPort() == -1) {
                     // KA019 Destination address is null
                     throw new NullPointerException(Messages.getString("luni.59")); //$NON-NLS-1$
-                }
-                return;
             }
             SecurityManager security = System.getSecurityManager();
             if (security != null) {

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java?rev=932673&r1=932672&r2=932673&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java Sat Apr 10 06:54:13 2010
@@ -359,6 +359,8 @@ public class HttpURLConnectionImpl exten
         boolean closed;
 
         int limit;
+        
+        boolean fixedMod = false;
 
         public HttpOutputStream() {
             cacheLength = defaultCacheSize;
@@ -366,9 +368,10 @@ public class HttpURLConnectionImpl exten
             limit = -1;
         }
 
-        public HttpOutputStream(int limit) {
+        public HttpOutputStream(int limit, boolean fixedMode) {
             writeToSocket = true;
             this.limit = limit;
+            this.fixedMod = fixedMode;
             if (limit > 0) {
                 cacheLength = limit;
             } else {
@@ -445,7 +448,10 @@ public class HttpURLConnectionImpl exten
                 return;
             }
             closed = true;
-            if (writeToSocket) {
+            //Only with such situation when the fixedContentLength field of HttpURLConnection
+            //is set by HttpURLConnection.setFixedLengthStreamingMode and larger than 0, the
+            //IOException will be throwed
+            if (writeToSocket && fixedMod) {
                 if (limit > 0) {
                     throw new IOException(Messages.getString("luni.25")); //$NON-NLS-1$
                 }
@@ -952,11 +958,14 @@ public class HttpURLConnectionImpl exten
             sendChunked = true;
             limit = -1;
         }
+        
+        boolean fixedMode = false;
         if (fixedContentLength >= 0) {
             limit = fixedContentLength;
+            fixedMode = true;
         }
         if ((httpVersion > 0 && sendChunked) || limit >= 0) {
-            os = new HttpOutputStream(limit);
+            os = new HttpOutputStream(limit, fixedMode);
             doRequest();
             return os;
         }

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramSocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramSocketTest.java?rev=932673&r1=932672&r2=932673&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramSocketTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/DatagramSocketTest.java Sat Apr 10 06:54:13 2010
@@ -36,6 +36,7 @@ import java.net.UnknownHostException;
 import java.util.Date;
 
 import org.apache.harmony.luni.net.PlainDatagramSocketImpl;
+import org.junit.Test;
 
 import tests.support.Support_Configuration;
 import tests.support.Support_PortManager;
@@ -940,6 +941,29 @@ public class DatagramSocketTest extends 
     }
     
     /**
+     * If the InetAddress of DatagramPacket is null, DatagramSocket.send(DatagramPacket)
+     * should throw NullPointer Exception.
+     * @tests java.net.DatagramSocket#send(java.net.DatagramPacket)
+     */
+    @Test
+    public void test_sendLjava_net_DatagramPacket2() throws IOException {
+        int udp_port = 20000;
+        int send_port = 23000;
+        DatagramSocket udpSocket = new DatagramSocket(udp_port);
+        byte[] data = {65};
+        DatagramPacket sendPacket = new DatagramPacket(data, data.length, null, send_port);
+        try {
+            udpSocket.send(sendPacket);
+            fail("Should throw SocketException");
+        } catch (NullPointerException e) {
+          // Expected
+        } finally {
+            udpSocket.close();
+        }
+
+    }
+    
+    /**
      * @tests {@link java.net.DatagramSocket#setDatagramSocketImplFactory(DatagramSocketImplFactory)}
      */
     public void test_set_Datagram_SocketImpl_Factory() throws IOException {

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/HttpURLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/HttpURLConnectionTest.java?rev=932673&r1=932672&r2=932673&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/HttpURLConnectionTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/HttpURLConnectionTest.java Sat Apr 10 06:54:13 2010
@@ -317,6 +317,34 @@ public class HttpURLConnectionTest exten
             // correct, too many bytes written
         }
     }
+    
+    /**
+     * When an OutputStream of HtttpURLConnection is closed with below
+     * situation: fixed-length mod is disable and the content-length of the
+     * HtttpURLConnection is larger than 0, it should not throw IOExeption which
+     * indicates there are more bytes need be written into the underlying
+     * Socket.
+     * 
+     * @throws IOException
+     */
+    public void test_closeWithFixedLengthDisableMod() throws IOException {
+        String posted = "just a test";
+        java.net.HttpURLConnection conn = (java.net.HttpURLConnection) url
+                .openConnection();
+        conn.setDoOutput(true);
+        conn.setRequestMethod("POST");
+        conn.setRequestProperty("Content-Length", "" + (888));
+
+        OutputStream out = conn.getOutputStream();
+        out.write(posted.getBytes());
+
+        try {
+            out.close();
+            // expected
+        } catch (IOException e) {
+            fail("should not throw IOException");
+        }
+    }
 
     /**
      * @tests java.net.HttpURLConnection#setChunkedStreamingMode_I()

Propchange: harmony/enhanced/java/branches/java6/common_resources/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Apr 10 06:54:13 2010
@@ -1,3 +1,3 @@
-/harmony/enhanced/java/trunk/common_resources:929253-930072
+/harmony/enhanced/java/trunk/common_resources:929253-932581
 /harmony/enhanced/trunk/common_resources:476396-929252
 /incubator/harmony/enhanced/trunk/common_resources:423974-476394

Propchange: harmony/enhanced/java/branches/java6/drlvm/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Apr 10 06:54:13 2010
@@ -1,4 +1,4 @@
-/harmony/enhanced/java/trunk/drlvm:929253-930072
+/harmony/enhanced/java/trunk/drlvm:929253-932581
 /harmony/enhanced/trunk/drlvm:810871-929252
 /harmony/enhanced/trunk/working_vm:476396-920147
 /incubator/harmony/enhanced/trunk/working_vm:423974-476394

Modified: harmony/enhanced/java/branches/java6/drlvm/make/depends.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/drlvm/make/depends.properties?rev=932673&r1=932672&r2=932673&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/drlvm/make/depends.properties (original)
+++ harmony/enhanced/java/branches/java6/drlvm/make/depends.properties Sat Apr 10 06:54:13 2010
@@ -25,10 +25,10 @@ vmmagic.md5=c20a2e1b4b54a4fa4cc03a1fbb21
 
 # Apache Portable Runtime, version 1.1 or above
 # http://apr.apache.org/download.cgi
-apr.src.tgz=${depends.oss}/apr/apr-1.3.9.tar.gz
-apr.src.rootdir=apr-1.3.9
-apr.src.tgz.url=http://www.apache.org/dist/apr/apr-1.3.9.tar.gz
-apr.src.tgz.md5=85bcd8005153b8fa63b1e3f95ea31f07
+apr.src.tgz=${depends.oss}/apr/apr-1.4.2.tar.gz
+apr.src.rootdir=apr-1.4.2
+apr.src.tgz.url=http://www.apache.org/dist/apr/apr-1.4.2.tar.gz
+apr.src.tgz.md5=fc80cb54f158c2674f9eeb47a1f672cd
 
 # ZLIB, version 1.2.1 or above
 # http://www.zlib.net/

Modified: harmony/enhanced/java/branches/java6/drlvm/vm/port/src/crash_handler/stack_dump.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/drlvm/vm/port/src/crash_handler/stack_dump.cpp?rev=932673&r1=932672&r2=932673&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/drlvm/vm/port/src/crash_handler/stack_dump.cpp (original)
+++ harmony/enhanced/java/branches/java6/drlvm/vm/port/src/crash_handler/stack_dump.cpp Sat Apr 10 06:54:13 2010
@@ -182,11 +182,19 @@ static void sd_print_stack(Registers* re
         CFunInfo cfi = {0};
         native_module_t* module = port_find_module(uwcontext.modules, locregs.get_ip());
         sd_get_c_method_info(&cfi, module, locregs.get_ip());
-        sd_print_c_line(stderr, framenum++, &locregs, &cfi);
 
-        if (unwind && uwresult < 0 && uwinfo.method_name)
-        { // VM has not unwound but has provided additional frame info
-            sd_print_vm_line(stderr, -1, NULL, &uwinfo); // Print as additional info
+        if (!*cfi.name && unwind && uwresult < 0 && uwinfo.method_name)
+        { // No native but some VM info, so print VM info as main info
+            sd_print_vm_line(stderr, framenum++, &locregs, &uwinfo);
+        }
+        else
+        {
+            sd_print_c_line(stderr, framenum++, &locregs, &cfi);
+
+            if (unwind && uwresult < 0 && uwinfo.method_name)
+            { // VM has not unwound but has provided additional frame info
+                sd_print_vm_line(stderr, -1, NULL, &uwinfo); // Print as additional info
+            }
         }
 
         if (!hasnative) // Native unwinding is not initialized

Modified: harmony/enhanced/java/branches/java6/drlvm/vm/port/src/modules/unix/freebsd/native_modules_procmap.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/drlvm/vm/port/src/modules/unix/freebsd/native_modules_procmap.c?rev=932673&r1=932672&r2=932673&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/drlvm/vm/port/src/modules/unix/freebsd/native_modules_procmap.c (original)
+++ harmony/enhanced/java/branches/java6/drlvm/vm/port/src/modules/unix/freebsd/native_modules_procmap.c Sat Apr 10 06:54:13 2010
@@ -35,7 +35,7 @@ int port_modules_procmap_readline(FILE* 
             char* pacc_r, char* pacc_x, char* filename)
 {
     char buf[PATH_MAX];
-    char type[64];
+    char acc_w;
 
     if (!map || feof(map))
         return -1;
@@ -43,14 +43,17 @@ int port_modules_procmap_readline(FILE* 
     if (!fgets(buf, sizeof(buf), map))
         return -1;
 
-    int res = sscanf(buf, "%" PI_FMT "x %" PI_FMT "x %*d %*d %*" PI_FMT "x %c%*c%c %*d %*d %*x %*s %*s %s %s",
-                    pstart, pend, pacc_r, pacc_x, type, filename);
+    int res = sscanf(buf, "%" PI_FMT "x %" PI_FMT "x %*d %*d %*" PI_FMT "x %c%c%c %*d %*d %*x %*s %*s %*s %s",
+                    pstart, pend, pacc_r, &acc_w, pacc_x, filename);
 
-    if (res < 5 || strcmp(type, "vnode") != 0)
+    if (res < 5)
         return 0;
 
     if (res == 6 && filename[0] == '-' && filename[1] == '\0')
         filename[0] = 0;
 
+    if (*pacc_r == '-' && acc_w == '-' && *pacc_x == '-')
+        return 0; // Skip these useless regions that may separate parts of one module
+
      return res - 1;
 }



Mime
View raw message