You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Nathan Beyer <nb...@kc.rr.com> on 2006/08/26 01:54:50 UTC

[classlib] Sun compiler change?

Is anyone else using the latest Sun JDK, v5.0 Update 8 on Windows?

 

I'm seeing a compilation error in the LUNI that I don't see with 5.0 Update
7. Here's the error I'm getting.

 

compile:

    [mkdir] Created dir:
C:\dev\harmony\enhanced\classlib\trunk\build\classes

    [javac] Compiling 3173 source files to
C:\dev\harmony\enhanced\classlib\trun

k\build\classes

    [javac]
C:\dev\harmony\enhanced\classlib\trunk\modules\luni\src\main\java\ja

va\util\MiniEnumSet.java:78: inconvertible types

    [javac] found   : java.util.Collection<capture of ? extends E>

    [javac] required: java.util.EnumSet<E>

    [javac]             EnumSet<E> set = (EnumSet<E>) collection;

    [javac]                                           ^

 

 

When I compile in Eclipse 3.2 there's no error.

 

-Nathan


Re: [classlib] Sun compiler change?

Posted by Spark Shen <sm...@gmail.com>.
Alexey Petrenko 写道:
> 2006/8/28, Spark Shen <sm...@gmail.com>:
>> Richard Liang 写道:
>> >
>> >
>> > Richard Liang wrote:
>> >>
>> >>
>> >> Nathan Beyer wrote:
>> >>> Is anyone else using the latest Sun JDK, v5.0 Update 8 on Windows?
>> >>>
>> >>>
>> >>>
>> >>> I'm seeing a compilation error in the LUNI that I don't see with 5.0
>> >>> Update
>> >>> 7. Here's the error I'm getting.
>> >>>
>> >>>
>> >>>
>> >>> compile:
>> >>>
>> >>> [mkdir] Created dir:
>> >>> C:\dev\harmony\enhanced\classlib\trunk\build\classes
>> >>>
>> >>> [javac] Compiling 3173 source files to
>> >>> C:\dev\harmony\enhanced\classlib\trun
>> >>>
>> >>> k\build\classes
>> >>>
>> >>> [javac]
>> >>> C:\dev\harmony\enhanced\classlib\trunk\modules\luni\src\main\java\ja
>> >>>
>> >>> va\util\MiniEnumSet.java:78: inconvertible types
>> >>>
>> >>> [javac] found : java.util.Collection<capture of ? extends E>
>> >>>
>> >>> [javac] required: java.util.EnumSet<E>
>> >>>
>> >>> [javac] EnumSet<E> set = (EnumSet<E>) collection;
>> >>>
>> >>> [javac] ^
>> >>>
>> >>>
>> >> Yes, I got the same error using 1.5.0_08. Will have a look at it. :-)
>> > This should be an enhancement/bug-fixing of java compiler. There are
>> > bugs in java.util.MiniEnumSet. I will try to fix it later....
>> Seems that in new version of JDK, EnumSet<E> and <capture of ? extends
>> E> (E was previously stated as <E extends Enum<E>>) are not considered
>> compatible.
>> After changing
>> EnumSet<E> set = (EnumSet<E>)collection;
>> into
>> EnumSet set = (EnumSet)collection;
>> , compilation using ant in command line succeeds.
>> Would any one give a clue, why the are considered incompatible in this
>> version of JDK?
>>
>> Eclipse uses its own JDK compiler, which may differ from this 1.5.0_08
>> version compiler.
> Which IS differ :)
I mean Eclipse uses its own JDT incremental Java compiler (not JDK :-) 
),  which may differ from 1.5.0_08 version JDK compiler.
>
>> I guess this is the reason why compilation only fails in command line on
>> your machine.
>>
>> Best regards
>> >
>> > Richard.
>> >>
>> >> Best regards,
>> >> Richard
>> >>
>> >>>
>> >>>
>> >>> When I compile in Eclipse 3.2 there's no error.
>> >>>
>> >>>
>> >>>
>> >>> -Nathan
>> >>>
>> >>>
>> >>
>> >
>>
>>
>> -- 
>> Spark Shen
>> China Software Development Lab, IBM
>>
>>
>> ---------------------------------------------------------------------
>> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>>
>>
>
>


-- 
Spark Shen
China Software Development Lab, IBM


---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Sun compiler change?

