JDK-6541884 : javac bug (JDK6): missing unchecked warning
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: linux
  • CPU: x86
  • Submitted: 2007-04-03
  • Updated: 2011-02-16
  • Resolved: 2010-03-29
Related Reports
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
JDK6

ADDITIONAL OS VERSION INFORMATION :
All platforms

EXTRA RELEVANT SYSTEM CONFIGURATION :
All configurations

A DESCRIPTION OF THE PROBLEM :
javac 1.6 give no unchecked warning on this:

interface I1<T> {}
final class GC33<T> implements I1<Short> {}

class Z<T, U extends T, V extends Number> {
        GC33<Short> x = null;
        I1<V> y = (I1<V>)x;
}

We can tell that a GC33<Short> can be cast safely to an I1<Short>, but if V is something other than Short the cast to I1<V> is not valid.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the program and observe the absence of the required warning.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
An unchecked warning is required by the JLS.
ACTUAL -
No warning is produced.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
The required warning message is not produced by the compiler.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
interface I1<T> {}
final class GC33<T> implements I1<Short> {}

class Z<T, U extends T, V extends Number> {
        GC33<Short> x = null;
        I1<V> y = (I1<V>)x;
}
---------- END SOURCE ----------

Comments
EVALUATION Not reproducible in JDK 7 (see 6557182)
29-03-2010