I think I have found a solution for a bug JDK-8071693.
The problem is the Introspector does scan only in super classes and does not
know about default methods.
I just added condition method.isDefault() and manual testing proves my idea
does work. I did NOT run junit tests.
Can you please review this patch in attachment?
LK
Bug: https://bugs.openjdk.java.net/browse/JDK-8071693
--- jdk/src/share/classes/java/beans/Introspector.java 2014-03-04 03:57:57.000000000 +0100
+++ Introspector.java 2016-06-29 19:39:28.309976038 +0200
@@ -1294,21 +1294,19 @@
result = clz.getMethods();
for (int i = 0; i < result.length; i++) {
Method method = result[i];
- if (!method.getDeclaringClass().equals(clz)) {
- result[i] = null; // ignore methods declared elsewhere
- }
- else {
+ if (method.getDeclaringClass().equals(clz) || method.isDefault()) {
try {
method = MethodFinder.findAccessibleMethod(method);
- Class<?> type = method.getDeclaringClass();
+ final Class<?> type = method.getDeclaringClass();
result[i] = type.equals(clz) || type.isInterface()
? method
: null; // ignore methods from superclasses
- }
- catch (NoSuchMethodException exception) {
+ } catch (NoSuchMethodException exception) {
// commented out because of 6976577
// result[i] = null; // ignore inaccessible methods
}
+ } else {
+ result[i] = null; // ignore methods declared elsewhere
}
}
declaredMethodCache.put(clz, result);