• Post Reply Bookmark Topic Watch Topic
  • New Topic

Casting to parameterized types and unchecked warnings  RSS feed

 
Arthur Vinicius Rebelo
Ranch Hand
Posts: 30
1
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone !
There is a sentence in JLS 7 which I can't figure it out. It says :
A cast from a type S to a parameterized type T is unchecked unless at least one of the following conditions holds:
-S <: T
-All of the type arguments (§4.5.1) of T are unbounded wildcards
-T <: S and S has no subtype X other than T where the type arguments of X are not contained in the type arguments of T.

Condition one and two I got it. But the number three is really bugging me.
I write some code in order to try to understand it.


In Eclipse I got no warning but it shouldn't give one ?
Because g has others subtypes than D<String, Integer> (e.g. D<String, List> , D<String, G>)
Am I missing something about the contained type arguments ?

Thank you in advance.
 
Arthur Vinicius Rebelo
Ranch Hand
Posts: 30
1
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to close this thread, it was an Eclipse bug. Tried with another IDE and it gave the unchecked warning.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arthur Vinicius Rebelo wrote:Just to close this thread, it was an Eclipse bug. Tried with another IDE and it gave the unchecked warning.


Thanks for telling us that it is no longer an issue. And also thanks for not deleting your original post too -- as some others will do.

You earned a cow...

Henry
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!