Hello,
The attached patch uses a TreeMap to ensure PropertyDescriptors
are sorted properly as demonstrated by the attached test case.
The GNU Classpath behavior now matches jdk, okay to commit?
Thanks,
Craig
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 10 Nov 2004 21:27:10 -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 10 Nov 2004 21:27:10 -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,8 @@
**/
public class BeanInfoEmbryo {
- Hashtable properties = new Hashtable();
+
+ TreeMap properties = new TreeMap();
Hashtable events = new Hashtable();
Vector methods = new Vector();
@@ -85,9 +89,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 +100,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)) {
import java.beans.*;
public class Main
{
public static void main(String[] a)
throws Throwable
{
BeanInfo bi = Introspector.getBeanInfo(GetBeanInfoTestClass.class,
Object.class);
System.out.println(bi.getPropertyDescriptors().length);
PropertyDescriptor[] pd = bi.getPropertyDescriptors();
for (int i=0; i < pd.length; i++)
{
PropertyDescriptor p = pd[i];
System.out.println(p.getReadMethod());
System.out.println(p.getWriteMethod());
System.out.println();
}
}
private static class GetBeanInfoTestClass
{
public void setCorrectProperty(int i)
{
}
public int getCorrectProperty()
{
return 0;
}
public int getCorrectReadOnlyProperty()
{
return 0;
}
public void setCorrectWriteOnlyProperty(int i)
{
}
void setSomeValue(int i)
{
}
int getSomeValue()
{
return 0;
}
public static void setSomeStaticValue(int i)
{
}
public static int getSomeStaticValue()
{
return 0;
}
}
}
_______________________________________________
Classpath-patches mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/classpath-patches