Posted by Alexey Petrenko <al...@gmail.com>.
2006/8/28, Spark Shen <sm...@gmail.com>:
> Richard Liang 写道:
> >
> >
> > Richard Liang wrote:
> >>
> >>
> >> Nathan Beyer wrote:
> >>> Is anyone else using the latest Sun JDK, v5.0 Update 8 on Windows?
> >>>
> >>>
> >>>
> >>> I'm seeing a compilation error in the LUNI that I don't see with 5.0
> >>> Update
> >>> 7. Here's the error I'm getting.
> >>>
> >>>
> >>>
> >>> compile:
> >>>
> >>> [mkdir] Created dir:
> >>> C:\dev\harmony\enhanced\classlib\trunk\build\classes
> >>>
> >>> [javac] Compiling 3173 source files to
> >>> C:\dev\harmony\enhanced\classlib\trun
> >>>
> >>> k\build\classes
> >>>
> >>> [javac]
> >>> C:\dev\harmony\enhanced\classlib\trunk\modules\luni\src\main\java\ja
> >>>
> >>> va\util\MiniEnumSet.java:78: inconvertible types
> >>>
> >>> [javac] found : java.util.Collection<capture of ? extends E>
> >>>
> >>> [javac] required: java.util.EnumSet<E>
> >>>
> >>> [javac] EnumSet<E> set = (EnumSet<E>) collection;
> >>>
> >>> [javac] ^
> >>>
> >>>
> >> Yes, I got the same error using 1.5.0_08. Will have a look at it. :-)
> > This should be an enhancement/bug-fixing of java compiler. There are
> > bugs in java.util.MiniEnumSet. I will try to fix it later....
> Seems that in new version of JDK, EnumSet<E> and <capture of ? extends
> E> (E was previously stated as <E extends Enum<E>>) are not considered
> compatible.
> After changing
> EnumSet<E> set = (EnumSet<E>)collection;
> into
> EnumSet set = (EnumSet)collection;
> , compilation using ant in command line succeeds.
> Would any one give a clue, why the are considered incompatible in this
> version of JDK?
>
> Eclipse uses its own JDK compiler, which may differ from this 1.5.0_08
> version compiler.
Which IS differ :)

> I guess this is the reason why compilation only fails in command line on
> your machine.
>
> Best regards
> >
> > Richard.
> >>
> >> Best regards,
> >> Richard
> >>
> >>>
> >>>
> >>> When I compile in Eclipse 3.2 there's no error.
> >>>
> >>>
> >>>
> >>> -Nathan
> >>>
> >>>
> >>
> >
>
>
> --
> Spark Shen
> China Software Development Lab, IBM
>
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Alexey A. Petrenko
Intel Middleware Products Division

Re: [classlib] Sun compiler change?

Posted by Spark Shen <sm...@gmail.com>.
Krzysztof Sobolewski 写道:
> Spark Shen wrote:
>
>   
>>> As far as I understand generics, SomeClass<A> and SomeClass<B>, where B
>>> extends A, *are* incompatible (per the spec). Generic types are not
>>> polymorphic.
>>> The problematic line IMO should read:
>>>
>>> EnumSet<? extends E> set = (EnumSet<? extends E>)collection;
>>>   
>>>       
>> Do you mean to change the problematic line into the above statement? I
>> have tried this already, but this type of cast will also give a
>> compilation error.
>>     
>
> That's odd. I used a compiler this time and could not reproduce it (with
> javac 1.5.0_08-b03 and quick-and-dirty from-the-scratch EnumSet impl). It
> always gives me "unchecked cast" warning, no errors. Maybe I should check
> out Harmony sources? :)
>
>   
Hi
That's really odd. :-) 
I use javac:
java version "1.5.0_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode)

And I check out Harmony sources and run build task using ant under 
command, which gives the following error prompt:
[mkdir] Created dir: C:\spark\harmony\build\classes
[javac] Compiling 3173 source files to C:\spark\harmony\build\classes
[javac] 
C:\spark\harmony\modules\luni\src\main\java\java\util\MiniEnumSet.java:78: 
inconvertible types
[javac] found   : java.util.Collection<capture of ? extends E>
[javac] required: java.util.EnumSet<? extends E>
[javac]             EnumSet<? extends E> set = (EnumSet<? extends E>) 
collection;
[javac]                                                               ^
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 1 error

BTW, before every build, I run 'ant clean' to clean all previous outputs.

Best regards
>> And I did not find a way to suppress the unchecked warning while
>> compilation succeed.
>>     
>
> Maybe @SuppressWarnings("unchecked")? If you're absolutely sure it's OK...
>
> BTW:
> EnumSet<?> set = (EnumSet<?>)collection;
> seems to compile fine, but I'm not sure it's enough for you :)
>
>   
>>> [1] I guess this is in addAll() or its friends?
>>>   
>>>       
>> I guess 'its friends' refers to removeAll, containsAll, and retainAll.
>> :-)   But all its friends have different signature as addAll
>>
>> boolean     addAll(*Collection<? extends E>* c)
>> boolean     containsAll(*Collection<?>* c)
>> boolean     removeAll(*Collection<?>* c)
>> boolean     retainAll(*Collection<?>* c)
>> I guess you know why they are different.
>>
>> So, in the implementation of all its friends, same problem is not
>> encountered.
>>     
>
> Oh, yeah... Who'd remember all that... ;)
> -KS
>
>   


