You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2014/07/31 17:55:58 UTC

[Bug 56797] New: EL-API does not find overriden method

https://issues.apache.org/bugzilla/show_bug.cgi?id=56797

            Bug ID: 56797
           Summary: EL-API does not find overriden method
           Product: Tomcat 7
           Version: 7.0.55
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Jasper
          Assignee: dev@tomcat.apache.org
          Reporter: dabek@gmx.de

Util.findWrapper(..) returns with a MethodNotFoundException
(util.method.ambiguous) under the following conditions:
- A method is overriden and the return type in the overriden method is
inherited from the original method's return type
- The method is called with a parameter whose type is inherited from the
declared type (assignable)

Apparently, this leads to a situation with multiple matches.
If only one of those conditions is true, the error does not occur.

Example:
--------

TesterBeanA.java:

    public CharSequence getCharSequence(CharSequence cs) {
        return cs;
    }

TesterBeanAA.java

    @Override
    public String getCharSequence(CharSequence cs) {
        return cs.toString();
    }

Test Case:
----------

TestMethodExpressionImpl.java:

    @Test
    public void testInvokeOverridenParamAndReturnType() {
        MethodExpression me = factory.createMethodExpression(context,
                "${beanAA.getCharSequence('test')}", null ,
                new Class<?>[] { TesterBeanB.class });
        assertEquals("test", me.invoke(context, null));
    }

Note 1: The error also occurs if getCharSequence(..) in TesterBeanA is
abstract.
I suggest adding a check for isAbstract() upon reading method modifiers and
drop abstract method right away.

Note 2: This worked in Tomcat 7.0.40.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56797] EL-API does not find overriden method

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56797

--- Comment #1 from Christopher Schultz <ch...@christopherschultz.net> ---
That's because the method is ambiguous. Even Java can't figure it out.

Something is wrong with your sample code: it won't compile.

public class AmbiguousTest
{
    public static class TesterBeanA {
        public CharSequence getCharSequence(CharSequence cs) {
          return cs;
        }
    }

    public static class TesterBeanAA {

        @Override
        public String getCharSequence(CharSequence cs) {
            return cs.toString();
        }
    }
    public static void main(String[] args) {
        new TesterBeanAA().getCharSequence("test");
    }
}

The code above will not compile under Java 8:
$ javac AmbiguousTest.java 
AmbiguousTest.java:11: error: method does not override or implement a method
from a supertype
        @Override
        ^
1 error

You may have to come up with a better test case.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56797] EL-API does not find overriden method

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56797

--- Comment #2 from S. Dabek <da...@gmx.de> ---
The test-code is fine. Of course, it won't compile if you don't extend
TesterBeanAA from TesterBeanA.
Just add the code to the test-classes of the same name in the tomcat7 trunk.

And of course an overriden method can't be ambiguous. That's the essence of
polymorphism.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56797] EL-API does not find overriden method

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56797

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Mark Thomas <ma...@apache.org> ---
Thanks for the report. This has been fixed in 8.0.x for 8.0.11 onwards and in
7.0.x for 7.0.56 onwards.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56797] EL-API does not find overriden method

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56797

--- Comment #3 from Christopher Schultz <ch...@christopherschultz.net> ---
Aw, crap. I missed that, obviously. It's always easier to run a unit test when
it comes in a self-contained example. ;)

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org