harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r1002152 [3/5] - in /harmony/enhanced/java/branches/mrh: ./ classlib/ classlib/depends/files/ classlib/doc/awt/images/ classlib/doc/regex/images/ classlib/doc/security/images/ classlib/doc/vminterface/ classlib/modules/archive/src/test/java...
Date Tue, 28 Sep 2010 13:08:57 GMT
Modified: harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/XMLEncoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/XMLEncoder.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/XMLEncoder.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/java/beans/XMLEncoder.java Tue Sep 28 13:08:47 2010
@@ -30,11 +30,12 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.harmony.beans.BeansUtils;
 import org.apache.harmony.beans.internal.nls.Messages;
 
 /**
- * <code>XMLEncoder</code> extends <code>Encoder</code> to write out the
- * encoded statements and expressions in xml format. The xml can be read by
+ * <code>XMLEncoder</code> extends <code>Encoder</code> to write out the encoded
+ * statements and expressions in XML format. The XML can be read by
  * <code>XMLDecoder</code> later to restore objects and their states.
  * <p>
  * The API is similar to <code>ObjectOutputStream</code>.
@@ -46,67 +47,67 @@ public class XMLEncoder extends Encoder 
     private static int DEADLOCK_THRESHOLD = 7;
 
     /*
-	 * Every object written by the encoder has a record.
-	 */
-	private static class Record {
-		// The expression by which the object is created or obtained.
-		Expression exp = null;
+     * Every object written by the encoder has a record.
+     */
+    private static class Record {
+        // The expression by which the object is created or obtained.
+        Expression exp = null;
 
-		// Id of the object, if it is referenced more than once.
-		String id = null;
+        // Id of the object, if it is referenced more than once.
+        String id = null;
 
-		// Count of the references of the object.
-		int refCount = 0;
+        // Count of the references of the object.
+        int refCount = 0;
 
-		// A list of statements that execute on the object.
-		ArrayList<Statement> stats = new ArrayList<Statement>();
-	}
+        // A list of statements that execute on the object.
+        ArrayList<Statement> stats = new ArrayList<Statement>();
+    }
 
-	private static final int INDENT_UNIT = 1;
+    private static final int INDENT_UNIT = 1;
 
-	private static final boolean isStaticConstantsSupported = true;
+    private static final boolean isStaticConstantsSupported = true;
 
-	// the main record of all root objects
-	private ArrayList<Object> flushPending = new ArrayList<Object>();
+    // the main record of all root objects
+    private ArrayList<Object> flushPending = new ArrayList<Object>();
 
-	// the record of root objects with a void tag
-	private ArrayList<Object> flushPendingStat = new ArrayList<Object>();
+    // the record of root objects with a void tag
+    private ArrayList<Object> flushPendingStat = new ArrayList<Object>();
 
-	// keep the pre-required objects for each root object
-	private ArrayList<Object> flushPrePending = new ArrayList<Object>();
+    // keep the pre-required objects for each root object
+    private ArrayList<Object> flushPrePending = new ArrayList<Object>();
 
-	private boolean hasXmlHeader = false;
+    private boolean hasXmlHeader = false;
 
-	/*
-	 * if any expression or statement references owner, it is set true in method
-	 * recordStatement() or recordExpressions(), and, at the first time
-	 * flushObject() meets an owner object, it calls the flushOwner() method and
-	 * then set needOwner to false, so that all succeeding flushing of owner
-	 * will call flushExpression() or flushStatement() normally, which will get
-	 * a reference of the owner property.
-	 */
-	private boolean needOwner = false;
+    /*
+     * if any expression or statement references owner, it is set true in method
+     * recordStatement() or recordExpressions(), and, at the first time
+     * flushObject() meets an owner object, it calls the flushOwner() method and
+     * then set needOwner to false, so that all succeeding flushing of owner
+     * will call flushExpression() or flushStatement() normally, which will get
+     * a reference of the owner property.
+     */
+    private boolean needOwner = false;
 
-	private PrintWriter out;
+    private PrintWriter out;
 
-	private Object owner = null;
+    private Object owner = null;
 
-	private ReferenceMap records = new ReferenceMap();
+    private ReferenceMap records = new ReferenceMap();
 
     private ReferenceMap objPrePendingCache = new ReferenceMap();
 
     private ReferenceMap clazzCounterMap = new ReferenceMap();
 
-	private boolean writingObject = false;
+    private boolean writingObject = false;
 
-	/**
-	 * Construct a <code>XMLEncoder</code>.
-	 * 
-	 * @param out
-	 *            the output stream where xml is written to
-	 */
-	public XMLEncoder(OutputStream out) {
-		if (null != out) {
+    /**
+     * Construct a <code>XMLEncoder</code>.
+     * 
+     * @param out
+     *            the output stream where XML is written to
+     */
+    public XMLEncoder(OutputStream out) {
+        if (null != out) {
             try {
                 this.out = new PrintWriter(
                         new OutputStreamWriter(out, "UTF-8"), true); //$NON-NLS-1$
@@ -115,144 +116,146 @@ public class XMLEncoder extends Encoder 
                 e.printStackTrace();
             }
         }
-	}
+    }
+
+    /**
+     * Call <code>flush()</code> first, then write out XML footer and close the
+     * underlying output stream.
+     */
+    public void close() {
+        flush();
+        out.println("</java>"); //$NON-NLS-1$
+        out.close();
+    }
 
-	/**
-	 * Call <code>flush()</code> first, then write out xml footer and close
-	 * the underlying output stream.
-	 */
-	public void close() {
-		flush();
-		out.println("</java>"); //$NON-NLS-1$
-		out.close();
-	}
-
-	private StringBuffer decapitalize(String s) {
-		StringBuffer buf = new StringBuffer(s);
-		buf.setCharAt(0, Character.toLowerCase(buf.charAt(0)));
-		return buf;
-	}
+    private StringBuffer decapitalize(String s) {
+        StringBuffer buf = new StringBuffer(s);
+        buf.setCharAt(0, Character.toLowerCase(buf.charAt(0)));
+        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;
+        String id = BeansUtils.idOfClass(obj.getClass()) + serialNo;
         clazzCounterMap.put(clazz, ++serialNo);
         return id;
     }
 
-	/**
-	 * Writes out all objects since last flush to the output stream.
-	 * <p>
-	 * The implementation write the xml header first if it has not been
-	 * written. Then all pending objects since last flush are written.
-	 * </p>
-	 */
-	@SuppressWarnings("nls")
+    /**
+     * Writes out all objects since last flush to the output stream.
+     * <p>
+     * The implementation write the XML header first if it has not been written.
+     * Then all pending objects since last flush are written.
+     * </p>
+     */
+    @SuppressWarnings("nls")
     public void flush() {
-		synchronized (this) {
-			// write xml header
-			if (!hasXmlHeader) {
-				out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
-				out.println("<java version=\""
-						+ System.getProperty("java.version")
-						+ "\" class=\"java.beans.XMLDecoder\">");
-				hasXmlHeader = true;
-			}
-
-			// preprocess pending objects
-			for (Iterator<Object> iter = flushPending.iterator(); iter.hasNext();) {
-				Object o = iter.next();
-				Record rec = (Record) records.get(o);
-				if (rec != null) {
-					preprocess(o, rec);
-				}
-			}
-
-			// flush pending objects
-			for (Iterator<Object> iter = flushPending.iterator(); iter.hasNext();) {
-				Object o = iter.next();
-				flushObject(o, INDENT_UNIT);
-				// remove flushed obj
-				iter.remove();
-			}
+        synchronized (this) {
+            // write xml header
+            if (!hasXmlHeader) {
+                out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+                out.println("<java version=\""
+                        + System.getProperty("java.version")
+                        + "\" class=\"java.beans.XMLDecoder\">");
+                hasXmlHeader = true;
+            }
+
+            // preprocess pending objects
+            for (Iterator<Object> iter = flushPending.iterator(); iter
+                    .hasNext();) {
+                Object o = iter.next();
+                Record rec = (Record) records.get(o);
+                if (rec != null) {
+                    preprocess(o, rec);
+                }
+            }
 
-			// clear statement records
-			records.clear();
+            // flush pending objects
+            for (Iterator<Object> iter = flushPending.iterator(); iter
+                    .hasNext();) {
+                Object o = iter.next();
+                flushObject(o, INDENT_UNIT);
+                // remove flushed obj
+                iter.remove();
+            }
+
+            // clear statement records
+            records.clear();
             flushPendingStat.clear();
             objPrePendingCache.clear();
             clazzCounterMap.clear();
 
-			// remove all old->new mappings
-			super.clear();
-		}
-	}
+            // remove all old->new mappings
+            super.clear();
+        }
+    }
 
