I have a Java object obj that has attributes obj.attr1, obj.attr2 etc. The attributes are possibly accessed through an extra level of
Use Apache Commons BeanUtils: http://commons.apache.org/beanutils/.
An implementation of Map for JavaBeans which uses introspection to get and put properties in the bean:
Map<Object, Object> introspected = new org.apache.commons.beanutils.BeanMap(object);
Note: despite the fact the API returns Map<Object, Object> (since 1.9.0), the actual class for keys in the returned map is java.lang.String