previous | start | next

## Inspecting Objects

- Can obtain object contents at runtime
- Useful for generic debugging tools
- Need to gain access to private fields

      Class c = obj.getClass();
      Field f = c.getDeclaredField(name);
      f.setAccessible(true);

- Throws exception if security manager disallows access
- Access field value:

      Object value = f.get(obj);
      f.set(obj, value);

- Use wrappers for primitive types

previous | start | next