-	@SuppressWarnings("nls")
+    @SuppressWarnings("nls")
     private void flushBasicObject(Object obj, int indent) {
-		if( obj instanceof Proxy) {
-			return;
-		}
-		flushIndent(indent);
-		if (obj == null) {
-			out.println("<null />");
-		} else if (obj instanceof String) {
-			Record rec = (Record) records.get(obj);
-			if( null != rec) {
-				if (flushPendingStat.contains(obj)) {
-					flushExpression(obj, rec, indent - 3, true);
-				} else {
-					flushExpression(obj, rec, indent - 3, false);
-				}
-				return;
-			}
-			out.print("<string>");
-			flushString((String) obj);
-			out.println("</string>");
-		} else if (obj instanceof Class<?>) {
-			out.print("<class>");
-			out.print(((Class<?>) obj).getName());
-			out.println("</class>");
-		} else if (obj instanceof Boolean) {
-			out.print("<boolean>");
-			out.print(obj);
-			out.println("</boolean>");
-		} else if (obj instanceof Byte) {
-			out.print("<byte>");
-			out.print(obj);
-			out.println("</byte>");
-		} else if (obj instanceof Character) {
-			out.print("<char>");
-			out.print(obj);
-			out.println("</char>");
-		} else if (obj instanceof Double) {
-			out.print("<double>");
-			out.print(obj);
-			out.println("</double>");
-		} else if (obj instanceof Float) {
-			out.print("<float>");
-			out.print(obj);
-			out.println("</float>");
-		} else if (obj instanceof Integer) {
-			out.print("<int>");
-			out.print(obj);
-			out.println("</int>");
-		} else if (obj instanceof Long) {
-			out.print("<long>");
-			out.print(obj);
-			out.println("</long>");
-		} else if (obj instanceof Short) {
-			out.print("<short>");
-			out.print(obj);
-			out.println("</short>");
-		} else {
-			getExceptionListener().exceptionThrown(
-                                       new Exception(Messages.getString("beans.73", obj)));
-		}
-	}
+        if (obj instanceof Proxy) {
+            return;
+        }
+        flushIndent(indent);
+        if (obj == null) {
+            out.println("<null />");
+        } else if (obj instanceof String) {
+            Record rec = (Record) records.get(obj);
+            if (null != rec) {
+                if (flushPendingStat.contains(obj)) {
+                    flushExpression(obj, rec, indent - 3, true);
+                } else {
+                    flushExpression(obj, rec, indent - 3, false);
+                }
+                return;
+            }
+            out.print("<string>");
+            flushString((String) obj);
+            out.println("</string>");
+        } else if (obj instanceof Class<?>) {
+            out.print("<class>");
+            out.print(((Class<?>) obj).getName());
+            out.println("</class>");
+        } else if (obj instanceof Boolean) {
+            out.print("<boolean>");
+            out.print(obj);
+            out.println("</boolean>");
+        } else if (obj instanceof Byte) {
+            out.print("<byte>");
+            out.print(obj);
+            out.println("</byte>");
+        } else if (obj instanceof Character) {
+            out.print("<char>");
+            out.print(obj);
+            out.println("</char>");
+        } else if (obj instanceof Double) {
+            out.print("<double>");
+            out.print(obj);
+            out.println("</double>");
+        } else if (obj instanceof Float) {
+            out.print("<float>");
+            out.print(obj);
+            out.println("</float>");
+        } else if (obj instanceof Integer) {
+            out.print("<int>");
+            out.print(obj);
+            out.println("</int>");
+        } else if (obj instanceof Long) {
+            out.print("<long>");
+            out.print(obj);
+            out.println("</long>");
+        } else if (obj instanceof Short) {
+            out.print("<short>");
+            out.print(obj);
+            out.println("</short>");
+        } else {
+            getExceptionListener().exceptionThrown(
+                    new Exception(Messages.getString("beans.73", obj)));
+        }
+    }
 
-	@SuppressWarnings("nls")
+    @SuppressWarnings("nls")
     private void flushExpression(Object obj, Record rec, int indent,
             boolean asStatement) {
         // flush
@@ -282,197 +285,197 @@ public class XMLEncoder extends Encoder 
         flushStatement(stat, rec.id, rec.stats, indent);
     }
 
-	private void flushIndent(int indent) {
-		for (int i = 0; i < indent; i++) {
-			out.print(" "); //$NON-NLS-1$
-		}
-	}
-
-	private void flushObject(Object obj, int indent) {
-		Record rec = (Record) records.get(obj);
-		if (rec == null && !isBasicType(obj))
-			return;
-
-		if (obj == owner && this.needOwner) {
-			flushOwner(obj, rec, indent);
-			this.needOwner = false;
-			return;
-		}
-
-		if (isBasicType(obj)) {
-			flushBasicObject(obj, indent);
-		} else {
-			if (flushPendingStat.contains(obj)) {
-				flushExpression(obj, rec, indent, true);
-			} else {
-				flushExpression(obj, rec, indent, false);
-			}
-		}
-	}
+    private void flushIndent(int indent) {
+        for (int i = 0; i < indent; i++) {
+            out.print(" "); //$NON-NLS-1$
+        }
+    }
+
+    private void flushObject(Object obj, int indent) {
+        Record rec = (Record) records.get(obj);
+        if (rec == null && !isBasicType(obj))
+            return;
+
+        if (obj == owner && this.needOwner) {
+            flushOwner(obj, rec, indent);
+            this.needOwner = false;
+            return;
+        }
+
+        if (isBasicType(obj)) {
+            flushBasicObject(obj, indent);
+        } else {
+            if (flushPendingStat.contains(obj)) {
+                flushExpression(obj, rec, indent, true);
+            } else {
+                flushExpression(obj, rec, indent, false);
+            }
+        }
+    }
 
-	@SuppressWarnings("nls")
+    @SuppressWarnings("nls")
     private void flushOwner(Object obj, Record rec, int indent) {
         if (rec.refCount > 1 && rec.id == null) {
             rec.id = idSerialNoOfObject(obj);
         }
 
-		flushIndent(indent);
-		String tagName = "void";
-		out.print("<");
-		out.print(tagName);
-
-		// id attribute
-		if (rec.id != null) {
-			out.print(" id=\"");
-			out.print(rec.id);
-			out.print("\"");
-		}
-
-		out.print(" property=\"owner\"");
-
-		// open tag, end
-		if (rec.exp.getArguments().length == 0 && rec.stats.isEmpty()) {
-			out.println("/>");
-			return;
-		}
-		out.println(">");
-
-		// arguments
-		for (int i = 0; i < rec.exp.getArguments().length; i++) {
-			flushObject(rec.exp.getArguments()[i], indent + INDENT_UNIT);
-		}
-
-		// sub statements
-		flushSubStatements(rec.stats, indent);
-
-		// close tag
-		flushIndent(indent);
-		out.print("</");
-		out.print(tagName);
-		out.println(">");
-	}
+        flushIndent(indent);
+        String tagName = "void";
+        out.print("<");
+        out.print(tagName);
+
+        // id attribute
+        if (rec.id != null) {
+            out.print(" id=\"");
+            out.print(rec.id);
+            out.print("\"");
+        }
+
+        out.print(" property=\"owner\"");
+
+        // open tag, end
+        if (rec.exp.getArguments().length == 0 && rec.stats.isEmpty()) {
+            out.println("/>");
+            return;
+        }
+        out.println(">");
 
-	@SuppressWarnings("nls")
+        // arguments
+        for (int i = 0; i < rec.exp.getArguments().length; i++) {
+            flushObject(rec.exp.getArguments()[i], indent + INDENT_UNIT);
+        }
+
+        // sub statements
+        flushSubStatements(rec.stats, indent);
+
+        // close tag
+        flushIndent(indent);
+        out.print("</");
+        out.print(tagName);
+        out.println(">");
+    }
+
+    @SuppressWarnings("nls")
     private void flushStatArray(Statement stat, String id, List<?> subStats,
-			int indent) {
-		// open tag, begin
-		flushIndent(indent);
-		out.print("<array");
-
-		// id attribute
-		if (id != null) {
-			out.print(" id=\"");
-			out.print(id);
-			out.print("\"");
-		}
-
-		// class & length
-		out.print(" class=\"");
-		out.print(((Class<?>) stat.getArguments()[0]).getName());
-		out.print("\" length=\"");
-		out.print(stat.getArguments()[1]);
-		out.print("\"");
-
-		// open tag, end
-		if (subStats.isEmpty()) {
-			out.println("/>");
-			return;
-		}
-		out.println(">");
-
-		// sub statements
-		flushSubStatements(subStats, indent);
-
-		// close tag
-		flushIndent(indent);
-		out.println("</array>");
-	}
+            int indent) {
+        // open tag, begin
+        flushIndent(indent);
+        out.print("<array");
+
+        // id attribute
+        if (id != null) {
+            out.print(" id=\"");
+            out.print(id);
+            out.print("\"");
+        }
+
+        // class & length
+        out.print(" class=\"");
+        out.print(((Class<?>) stat.getArguments()[0]).getName());
+        out.print("\" length=\"");
+        out.print(stat.getArguments()[1]);
+        out.print("\"");
+
+        // open tag, end
+        if (subStats.isEmpty()) {
+            out.println("/>");
+            return;
+        }
+        out.println(">");
+
+        // sub statements
+        flushSubStatements(subStats, indent);
+
+        // close tag
+        flushIndent(indent);
+        out.println("</array>");
+    }
 
