Problem with extension methods
Howard Lovatt
howard.lovatt at gmail.com
Sat Aug 21 21:18:09 PDT 2010
Mant thanks
On 22 August 2010 12:47, Brian Goetz <brian.goetz at oracle.com> wrote:
> 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.
>>
>
>
--
-- Howard.
More information about the lambda-dev
mailing list