RE: [project lombok] Strange behavior of @Delegate with javac and Collections Framewok

305 views
Skip to first unread message

Jesús (Milano)

unread,
Jun 6, 2012, 5:36:54 PM6/6/12
to project...@googlegroups.com

The same problem actually happens also with:

 

public class ListDelegate implements List {

    @Delegate

    private /*List*/ ArrayList arrayList = new  ArrayList();

}

 

Fuuny enough, the NetBeans IDE does mark an error equivalent to Tulio’s (“does not override abstract method subList(int, int) in java.util.List”), but NOT when compiling the class with javac or building the whole project. Then only happen some unchecked warnings:

 

warning: [unchecked] unchecked call to <T>toArray(T[]) as a member of the raw type java.util.ArrayList

warning: [unchecked] unchecked call to set(int,E) as a member of the raw type java.util.ArrayList

warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList

warning: [unchecked] unchecked call to add(int,E) as a member of the raw type java.util.ArrayList

warning: [unchecked] unchecked call to addAll(java.util.Collection<? extends E>) as a member of the raw type java.util.ArrayList

warning: [unchecked] unchecked call to addAll(int,java.util.Collection<? extends E>) as a member of the raw type java.util.ArrayList

warning: [unchecked] unchecked call to containsAll(java.util.Collection<?>) as a member of the raw type java.util.AbstractCollection

warning: [unchecked] unchecked call to removeAll(java.util.Collection<?>) as a member of the raw type java.util.AbstractCollection

warning: [unchecked] unchecked call to retainAll(java.util.Collection<?>) as a member of the raw type java.util.AbstractCollection

9 warnings

 

De: project...@googlegroups.com [mailto:project...@googlegroups.com] En nombre de Tulio Arends
Enviado el: miércoles, 06 de junio de 2012 23:20
Para: project...@googlegroups.com
Asunto: [project lombok] Strange behavior of @Delegate with javac and Collections Framewok

 

I'm using openJDK-7, Ubuntu 12.04 and Lombok 11 and ran into this beaty today at work, it has me baffled:

 

import java.util.ArrayList;

import java.util.List;

import lombok.Delegate;

 

public class ListDelegate implements List {

    @Delegate

    private List arrayList = new  ArrayList();

}

This code makes javac happy ;)

 

import java.util.Queue;

import java.util.concurrent.LinkedBlockingQueue;

import lombok.Delegate;

 

public class QueDelegate implements Queue {

    @Delegate()

    private Queue queue = new LinkedBlockingQueue();

}

This code makes javac choke  and spit out: QueDelegate is not abstract and does not override abstract method clear() in Collection

wich is untrue.

 

Checking the source I find that LinkedBlockingQueue implements BlockingQueue and that BlockingQueue extends Queue.

This should be valid.

 

Any thoughts on this?

--
You received this message because you are subscribed to the Google
Groups group for http://projectlombok.org/
 
To post to this group, send email to project...@googlegroups.com
To unsubscribe from this group, send email to
project-lombo...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/project-lombok?hl=en

Reinier Zwitserloot

unread,
Jun 8, 2012, 11:13:30 AM6/8/12
to project...@googlegroups.com
There are a number of issues with @Delegate and generics, which depend on java version; the last time we looked at it seemed almost impossible to fix in a timely fashion, and under java7 there are way fewer of them. We were kinda hoping java6 would sort of fade out of common use, taking most of this bug with it :/

To post to this group, send email to project-lombok@googlegroups.com


To unsubscribe from this group, send email to

Tulio Arends

unread,
Jun 13, 2012, 2:34:52 PM6/13/12
to project...@googlegroups.com
Let me see if I understand this, @Delegate has issues with generic classes even when they are not being used in a generic manner ( Eg: ArrayList vs. ArrayList<SomeClass>)?  If so, is it a conflict with the type erasure implementation?

Reply all
Reply to author
Forward
0 new messages