They Thomas, thanks for the quick reply.

Yea.  Sorry about that.  I should have been more clear.  I realized that, 
at least for my implementation, reading the field isn't exactly what I 
wanted.

I'm writing writing generators to generate bean validator classes, only the 
bean fields are annotated with custom annotations that dictate the 
requirements of the field (which come from some industry specs).  We cannot 
use a JSR-303 solution (which probably would have been the easiest) because 
we cannot introduce a 3rd party dependency on our beans (even though we 
already using JAXB, so this requirement seems a bit silly).

The path I went down was to generate a validate(FooBean bean) method and 
using GWT reflection iterate over the fields of the bean looking for my 
annotation.  If present, get the details and then attempt to validate that 
the bean method parameter validated according to the annotations.  What I 
realized is that I don't need access to the field value, rather, I need to 
execute a getter method on the bean and validate that value - only, there's 
no way to map the bean methods to whatever field on which I'm iterating.

So ultimately, I was going down the wrong path to begin with in that I 
didn't need the JField value, rather, I needed a way to do the mapping as 
described above, which essentially cannot be done...or at least, not easily.

Thanks for the quick reply.

On Monday, September 10, 2012 10:44:13 AM UTC-6, Thomas Broyer wrote:
>
>
> On Monday, September 10, 2012 6:36:50 PM UTC+2, Adam Gordon wrote:
>>
>> I'm building a GWT generator and I'm parsing a class.  I've gotten to the 
>> point where i have a JField[] and am iterating over the class fields.  I 
>> need to know how to get the value from a field and the GWT documentation is 
>> a bit lacking (i.e., non-existent, at least from a javadoc perspective). 
>>  Anyone have any insight?  Thanks.
>
>
> Getting the value of a field is a runtime operation, and a generator runs 
> at compile-time. The only thing you can do is generate code that will read 
> the field's value and act upon it at runtime, and then hope for the 
> compiler to possibly detect that the value is actually constant and thus 
> optimize out all the code you generated that would never be reached.
>
> Put differently, imagine the generator runs right within Eclipse (or your 
> IDE of choice) and generates *.java files. This is more or less what 
> happens actually, except internally during the compilation.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/C9f6w_rIb1IJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to