commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rahul Akolkar (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (JEXL-40) JEXL fails to find abstract public methods in the base class if overridden by non-public derived types
Date Fri, 17 Jul 2009 06:26:15 GMT

     [ https://issues.apache.org/jira/browse/JEXL-40?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Rahul Akolkar resolved JEXL-40.
-------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0

Should be fixed as part of r794976 in the 2.0 branch.


> JEXL fails to find abstract public methods in the base class if overridden by non-public
derived types
> ------------------------------------------------------------------------------------------------------
>
>                 Key: JEXL-40
>                 URL: https://issues.apache.org/jira/browse/JEXL-40
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 1.1
>            Reporter: Kohsuke Kawaguchi
>             Fix For: 2.0
>
>         Attachments: JEXL-40.patch
>
>
> If I have a code that fits the following pattern:
> {noformat}
> public class Base {
>   public abstract void foo();
> }
> class Derived extends Base {
>   public void foo() {}
> }
> {noformat}
> JEXL fails to discover the foo method on an instance of Derived, even if this method
is invokable.
> This is because in ClassMap.java, the populateMethodCache method reads:
> {noformat}
> // Some of the interfaces contain abstract methods. That is fine, because the actual
object must
> // implement them anyway (else it wouldn't be implementing the interface). If we find
an abstract
> // method in a non-interface, we skip it, because we do want to make sure that no abstract
methods end up in
> // the cache.
> if (classToReflect.isInterface() || !Modifier.isAbstract(modifiers)) {
> {noformat}
> The problem can be fixed by simply getting rid this check and always do "methodCache.put(methods[i]);"
> The comment above doesn't make much sense to me. First, interfaces only contain abstract
methods by definition. And if interfaces are deemed OK, I don't see why abstract methods in
the base classes are treated any differently. Given any instance that's assignable to the
base type, under normal circumstances every abstract method is invokable. There's no difference
between interfaces and base classes on this point.
> (The only situation where abstract methods are not implemented is when class files were
changed in incompatible way)
> This pattern of having abstract methods in the base type to be implemented by non-public
class is a common pattern. So I suggest we simply remove the if block shown above.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message