-- 
Spark Shen
China Software Development Lab, IBM


---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Sun compiler change?

Posted by Alexey Varlamov <al...@gmail.com>.
2006/8/29, Spark Shen <sm...@gmail.com>:
> Alexey Varlamov 写道:
> > 2006/8/29, Spark Shen <sm...@gmail.com>:
> >> Krzysztof Sobolewski 写道:
> >> > Spark Shen wrote:
> >> >
> >> >
> >> >> Did you (refer to thread [app] ant with ecj) put
> >> >>
> >> >> Eclipse compiler JAR on Ant's
> >> >> execution classpath to execute the javac task.
> >> >>
> >> >> If so, may be that's why It always gives you "unchecked cast"
> >> warning,
> >> >> no errors.
> >> >>
> >> >
> >> > Well, I created a new EnumSet class in completly unrelated
> >> environment... So
> >> > it is perfectly possible that there's a classpath conflict
> >> somewhere. I
> >> > can't verify that because don't have the Harmony build here :)
> >> >
> >> > BTW: another experiment revealed that
> >> > EnumSet<? extends Enum<E>> set = (EnumSet<? extends
> >> Enum<E>>)collection;
> >> > compiles without warnings. No matter how much I think I understand
> >> generics,
> >> > there's always something that surprises me ;)
> >> >
> >> Conceptually speaking, I think EnumSet<? extends Enum<E>> still has
> >> potential pitfall:
> >>
> >> In the signature of addAll(Collection<? extends E> collection) method, ?
> >> denotes subclass of E.
> >> While in EnumSet<? extends Enum<E>>, ? denotes subclass of Enum<E>. But
> >> consider the relationship
> >> between E and Enum<E>, E is subclass of Enum<E>. So, we can not
> >> guarantee that subclass of E is definitely
> >> subclass of Enum<E>.
> >
> > Hmm, as E is a subclass of Enum<E>, subclasses of E definitely have
> > Enum<E> among ancestors ;)
> Yes, you are right. And I made a wrong judgement here. :-P
>
> The actual statement I want to judge is that:
> E is subclass of Enum<E>. So, we can not guarantee that subclasses of
> E(? extends E) is definitely
> compatible with subclasses of Enum<E>(? extends Enum<E>).
>
> Since the input collection is of type <? extends E>, cast it to <?
> extends Enum<E>> seems suspicious.

Nothing suspicious actually - the cast just lifts upper bound up.
Taking into account cyclic declaration of E, the bound in fact remains
the same. So I believe this is correct way in this particular case.
--
Alexey

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Sun compiler change?

Posted by Spark Shen <sm...@gmail.com>.
Alexey Varlamov 写道:
> 2006/8/29, Spark Shen <sm...@gmail.com>:
>> Krzysztof Sobolewski 写道:
>> > Spark Shen wrote:
>> >
>> >
>> >> Did you (refer to thread [app] ant with ecj) put
>> >>
>> >> Eclipse compiler JAR on Ant's
>> >> execution classpath to execute the javac task.
>> >>
>> >> If so, may be that's why It always gives you "unchecked cast"
>> warning,
>> >> no errors.
>> >>
>> >
>> > Well, I created a new EnumSet class in completly unrelated
>> environment... So
>> > it is perfectly possible that there's a classpath conflict
>> somewhere. I
>> > can't verify that because don't have the Harmony build here :)
>> >
>> > BTW: another experiment revealed that
>> > EnumSet<? extends Enum<E>> set = (EnumSet<? extends
>> Enum<E>>)collection;
>> > compiles without warnings. No matter how much I think I understand
>> generics,
>> > there's always something that surprises me ;)
>> >
>> Conceptually speaking, I think EnumSet<? extends Enum<E>> still has
>> potential pitfall:
>>
>> In the signature of addAll(Collection<? extends E> collection) method, ?
>> denotes subclass of E.
>> While in EnumSet<? extends Enum<E>>, ? denotes subclass of Enum<E>. But
>> consider the relationship
>> between E and Enum<E>, E is subclass of Enum<E>. So, we can not
>> guarantee that subclass of E is definitely
>> subclass of Enum<E>.
>
> Hmm, as E is a subclass of Enum<E>, subclasses of E definitely have
> Enum<E> among ancestors ;)
Yes, you are right. And I made a wrong judgement here. :-P

The actual statement I want to judge is that:
E is subclass of Enum<E>. So, we can not guarantee that subclasses of
E(? extends E) is definitely
compatible with subclasses of Enum<E>(? extends Enum<E>).

