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