-	@SuppressWarnings("nls")
+    @SuppressWarnings("nls")
     private void flushStatCommon(Statement stat, String id, List<?> subStats,
-			int indent) {
-		// open tag, begin
-		flushIndent(indent);
-		String tagName = stat instanceof Expression ? "object" : "void";
-		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("\"");
-		}
-
-		// method attribute
-		if (!"new".equals(stat.getMethodName())) {
-			out.print(" method=\"");
-			out.print(stat.getMethodName());
-			out.print("\"");
-		}
-
-		// open tag, end
-		if (stat.getArguments().length == 0 && subStats.isEmpty()) {
-			out.println("/>");
-			return;
-		}
-		out.println(">");
-
-		// arguments
-		for (int i = 0; i < stat.getArguments().length; i++) {
-			flushObject(stat.getArguments()[i], indent + INDENT_UNIT);
-		}
-
-		// sub statements
-		flushSubStatements(subStats, indent);
-
-		// close tag
-		flushIndent(indent);
-		out.print("</");
-		out.print(tagName);
-		out.println(">");
-	}
+            int indent) {
+        // open tag, begin
+        flushIndent(indent);
+        String tagName = stat instanceof Expression ? "object" : "void";
+        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("\"");
+        }
+
+        // method attribute
+        if (!"new".equals(stat.getMethodName())) {
+            out.print(" method=\"");
+            out.print(stat.getMethodName());
+            out.print("\"");
+        }
+
+        // open tag, end
+        if (stat.getArguments().length == 0 && subStats.isEmpty()) {
+            out.println("/>");
+            return;
+        }
+        out.println(">");
+
+        // arguments
+        for (int i = 0; i < stat.getArguments().length; i++) {
+            flushObject(stat.getArguments()[i], indent + INDENT_UNIT);
+        }
+
+        // sub statements
+        flushSubStatements(subStats, indent);
+
+        // close tag
+        flushIndent(indent);
+        out.print("</");
+        out.print(tagName);
+        out.println(">");
+    }
 
-	@SuppressWarnings("nls")
+    @SuppressWarnings("nls")
     private void flushStatement(Statement stat, String id, List<?> subStats,
-			int indent) {
-		Object target = stat.getTarget();
-		String method = stat.getMethodName();
-		Object args[] = stat.getArguments();
-
-		// special case for array
-		if (Array.class == target && "newInstance".equals(method)) {
-			flushStatArray(stat, id, subStats, indent);
-			return;
-		}
-		// special case for get(int) and set(int, Object)
-		if (isGetArrayStat(target, method, args)
-				|| isSetArrayStat(target, method, args)) {
-			flushStatIndexed(stat, id, subStats, indent);
-			return;
-		}
-		// special case for getProperty() and setProperty(Object)
-		if (isGetPropertyStat(method, args) || isSetPropertyStat(method, args)) {
-			flushStatGetterSetter(stat, id, subStats, indent);
-			return;
-		}
+            int indent) {
+        Object target = stat.getTarget();
+        String method = stat.getMethodName();
+        Object args[] = stat.getArguments();
 
-		if (isStaticConstantsSupported
-				&& "getField".equals(stat.getMethodName())) {
+        // special case for array
+        if (Array.class == target && "newInstance".equals(method)) {
+            flushStatArray(stat, id, subStats, indent);
+            return;
+        }
+        // special case for get(int) and set(int, Object)
+        if (isGetArrayStat(target, method, args)
+                || isSetArrayStat(target, method, args)) {
+            flushStatIndexed(stat, id, subStats, indent);
+            return;
+        }
+        // special case for getProperty() and setProperty(Object)
+        if (isGetPropertyStat(method, args) || isSetPropertyStat(method, args)) {
+            flushStatGetterSetter(stat, id, subStats, indent);
+            return;
+        }
+
+        if (isStaticConstantsSupported
+                && "getField".equals(stat.getMethodName())) {
             flushStatField(stat, indent);
-			return;
-		}
+            return;
+        }
 
-		// common case
-		flushStatCommon(stat, id, subStats, indent);
-	}
+        // common case
+        flushStatCommon(stat, id, subStats, indent);
+    }
 
     @SuppressWarnings("nls")
     private void flushStatField(Statement stat, int indent) {
@@ -515,194 +518,182 @@ public class XMLEncoder extends Encoder 
         }
     }
 
-	@SuppressWarnings("nls")
+    @SuppressWarnings("nls")
     private void flushStatGetterSetter(Statement stat, String id,
-			List<?> subStats, int indent) {
-		// open tag, begin
-		flushIndent(indent);
-		String tagName = stat instanceof Expression ? "object" : "void";
-		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("\"");
-		}
-
-		// property attribute
-		out.print(" property=\"");
-		out.print(decapitalize(stat.getMethodName().substring(3)));
-		out.print("\"");
-
-		// open tag, end
-		if (stat.getArguments().length == 0 && subStats.isEmpty()) {
-			out.println("/>");
-			return;
-		}
-		out.println(">");
-
-		// arguments
-		for (int i = 0; i < stat.getArguments().length; i++) {
-			flushObject(stat.getArguments()[i], indent + INDENT_UNIT);
-		}
-
-		// sub statements
-		flushSubStatements(subStats, indent);
-
-		// close tag
-		flushIndent(indent);
-		out.print("</");
-		out.print(tagName);
-		out.println(">");
-	}
+            List<?> subStats, int indent) {
+        // open tag, begin
+        flushIndent(indent);
+        String tagName = stat instanceof Expression ? "object" : "void";
+        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("\"");
+        }
+
+        // property attribute
+        out.print(" property=\"");
+        out.print(decapitalize(stat.getMethodName().substring(3)));
+        out.print("\"");
+
+        // open tag, end
+        if (stat.getArguments().length == 0 && subStats.isEmpty()) {
+            out.println("/>");
+            return;
+        }
+        out.println(">");
 
-	@SuppressWarnings("nls")
+        // arguments
+        for (int i = 0; i < stat.getArguments().length; i++) {
+            flushObject(stat.getArguments()[i], indent + INDENT_UNIT);
+        }
+
+        // sub statements
+        flushSubStatements(subStats, indent);
+
+        // close tag
+        flushIndent(indent);
+        out.print("</");
+        out.print(tagName);
+        out.println(">");
+    }
+
+    @SuppressWarnings("nls")
     private void flushStatIndexed(Statement stat, String id, List<?> subStats,
-			int indent) {
-		// open tag, begin
-		flushIndent(indent);
-		String tagName = stat instanceof Expression ? "object" : "void";
-		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("\"");
-		}
-
-		// index attribute
-		out.print(" index=\"");
-		out.print(stat.getArguments()[0]);
-		out.print("\"");
-
-		// open tag, end
-		if (stat.getArguments().length == 1 && subStats.isEmpty()) {
-			out.println("/>");
-			return;
-		}
-		out.println(">");
-
-		// arguments
-		for (int i = 1; i < stat.getArguments().length; i++) {
-			flushObject(stat.getArguments()[i], indent + INDENT_UNIT);
-		}
-
-		// sub statements
-		flushSubStatements(subStats, indent);
-
-		// close tag
-		flushIndent(indent);
-		out.print("</");
-		out.print(tagName);
-		out.println(">");
-	}
+            int indent) {
+        // open tag, begin
+        flushIndent(indent);
+        String tagName = stat instanceof Expression ? "object" : "void";
+        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("\"");
+        }
+
+        // index attribute
+        out.print(" index=\"");
+        out.print(stat.getArguments()[0]);
+        out.print("\"");
+
+        // open tag, end
+        if (stat.getArguments().length == 1 && subStats.isEmpty()) {
+            out.println("/>");
+            return;
+        }
+        out.println(">");
+
+        // arguments
+        for (int i = 1; i < stat.getArguments().length; i++) {
+            flushObject(stat.getArguments()[i], indent + INDENT_UNIT);
+        }
 
