Problem with extension methods
Brian Goetz
brian.goetz at oracle.com
Sat Aug 21 19:47:34 PDT 2010
Yes, the runtime part is not implemented -- only the compiler part at this time.
On Aug 21, 2010, at 5:55 PM, Howard Lovatt wrote:
> Hi,
>
> I am trying out extension methods:
>
> public interface NewList<T> extends List<T> {
> extension void sort( final Comparator<? super T> c ) default Collections.sort;
> }
>
> public class MinimalIntegerList extends AbstractList<Integer>
> implements NewList<Integer> {
> [snip] // no sort method
> }
>
> 21: final MinimalIntegerList il = new MinimalIntegerList();
> 22: out.println( il );
> 23: il.sort( #( i1, i2 ) { i1 - i2 } );
> 24: out.println( il );
>
> I get:
>
> [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
> Exception in thread "main" java.lang.AbstractMethodError:
> lambdas.MinimalIntegerList.sort(Ljava/util/Comparator;)V
> at lambdas.Main.extensionMethods(Main.java:23)
> at lambdas.Main.main(Main.java:16)
>
> Any idea what's wrong?
>
> --
> -- Howard.
>
More information about the lambda-dev
mailing list