am 7b3745fe: Merge "Update scrubClass() to match CoreTestRunner."
# Via Android (Google) Code Review (1) and Jeff Sharkey (1)
* commit '7b3745fe9aa0d78add1045258d2855d5980a650b':
Update scrubClass() to match CoreTestRunner.
diff --git a/core/java/android/test/AndroidTestCase.java b/core/java/android/test/AndroidTestCase.java
index 0c8cbe6..0635559 100644
--- a/core/java/android/test/AndroidTestCase.java
+++ b/core/java/android/test/AndroidTestCase.java
@@ -20,9 +20,11 @@
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
+
import junit.framework.TestCase;
import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
/**
* Extend this if you need to access Resources or other things that depend on Activity Context.
@@ -152,11 +154,11 @@
* @throws IllegalAccessException
*/
protected void scrubClass(final Class<?> testCaseClass)
- throws IllegalAccessException {
+ throws IllegalAccessException {
final Field[] fields = getClass().getDeclaredFields();
for (Field field : fields) {
- final Class<?> fieldClass = field.getDeclaringClass();
- if (testCaseClass.isAssignableFrom(fieldClass) && !field.getType().isPrimitive()) {
+ if (!field.getType().isPrimitive() &&
+ !Modifier.isStatic(field.getModifiers())) {
try {
field.setAccessible(true);
field.set(this, null);
@@ -170,6 +172,4 @@
}
}
}
-
-
}