-	@SuppressWarnings("nls")
+        // sub statements
+        flushSubStatements(subStats, indent);
+
+        // close tag
+        flushIndent(indent);
+        out.print("</");
+        out.print(tagName);
+        out.println(">");
+    }
+
+    @SuppressWarnings("nls")
     private void flushString(String s) {
-		char c;
-		for (int i = 0; i < s.length(); i++) {
-			c = s.charAt(i);
-			if (c == '<') {
-				out.print("&lt;");
-			} else if (c == '>') {
-				out.print("&gt;");
-			} else if (c == '&') {
-				out.print("&amp;");
-			} else if (c == '\'') {
-				out.print("&apos;");
-			} else if (c == '"') {
-				out.print("&quot;");
-			} else {
-				out.print(c);
-			}
-		}
-	}
-
-	private void flushSubStatements(List<?> subStats, int indent) {
-		for (int i = 0; i < subStats.size(); i++) {
-			Statement subStat = (Statement) subStats.get(i);
-			try {
-				if (subStat instanceof Expression) {
-					Expression subExp = (Expression) subStat;
-					Object obj = subExp.getValue();
-					Record rec = (Record) records.get(obj);
-					flushExpression(obj, rec, indent + INDENT_UNIT, true);
-				} else {
-					flushStatement(subStat, null, Collections.EMPTY_LIST,
-							indent + INDENT_UNIT);
-				}
-			} catch (Exception e) {
-				// should not happen
-				getExceptionListener().exceptionThrown(e);
-			}
-		}
-	}
-
-	/**
-	 * Returns the owner of this encoder.
-	 * 
-	 * @return the owner of this encoder
-	 */
-	public Object getOwner() {
-		return owner;
-	}
-
-	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 Float || value instanceof Integer
-				|| value instanceof Long || value instanceof Short
-				|| value instanceof String || value instanceof Proxy;
-	}
-
-	private boolean isGetArrayStat(Object target, String method, Object[] args) {
-		return ("get".equals(method) && args.length == 1 //$NON-NLS-1$
-				&& args[0] instanceof Integer && target.getClass().isArray());
-	}
-
-	private boolean isGetPropertyStat(String method, Object[] args) {
-		return (method.startsWith("get") && method.length() > 3 && args.length == 0); //$NON-NLS-1$
-	}
-
-	private boolean isSetArrayStat(Object target, String method, Object[] args) {
-		return ("set".equals(method) && args.length == 2 //$NON-NLS-1$
-				&& args[0] instanceof Integer && target.getClass().isArray());
-	}
-
-	private boolean isSetPropertyStat(String method, Object[] args) {
-		return (method.startsWith("set") && method.length() > 3 && args.length == 1); //$NON-NLS-1$
-	}
-
-	private String nameForClass(Class<?> c) {
-		if (c.isArray()) {
-			return nameForClass(c.getComponentType()) + "Array"; //$NON-NLS-1$
-		}
-        String name = c.getName();
-        int i = name.lastIndexOf('.');
-        if (-1 == i) {
-        	return name;
+        char c;
+        for (int i = 0; i < s.length(); i++) {
+            c = s.charAt(i);
+            if (c == '<') {
+                out.print("&lt;");
+            } else if (c == '>') {
+                out.print("&gt;");
+            } else if (c == '&') {
+                out.print("&amp;");
+            } else if (c == '\'') {
+                out.print("&apos;");
+            } else if (c == '"') {
+                out.print("&quot;");
+            } else {
+                out.print(c);
+            }
         }
-        return name.substring(i + 1);
-	}
+    }
+
+    private void flushSubStatements(List<?> subStats, int indent) {
+        for (int i = 0; i < subStats.size(); i++) {
+            Statement subStat = (Statement) subStats.get(i);
+            try {
+                if (subStat instanceof Expression) {
+                    Expression subExp = (Expression) subStat;
+                    Object obj = subExp.getValue();
+                    Record rec = (Record) records.get(obj);
+                    flushExpression(obj, rec, indent + INDENT_UNIT, true);
+                } else {
+                    flushStatement(subStat, null, Collections.EMPTY_LIST,
+                            indent + INDENT_UNIT);
+                }
+            } catch (Exception e) {
+                // should not happen
+                getExceptionListener().exceptionThrown(e);
+            }
+        }
+    }
+
+    /**
+     * Returns the owner of this encoder.
+     * 
+     * @return the owner of this encoder
+     */
+    public Object getOwner() {
+        return owner;
+    }
+
+    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 Float || value instanceof Integer
+                || value instanceof Long || value instanceof Short
+                || value instanceof String || value instanceof Proxy;
+    }
+
+    private boolean isGetArrayStat(Object target, String method, Object[] args) {
+        return ("get".equals(method) && args.length == 1 //$NON-NLS-1$
+                && args[0] instanceof Integer && target.getClass().isArray());
+    }
+
+    private boolean isGetPropertyStat(String method, Object[] args) {
+        return (method.startsWith("get") && method.length() > 3 && args.length == 0); //$NON-NLS-1$
+    }
+
+    private boolean isSetArrayStat(Object target, String method, Object[] args) {
+        return ("set".equals(method) && args.length == 2 //$NON-NLS-1$
+                && args[0] instanceof Integer && target.getClass().isArray());
+    }
+
+    private boolean isSetPropertyStat(String method, Object[] args) {
+        return (method.startsWith("set") && method.length() > 3 && args.length == 1); //$NON-NLS-1$
+    }
 
     /*
      * The preprocess removes unused statements and counts references of every
@@ -743,102 +734,103 @@ public class XMLEncoder extends Encoder 
             }
         }
 
-		for (Iterator<?> iter = rec.stats.iterator(); iter.hasNext();) {
-			Statement subStat = (Statement) iter.next();
-			if (subStat instanceof Expression) {
-				try {
-					Expression subExp = (Expression) subStat;
-					Record subRec = (Record) records.get(subExp.getValue());
-					if (subRec == null || subRec.exp == null
-							|| subRec.exp != subExp) {
-						iter.remove();
-						continue;
-					}
-					preprocess(subExp.getValue(), subRec);
-					if (subRec.stats.isEmpty()) {
-						if (isGetArrayStat(subExp.getTarget(), subExp
-								.getMethodName(), subExp.getArguments())
-								|| isGetPropertyStat(subExp.getMethodName(),
-										subExp.getArguments())) {
-							iter.remove();
-							continue;
-						}
-					}
-				} catch (Exception e) {
-					getExceptionListener().exceptionThrown(e);
-					iter.remove();
-				}
-				continue;
-			}
-
-			Object subStatArgs[] = subStat.getArguments();
-			for (int i = 0; i < subStatArgs.length; i++) {
-				Record argRec = (Record) records.get(subStatArgs[i]);
-				if (argRec != null) {
-					preprocess(subStatArgs[i], argRec);
-				}
-			}
-		}
-	}
-
-	private void recordExpression(Object value, Expression exp) {
-		// record how a new object is created or obtained
-		Record rec = (Record) records.get(value);
-		if (rec == null) {
-			rec = new Record();
-			records.put(value, rec);
-		}
-
-		if (rec.exp == null) {
-			// it is generated by its sub stats
-			for (Iterator<?> iter = rec.stats.iterator(); iter.hasNext();) {
-				Statement stat = (Statement) iter.next();
-				try {
-					if (stat instanceof Expression) {
-						flushPrePending.add(value);
-					}
-				} catch (Exception e) {
-					e.printStackTrace();
-				}
-
-			}
-		}
-
-		rec.exp = exp;
-
-		// deal with 'owner' property
-		if (value == owner && owner != null) {
-			needOwner = true;
-		}
-
-		// also record as a statement
-		recordStatement(exp);
-	}
-
-	private void recordStatement(Statement stat) {
-        if (null == stat) return;
-		// deal with 'owner' property
-		if (stat.getTarget() == owner && owner != null) {
-			needOwner = true;
-		}
-
-		// record how a statement affects the target object
-		Record rec = (Record) records.get(stat.getTarget());
-		if (rec == null) {
-			rec = new Record();
-			records.put(stat.getTarget(), rec);
-		}
-		rec.stats.add(stat);
-	}
+        for (Iterator<?> iter = rec.stats.iterator(); iter.hasNext();) {
+            Statement subStat = (Statement) iter.next();
+            if (subStat instanceof Expression) {
+                try {
+                    Expression subExp = (Expression) subStat;
+                    Record subRec = (Record) records.get(subExp.getValue());
+                    if (subRec == null || subRec.exp == null
+                            || subRec.exp != subExp) {
+                        iter.remove();
+                        continue;
+                    }
+                    preprocess(subExp.getValue(), subRec);
+                    if (subRec.stats.isEmpty()) {
+                        if (isGetArrayStat(subExp.getTarget(),
+                                subExp.getMethodName(), subExp.getArguments())
+                                || isGetPropertyStat(subExp.getMethodName(),
+                                        subExp.getArguments())) {
+                            iter.remove();
+                            continue;
+                        }
+                    }
+                } catch (Exception e) {
+                    getExceptionListener().exceptionThrown(e);
+                    iter.remove();
+                }
+                continue;
+            }
+
+            Object subStatArgs[] = subStat.getArguments();
+            for (int i = 0; i < subStatArgs.length; i++) {
+                Record argRec = (Record) records.get(subStatArgs[i]);
+                if (argRec != null) {
+                    preprocess(subStatArgs[i], argRec);
+                }
+            }
+        }
+    }
+
+    private void recordExpression(Object value, Expression exp) {
+        // record how a new object is created or obtained
+        Record rec = (Record) records.get(value);
+        if (rec == null) {
+            rec = new Record();
+            records.put(value, rec);
+        }
+
+        if (rec.exp == null) {
+            // it is generated by its sub stats
+            for (Iterator<?> iter = rec.stats.iterator(); iter.hasNext();) {
+                Statement stat = (Statement) iter.next();
+                try {
+                    if (stat instanceof Expression) {
+                        flushPrePending.add(value);
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+
+            }
+        }
+
+        rec.exp = exp;
+
+        // deal with 'owner' property
+        if (value == owner && owner != null) {
+            needOwner = true;
+        }
+
+        // also record as a statement
+        recordStatement(exp);
+    }
+
+    private void recordStatement(Statement stat) {
+        if (null == stat)
+            return;
+        // deal with 'owner' property
+        if (stat.getTarget() == owner && owner != null) {
+            needOwner = true;
+        }
+
+        // record how a statement affects the target object
+        Record rec = (Record) records.get(stat.getTarget());
+        if (rec == null) {
+            rec = new Record();
+            records.put(stat.getTarget(), rec);
+        }
+        rec.stats.add(stat);
+    }
 
     /**
      * Imperfect attempt to detect a dead loop. This works with specific
-     * patterns that can be found in our AWT implementation.
-     * See HARMONY-5707 for details.
-     *
-     * @param value the object to check dupes for
-     * @return true if a dead loop detected; false otherwise
-     * FIXME
+     * patterns that can be found in our AWT implementation. See HARMONY-5707
+     * for details.
+     * 
+     * @param value
+     *            the object to check dupes for
+     * @return true if a dead loop detected; false otherwise FIXME
      */
     private boolean checkDeadLoop(Object value) {
         int n = 0;
@@ -852,14 +844,14 @@ public class XMLEncoder extends Encoder 
             } else {
                 break;
             }
