correct cast not allowed

I think the spec allows this scenario underneath as unchecked cast, however javac does not allow it.

Can someone confirm this?

Coconha

publicclass TestCasting<Sextends Comparable><S>>{

public TestCasting(){

S a = (S)(Integer)3;// this should not fail

}

}

[590 byte] By [coconhaa] at [2007-10-1 13:48:37]
# 1

TestCasting<S

'>' is omitted, supposed to be so?

What's 'S'?

I don't think you cast figure into Integer, it ain't an Object

Here's solution, should work

public class TestCasting {

public TestCasting() {

Integer i = new Integer(3); // that's the way to init an Integer

S a = (S)i; // not sure 'bout this one, what's S?!

}

}

yahooa at 2007-7-10 16:58:17 > top of Java-index,Developer Tools,Java Compiler...
# 2
Integer is final:public final class IntegerYou can not derive a class from it, so an Integer can [bnot ] be an S.Casting is not converting!
BIJ001a at 2007-7-10 16:58:17 > top of Java-index,Developer Tools,Java Compiler...
# 3

Hi,

There is no '>' omited and I am not looking for an alternative solution to the problem. I am sorry for not clarifying the problem correctly, but all I am saying is that according to the Java Specification (if I understood it right) this cast should be allowed with an 'unchecked cast' warning (there is a Bug in javac).

Can someone also confirm this?

Coconha

coconhaa at 2007-7-10 16:58:17 > top of Java-index,Developer Tools,Java Compiler...