lambda syntax tutorial

"Zdeněk Troníček" tronicek at fit.cvut.cz
Thu Aug 5 07:14:26 PDT 2010


Adding an overloaded method can break source compatibility even now:

class A {
  static void m(int i, double d) { }
  //static void m(double d, int i) { }
}

class Main {
  public static void main(String[] args) {
    A.m(1, 2);
  }
}

Z.
-- 
Zdenek Tronicek
FIT CTU in Prague
http://www.dzone.com/links/api_evolution_with_refactoringng.html


Rémi Forax napsal(a):
> Ok, I was not crystal clear. Let's take an example,
> this code compile.
> Following the criterion of Joe, I can add A.m(B) because
> its semantics is equivalent to the semantics of A.m(A).
> However it will not compile anymore !
>    class A {
>     public static A m(A a) { return null; }
>     //public static A m(B b) { return null; }
>    }
>    class B extends A { }
>    interface Foo<T> {
>     T m(T t);
>    }
>    ...
>    Foo<A> foo = A#m;
> It will always compile if the last instruction is:
>    Foo<A> foo = A#m(A);
> Rémi





More information about the lambda-dev mailing list