History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: OGNL-136
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Jesse Kuhnert
Reporter: Robert-Jan Westerhof
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OGNL

Ignore synthetic methods when using getDeclaredMethods()

Created: 12/Dec/07 09:11 AM   Updated: 18/Jan/08 02:57 PM
Component/s: Core Runtime
Affects Version/s: 2.6.11
Fix Version/s: 2.7.2

Environment: Java 5 and up


 Description  « Hide
<class>.getDeclaredMethods() will return synthetic methods, which are required when there are covariant return types.

F.i. a class defines

protected List getList()

and its subclass defines

public ArrayList getList()

In this case getDeclaredMethods() on the subclass will yield 2 results:

/*synthetic*/ public volatile List getList()
public ArrayList getList()

both of which have <subclass> as the declaring class.

Whenever getDeclaredMethods() is used to determine available getters and setters, all found synthetic methods should be ignored
(with Modifier.isSynthetic(method.getModifiers()))
(occurrences f.i. OgnlRuntime.getMethods(Class, boolean), OgnlRuntime.getDeclaredMethods(Class, String, boolean))

Generation of these synthetic methods has taken flight since the introduction of Generics (which is why I've listed the environment as Java 5 and up), I'm not sure to what extent they are present in older versions (up to 1.4).

Note that the java.beans.Introspector has a similar bug report (known bug): 6528714 at bugs.sun.com
The Introspector is currently only fixed for Java 7 and up, so be prepared that its use under Java 5 (at least until current version 1.5.0 u 14) and Java 6 (at least until current version 1.6.0 u 3) may yield unexpected results (it returns the first getter/setter it finds, which could be the synthetic ones)

(occurrences f.i. OgnlRuntime.getPropertyDescriptors(Class), OgnlRuntime.getPropertyDescriptorsArray(Class))

Affected versions listed is only 2.6.11, as that is the version I currently use and have checked. Most likely this issue affects all versions.


 All   Comments   Change History      Sort Order:
Jesse Kuhnert - [18/Jan/08 02:57 PM ]
Thanks for the heads up.