Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkscheglov2014-09-25 02:15:13 +0000
committerkscheglov2014-09-25 02:15:13 +0000
commit58a062a5e78e7f807b775e44964312b9c6d5f80a (patch)
treed1e53df8975de2ff04b2725daedf77d9cf19df41
parentddb982ee34f307609437cf9befe7a6bad20dd8a9 (diff)
downloadorg.eclipse.windowbuilder-58a062a5e78e7f807b775e44964312b9c6d5f80a.tar.gz
org.eclipse.windowbuilder-58a062a5e78e7f807b775e44964312b9c6d5f80a.tar.xz
org.eclipse.windowbuilder-58a062a5e78e7f807b775e44964312b9c6d5f80a.zip
Possible fix for
https://bugs.eclipse.org/bugs/show_bug.cgi?id=444704
-rw-r--r--org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/JavaInfoUtils.java4
-rw-r--r--org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/description/helpers/FactoryDescriptionHelper.java2
-rw-r--r--org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/description/rules/StandardBeanPropertiesRule.java4
-rw-r--r--org.eclipse.wb.core.xml/src/org/eclipse/wb/internal/core/xml/model/description/rules/CreatePropertiesPropertyDescriptorRule.java4
-rw-r--r--org.eclipse.wb.core/src/org/eclipse/wb/internal/core/utils/reflect/ReflectionUtils.java40
5 files changed, 43 insertions, 11 deletions
diff --git a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/JavaInfoUtils.java b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/JavaInfoUtils.java
index 512259c3..ffa345ef 100644
--- a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/JavaInfoUtils.java
+++ b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/JavaInfoUtils.java
@@ -444,9 +444,9 @@ public class JavaInfoUtils {
List<PropertyDescriptor> propertyDescriptors = host.getDescription().getPropertyDescriptors();
// check all PropertyDescriptor's
for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
- Method setMethod = propertyDescriptor.getWriteMethod();
+ Method setMethod = ReflectionUtils.getWriteMethod(propertyDescriptor);
// prepare "getter"
- Method getMethod = propertyDescriptor.getReadMethod();
+ Method getMethod = ReflectionUtils.getReadMethod(propertyDescriptor);
if (getMethod == null) {
continue;
}
diff --git a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/description/helpers/FactoryDescriptionHelper.java b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/description/helpers/FactoryDescriptionHelper.java
index 89028917..d70b857f 100644
--- a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/description/helpers/FactoryDescriptionHelper.java
+++ b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/description/helpers/FactoryDescriptionHelper.java
@@ -787,7 +787,7 @@ public class FactoryDescriptionHelper {
String title) {
for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
// prepare setter
- Method setMethod = propertyDescriptor.getWriteMethod();
+ Method setMethod = ReflectionUtils.getWriteMethod(propertyDescriptor);
if (setMethod == null) {
continue;
}
diff --git a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/description/rules/StandardBeanPropertiesRule.java b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/description/rules/StandardBeanPropertiesRule.java
index 0008f51b..8fc9af4f 100644
--- a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/description/rules/StandardBeanPropertiesRule.java
+++ b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/description/rules/StandardBeanPropertiesRule.java
@@ -51,8 +51,8 @@ public final class StandardBeanPropertiesRule extends Rule {
for (PropertyDescriptor propertyDescriptor : descriptors) {
// prepare property parts
String propertyName = propertyDescriptor.getName();
- Method setMethod = propertyDescriptor.getWriteMethod();
- Method getMethod = propertyDescriptor.getReadMethod();
+ Method setMethod = ReflectionUtils.getWriteMethod(propertyDescriptor);
+ Method getMethod = ReflectionUtils.getReadMethod(propertyDescriptor);
// add property
if (setMethod != null) {
GenericPropertyDescription propertyDescription =
diff --git a/org.eclipse.wb.core.xml/src/org/eclipse/wb/internal/core/xml/model/description/rules/CreatePropertiesPropertyDescriptorRule.java b/org.eclipse.wb.core.xml/src/org/eclipse/wb/internal/core/xml/model/description/rules/CreatePropertiesPropertyDescriptorRule.java
index 23fb657a..d393ae53 100644
--- a/org.eclipse.wb.core.xml/src/org/eclipse/wb/internal/core/xml/model/description/rules/CreatePropertiesPropertyDescriptorRule.java
+++ b/org.eclipse.wb.core.xml/src/org/eclipse/wb/internal/core/xml/model/description/rules/CreatePropertiesPropertyDescriptorRule.java
@@ -57,7 +57,7 @@ public final class CreatePropertiesPropertyDescriptorRule extends Rule {
private void addSingleProperty(ComponentDescription componentDescription,
PropertyDescriptor propertyDescriptor) throws Exception {
- Method setMethod = propertyDescriptor.getWriteMethod();
+ Method setMethod = ReflectionUtils.getWriteMethod(propertyDescriptor);
if (setMethod == null) {
return;
}
@@ -67,7 +67,7 @@ public final class CreatePropertiesPropertyDescriptorRule extends Rule {
// prepare description parts
String title = propertyDescriptor.getName();
String attribute = StringUtils.substringBeforeLast(StringUtils.uncapitalize(title), "(");
- Method getMethod = propertyDescriptor.getReadMethod();
+ Method getMethod = ReflectionUtils.getReadMethod(propertyDescriptor);
Class<?> propertyType = resolvePropertyType(componentDescription, setMethod);
// prepare property parts
String id =
diff --git a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/utils/reflect/ReflectionUtils.java b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/utils/reflect/ReflectionUtils.java
index a6d4b460..ec23ac98 100644
--- a/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/utils/reflect/ReflectionUtils.java
+++ b/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/utils/reflect/ReflectionUtils.java
@@ -29,6 +29,7 @@ import java.beans.IndexedPropertyDescriptor;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
+import java.lang.ref.SoftReference;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
@@ -64,6 +65,37 @@ public class ReflectionUtils {
////////////////////////////////////////////////////////////////////////////
//
+ // Access
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ /**
+ * Java 8 uses "MethodRef" that uses {@link SoftReference} to a {@link Method}. But this means
+ * that when it looses a reference to a <em>protected</em> {@link Method}, it cannot restore it. I
+ * wish we had done it differently, not by using {@link PropertyDescriptor}.
+ */
+ public static Method getWriteMethod(PropertyDescriptor propertyDescriptor) {
+ try {
+ return propertyDescriptor.getWriteMethod();
+ } catch (Throwable e) {
+ return null;
+ }
+ }
+
+ /**
+ * Java 8 uses "MethodRef" that uses {@link SoftReference} to a {@link Method}. But this means
+ * that when it looses a reference to a <em>protected</em> {@link Method}, it cannot restore it. I
+ * wish we had done it differently, not by using {@link PropertyDescriptor}.
+ */
+ public static Method getReadMethod(PropertyDescriptor propertyDescriptor) {
+ try {
+ return propertyDescriptor.getReadMethod();
+ } catch (Throwable e) {
+ return null;
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ //
// Class
//
////////////////////////////////////////////////////////////////////////////
@@ -1419,8 +1451,8 @@ public class ReflectionUtils {
Map<String, Method> propertyToSetter = Maps.newTreeMap();
// append existing getters/setters
for (PropertyDescriptor propertyDescriptor : descriptors) {
- Method readMethod = propertyDescriptor.getReadMethod();
- Method writeMethod = propertyDescriptor.getWriteMethod();
+ Method readMethod = getReadMethod(propertyDescriptor);
+ Method writeMethod = getWriteMethod(propertyDescriptor);
if (readMethod != null) {
String propertyName = getQualifiedPropertyName(readMethod);
propertyToGetter.put(propertyName, readMethod);
@@ -1466,8 +1498,8 @@ public class ReflectionUtils {
private static void makeMethodsAccessible(List<PropertyDescriptor> descriptors) {
for (PropertyDescriptor propertyDescriptor : descriptors) {
- Method getMethod = propertyDescriptor.getReadMethod();
- Method setMethod = propertyDescriptor.getWriteMethod();
+ Method getMethod = getReadMethod(propertyDescriptor);
+ Method setMethod = getWriteMethod(propertyDescriptor);
if (getMethod != null) {
getMethod.setAccessible(true);
}

Back to the top