-
Bug
-
Resolution: Unresolved
-
P4
-
8u51, 11
-
x86_64
-
windows_10
ADDITIONAL SYSTEM INFORMATION :
Tested in jdk1.8.0_51.
Won't work in jdk11.04, either.
A DESCRIPTION OF THE PROBLEM :
In "Introspector.getTargetPropertyInfo" method, it only support primitive "boolean" type.
if (argCount == 0) {
if (name.startsWith(GET_PREFIX)) {
// Simple getter
pd = new PropertyDescriptor(this.beanClass, name.substring(3), method, null);
} else if (resultType == boolean.class && name.startsWith(IS_PREFIX)) {
// Boolean getter
pd = new PropertyDescriptor(this.beanClass, name.substring(2), method, null);
}
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Define a class with a public method of type "Boolean".
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
print "class" and "isFirst".
ACTUAL -
print "class"
---------- BEGIN SOURCE ----------
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
class Child {
public Boolean isFirst() {
return true;
}
}
public class JdkBug {
public static void main(String[] args) {
try {
BeanInfo beanInfo = Introspector.getBeanInfo(Child.class);
// Only get "class" property
for (PropertyDescriptor propertyDescriptor: beanInfo.getPropertyDescriptors()) {
System.out.println(propertyDescriptor.getName());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
FREQUENCY : always
Tested in jdk1.8.0_51.
Won't work in jdk11.04, either.
A DESCRIPTION OF THE PROBLEM :
In "Introspector.getTargetPropertyInfo" method, it only support primitive "boolean" type.
if (argCount == 0) {
if (name.startsWith(GET_PREFIX)) {
// Simple getter
pd = new PropertyDescriptor(this.beanClass, name.substring(3), method, null);
} else if (resultType == boolean.class && name.startsWith(IS_PREFIX)) {
// Boolean getter
pd = new PropertyDescriptor(this.beanClass, name.substring(2), method, null);
}
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Define a class with a public method of type "Boolean".
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
print "class" and "isFirst".
ACTUAL -
print "class"
---------- BEGIN SOURCE ----------
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
class Child {
public Boolean isFirst() {
return true;
}
}
public class JdkBug {
public static void main(String[] args) {
try {
BeanInfo beanInfo = Introspector.getBeanInfo(Child.class);
// Only get "class" property
for (PropertyDescriptor propertyDescriptor: beanInfo.getPropertyDescriptors()) {
System.out.println(propertyDescriptor.getName());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
FREQUENCY : always