
|
If you were logged in you would be able to see more operations.
|
|
|
|
Environment:
|
Java 5 and up
|
|
|
<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.
|
|
Description
|
<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.
|
Show » |
|