Since the input collection is of type <? extends E>, cast it to <?
extends Enum<E>> seems suspicious.
>
>>
>> Correct me if I am wrong.
>>
>> Best regards
>> > -KS
>> >
>> >
>>
>>
>> -- 
>> Spark Shen
>> China Software Development Lab, IBM
>>
>>
>> ---------------------------------------------------------------------
>> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Spark Shen
China Software Development Lab, IBM


---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Sun compiler change?

Posted by Alexey Varlamov <al...@gmail.com>.
2006/8/29, Spark Shen <sm...@gmail.com>:
> Krzysztof Sobolewski 写道:
> > Spark Shen wrote:
> >
> >
> >> Did you (refer to thread [app] ant with ecj) put
> >>
> >> Eclipse compiler JAR on Ant's
> >> execution classpath to execute the javac task.
> >>
> >> If so, may be that's why It always gives you "unchecked cast" warning,
> >> no errors.
> >>
> >
> > Well, I created a new EnumSet class in completly unrelated environment... So
> > it is perfectly possible that there's a classpath conflict somewhere. I
> > can't verify that because don't have the Harmony build here :)
> >
> > BTW: another experiment revealed that
> > EnumSet<? extends Enum<E>> set = (EnumSet<? extends Enum<E>>)collection;
> > compiles without warnings. No matter how much I think I understand generics,
> > there's always something that surprises me ;)
> >
> Conceptually speaking, I think EnumSet<? extends Enum<E>> still has
> potential pitfall:
>
> In the signature of addAll(Collection<? extends E> collection) method, ?
> denotes subclass of E.
> While in EnumSet<? extends Enum<E>>, ? denotes subclass of Enum<E>. But
> consider the relationship
> between E and Enum<E>, E is subclass of Enum<E>. So, we can not
> guarantee that subclass of E is definitely
> subclass of Enum<E>.

Hmm, as E is a subclass of Enum<E>, subclasses of E definitely have
Enum<E> among ancestors ;)

>
> Correct me if I am wrong.
>
> Best regards
> > -KS
> >
> >
>
>
> --
> Spark Shen
> China Software Development Lab, IBM
>
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Sun compiler change?

Posted by Spark Shen <sm...@gmail.com>.
Krzysztof Sobolewski 写道:
> Spark Shen wrote:
>
>   
>> Did you (refer to thread [app] ant with ecj) put
>>
>> Eclipse compiler JAR on Ant's
>> execution classpath to execute the javac task.
>>
>> If so, may be that's why It always gives you "unchecked cast" warning,
>> no errors.
>>     
>
> Well, I created a new EnumSet class in completly unrelated environment... So
> it is perfectly possible that there's a classpath conflict somewhere. I
> can't verify that because don't have the Harmony build here :)
>
> BTW: another experiment revealed that
> EnumSet<? extends Enum<E>> set = (EnumSet<? extends Enum<E>>)collection;
> compiles without warnings. No matter how much I think I understand generics,
> there's always something that surprises me ;)
>   
Conceptually speaking, I think EnumSet<? extends Enum<E>> still has 
potential pitfall:

In the signature of addAll(Collection<? extends E> collection) method, ? 
denotes subclass of E.
While in EnumSet<? extends Enum<E>>, ? denotes subclass of Enum<E>. But 
consider the relationship
between E and Enum<E>, E is subclass of Enum<E>. So, we can not 
guarantee that subclass of E is definitely
subclass of Enum<E>.

Correct me if I am wrong.

Best regards
> -KS
>
>   


-- 
Spark Shen
China Software Development Lab, IBM


---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Sun compiler change?

Posted by Spark Shen <sm...@gmail.com>.
Krzysztof Sobolewski 写道:
> Spark Shen wrote:
>
>   
>> Did you (refer to thread [app] ant with ecj) put
>>
>> Eclipse compiler JAR on Ant's
>> execution classpath to execute the javac task.
>>
>> If so, may be that's why It always gives you "unchecked cast" warning,
>> no errors.
>>     
>
> Well, I created a new EnumSet class in completly unrelated environment... So
> it is perfectly possible that there's a classpath conflict somewhere. I
> can't verify that because don't have the Harmony build here :)
>
> BTW: another experiment revealed that
> EnumSet<? extends Enum<E>> set = (EnumSet<? extends Enum<E>>)collection;
> compiles without warnings. No matter how much I think I understand generics,
> there's always something that surprises me ;)
>   
HaHa,  agree!!! :-)     
And thank you for your information.

Best regards
> -KS
>
>   


-- 
Spark Shen
China Software Development Lab, IBM


---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Sun compiler change?

Posted by Krzysztof Sobolewski <je...@interia.pl>.
Spark Shen wrote:

> Did you (refer to thread [app] ant with ecj) put
> 
> Eclipse compiler JAR on Ant's
> execution classpath to execute the javac task.
> 
> If so, may be that's why It always gives you "unchecked cast" warning,
> no errors.

