summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-05-04 16:22:33 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-05-04 16:22:33 -0700
commitd52d8dee7768e04b936b8df86028823bdc5b1dc6 (patch)
tree0765f14ba821b33cf36adcfb96184bc697f03d90
parent4cc03076c2609cf137c24679e05ea86fa49954ec (diff)
parent2c9eec6b1d072a665b17dd4285260aa4d4fadcf4 (diff)
downloadframeworks_base-d52d8dee7768e04b936b8df86028823bdc5b1dc6.zip
frameworks_base-d52d8dee7768e04b936b8df86028823bdc5b1dc6.tar.gz
frameworks_base-d52d8dee7768e04b936b8df86028823bdc5b1dc6.tar.bz2
am 2c9eec6: Merge change 952 into donut
Merge commit '2c9eec6b1d072a665b17dd4285260aa4d4fadcf4' * commit '2c9eec6b1d072a665b17dd4285260aa4d4fadcf4': Debug: Minor cleanup
-rw-r--r--core/java/android/os/Debug.java79
1 files changed, 40 insertions, 39 deletions
diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java
index 6ab4ce4..a7de895 100644
--- a/core/java/android/os/Debug.java
+++ b/core/java/android/os/Debug.java
@@ -768,7 +768,7 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
final TypedProperties tp = new TypedProperties();
// Read the properties from each of the files, if present.
- for (String file: files) {
+ for (String file : files) {
Reader r;
try {
r = new FileReader(file);
@@ -777,16 +777,16 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
continue;
}
- Exception failure = null;
try {
tp.load(r);
- } catch (IOException ex) {
- failure = ex;
- } catch (TypedProperties.ParseException ex) {
- failure = ex;
- }
- if (failure != null) {
- throw new RuntimeException("Problem loading " + file, failure);
+ } catch (Exception ex) {
+ throw new RuntimeException("Problem loading " + file, ex);
+ } finally {
+ try {
+ r.close();
+ } catch (IOException ex) {
+ // Ignore this error.
+ }
}
}
@@ -819,7 +819,7 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
return false;
}
try {
- return fieldClass == (Class<?>)primitiveTypeField.get(null);
+ return fieldClass == (Class<?>) primitiveTypeField.get(null);
} catch (IllegalAccessException ex) {
return false;
}
@@ -830,34 +830,35 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
* Looks up the property that corresponds to the field, and sets the field's value
* if the types match.
*/
- private static void modifyFieldIfSet(final Field field, final String propertyName) {
+ private static void modifyFieldIfSet(final Field field, final TypedProperties properties,
+ final String propertyName) {
if (field.getType() == java.lang.String.class) {
- int stringInfo = debugProperties.getStringInfo(propertyName);
+ int stringInfo = properties.getStringInfo(propertyName);
switch (stringInfo) {
- case TypedProperties.STRING_SET:
- // Handle as usual below.
- break;
- case TypedProperties.STRING_NULL:
- try {
- field.set(null, null); // null object for static fields; null string
- } catch (IllegalAccessException ex) {
+ case TypedProperties.STRING_SET:
+ // Handle as usual below.
+ break;
+ case TypedProperties.STRING_NULL:
+ try {
+ field.set(null, null); // null object for static fields; null string
+ } catch (IllegalAccessException ex) {
+ throw new IllegalArgumentException(
+ "Cannot set field for " + propertyName, ex);
+ }
+ return;
+ case TypedProperties.STRING_NOT_SET:
+ return;
+ case TypedProperties.STRING_TYPE_MISMATCH:
throw new IllegalArgumentException(
- "Cannot set field for " + propertyName, ex);
- }
- return;
- case TypedProperties.STRING_NOT_SET:
- return;
- case TypedProperties.STRING_TYPE_MISMATCH:
- throw new IllegalArgumentException(
- "Type of " + propertyName + " " +
- " does not match field type (" + field.getType() + ")");
- default:
- throw new IllegalStateException(
- "Unexpected getStringInfo(" + propertyName + ") return value " +
- stringInfo);
+ "Type of " + propertyName + " " +
+ " does not match field type (" + field.getType() + ")");
+ default:
+ throw new IllegalStateException(
+ "Unexpected getStringInfo(" + propertyName + ") return value " +
+ stringInfo);
}
}
- Object value = debugProperties.get(propertyName);
+ Object value = properties.get(propertyName);
if (value != null) {
if (!fieldTypeMatches(field, value.getClass())) {
throw new IllegalArgumentException(
@@ -886,7 +887,7 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
* Class setup: define a class whose only fields are non-final, static
* primitive types (except for "char") or Strings. In a static block
* after the field definitions/initializations, pass the class to
- * this method, Debug.setPropertiesOn(). Example:
+ * this method, Debug.setFieldsOn(). Example:
* <pre>
* package com.example;
*
@@ -903,11 +904,11 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
*
* // This MUST appear AFTER all fields are defined and initialized!
* static {
- * Debug.setPropertiesOn(MyDebugVars.class);
+ * Debug.setFieldsOn(MyDebugVars.class);
* }
* }
* </pre>
- * setPropertiesOn() may override the value of any field in the class based
+ * setFieldsOn() may override the value of any field in the class based
* on internal properties that are fixed at boot time.
* <p>
* These properties are only set during platform debugging, and are not
@@ -920,7 +921,7 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
* or if the type of the field does not match the type of
* the internal debugging property value.
*/
- public static void setPropertiesOn(Class<?> cl) {
+ public static void setFieldsOn(Class<?> cl) {
if (Config.DEBUG) {
if (debugProperties != null) {
/* Only look for fields declared directly by the class,
@@ -934,12 +935,12 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
throw new IllegalArgumentException(propertyName +
" must be static and non-final");
}
- modifyFieldIfSet(field, propertyName);
+ modifyFieldIfSet(field, debugProperties, propertyName);
}
}
} else {
Log.w("android.os.Debug",
- "setPropertiesOn(" + (cl == null ? "null" : cl.getName()) +
+ "setFieldsOn(" + (cl == null ? "null" : cl.getName()) +
") called in non-DEBUG build");
}
}