Bug 83176

Summary: [1.5][compiler] Hiding of static method in superclass: Eclipse errors where java allows unchecked conversion
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: RESOLVED WORKSFORME QA Contact:
Severity: minor    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 RC2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Markus Keller CLA 2005-01-19 06:54:33 EST
I20050118-1015

Hiding of static method in superclass: Eclipse errors where java allows
unchecked conversion:

package p;
enum Color {
    RED, GREEN, BLUE;
    public static Color valueOf(Class c, String s) {
        return null;
    }
}

Eclipse:
Error: The return type is incompatible with Enum<Color>.valueOf(Class<T>, String)

javac:
warning: valueOf(java.lang.Class,java.lang.String) in p.Color overrides
<T>valueOf(java.lang.Class<T>,java.lang.String) in java.lang.Enum; return type
requires unchecked conversion
Comment 1 John Bollinger CLA 2005-02-18 17:14:51 EST
(In reply to comment #0)
This problem doesn't seem to be limited to static methods.  Consider this method:

    List<String> createStringList(final String[] array) {
        return new AbstractList<String>() {

            public int size() {
                return array.length;
            }
    
            public String get(int i) {      // Here is where the problem lies
                return array[i];
            }
        };
    }

M4 flags the return value of the get(int) method with an unchecked conversion
warning very much like the one described in the original report.  The applicable
value of the List's type parameter is known to the compiler at this point, but
it doesn't seem to be used.  The anonymous class is using a covariant return
type, true, but that's a legal.  Sun's version 1.5.0 compiler handles the code
without warning.
Comment 2 Philipe Mulet CLA 2005-06-09 05:59:16 EDT
Kent - is this still an issue ?
Comment 3 Kent Johnson CLA 2005-06-09 10:15:44 EDT
Both of these cases work for me with the latest.

Unsure when exactly they were fixed.