Bug 83176 - [1.5][compiler] Hiding of static method in superclass: Eclipse errors where java allows unchecked conversion
Summary: [1.5][compiler] Hiding of static method in superclass: Eclipse errors where j...
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.1 RC2   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-19 06:54 EST by Markus Keller CLA
Modified: 2005-06-09 10:15 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.