Hi,

first of all: Thank you for Stripes 1.5! Thank you for all your hard  
work to make Stripes the best web framework! :)

I think I found a problem that we talked about 2 years ago (in a  
different context though). Stripes 1.5 is using  
java.beans.Introspector in DefaultValidationMetadataProvider to  
collect the validation information. Unfortunately, there is (still) a  
bug in the (stable) JDK(s): bean introspection doesn't consider  
generics [1]. Seems it is fixed in version 7 :)

Say I have a parameterized BaseAction like this:

public abstract class AbstractCRUDAction<T>  implements ActionBean {
   private T model;
   public T getModel{...}
   public void setModel(T model) {...}
...
}

and an implementation like:

public class UserAction extends AbstractCRUDAction<User>  {
   @ValidateNested(...)
   @Override
   public User getModel() { return super.getModel(); }
...
}

The model (a User object) is not validated. Having a look in the  
debugger shows that the bean introspection returns the wrong read  
method for "model", i.e. the base-class method (containing no  
annotations of course).

We had the same problem in Oct 2006 on the mailing list [2] an Tim  
found a workaround:

> From reading up it would appear that the compiler generates a bridge  
> method for any concrete implementation of an interface method that  
> involves a type variable that is parameterized in the class. [...]
>
> A bit of poking shows that you can actually get around this by  
> basically doing:
>     Method m = pd.getReadMethod();
>     if (m.isBridge()) m =  
> m.getDeclaringClass().getMethod(m.getName());
>
> which returns the correct, non-bridge method. [...]

So I think it would be a good idea to include this line in  
DefaultValidationMetadataProvider.loadForClass() to get the "right"  
getter method. Otherwise it's no possible to add validation to generic  
ActionBean properties.

What do you think?

Sebatian


References:

[1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6422403
[2] http://www.nabble.com/Re%3A-generics-interface-to6806773.html#a6806773

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to