summaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
authorDenis Anisimov <denis@vaadin.com>2014-10-11 17:41:48 +0300
committerMarkus Koivisto <markus@vaadin.com>2014-10-14 18:06:19 +0300
commit6a4a4a72f2ed29209e64d3f21d36507f3ae30c27 (patch)
treea47b95d69c0e887ab0d2ed93864d41eb26eed8e9 /server/src
parent55a7cf34e5a52486df36355f7bfbf7fccc1bf035 (diff)
downloadvaadin-framework-6a4a4a72f2ed29209e64d3f21d36507f3ae30c27.tar.gz
vaadin-framework-6a4a4a72f2ed29209e64d3f21d36507f3ae30c27.zip
Use workaround for JDK6 Introspection bug JDK-6788525 (#14839).
Change-Id: Ib7ef769b7537675c681ac1fab24a425d19a267e7
Diffstat (limited to 'server/src')
-rw-r--r--server/src/com/vaadin/data/util/BeanItem.java68
1 files changed, 65 insertions, 3 deletions
diff --git a/server/src/com/vaadin/data/util/BeanItem.java b/server/src/com/vaadin/data/util/BeanItem.java
index ac3ef86434..12d9b23d0a 100644
--- a/server/src/com/vaadin/data/util/BeanItem.java
+++ b/server/src/com/vaadin/data/util/BeanItem.java
@@ -214,13 +214,75 @@ public class BeanItem<BT> extends PropertysetItem {
}
BeanInfo info = Introspector.getBeanInfo(beanClass);
- propertyDescriptors.addAll(Arrays.asList(info
- .getPropertyDescriptors()));
+ propertyDescriptors.addAll(getPropertyDescriptors(info));
return propertyDescriptors;
} else {
BeanInfo info = Introspector.getBeanInfo(beanClass);
- return Arrays.asList(info.getPropertyDescriptors());
+ return getPropertyDescriptors(info);
+ }
+ }
+
+ // Workaround for Java6 bug JDK-6788525. Do nothing for JDK7+.
+ private static List<PropertyDescriptor> getPropertyDescriptors(
+ BeanInfo beanInfo) {
+ PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
+ List<PropertyDescriptor> result = new ArrayList<PropertyDescriptor>(
+ descriptors.length);
+ for (PropertyDescriptor descriptor : descriptors) {
+ try {
+ Method readMethod = getMethodFromBridge(descriptor
+ .getReadMethod());
+ if (readMethod != null) {
+ Method writeMethod = getMethodFromBridge(
+ descriptor.getWriteMethod(),
+ readMethod.getReturnType());
+ if (writeMethod == null) {
+ writeMethod = descriptor.getWriteMethod();
+ }
+ PropertyDescriptor descr = new PropertyDescriptor(
+ descriptor.getName(), readMethod, writeMethod);
+ result.add(descr);
+ } else {
+ result.add(descriptor);
+ }
+ } catch (SecurityException ignore) {
+ // handle next descriptor
+ } catch (IntrospectionException e) {
+ result.add(descriptor);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Return not bridged method for bridge {@code bridgeMethod} method. If
+ * method {@code bridgeMethod} is not bridge method then return null.
+ */
+ private static Method getMethodFromBridge(Method bridgeMethod)
+ throws SecurityException {
+ if (bridgeMethod == null) {
+ return null;
+ }
+ return getMethodFromBridge(bridgeMethod,
+ bridgeMethod.getParameterTypes());
+ }
+
+ /**
+ * Return not bridged method for bridge {@code bridgeMethod} method and
+ * declared {@code paramTypes}. If method {@code bridgeMethod} is not bridge
+ * method then return null.
+ */
+ private static Method getMethodFromBridge(Method bridgeMethod,
+ Class<?>... paramTypes) throws SecurityException {
+ if (bridgeMethod == null || !bridgeMethod.isBridge()) {
+ return null;
+ }
+ try {
+ return bridgeMethod.getDeclaringClass().getMethod(
+ bridgeMethod.getName(), paramTypes);
+ } catch (NoSuchMethodException e) {
+ return null;
}
}