Modified getField(Class, String) method in order to be able to introspect
private fields from parent class.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1350680 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java b/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
index d89b4fc..b9d87e7 100644
--- a/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
+++ b/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
@@ -325,9 +325,22 @@
protected static Field getField( Class<?> type, String fieldName ) throws NoSuchFieldException
{
- Field field = type.getDeclaredField( fieldName );
- field.setAccessible( true );
- return field;
+ Class<?> clazz = type;
+ while (clazz != null)
+ {
+ Field[] fields = clazz.getDeclaredFields();
+ for (int i = 0; i < fields.length; i++)
+ {
+ Field field = fields[i];
+ if (field.getName().equals(fieldName))
+ {
+ field.setAccessible( true );
+ return field;
+ }
+ }
+ clazz = clazz.getSuperclass();
+ }
+ throw new NoSuchFieldException(fieldName);
}