I have mostly solved the problem but can't figure out the error trace at the end - it'll be something subtle I'm doing wrong probably.
I'm implementing a workaround for GSON, which has real problems parsing nested maps.
public class RegisterValues
{
int Earth;
int Mars;
//etc for 200 planets
public Map returnValues()throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException{
final String [] fieldValues = new String[] {"Earth", "Mars", //etc }
RegisterValues regValues = new RegisterValues();
Map values = new HashMap<String, Integer>();
//values.put("Earth", Earth); manually this works, I'd rather loop through a readymade array of String values.
for (String value : fieldValues){
values.put(field, regValues.getClass().getField(field).getInt(field);) //here it breaks
}
return values;
}
}
The error trace:
Rebinding example.client.Panel // This is the class that is calling the above function
02:24:31.704 [DEBUG] Checking rule <generate-with class='com.google.gwtjsonrpc.rebind.RemoteJsonServiceProxyGenerator'/>
02:24:31.704 [ERROR] Errors in '.../RegisterValues.java'
02:24:31.704 [ERROR] Line 324: No source code is available for type java.lang.SecurityException; did you forget to inherit a required module?
02:24:31.704 [ERROR] Line 333: The method getField(String) is undefined for the type Class<capture#1-of ? extends RegisterValues>
All the line numbers are referring to the part where I call this class. It works when I fill the map manually, but it doesn't work when I try doing this looping method.
Basically I'm wondering if the above is correct?
Sidenote : If the above looks correct, is it due to this being impossible since this is a reflected class i.e it is compiled on the fly (GWT.create()) only when I access this part of the program - therefore it is having some problem with that?