Well, I created a new EnumSet class in completly unrelated environment... So
it is perfectly possible that there's a classpath conflict somewhere. I
can't verify that because don't have the Harmony build here :)

BTW: another experiment revealed that
EnumSet<? extends Enum<E>> set = (EnumSet<? extends Enum<E>>)collection;
compiles without warnings. No matter how much I think I understand generics,
there's always something that surprises me ;)
-KS


Re: [classlib] Sun compiler change?

Posted by Spark Shen <sm...@gmail.com>.
Krzysztof Sobolewski 写道:
> Spark Shen wrote:
>
>   
>>> As far as I understand generics, SomeClass<A> and SomeClass<B>, where B
>>> extends A, *are* incompatible (per the spec). Generic types are not
>>> polymorphic.
>>> The problematic line IMO should read:
>>>
>>> EnumSet<? extends E> set = (EnumSet<? extends E>)collection;
>>>   
>>>       
>> Do you mean to change the problematic line into the above statement? I
>> have tried this already, but this type of cast will also give a
>> compilation error.
>>     
>
> That's odd. I used a compiler this time and could not reproduce it (with
> javac 1.5.0_08-b03 and quick-and-dirty from-the-scratch EnumSet impl). It
> always gives me "unchecked cast" warning, no errors. Maybe I should check
> out Harmony sources? :)
>   
Did you (refer to thread [app] ant with ecj) put

Eclipse compiler JAR on Ant's
execution classpath to execute the javac task.

If so, may be that's why 
It always gives you "unchecked cast" warning, no errors.

Best regards

>   
>> And I did not find a way to suppress the unchecked warning while
>> compilation succeed.
>>     
>
> Maybe @SuppressWarnings("unchecked")? If you're absolutely sure it's OK...
>
> BTW:
> EnumSet<?> set = (EnumSet<?>)collection;
> seems to compile fine, but I'm not sure it's enough for you :)
>
>   
>>> [1] I guess this is in addAll() or its friends?
>>>   
>>>       
>> I guess 'its friends' refers to removeAll, containsAll, and retainAll.
>> :-)   But all its friends have different signature as addAll
>>
>> boolean     addAll(*Collection<? extends E>* c)
>> boolean     containsAll(*Collection<?>* c)
>> boolean     removeAll(*Collection<?>* c)
>> boolean     retainAll(*Collection<?>* c)
>> I guess you know why they are different.
>>
>> So, in the implementation of all its friends, same problem is not
>> encountered.
>>     
>
> Oh, yeah... Who'd remember all that... ;)
> -KS
>
>   


-- 
Spark Shen
China Software Development Lab, IBM


---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Sun compiler change?

Posted by Krzysztof Sobolewski <je...@interia.pl>.
Spark Shen wrote:

>> As far as I understand generics, SomeClass<A> and SomeClass<B>, where B
>> extends A, *are* incompatible (per the spec). Generic types are not
>> polymorphic.
>> The problematic line IMO should read:
>>
>> EnumSet<? extends E> set = (EnumSet<? extends E>)collection;
>>   
> Do you mean to change the problematic line into the above statement? I
> have tried this already, but this type of cast will also give a
> compilation error.

That's odd. I used a compiler this time and could not reproduce it (with
javac 1.5.0_08-b03 and quick-and-dirty from-the-scratch EnumSet impl). It
always gives me "unchecked cast" warning, no errors. Maybe I should check
out Harmony sources? :)

> And I did not find a way to suppress the unchecked warning while
> compilation succeed.

Maybe @SuppressWarnings("unchecked")? If you're absolutely sure it's OK...

BTW:
EnumSet<?> set = (EnumSet<?>)collection;
seems to compile fine, but I'm not sure it's enough for you :)

>> [1] I guess this is in addAll() or its friends?
>>   
> I guess 'its friends' refers to removeAll, containsAll, and retainAll.
> :-)   But all its friends have different signature as addAll
> 
> boolean     addAll(*Collection<? extends E>* c)
> boolean     containsAll(*Collection<?>* c)
> boolean     removeAll(*Collection<?>* c)
> boolean     retainAll(*Collection<?>* c)
> I guess you know why they are different.
> 
> So, in the implementation of all its friends, same problem is not
> encountered.

Oh, yeah... Who'd remember all that... ;)
-KS


Re: [classlib] Sun compiler change?

