On Thu, 11 Nov 2004, Robert Schuster wrote:
Thanks for you patch.
Is the sort order defined somewhere? (If not: Do you think applications
rely on it?)
I was not able to find any documentation on the sort order. Thus I would
say a properly written app should not rely on it. However by matching jdk
any tests that print the properties will have the same output and any
applications that do rely on the behavior will still work.
Could please you add a comment in BeanInfoEmbryo that says that by using
the TreeMap
the sort order of the JDK is matched.
Done, see new patch.
Craig
cu
Robert
Index: ChangeLog
===================================================================
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.2768
diff -u -r1.2768 ChangeLog
--- ChangeLog 10 Nov 2004 03:41:21 -0000 1.2768
+++ ChangeLog 11 Nov 2004 17:23:36 -0000
@@ -1,3 +1,7 @@
+2004-11-10 Craig Black <address@hidden>
+
+ * gnu/java/beans/BeanInfoEmbryo.java: Use TreeMap for proper sorting.
+
2004-11-09 Tom Tromey <address@hidden>
* scripts/eclipse-gnu.xml: New file.
Index: gnu/java/beans/BeanInfoEmbryo.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/beans/BeanInfoEmbryo.java,v
retrieving revision 1.9
diff -u -r1.9 BeanInfoEmbryo.java
--- gnu/java/beans/BeanInfoEmbryo.java 21 May 2004 07:54:33 -0000 1.9
+++ gnu/java/beans/BeanInfoEmbryo.java 11 Nov 2004 17:23:36 -0000
@@ -48,6 +48,9 @@
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
import java.util.Vector;
/**
@@ -66,7 +69,10 @@
**/
public class BeanInfoEmbryo {
- Hashtable properties = new Hashtable();
+
+ // by using a TreeMap the properties will be sorted alphabetically by name
+ // which matches the (undocumented) behavior of jdk
+ TreeMap properties = new TreeMap();
Hashtable events = new Hashtable();
Vector methods = new Vector();
@@ -85,9 +91,9 @@
PropertyDescriptor[] Aproperties = new PropertyDescriptor[properties.size()];
int i = 0;
- Enumeration e = properties.elements();
- while (e.hasMoreElements()) {
- Aproperties[i] = (PropertyDescriptor) e.nextElement();
+ Iterator it = properties.entrySet().iterator();
+ while (it.hasNext()) {
+ Aproperties[i] = (PropertyDescriptor) (((Map.Entry)it.next()).getValue());
if(defaultPropertyName != null && Aproperties[i].getName().equals(defaultPropertyName)) {
defaultProperty = i;
}
@@ -96,7 +102,7 @@
EventSetDescriptor[] Aevents = new EventSetDescriptor[events.size()];
i = 0;
- e = events.elements();
+ Enumeration e = events.elements();
while (e.hasMoreElements()) {
Aevents[i] = (EventSetDescriptor) e.nextElement();
if(defaultEventName != null && Aevents[i].getName().equals(defaultEventName)) {
_______________________________________________
Classpath-patches mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/classpath-patches