Monday, November 30, 2015

Is there any GWT equivalent to Class.getDeclaredField?

Basically, I want to cut down on a bunch of boilerplate code (needing to check if a list of boolean fields are true/false across a collection of objects). In normal Java, I can use Class.getDeclaredField and Field.getBoolean to do that, something like:

public static boolean allTrue(Class<? extends Object> cls, List<? extends Object> things, String fieldName) {
try {
Field field = cls.getDeclaredField(fieldName);
boolean val = true;
for (Object o : things) {
= val && field.getBoolean(o);

return val;
} catch (Exception e) {
return false;

I don't see any way to accomplish the same thing in GWT code, at least not in the GWT site. Is this just not an option under GWT?

You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment