Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalgorzata Janczarska2011-10-18 10:15:31 +0000
committerTomasz Zarna2011-10-18 10:15:31 +0000
commit33f3884b44162a4fc6b1236e969d2804dcd07c28 (patch)
tree48a66f21738340afc1009cde08e1210810b2478e /tests/org.eclipse.compare.tests
parent80a54a39d399d98f5ea5ad12908faf3b80d625a7 (diff)
downloadeclipse.platform.team-33f3884b44162a4fc6b1236e969d2804dcd07c28.tar.gz
eclipse.platform.team-33f3884b44162a4fc6b1236e969d2804dcd07c28.tar.xz
eclipse.platform.team-33f3884b44162a4fc6b1236e969d2804dcd07c28.zip
bug 347557: NPE when saving a file in a compare editor (always)I20111018-0800
Diffstat (limited to 'tests/org.eclipse.compare.tests')
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/ReflectionUtils.java23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/ReflectionUtils.java b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/ReflectionUtils.java
index 538738a4f..8d19b3415 100644
--- a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/ReflectionUtils.java
+++ b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/ReflectionUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
+ * Copyright (c) 2009, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -53,4 +53,25 @@ public class ReflectionUtils {
return ret;
}
+ public static Object getField(Object object, String name, boolean deep)
+ throws IllegalArgumentException, IllegalAccessException,
+ SecurityException, NoSuchFieldException {
+ Class clazz = object.getClass();
+ NoSuchFieldException ex = null;
+ while (clazz != null) {
+ try {
+ Field field = clazz.getDeclaredField(name);
+ field.setAccessible(true);
+ return field.get(object);
+ } catch (NoSuchFieldException e) {
+ if (ex == null) {
+ ex = e;
+ }
+ if (!deep)
+ break;
+ clazz = clazz.getSuperclass();
+ }
+ }
+ throw ex;
+ }
} \ No newline at end of file

Back to the top