try {
f = c.getField(field);
} catch (NoSuchFieldException e) {
// We'll try again below.
} catch (SecurityException e) {
RuntimeException r = new MissingResourceException("SecurityException trying to reflect on field field", c.getName(), field);
r.initCause(e);
throw r;
}
if (f == null) {
try {
f = c.getDeclaredField(field);
} catch (NoSuchFieldException e) {
RuntimeException r = new MissingResourceException("Can't find field via reflection", c.getName(), field);
r.initCause(e);
throw r;
} catch (SecurityException e) {
RuntimeException r = new MissingResourceException("SecurityException trying to reflect on field field", c.getName(), field);
r.initCause(e);
throw r;
}
}
// Try to set it accessible:
try {
f.setAccessible(true);
} catch (SecurityException e) {
Debug.message(DEBUG, "Coudn't set field " + field + " accessible");
}
// Ok, now try to get the data:
Class type = f.getType();
Object fd = null;
try {
fd = f.get(requestor);
} catch (IllegalArgumentException e) {
RuntimeException r = new MissingResourceException("Couldn't get field", c.getName(), field);
r.initCause(e);
throw r;
} catch (IllegalAccessException e) {
RuntimeException r = new MissingResourceException("Couldn't access field", c.getName(), field);
r.initCause(e);
throw r;
}
// Now do the calls:
if (JLabel.class.isInstance(type)) {
set(requestor, field, (JLabel) fd);