|
31 | 31 | import java.lang.reflect.Modifier;
|
32 | 32 |
|
33 | 33 | import java.util.ArrayList;
|
| 34 | +import java.util.Collections; |
34 | 35 | import java.util.Comparator;
|
35 | 36 | import java.util.Enumeration;
|
36 | 37 | import java.util.List;
|
@@ -116,6 +117,14 @@ private List<Method> findNonVoidWriteMethods(MethodDescriptor[] methodDescriptor
|
116 | 117 | matches.add(method);
|
117 | 118 | }
|
118 | 119 | }
|
| 120 | + // sort non-void returning write methods to guard against the ill effects of |
| 121 | + // non-deterministic sorting of methods returned from Class#getDeclaredMethods |
| 122 | + // under JDK 7. See http://bugs.sun.com/view_bug.do?bug_id=7023180 |
| 123 | + Collections.sort(matches, new Comparator<Method>() { |
| 124 | + public int compare(Method m1, Method m2) { |
| 125 | + return m2.toString().compareTo(m1.toString()); |
| 126 | + } |
| 127 | + }); |
119 | 128 | return matches;
|
120 | 129 | }
|
121 | 130 |
|
@@ -261,7 +270,7 @@ public SimpleNonIndexedPropertyDescriptor(PropertyDescriptor original)
|
261 | 270 | public SimpleNonIndexedPropertyDescriptor(String propertyName,
|
262 | 271 | Method readMethod, Method writeMethod) throws IntrospectionException {
|
263 | 272 |
|
264 |
| - super(propertyName, readMethod, writeMethod); |
| 273 | + super(propertyName, null, null); |
265 | 274 | this.setReadMethod(readMethod);
|
266 | 275 | this.setWriteMethod(writeMethod);
|
267 | 276 | this.propertyType = findPropertyType(readMethod, writeMethod);
|
@@ -350,7 +359,7 @@ public SimpleIndexedPropertyDescriptor(String propertyName,
|
350 | 359 | Method indexedReadMethod, Method indexedWriteMethod)
|
351 | 360 | throws IntrospectionException {
|
352 | 361 |
|
353 |
| - super(propertyName, readMethod, writeMethod, indexedReadMethod, indexedWriteMethod); |
| 362 | + super(propertyName, null, null, null, null); |
354 | 363 | this.setReadMethod(readMethod);
|
355 | 364 | this.setWriteMethod(writeMethod);
|
356 | 365 | this.propertyType = findPropertyType(readMethod, writeMethod);
|
@@ -495,7 +504,7 @@ public static void copyNonMethodProperties(PropertyDescriptor source, PropertyDe
|
495 | 504 | // copy all attributes (emulating behavior of private FeatureDescriptor#addTable)
|
496 | 505 | Enumeration<String> keys = source.attributeNames();
|
497 | 506 | while (keys.hasMoreElements()) {
|
498 |
| - String key = (String)keys.nextElement(); |
| 507 | + String key = keys.nextElement(); |
499 | 508 | target.setValue(key, source.getValue(key));
|
500 | 509 | }
|
501 | 510 |
|
|
0 commit comments