Posted by Spark Shen <sm...@gmail.com>.
Krzysztof Sobolewski 写道:
> Spark Shen wrote:
>
>   
>> Seems that in new version of JDK, EnumSet<E> and <capture of ? extends
>> E> (E was previously stated as <E extends Enum<E>>) are not considered
>> compatible.
>> After changing
>> EnumSet<E> set = (EnumSet<E>)collection;
>> into
>> EnumSet set = (EnumSet)collection;
>> , compilation using ant in command line succeeds.
>>     
>
> ...but gives "unsafe" warnings.
>
>   
>> Would any one give a clue, why the are considered incompatible in this
>> version of JDK?
>>     
>
> Maybe a bugfix? :)
>
>
> As far as I understand generics, SomeClass<A> and SomeClass<B>, where B
> extends A, *are* incompatible (per the spec). Generic types are not polymorphic.
> The problematic line IMO should read:
>
> EnumSet<? extends E> set = (EnumSet<? extends E>)collection;
>   
Do you mean to change the problematic line into the above statement? I 
have tried this already, but this type of cast will also give a 
compilation error.
And I did not find a way to suppress the unchecked warning while 
compilation succeed.
> That's because collection seems to be an EnumSet of some unknown subclass of
> E[1] and that connot be safely converted to EnumSet<E>.
>
> [1] I guess this is in addAll() or its friends?
>   
I guess 'its friends' refers to removeAll, containsAll, and retainAll. 
:-)   But all its friends have different signature as addAll

boolean     addAll(*Collection<? extends E>* c) 

boolean     containsAll(*Collection<?>* c)
boolean     removeAll(*Collection<?>* c)
boolean     retainAll(*Collection<?>* c)
I guess you know why they are different.

So, in the implementation of all its friends, same problem is not 
encountered.
> -KS
>
>   


-- 
Spark Shen
China Software Development Lab, IBM


---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Sun compiler change?

Posted by Krzysztof Sobolewski <je...@interia.pl>.
Spark Shen wrote:

> Seems that in new version of JDK, EnumSet<E> and <capture of ? extends
> E> (E was previously stated as <E extends Enum<E>>) are not considered
> compatible.
> After changing
> EnumSet<E> set = (EnumSet<E>)collection;
> into
> EnumSet set = (EnumSet)collection;
> , compilation using ant in command line succeeds.

...but gives "unsafe" warnings.

> Would any one give a clue, why the are considered incompatible in this
> version of JDK?

Maybe a bugfix? :)


As far as I understand generics, SomeClass<A> and SomeClass<B>, where B
extends A, *are* incompatible (per the spec). Generic types are not polymorphic.
The problematic line IMO should read:

EnumSet<? extends E> set = (EnumSet<? extends E>)collection;

That's because collection seems to be an EnumSet of some unknown subclass of
E[1] and that connot be safely converted to EnumSet<E>.

[1] I guess this is in addAll() or its friends?
-KS


Re: [classlib] Sun compiler change?

Posted by Spark Shen <sm...@gmail.com>.
Richard Liang 写道:
>
>
> Richard Liang wrote:
>>
>>
>> Nathan Beyer wrote:
>>> Is anyone else using the latest Sun JDK, v5.0 Update 8 on Windows?
>>>
>>>
>>>
>>> I'm seeing a compilation error in the LUNI that I don't see with 5.0 
>>> Update
>>> 7. Here's the error I'm getting.
>>>
>>>
>>>
>>> compile:
>>>
>>> [mkdir] Created dir:
>>> C:\dev\harmony\enhanced\classlib\trunk\build\classes
>>>
>>> [javac] Compiling 3173 source files to
>>> C:\dev\harmony\enhanced\classlib\trun
>>>
>>> k\build\classes
>>>
>>> [javac]
>>> C:\dev\harmony\enhanced\classlib\trunk\modules\luni\src\main\java\ja
>>>
>>> va\util\MiniEnumSet.java:78: inconvertible types
>>>
>>> [javac] found : java.util.Collection<capture of ? extends E>
>>>
>>> [javac] required: java.util.EnumSet<E>
>>>
>>> [javac] EnumSet<E> set = (EnumSet<E>) collection;
>>>
>>> [javac] ^
>>>
>>>
>> Yes, I got the same error using 1.5.0_08. Will have a look at it. :-)
> This should be an enhancement/bug-fixing of java compiler. There are 
> bugs in java.util.MiniEnumSet. I will try to fix it later....
Seems that in new version of JDK, EnumSet<E> and <capture of ? extends 
E> (E was previously stated as <E extends Enum<E>>) are not considered
compatible.
After changing
EnumSet<E> set = (EnumSet<E>)collection;
into
EnumSet set = (EnumSet)collection;
, compilation using ant in command line succeeds.
Would any one give a clue, why the are considered incompatible in this 
version of JDK?

Eclipse uses its own JDK compiler, which may differ from this 1.5.0_08 
version compiler.
I guess this is the reason why compilation only fails in command line on 
your machine.

Best regards
>
> Richard.
>>
>> Best regards,
>> Richard
>>
>>>
>>>
>>> When I compile in Eclipse 3.2 there's no error.
>>>
>>>
>>>
>>> -Nathan
>>>
>>>
>>
>


-- 
Spark Shen
China Software Development Lab, IBM


---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Sun compiler change?

Posted by Richard Liang <ri...@gmail.com>.

