Details
-
Bug
-
Resolution: Fixed
-
P4
-
8u25, 9
-
b21
-
x86
-
windows_8
Description
FULL PRODUCT VERSION :
JDK 1.8.0 Update 25
ADDITIONAL OS VERSION INFORMATION :
Windows 8.1 Pro 64 Bit
A DESCRIPTION OF THE PROBLEM :
When retrieving the properties from a bean the java.beans.Introspector does not return the properties defined by getter/setter methods implemented as default methods in an interface implemented by the bean.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Implement a default getter method in an interface. Create a class that implements the interface but does not override the default method. Now use Introspector.getBeanInfo(beanClass) to get the properties.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The result should contain the properties defined by the default methods in the interface.
ACTUAL -
The result does not contain the properties defined by the default methods in the interface.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
public class Test {
public static interface Named {
public default String getName() {
return "always the same";
}
}
public static class NamedBean implements Named {
}
public static void main(final String[] args) throws IntrospectionException {
for (final PropertyDescriptor desc : Introspector.getBeanInfo(NamedBean.class).getPropertyDescriptors()) {
System.out.println(desc.getName());
}
// prints out "class" as the only property
// should have inclided "name" too
}
}
---------- END SOURCE ----------
JDK 1.8.0 Update 25
ADDITIONAL OS VERSION INFORMATION :
Windows 8.1 Pro 64 Bit
A DESCRIPTION OF THE PROBLEM :
When retrieving the properties from a bean the java.beans.Introspector does not return the properties defined by getter/setter methods implemented as default methods in an interface implemented by the bean.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Implement a default getter method in an interface. Create a class that implements the interface but does not override the default method. Now use Introspector.getBeanInfo(beanClass) to get the properties.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The result should contain the properties defined by the default methods in the interface.
ACTUAL -
The result does not contain the properties defined by the default methods in the interface.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
public class Test {
public static interface Named {
public default String getName() {
return "always the same";
}
}
public static class NamedBean implements Named {
}
public static void main(final String[] args) throws IntrospectionException {
for (final PropertyDescriptor desc : Introspector.getBeanInfo(NamedBean.class).getPropertyDescriptors()) {
System.out.println(desc.getName());
}
// prints out "class" as the only property
// should have inclided "name" too
}
}
---------- END SOURCE ----------
Attachments
Issue Links
- csr for
-
JDK-8306477 Introspector ignores default interface methods
- Closed
- duplicates
-
JDK-8139193 java.beans.Introspector misses default interface methods
- Resolved
-
JDK-8182025 PropertyDescriptor ignores default methods from interfaces implemented by superclasses
- Resolved