-            
+
             if (obj != null
                     && (obj.getClass().isAssignableFrom(value.getClass()))
                     && obj.equals(value)) {
                 n++;
 
                 if (n >= DEADLOCK_THRESHOLD) {
-                    //System.out.println("Dead loop hit!");
+                    // System.out.println("Dead loop hit!");
                     return true;
                 }
             }
@@ -868,48 +860,49 @@ public class XMLEncoder extends Encoder 
     }
 
     /**
-	 * Sets the owner of this encoder.
-	 * 
-	 * @param owner
-	 *            the owner to set
-	 */
-	public void setOwner(Object owner) {
-		this.owner = owner;
-	}
-
-	/**
-	 * Records the expression so that it can be written out later, then calls
-	 * super implementation.
-	 */
-	@Override
+     * Sets the owner of this encoder.
+     * 
+     * @param owner
+     *            the owner to set
+     */
+    public void setOwner(Object owner) {
+        this.owner = owner;
+    }
+
+    /**
+     * Records the expression so that it can be written out later, then calls
+     * super implementation.
+     */
+    @Override
     public void writeExpression(Expression oldExp) {
         if (null == oldExp) {
             throw new NullPointerException();
         }
-	    boolean oldWritingObject = writingObject;
-	    writingObject = true;
-		// get expression value
-		Object oldValue = null;
+        boolean oldWritingObject = writingObject;
+        writingObject = true;
+        // get expression value
+        Object oldValue = null;
 
         try {
-			oldValue = oldExp.getValue();
-		} catch (Exception e) {
-			getExceptionListener()
-					.exceptionThrown(
-							new Exception("failed to execute expression: " //$NON-NLS-1$
-									+ oldExp, e));
-			return;
-		}
-
-		// check existence
-		if (get(oldValue) != null && (!(oldValue instanceof String) || oldWritingObject)) {
-			return;
-		}
-
-		// record how the object is obtained
-		if (!isBasicType(oldValue) || (oldValue instanceof String && !oldWritingObject)) {
-			recordExpression(oldValue, oldExp);
-		}
+            oldValue = oldExp.getValue();
+        } catch (Exception e) {
+            getExceptionListener().exceptionThrown(
+                    new Exception("failed to execute expression: " //$NON-NLS-1$
+                            + oldExp, e));
+            return;
+        }
+
+        // check existence
+        if (get(oldValue) != null
+                && (!(oldValue instanceof String) || oldWritingObject)) {
+            return;
+        }
+
+        // record how the object is obtained
+        if (!isBasicType(oldValue)
+                || (oldValue instanceof String && !oldWritingObject)) {
+            recordExpression(oldValue, oldExp);
+        }
 
         // try to detect if we run into a dead loop
         if (checkDeadLoop(oldValue)) {
@@ -917,13 +910,13 @@ public class XMLEncoder extends Encoder 
         }
 
         super.writeExpression(oldExp);
-		writingObject = oldWritingObject;
-	}
+        writingObject = oldWritingObject;
+    }
 
-	/**
-	 * Records the object so that it can be written out later, then calls super
-	 * implementation.
-	 */
+    /**
+     * Records the object so that it can be written out later, then calls super
+     * implementation.
+     */
     @SuppressWarnings("unchecked")
     @Override
     public void writeObject(Object o) {
@@ -971,23 +964,21 @@ public class XMLEncoder extends Encoder 
         }
     }
 
-	/**
-	 * Records the statement so that it can be written out later, then calls
-	 * super implementation.
-	 */
-	@Override
+    /**
+     * Records the statement so that it can be written out later, then calls
+     * super implementation.
+     */
+    @Override
     public void writeStatement(Statement oldStat) {
-        if(null == oldStat) {
-            System.err.println("java.lang.Exception: XMLEncoder: discarding statement null");
+        if (null == oldStat) {
+            System.err
+                    .println("java.lang.Exception: XMLEncoder: discarding statement null");
             System.err.println("Continuing...");
             return;
         }
-		// record how the object is changed
-		recordStatement(oldStat);
-
-		super.writeStatement(oldStat);
-	}
-
-}
-
+        // record how the object is changed
+        recordStatement(oldStat);
 
+        super.writeStatement(oldStat);
+    }
+}
\ No newline at end of file

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/org/apache/harmony/beans/BeansUtils.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/org/apache/harmony/beans/BeansUtils.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/org/apache/harmony/beans/BeansUtils.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/main/java/org/apache/harmony/beans/BeansUtils.java Tue Sep 28 13:08:47 2010
@@ -17,8 +17,35 @@
 
 package org.apache.harmony.beans;
 
+import java.lang.reflect.Method;
+import java.util.Arrays;
+
 public class BeansUtils {
 
+    public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
+
+    public static final String NEW = "new"; //$NON-NLS-1$
+
+    public static final String NEWINSTANCE = "newInstance"; //$NON-NLS-1$
+
+    public static final String NEWARRAY = "newArray"; //$NON-NLS-1$
+
+    public static final String FORNAME = "forName"; //$NON-NLS-1$
+
+    public static final String GET = "get"; //$NON-NLS-1$
+
+    public static final String IS = "is"; //$NON-NLS-1$
+
+    public static final String SET = "set"; //$NON-NLS-1$
+
+    public static final String ADD = "add"; //$NON-NLS-1$
+
+    public static final String PUT = "put"; //$NON-NLS-1$
+
+    public static final String NULL = "null"; //$NON-NLS-1$
+
+    public static final String QUOTE = "\"\""; //$NON-NLS-1$
+
     public static final int getHashCode(Object obj) {
         return obj != null ? obj.hashCode() : 0;
     }
@@ -63,4 +90,33 @@ public class BeansUtils {
                 || (base == float.class) && (wrapper == Float.class)
                 || (base == double.class) && (wrapper == Double.class);
     }
+
+    private static final String EQUALS_METHOD = "equals";
+
+    private static final Class<?>[] EQUALS_PARAMETERS = new Class<?>[] { Object.class };
+
+    public static boolean declaredEquals(Class<?> clazz) {
+        for (Method declaredMethod : clazz.getDeclaredMethods()) {
+            if (EQUALS_METHOD.equals(declaredMethod.getName())
+                    && Arrays.equals(declaredMethod.getParameterTypes(),
+                            EQUALS_PARAMETERS)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public static String idOfClass(Class<?> clazz) {
+        Class<?> theClass = clazz;
+        StringBuilder sb = new StringBuilder();
+        if (theClass.isArray()) {
+            do {
+                sb.append("Array"); //$NON-NLS-1$
+                theClass = theClass.getComponentType();
+            } while (theClass.isArray());
+        }
+        String clazzName = theClass.getName();
+        clazzName = clazzName.substring(clazzName.lastIndexOf('.') + 1);
+        return clazzName + sb.toString();
+    }
 }

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java Tue Sep 28 13:08:47 2010
@@ -1313,4 +1313,37 @@ public class StatementTest extends TestC
             assertTrue(receivedArguments.isEmpty());
         }
     }
+
+    public interface IMockObjectA {
+    }
+
+    public class MockObjectA implements IMockObjectA {
+    }
+
+    public interface IMockAccess<E> {
+        public void setProperty(E e);
+    }
+
+    public class MockAccess implements IMockAccess<IMockObjectA> {
+
+        private IMockObjectA property;
+
+        public void setProperty(IMockObjectA prop) {
+            property = prop;
+        }
+
+        public IMockObjectA getProperty() {
+            return property;
+        }
+
+    }
+
+    public void testExecute_ObjectInterface() throws Exception {
+        MockAccess mockAccess = new MockAccess();
+        MockObjectA mockObjectA = new MockObjectA();
+        new Statement(mockAccess, "setProperty", new Object[] { mockObjectA })
+                .execute();
+        assertSame(mockObjectA, mockAccess.getProperty());
+    }
+
 }

