[
http://www.stripesframework.org/jira/browse/STS-171?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ben Gunter closed STS-171.
--------------------------
> problem in OgnlCustomNullHandler when dealing with generics-based setters
> -------------------------------------------------------------------------
>
> Key: STS-171
> URL: http://www.stripesframework.org/jira/browse/STS-171
> Project: Stripes
> Issue Type: Bug
> Components: ActionBean Dispatching
> Reporter: Renaud Bruyeron
> Assignee: Tim Fennell
> Fix For: Release 1.4
>
>
> I am running into problems when I use generics to template crud action beans.
> What I am trying to do is to have an abstract actionbean which has all the
> machinery needed to load/save/edit entities (in my case hibernate entities):
> public abstract AbstractDAOBean<T extends Persistent<T>> implements
> ActionBean {
> protected T entity;
> public abstract T getEntity();
> public abstract void setEntity(T value);
> //...other stuff hidden
> }
> Then a concrete class:
> public FooBean extends AbstractDAOBean<Foo>{
> public Foo getEntity(){
> return entity;
> }
> public void setEntity(Foo value){
> this.entity = value;
> }
> //...
> }
> Foo is a Persistent<Foo>, and Persistent is a template for all my entities.
> The problem I have is that OgnlRuntime.getSetMethod(ctx, Foo.class, "entity")
> does not return the concrete setter Method object. Instead it returns a
> "volatile" method - yes, the Modifier.VOLATILE bit is set! I looked up the
> JVM spec and could not find information on the volatile modified when applied
> to a method, but I am guessing this has to do with erasure and the way the
> JVM deals with parametized types/methods.
> The volatile method Ognl finds has the same signature as the abstract method
> in AbstractDAOBean and therefore this breaks the OgnlCustomNullHandler when
> it then tries to instantiate the bean - the clazzes array contains a
> Persistent class object, which is not instantiatable...
> To make the long story short: FooBean.getClass().getMethods() contains 2
> setter methods for the property "entity", one of them is volatile and has the
> generics type, which is not useable directly. I added the following code
> after the line "Method method = OgnlRuntime.getSetMethod(ctx,
> target.getClass(), propertyName);" to fix the problem:
> // if the method is "volatile", then we need to go back
> and find the concrete version of the method
> if(Modifier.isVolatile(method.getModifiers())){
> for(Method m : target.getClass().getMethods()){
> if(!Modifier.isVolatile(m.getModifiers())){
> if(m.getName().toLowerCase().equals("set" +
> propertyName)){
> method = m;
> }
> }
> }
> }
> This is a hack that fixes my problem - but I think either Ognl should be
> fixed to be JDK5-aware, or stripes should have its own getSetMethod() (in
> ReflectUtils probably).
> What do you think?
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development