Richard Liang wrote:
>
>
> Nathan Beyer wrote:
>> Is anyone else using the latest Sun JDK, v5.0 Update 8 on Windows?
>>
>>  
>>
>> I'm seeing a compilation error in the LUNI that I don't see with 5.0 
>> Update
>> 7. Here's the error I'm getting.
>>
>>  
>>
>> compile:
>>
>>     [mkdir] Created dir:
>> C:\dev\harmony\enhanced\classlib\trunk\build\classes
>>
>>     [javac] Compiling 3173 source files to
>> C:\dev\harmony\enhanced\classlib\trun
>>
>> k\build\classes
>>
>>     [javac]
>> C:\dev\harmony\enhanced\classlib\trunk\modules\luni\src\main\java\ja
>>
>> va\util\MiniEnumSet.java:78: inconvertible types
>>
>>     [javac] found   : java.util.Collection<capture of ? extends E>
>>
>>     [javac] required: java.util.EnumSet<E>
>>
>>     [javac]             EnumSet<E> set = (EnumSet<E>) collection;
>>
>>     [javac]                                           ^
>>
>>  
>>   
> Yes, I got the same error using  1.5.0_08. Will have a look at it. :-)
This should be an enhancement/bug-fixing of java compiler. There are 
bugs in java.util.MiniEnumSet. I will try to fix it later....

Richard.
>
> Best regards,
> Richard
>
>>  
>>
>> When I compile in Eclipse 3.2 there's no error.
>>
>>  
>>
>> -Nathan
>>
>>
>>   
>

-- 
Richard Liang
China Software Development Lab, IBM 



---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Sun compiler change?

Posted by Richard Liang <ri...@gmail.com>.

Nathan Beyer wrote:
> Is anyone else using the latest Sun JDK, v5.0 Update 8 on Windows?
>
>  
>
> I'm seeing a compilation error in the LUNI that I don't see with 5.0 Update
> 7. Here's the error I'm getting.
>
>  
>
> compile:
>
>     [mkdir] Created dir:
> C:\dev\harmony\enhanced\classlib\trunk\build\classes
>
>     [javac] Compiling 3173 source files to
> C:\dev\harmony\enhanced\classlib\trun
>
> k\build\classes
>
>     [javac]
> C:\dev\harmony\enhanced\classlib\trunk\modules\luni\src\main\java\ja
>
> va\util\MiniEnumSet.java:78: inconvertible types
>
>     [javac] found   : java.util.Collection<capture of ? extends E>
>
>     [javac] required: java.util.EnumSet<E>
>
>     [javac]             EnumSet<E> set = (EnumSet<E>) collection;
>
>     [javac]                                           ^
>
>  
>   
Yes, I got the same error using  1.5.0_08. Will have a look at it. :-)

Best regards,
Richard

>  
>
> When I compile in Eclipse 3.2 there's no error.
>
>  
>
> -Nathan
>
>
>   

-- 
Richard Liang
China Software Development Lab, IBM 



---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


RE: [classlib] Sun compiler change?

Posted by Nathan Beyer <nb...@kc.rr.com>.
> -----Original Message-----
> From: Spark Shen [mailto:smallsmallorgan@gmail.com]
> 
> Nathan Beyer 写道:
> > There were some compiler changes according to the release notes [1]. Of
> > particular note is this bug fix [2], which is related to a number of
> bugs. I
> > think this may be it.
> >
> So, I think at the moment, it is more safe to use the below
> pattern(different compiler implements slightly different generic feature):

They shouldn't be. If this is something that should also fail to compile
with Eclipse, then I would suggest logging a bug for the JDT. They'll be
able to confirm the correct behavior.

> 
> EnumSet set = (EnumSet)collection;
> and leave the warning as it is. When compiler itself is consistent with
> generic,
> these warning may remind us later.
> 
> Best regards
> > -Nathan
> >
> > [1] https://java.sun.com/j2se/1.5.0/ReleaseNotes.html#150_08
> > [2] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4916620
> >
> >
> >> -----Original Message-----
> >> From: Nathan Beyer [mailto:nbeyer@kc.rr.com]
> >> Sent: Friday, August 25, 2006 6:55 PM
> >> To: harmony-dev@incubator.apache.org
> >> Subject: [classlib] Sun compiler change?
> >>
> >> Is anyone else using the latest Sun JDK, v5.0 Update 8 on Windows?
> >>
> >>
> >>
> >> I'm seeing a compilation error in the LUNI that I don't see with 5.0
> >> Update
> >> 7. Here's the error I'm getting.
> >>
> >>
> >>
> >> compile:
> >>
> >>     [mkdir] Created dir:
> >> C:\dev\harmony\enhanced\classlib\trunk\build\classes
> >>
> >>     [javac] Compiling 3173 source files to
> >> C:\dev\harmony\enhanced\classlib\trun
> >>
> >> k\build\classes
> >>
> >>     [javac]
> >> C:\dev\harmony\enhanced\classlib\trunk\modules\luni\src\main\java\ja
> >>
> >> va\util\MiniEnumSet.java:78: inconvertible types
> >>
> >>     [javac] found   : java.util.Collection<capture of ? extends E>
> >>
> >>     [javac] required: java.util.EnumSet<E>
> >>
> >>     [javac]             EnumSet<E> set = (EnumSet<E>) collection;
> >>
> >>     [javac]                                           ^
> >>
> >>
> >>
> >>
> >>
> >> When I compile in Eclipse 3.2 there's no error.
> >>
> >>
> >>
> >> -Nathan
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> >
> >
> 
> 
> --
> Spark Shen
> China Software Development Lab, IBM
> 
> 
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org


