Shall we expect same behavior for bridge method

Zhong Yu zhong.j.yu at gmail.com
Thu Sep 19 11:35:01 PDT 2013


The test() in Sub does not override the test() in Base; it's rather an overload.

On Thu, Sep 19, 2013 at 1:11 PM, Tristan Yan <tristan.yan at oracle.com> wrote:
> Lambda expression behaves different on bridge method, check the code below, are we implementing such a way on purpose?
>
>
>
>        Consumer<Base> bc = b -> b.test("Hello");
>
>         Sub sb = new Sub();
>
>         bc.accept(sb);      //call Base class's test
>
>
>
>         sb.test("Hello");   // call Base class's test
>
>
>
> class Base<T>{
>
>     public void test(T t){ System.out.println("Base"); }
>
> }
>
>
>
> class Sub<T> extends Base<T>{
>
>     public void test(String s){ System.out.println("Sub"); }
>
> }
>
> Tristan Yan(Haibo Yan)
>
> Office : 8610-61066212
>
> Fax  : 8610-61065441
>
> Cell  : 86-18610696822
>
>
>
> 2F, Building No. 24, Zhongguancun Software Park
>
> Haidian District HYPERLINK "http://people.us.oracle.com/pls/oracle/f?p=8000:6:396067987304343:::6:P6_CITY:Beijing"Beijing , 100193
>
> oracle
>
>
>
>
>


More information about the lambda-dev mailing list