[
http://www.stripesframework.org/jira/browse/STS-664?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ben Gunter resolved STS-664.
----------------------------
Resolution: Fixed
Fixed as suggested for 1.5.2 and 1.6.
> JDK bug in bean introspection prevents Stripes validation
> ---------------------------------------------------------
>
> Key: STS-664
> URL: http://www.stripesframework.org/jira/browse/STS-664
> Project: Stripes
> Issue Type: Bug
> Components: Validation
> Affects Versions: Release 1.5.1
> Reporter: Sebastian Beigel
> Fix For: Release 1.5.2, Release 1.6
>
>
> I think I found a problem that we talked about 2 years ago (in a different
> context though) on the mailing list. Stripes 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 message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://www.stripesframework.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development