Merge change 952 into donut

* changes:
  Debug: Minor cleanup
This commit is contained in:
Android (Google) Code Review
2009-05-04 16:20:14 -07:00

View File

@@ -758,16 +758,16 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
continue; continue;
} }
Exception failure = null;
try { try {
tp.load(r); tp.load(r);
} catch (Exception ex) {
throw new RuntimeException("Problem loading " + file, ex);
} finally {
try {
r.close();
} catch (IOException ex) { } catch (IOException ex) {
failure = ex; // Ignore this error.
} catch (TypedProperties.ParseException ex) {
failure = ex;
} }
if (failure != null) {
throw new RuntimeException("Problem loading " + file, failure);
} }
} }
@@ -811,9 +811,10 @@ 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 * Looks up the property that corresponds to the field, and sets the field's value
* if the types match. * 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) { if (field.getType() == java.lang.String.class) {
int stringInfo = debugProperties.getStringInfo(propertyName); int stringInfo = properties.getStringInfo(propertyName);
switch (stringInfo) { switch (stringInfo) {
case TypedProperties.STRING_SET: case TypedProperties.STRING_SET:
// Handle as usual below. // Handle as usual below.
@@ -838,7 +839,7 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
stringInfo); stringInfo);
} }
} }
Object value = debugProperties.get(propertyName); Object value = properties.get(propertyName);
if (value != null) { if (value != null) {
if (!fieldTypeMatches(field, value.getClass())) { if (!fieldTypeMatches(field, value.getClass())) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
@@ -867,7 +868,7 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
* Class setup: define a class whose only fields are non-final, static * Class setup: define a class whose only fields are non-final, static
* primitive types (except for "char") or Strings. In a static block * primitive types (except for "char") or Strings. In a static block
* after the field definitions/initializations, pass the class to * after the field definitions/initializations, pass the class to
* this method, Debug.setPropertiesOn(). Example: * this method, Debug.setFieldsOn(). Example:
* <pre> * <pre>
* package com.example; * package com.example;
* *
@@ -884,11 +885,11 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
* *
* // This MUST appear AFTER all fields are defined and initialized! * // This MUST appear AFTER all fields are defined and initialized!
* static { * static {
* Debug.setPropertiesOn(MyDebugVars.class); * Debug.setFieldsOn(MyDebugVars.class);
* } * }
* } * }
* </pre> * </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. * on internal properties that are fixed at boot time.
* <p> * <p>
* These properties are only set during platform debugging, and are not * These properties are only set during platform debugging, and are not
@@ -901,7 +902,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 * or if the type of the field does not match the type of
* the internal debugging property value. * the internal debugging property value.
*/ */
public static void setPropertiesOn(Class<?> cl) { public static void setFieldsOn(Class<?> cl) {
if (Config.DEBUG) { if (Config.DEBUG) {
if (debugProperties != null) { if (debugProperties != null) {
/* Only look for fields declared directly by the class, /* Only look for fields declared directly by the class,
@@ -915,12 +916,12 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
throw new IllegalArgumentException(propertyName + throw new IllegalArgumentException(propertyName +
" must be static and non-final"); " must be static and non-final");
} }
modifyFieldIfSet(field, propertyName); modifyFieldIfSet(field, debugProperties, propertyName);
} }
} }
} else { } else {
Log.w("android.os.Debug", Log.w("android.os.Debug",
"setPropertiesOn(" + (cl == null ? "null" : cl.getName()) + "setFieldsOn(" + (cl == null ? "null" : cl.getName()) +
") called in non-DEBUG build"); ") called in non-DEBUG build");
} }
} }