[Bug 859] javac to strict when checking cast

bugzilla-daemon at icedtea.classpath.org bugzilla-daemon at icedtea.classpath.org
Tue Feb 21 06:14:07 PST 2012


http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=859

Andrew John Hughes <ahughes at redhat.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |WONTFIX

--- Comment #3 from Andrew John Hughes <ahughes at redhat.com> 2012-02-21 14:14:07 UTC ---
I still think you're wrong, but I suggest you take this up on
compiler-dev at openjdk.java.net.  If such a change was to be made, it wouldn't be
made locally in IcedTea.

If you really want to do this, maybe you should use an array instead as these
do allow covariance i.e.

StepRequest[] steps = (StepRequest[]) fRequests.get(STEP_INDEX)

where fRequests.get(STEP_INDEX) now returns a EventRequest[].

Parameterized types won't even allow the more obviously correct:

Collection<Super> subs;
HashSet<Sub> set = new HashSet<Sub>();

subs = (Collection<Super>) set;

As Sub is a subclass of Super, everything in the set is going to be a Super if
it's a Sub.  Yet this isn't allowed:

TestSub.java:20: inconvertible types
found   : java.util.HashSet<TestSub.Sub>
required: java.util.Collection<TestSub.Super>
    subs = (Collection<Super>) set;
                               ^
>From 4.5:

"Two parameterized types are provably distinct if either of the following
conditions hold:

    They are invocations of distinct generic type declarations.
    Any of their type arguments are provably distinct. "

-- 
Configure bugmail: http://icedtea.classpath.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the distro-pkg-dev mailing list