---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Sun compiler change?

Posted by Spark Shen <sm...@gmail.com>.
Nathan Beyer 写道:
> There were some compiler changes according to the release notes [1]. Of
> particular note is this bug fix [2], which is related to a number of bugs. I
> think this may be it.
>   
So, I think at the moment, it is more safe to use the below 
pattern(different compiler implements slightly different generic feature):

EnumSet set = (EnumSet)collection;
and leave the warning as it is. When compiler itself is consistent with generic,
these warning may remind us later.

Best regards
> -Nathan
>
> [1] https://java.sun.com/j2se/1.5.0/ReleaseNotes.html#150_08
> [2] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4916620
>
>   
>> -----Original Message-----
>> From: Nathan Beyer [mailto:nbeyer@kc.rr.com]
>> Sent: Friday, August 25, 2006 6:55 PM
>> To: harmony-dev@incubator.apache.org
>> Subject: [classlib] Sun compiler change?
>>
>> Is anyone else using the latest Sun JDK, v5.0 Update 8 on Windows?
>>
>>
>>
>> I'm seeing a compilation error in the LUNI that I don't see with 5.0
>> Update
>> 7. Here's the error I'm getting.
>>
>>
>>
>> compile:
>>
>>     [mkdir] Created dir:
>> C:\dev\harmony\enhanced\classlib\trunk\build\classes
>>
>>     [javac] Compiling 3173 source files to
>> C:\dev\harmony\enhanced\classlib\trun
>>
>> k\build\classes
>>
>>     [javac]
>> C:\dev\harmony\enhanced\classlib\trunk\modules\luni\src\main\java\ja
>>
>> va\util\MiniEnumSet.java:78: inconvertible types
>>
>>     [javac] found   : java.util.Collection<capture of ? extends E>
>>
>>     [javac] required: java.util.EnumSet<E>
>>
>>     [javac]             EnumSet<E> set = (EnumSet<E>) collection;
>>
>>     [javac]                                           ^
>>
>>
>>
>>
>>
>> When I compile in Eclipse 3.2 there's no error.
>>
>>
>>
>> -Nathan
>>     
>
>
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>
>   


-- 
Spark Shen
China Software Development Lab, IBM


---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


RE: [classlib] Sun compiler change?

Posted by Nathan Beyer <nb...@kc.rr.com>.
There were some compiler changes according to the release notes [1]. Of
particular note is this bug fix [2], which is related to a number of bugs. I
think this may be it.

-Nathan

[1] https://java.sun.com/j2se/1.5.0/ReleaseNotes.html#150_08
[2] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4916620

> -----Original Message-----
> From: Nathan Beyer [mailto:nbeyer@kc.rr.com]
> Sent: Friday, August 25, 2006 6:55 PM
> To: harmony-dev@incubator.apache.org
> Subject: [classlib] Sun compiler change?
> 
> Is anyone else using the latest Sun JDK, v5.0 Update 8 on Windows?
> 
> 
> 
> I'm seeing a compilation error in the LUNI that I don't see with 5.0
> Update
> 7. Here's the error I'm getting.
> 
> 
> 
> compile:
> 
>     [mkdir] Created dir:
> C:\dev\harmony\enhanced\classlib\trunk\build\classes
> 
>     [javac] Compiling 3173 source files to
> C:\dev\harmony\enhanced\classlib\trun
> 
> k\build\classes
> 
>     [javac]
> C:\dev\harmony\enhanced\classlib\trunk\modules\luni\src\main\java\ja
> 
> va\util\MiniEnumSet.java:78: inconvertible types
> 
>     [javac] found   : java.util.Collection<capture of ? extends E>
> 
>     [javac] required: java.util.EnumSet<E>
> 
>     [javac]             EnumSet<E> set = (EnumSet<E>) collection;
> 
>     [javac]                                           ^
> 
> 
> 
> 
> 
> When I compile in Eclipse 3.2 there's no error.
> 
> 
> 
> -Nathan



---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org