Eclipse vs Javac difference
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Fri Aug 27 03:59:57 PDT 2010
Here's a reduced test case:
import java.util.*;
interface BooleanList extends List<Boolean>, BooleanCollection { }
interface BooleanCollection extends Collection<Boolean> {
BooleanIterator iterator();
}
interface BooleanIterator extends Iterator<Boolean> { }
class Test {
void test(BooleanList plist) {
BooleanIterator it = plist.iterator();
}
}
This is a duplicate of the following bug:
http://bugs.sun.com/view_bug.do?bug_id=6487370
Which is fixed in JDK 7.
Maurizio
On 27/08/10 10:06, Stephen Colebourne wrote:
> That sounds similar to the problem Benedict - one method inherited
> from two interfaces, one with a generic definition Iterator<T> and one
> with an extension of that BooleanIterator. I assume the convariant
> return type isn't picked up after the erasure occurs.
>
> I have limited internet connection, so can't search the bug database
> to find the reference. This will be very difficult to work around I
> suspect.
>
> Stephen
>
>
> On 27 August 2010 08:39, Benedict Elliott Smith<lists at laerad.com> wrote:
>
>> This is something that bit me once - if you implement two
>> methods from different interfaces with the same erasure, the JDK6 compiler
>> barfs. It has definitely been fixed, but I think only in JDK7.
>>
>>
>> On 27 August 2010 01:11, Jonathan Gibbons<jonathan.gibbons at oracle.com>
>> wrote:
>>
>>> Stephen,
>>>
>>> Have you tried versions of JDK, such as OpenJDK 6 or OpenJDK 7?
>>>
>>> Can you boil the code down to a simple example which illustrates the
>>> different behavior?
>>>
>>> -- Jon
>>>
>>> On 08/26/2010 04:10 PM, Stephen Colebourne wrote:
>>>
>>>> I'm currently seeing a difference between Eclipse and Javac and am
>>>> trying to determine who is at fault, and how to work around it.
>>>>
>>>> The code in question is at Joda Primitives -
>>>>
>>>> http://joda-primitives.svn.sourceforge.net/viewvc/joda-primitives/trunk/JodaPrimitives/?pathrev=30
>>>>
>>>> Running maven - mvn package - shows the problem (it compiles in
>>>> Eclipse 3.5.0 and not in javac 1.6.0_13-b03)
>>>>
>>>>
>>>> \dev\joda\primitives\src\test\java\org\joda\primitives\list\impl\AbstractTestBooleanList.java:[76,39]
>>>> reference to iterator is ambiguous, both method iterator() in
>>>> org.joda.primitives.collection.BooleanCollection and method iterator()
>>>> in java.util.List<java.lang.Boolean> match
>>>>
>>>> The code includes an interface BooleanCollection that extends
>>>> interface PrimitiveCollection, which extends Collection<Boolean>. The
>>>> iterator() method is overridden covariantly in BooleanCollection to
>>>> return BooleanIterator, a subinterface of PrimitiveIterator<Boolean>
>>>> and Iterator<Boolean>.
>>>>
>>>> Any ideas? The svn repo is available to view (Apache 2 license).
>>>> Stephen
>>>>
>>>>
>>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20100827/cf781436/attachment.html
More information about the compiler-dev
mailing list