Propchange: harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/test/resources/gif/harmony-logo.gif
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Tue Sep 28 13:08:47 2010
@@ -1 +1 @@
-application/octet-stream
+image/gif

Propchange: harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/test/resources/gif/test.gif
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Tue Sep 28 13:08:47 2010
@@ -1 +1 @@
-application/octet-stream
+image/gif

Propchange: harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/test/resources/org/apache/harmony/beans/tests/java/beans/testB.jpg
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Tue Sep 28 13:08:47 2010
@@ -1 +1 @@
-application/octet-stream
+image/jpeg

Propchange: harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/test/resources/xml/ChangedObject.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/test/resources/xml/ClassID.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/test/resources/xml/ObjectID.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/test/resources/xml/StaticField.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/CorruptedSerBean.ser
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Propchange: harmony/enhanced/java/branches/mrh/classlib/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/EmptySerBean.ser
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Propchange: harmony/enhanced/java/branches/mrh/classlib/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.ciphertext
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Propchange: harmony/enhanced/java/branches/mrh/classlib/modules/imageio/src/test/resources/images/utest.jpg
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Tue Sep 28 13:08:47 2010
@@ -1 +1 @@
-application/octet-stream
+image/jpeg

Propchange: harmony/enhanced/java/branches/mrh/classlib/modules/imageio/src/test/resources/images/utest.png
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Tue Sep 28 13:08:47 2010
@@ -1 +1 @@
-application/octet-stream
+image/png

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/jmx/make/depends.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/jmx/make/depends.properties?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/jmx/make/depends.properties (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/jmx/make/depends.properties Tue Sep 28 13:08:47 2010
@@ -14,12 +14,11 @@
 # limitations under the License.
 
 depends.jars=${depends.dir}/jars
-sf.base=http://dfn.dl.sourceforge.net/sourceforge
 
 mx4j.version=3.0.2
 mx4j.dir=${depends.jars}/mx4j_${mx4j.version}
 mx4j.zip=${mx4j.dir}/mx4j.zip
-mx4j.url=${sf.base}/mx4j/mx4j-${mx4j.version}.zip
+mx4j.url=http://downloads.sourceforge.net/sourceforge/mx4j/mx4j-${mx4j.version}.zip?use_mirror=autoselect
 mx4j.md5=443bd83ee36414de4b8fc5722b038b02
 mx4j.jar=${mx4j.dir}/mx4j.jar
 mx4j.remote.jar=${mx4j.dir}/mx4j-remote.jar

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/logging/src/main/java/java/util/logging/LogManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/logging/src/main/java/java/util/logging/LogManager.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/logging/src/main/java/java/util/logging/LogManager.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/logging/src/main/java/java/util/logging/LogManager.java Tue Sep 28 13:08:47 2010
@@ -323,11 +323,12 @@ public class LogManager {
         // find children
         // TODO: performance can be improved here?
         Collection<Logger> allLoggers = loggers.values();
+        boolean emptyName = name.length() == 0;
+        String namePrefix = name + '.';
         for (final Logger child : allLoggers) {
             Logger oldParent = child.getParent();
             if (parent == oldParent
-                    && (name.length() == 0 || child.getName().startsWith(
-                            name + '.'))) {
+                    && (emptyName || child.getName().startsWith(namePrefix))) {
                 final Logger thisLogger = logger;
                 AccessController.doPrivileged(new PrivilegedAction<Object>() {
                     public Object run() {

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/File.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/File.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/File.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/File.java Tue Sep 28 13:08:47 2010
@@ -24,6 +24,7 @@ import java.security.AccessController;
 import java.security.SecureRandom;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Locale;
 
 import org.apache.harmony.luni.internal.io.FileCanonPathCache;
 import org.apache.harmony.luni.util.DeleteOnExit;
@@ -753,7 +754,7 @@ public class File implements Serializabl
         if (caseSensitive) {
             return path.hashCode() ^ 1234321;
         }
-        return path.toLowerCase().hashCode() ^ 1234321;
+        return path.toLowerCase(Locale.ENGLISH).hashCode() ^ 1234321;
     }
 
     /**

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/FileDescriptor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/FileDescriptor.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/FileDescriptor.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/FileDescriptor.java Tue Sep 28 13:08:47 2010
@@ -62,10 +62,16 @@ public final class FileDescriptor {
 
     private static native void oneTimeInitialization();
 
+    private static native long getStdInDescriptor();
+    
+    private static native long getStdOutDescriptor();
+    
+    private static native long getStdErrDescriptor();
+
     static {
-        in.descriptor = 0;
-        out.descriptor = 1;
-        err.descriptor = 2;
+        in.descriptor = getStdInDescriptor();
+        out.descriptor = getStdOutDescriptor();
+        err.descriptor = getStdErrDescriptor();
 
         oneTimeInitialization();
     }

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/FileInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/FileInputStream.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/FileInputStream.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/FileInputStream.java Tue Sep 28 13:08:47 2010
@@ -45,8 +45,6 @@ public class FileInputStream extends Inp
     // initialized).
     private FileChannel channel;
 
-    boolean innerFD;
-
     private IFileSystem fileSystem = Platform.getFileSystem();
 
     private static class RepositioningLock {
@@ -81,7 +79,6 @@ public class FileInputStream extends Inp
         fd.readOnly = true;
         fd.descriptor = fileSystem.open(file.properPath(true),
                 IFileSystem.O_RDONLY);
-        innerFD = true;
         channel = FileChannelFactory.getFileChannel(this, fd.descriptor,
                 IFileSystem.O_RDONLY);
     }
@@ -109,7 +106,6 @@ public class FileInputStream extends Inp
             security.checkRead(fd);
         }
         this.fd = fd;
-        innerFD = false;
         channel = FileChannelFactory.getFileChannel(this, fd.descriptor,
                 IFileSystem.O_RDONLY);
     }
@@ -173,7 +169,7 @@ public class FileInputStream extends Inp
             }
         }
         synchronized (this) {
-            if (fd.descriptor >= 0 && innerFD) {
+            if (fd.descriptor >= 0) {
                 fileSystem.close(fd.descriptor);
                 fd.descriptor = -1;
             }

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/FileOutputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/FileOutputStream.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/FileOutputStream.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/FileOutputStream.java Tue Sep 28 13:08:47 2010
@@ -42,8 +42,6 @@ public class FileOutputStream extends Ou
      */
     FileDescriptor fd;
 
-    boolean innerFD;
-
     // The unique file channel associated with this FileInputStream (lazily
     // initialized).
     private FileChannel channel;
@@ -94,7 +92,6 @@ public class FileOutputStream extends Ou
         fd = new FileDescriptor();
         fd.descriptor = fileSystem.open(file.properPath(true),
                 append ? IFileSystem.O_APPEND : IFileSystem.O_WRONLY);
-        innerFD = true;
         channel = FileChannelFactory.getFileChannel(this, fd.descriptor,
                 append ? IFileSystem.O_APPEND : IFileSystem.O_WRONLY);
     }
@@ -123,7 +120,6 @@ public class FileOutputStream extends Ou
             security.checkWrite(fd);
         }
         this.fd = fd;
-        innerFD = false;
         channel = FileChannelFactory.getFileChannel(this, fd.descriptor,
                 IFileSystem.O_WRONLY);
     }
@@ -190,7 +186,7 @@ public class FileOutputStream extends Ou
         }
 
         synchronized (this) {
-            if (fd.descriptor >= 0 && innerFD) {
+            if (fd.descriptor >= 0) {
                 fileSystem.close(fd.descriptor);
                 fd.descriptor = -1;
             }

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/FilePermission.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/FilePermission.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/FilePermission.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/io/FilePermission.java Tue Sep 28 13:08:47 2010
@@ -22,6 +22,7 @@ import java.security.Permission;
 import java.security.PermissionCollection;
 import java.security.PrivilegedAction;
 
+import org.apache.harmony.luni.util.Util;
 import org.apache.harmony.luni.internal.nls.Messages;
 
 /**
@@ -54,8 +55,9 @@ public final class FilePermission extend
     private transient String canonPath;
 
     // list of actions permitted for socket permission in order
-    private static final String[] actionList = { "read", "write", "execute", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-            "delete" }; //$NON-NLS-1$
+    @SuppressWarnings("nls")
+    private static final String[] actionList = { "read", "write", "execute",
+            "delete" };
 
     // "canonicalized" action list
     private String actions;
@@ -132,7 +134,7 @@ public final class FilePermission extend
      * @return the string representing this permission's actions
      */
     private String toCanonicalActionString(String action) {
-        actions = action.trim().toLowerCase();
+        actions = Util.toASCIILowerCase(action.trim());
 
         // get the numerical representation of the action list
         mask = getMask(actions);

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/SecurityManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/SecurityManager.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/SecurityManager.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/SecurityManager.java Tue Sep 28 13:08:47 2010
@@ -32,7 +32,6 @@ import java.security.Permission;
 import java.security.Security;
 import java.security.SecurityPermission;
 import java.util.PropertyPermission;
-import java.util.StringTokenizer;
 
 import org.apache.harmony.luni.util.PriviAction;
 

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/String.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/String.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/String.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/String.java Tue Sep 28 13:08:47 2010
@@ -678,14 +678,17 @@ public final class String implements Ser
      *         specified string.
      */
     public String concat(String string) {
-        if (string.count > 0 && count > 0) {
-            char[] buffer = new char[count + string.count];
+        if (string.count == 0) {
+            return this;
+        }
+
+        char[] buffer = new char[count + string.count];
+        if (count > 0) {
             System.arraycopy(value, offset, buffer, 0, count);
-            System.arraycopy(string.value, string.offset, buffer, count,
-                    string.count);
-            return new String(0, buffer.length, buffer);
         }
-        return count == 0 ? string : this;
+        System.arraycopy(string.value, string.offset, buffer, count,
+                string.count);
+        return new String(0, buffer.length, buffer);
     }
 
     /**

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/net/SocketPermission.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/net/SocketPermission.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/net/SocketPermission.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/net/SocketPermission.java Tue Sep 28 13:08:47 2010
@@ -25,6 +25,7 @@ import java.security.Permission;
 import java.security.PermissionCollection;
 
 import org.apache.harmony.luni.util.Inet6Util;
+import org.apache.harmony.luni.util.Util;
 import org.apache.harmony.luni.internal.nls.Messages;
 
 /**
@@ -222,7 +223,7 @@ public final class SocketPermission exte
             if (pos == length) {
                 parsing = false;
             }
-            action = sb.toString().trim().toLowerCase();
+            action = Util.toASCIILowerCase(sb.toString().trim());
             if (action.equals(actionNames[SP_CONNECT])) {
                 actionsMask |= SP_CONNECT;
             } else if (action.equals(actionNames[SP_LISTEN])) {

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/net/URLClassLoader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/net/URLClassLoader.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/net/URLClassLoader.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/net/URLClassLoader.java Tue Sep 28 13:08:47 2010
@@ -47,6 +47,7 @@ import java.util.jar.JarFile;
 import java.util.jar.Manifest;
 
 import org.apache.harmony.luni.internal.nls.Messages;
+import org.apache.harmony.luni.util.Util;
 
 /**
  * This class loader is responsible for loading classes and resources from a
@@ -1145,12 +1146,12 @@ public class URLClassLoader extends Secu
     private boolean isSealed(Manifest manifest, String dirName) {
         Attributes mainAttributes = manifest.getMainAttributes();
         String value = mainAttributes.getValue(Attributes.Name.SEALED);
-        boolean sealed = value != null && value.toLowerCase().equals("true"); //$NON-NLS-1$
+        boolean sealed = value != null && Util.toASCIILowerCase(value).equals("true"); //$NON-NLS-1$
         Attributes attributes = manifest.getAttributes(dirName);
         if (attributes != null) {
             value = attributes.getValue(Attributes.Name.SEALED);
             if (value != null) {
-                sealed = value.toLowerCase().equals("true"); //$NON-NLS-1$
+                sealed = Util.toASCIILowerCase(value).equals("true"); //$NON-NLS-1$
             }
         }
         return sealed;

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/util/Calendar.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/util/Calendar.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/util/Calendar.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/util/Calendar.java Tue Sep 28 13:08:47 2010
@@ -654,11 +654,12 @@ public abstract class Calendar implement
      */
     public static final int PM = 1;
 
-    private static String[] fieldNames = { "ERA=", "YEAR=", "MONTH=", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-            "WEEK_OF_YEAR=", "WEEK_OF_MONTH=", "DAY_OF_MONTH=", "DAY_OF_YEAR=", //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-            "DAY_OF_WEEK=", "DAY_OF_WEEK_IN_MONTH=", "AM_PM=", "HOUR=", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$
-            "HOUR_OF_DAY", "MINUTE=", "SECOND=", "MILLISECOND=", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-            "ZONE_OFFSET=", "DST_OFFSET=" }; //$NON-NLS-1$ //$NON-NLS-2$
+    @SuppressWarnings("nls")
+    private static String[] fieldNames = { "ERA=", "YEAR=", "MONTH=",
+            "WEEK_OF_YEAR=", "WEEK_OF_MONTH=", "DAY_OF_MONTH=", "DAY_OF_YEAR=",
+            "DAY_OF_WEEK=", "DAY_OF_WEEK_IN_MONTH=", "AM_PM=", "HOUR=",
+            "HOUR_OF_DAY", "MINUTE=", "SECOND=", "MILLISECOND=",
+            "ZONE_OFFSET=", "DST_OFFSET=" };
 
     /**
      * Constructs a {@code Calendar} instance using the default {@code TimeZone} and {@code Locale}.

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/util/IllegalFormatFlagsException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/util/IllegalFormatFlagsException.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/util/IllegalFormatFlagsException.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/util/IllegalFormatFlagsException.java Tue Sep 28 13:08:47 2010
@@ -59,11 +59,12 @@ public class IllegalFormatFlagsException
      * @return the message string of the IllegalFormatFlagsException.
      */
     @Override
+    @SuppressWarnings("nls")
     public String getMessage() {
         StringBuilder buffer = new StringBuilder();
         buffer.append("Flags = '");
         buffer.append(flags);
-        buffer.append("'");
+        buffer.append('\'');
         return buffer.toString();
     }
 

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/util/PropertyPermission.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/util/PropertyPermission.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/util/PropertyPermission.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/util/PropertyPermission.java Tue Sep 28 13:08:47 2010
@@ -108,8 +108,9 @@ public final class PropertyPermission ex
      * @return the actions associated with the receiver.
      */
     @Override
+    @SuppressWarnings("nls")
     public String getActions() {
-        return read ? (write ? "read,write" : "read") : "write"; //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
+        return read ? (write ? "read,write" : "read") : "write";
     }
 
     /**

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/util/TimeZone.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/util/TimeZone.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/util/TimeZone.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/util/TimeZone.java Tue Sep 28 13:08:47 2010
@@ -74,6 +74,11 @@ import org.apache.harmony.luni.util.Priv
 public abstract class TimeZone implements Serializable, Cloneable {
     private static final long serialVersionUID = 3581463369166924961L;
 
+    static {
+        // Force ICU initialization ordering via Locale loading.
+        Locale dummy = Locale.US;
+    }
+
     /**
      * The SHORT display name style.
      */

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java Tue Sep 28 13:08:47 2010
@@ -69,7 +69,7 @@ public class FileURLConnection extends U
         if (fileName == null) {
             fileName = ""; //$NON-NLS-1$
         }
-        fileName = Util.decode(fileName, false);
+        fileName = Util.decode(fileName, false, "UTF-8"); //$NON-NLS-1$
         header = new LinkedHashMap<String, String>();
     }
 

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java Tue Sep 28 13:08:47 2010
@@ -280,6 +280,28 @@ public final class FloatingPointParser {
 		throw new NumberFormatException();
 	}
 
+	/*
+	 * Answers true if the string should be parsed as a hex encoding.
+	 * Assumes the string is trimmed.
+	 */
+    private static boolean parseAsHex(String s) {
+        int length = s.length();
+        if (length < 2) {
+            return false;
+        }
+        char first = s.charAt(0);
+        char second = s.charAt(1);
+        if (first == '+' || first == '-') {
+            // Move along
+            if (length < 3) {
+                return false;
+            }
+            first = second;
+            second = s.charAt(2);
+        }
+        return (first == '0') && (second == 'x' || second == 'X');
+    }
+
 	/**
 	 * Returns the closest double value to the real number in the string.
 	 * 
@@ -305,7 +327,7 @@ public final class FloatingPointParser {
 		}
         
         // See if it could be a hexadecimal representation
-        if (s.toLowerCase().indexOf("0x") != -1) { //$NON-NLS-1$
+        if (parseAsHex(s)) {
             return HexStringParser.parseDouble(s);
         }
         
@@ -354,7 +376,7 @@ public final class FloatingPointParser {
 		}
         
         // See if it could be a hexadecimal representation
-        if (s.toLowerCase().indexOf("0x") != -1) { //$NON-NLS-1$
+        if (parseAsHex(s)) {
             return HexStringParser.parseFloat(s);
         }
         

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/launcher/shared/main.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/launcher/shared/main.c?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/launcher/shared/main.c (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/launcher/shared/main.c Tue Sep 28 13:08:47 2010
@@ -373,7 +373,7 @@ gpProtectedMain (struct haCmdlineOptions
 
   /* main launcher processing in this function */
   rc = invocation
-      (PORTLIB, argc, argv, handle, JNI_VERSION_1_4, JNI_TRUE, mainClass,
+      (PORTLIB, argc, argv, handle, JNI_VERSION_1_4, JNI_FALSE, mainClass,
        classArg, propertiesFileName, isStandaloneJar, vmdllsubdir, versionFlag);
   if (rc)
     {

Propchange: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/launcher/windows/apache.ico
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Tue Sep 28 13:08:47 2010
@@ -1 +1 @@
-application/octet-stream
+image/x-icon

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/shared/filedesc.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/shared/filedesc.c?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/shared/filedesc.c (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/shared/filedesc.c Tue Sep 28 13:08:47 2010
@@ -19,6 +19,7 @@
 #include "nethelp.h"
 #include "exceptions.h"
 #include "harmonyglob.h"
+#include "helpers.h"
 
 JNIEXPORT void JNICALL
 Java_java_io_FileDescriptor_syncImpl (JNIEnv * env, jobject recv)
@@ -57,3 +58,21 @@ Java_java_io_FileDescriptor_oneTimeIniti
     return;
   HARMONY_CACHE_SET (env, FID_java_io_FileDescriptor_descriptor, descriptorFID);
 }
+
+JNIEXPORT jlong JNICALL
+Java_java_io_FileDescriptor_getStdInDescriptor (JNIEnv * env, jclass fdClazz)
+{
+  return getPlatformStdInFD();
+}
+
+JNIEXPORT jlong JNICALL
+Java_java_io_FileDescriptor_getStdOutDescriptor (JNIEnv * env, jclass fdClazz)
+{
+  return getPlatformStdOutFD();
+}
+
+JNIEXPORT jlong JNICALL
+Java_java_io_FileDescriptor_getStdErrDescriptor (JNIEnv * env, jclass fdClazz)
+{
+  return getPlatformStdErrFD();
+}

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/unix/exports.txt
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/unix/exports.txt?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/unix/exports.txt (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/unix/exports.txt Tue Sep 28 13:08:47 2010
@@ -42,6 +42,9 @@ Java_java_io_File_renameToImpl
 Java_java_io_File_rootsImpl
 Java_java_io_File_setLastModifiedImpl
 Java_java_io_File_setReadOnlyImpl
+Java_java_io_FileDescriptor_getStdErrDescriptor
+Java_java_io_FileDescriptor_getStdInDescriptor
+Java_java_io_FileDescriptor_getStdOutDescriptor
 Java_java_io_FileDescriptor_oneTimeInitialization
 Java_java_io_FileDescriptor_syncImpl
 Java_java_io_ObjectStreamClass_getConstructorSignature

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/unix/helpers.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/unix/helpers.c?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/unix/helpers.c (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/unix/helpers.c Tue Sep 28 13:08:47 2010
@@ -252,3 +252,13 @@ void getOSCharset(char *locale, const si
   }
   return;
 }
+
+jlong getPlatformStdInFD() {
+  return (jlong)0;
+}
+jlong getPlatformStdOutFD() {
+  return (jlong)1;
+}
+jlong getPlatformStdErrFD() {
+  return (jlong)2;
+}

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/unix/helpers.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/unix/helpers.h?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/unix/helpers.h (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/unix/helpers.h Tue Sep 28 13:08:47 2010
@@ -35,4 +35,7 @@ I_32 setPlatformLastModified (JNIEnv * e
 I_32 setPlatformReadOnly (JNIEnv * env, char *path);
 int portCmp (const void **a, const void **b);
 void getOSCharset(char *locale, const size_t size);
+jlong getPlatformStdInFD();
+jlong getPlatformStdOutFD();
+jlong getPlatformStdErrFD();
 #endif /* helpers_h */

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/windows/helpers.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/windows/helpers.c?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/windows/helpers.c (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/windows/helpers.c Tue Sep 28 13:08:47 2010
@@ -15,6 +15,11 @@
  *  limitations under the License.
  */
 
+/* windows.h defined UDATA.  Ignore its definition */
+#define UDATA UDATA_win32_
+#include <windows.h>
+#undef UDATA                    /* this is safe because our UDATA is a typedef, not a macro */
+
 /* Undefine the winsockapi because winsock2 defines it.  Removes warnings. */
 #if defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_)
 #undef _WINSOCKAPI_
@@ -446,3 +451,13 @@ void getOSCharset(char *locale, const si
   getCharset(cp, locale, size);
   return;
 }
+
+jlong getPlatformStdInFD() {
+  return (jlong)GetStdHandle(STD_INPUT_HANDLE);
+}
+jlong getPlatformStdOutFD() {
+  return (jlong)GetStdHandle(STD_OUTPUT_HANDLE);
+}
+jlong getPlatformStdErrFD() {
+  return (jlong)GetStdHandle(STD_ERROR_HANDLE);
+}

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/windows/helpers.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/windows/helpers.h?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/windows/helpers.h (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/native/luni/windows/helpers.h Tue Sep 28 13:08:47 2010
@@ -34,4 +34,7 @@ void setPlatformBindOptions (JNIEnv * en
 I_32 setPlatformLastModified (JNIEnv * env, char *path, I_64 time);
 I_32 setPlatformReadOnly (JNIEnv * env, char *path);
 void getOSCharset(char *locale, const size_t size);
+jlong getPlatformStdInFD();
+jlong getPlatformStdOutFD();
+jlong getPlatformStdErrFD();
 #endif /* helpers_h */

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java Tue Sep 28 13:08:47 2010
@@ -18,6 +18,7 @@
 package org.apache.harmony.luni.tests.java.io;
 
 import java.io.File;
+import java.io.FileDescriptor;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
@@ -121,6 +122,31 @@ public class FileInputStreamTest extends
         } catch (IOException e) {
             // Expected
         }
+        
+        // Regression test for HARMONY-6642
+        FileInputStream fis = new FileInputStream(fileName);
+        FileInputStream fis2 = new FileInputStream(fis.getFD());
+        try {
+            fis2.close();
+            fis.read();
+            fail("Able to read from closed fd");
+        } catch (IOException e) {
+            // Expected
+        } finally {
+            try {
+                fis.close();
+            } catch (IOException e) {}
+        }
+        
+        FileInputStream stdin = new FileInputStream(FileDescriptor.in);
+        stdin.close();
+        stdin = new FileInputStream(FileDescriptor.in);
+        try {
+            stdin.read();
+            fail("Able to read from stdin after close");
+        } catch (IOException e) {
+            // Expected
+        }
     }
 
     /**

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java?rev=1002152&r1=1002151&r2=1002152&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java (original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java Tue Sep 28 13:08:47 2010
@@ -1049,9 +1049,8 @@ public class FileTest extends TestCase {
      */
     public void test_hashCode() {
         // Regression for HARMONY-53
-        String mixedFname = "SoMe FiLeNaMe";
-        File mfile = new File(mixedFname);
-        File lfile = new File(mixedFname.toLowerCase());
+        File mfile = new File("SoMe FiLeNaMe"); // Mixed case
+        File lfile = new File("some filename"); // Lower case
 
         if (mfile.equals(lfile)) {
             assertTrue("Assert 0: wrong hashcode", mfile.hashCode() == lfile



Mime
View raw message