diff options
author | Malgorzata Janczarska | 2011-10-18 10:15:31 +0000 |
---|---|---|
committer | Tomasz Zarna | 2011-10-18 10:15:31 +0000 |
commit | 33f3884b44162a4fc6b1236e969d2804dcd07c28 (patch) | |
tree | 48a66f21738340afc1009cde08e1210810b2478e /tests/org.eclipse.compare.tests | |
parent | 80a54a39d399d98f5ea5ad12908faf3b80d625a7 (diff) | |
download | eclipse.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.java | 23 |
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 |