Community
Participate
Working Groups
Created attachment 275529 [details] The java files with the example from description. Trying to override a method with an argument which is a generic array of ? extends SomeGenericRawType leads to the following errors: 1. Name clash: The method method(Class<? extends List>...) of type SubClass has the same erasure as method(Class<? extends List>...) of type BaseClass but does not override it 2. The method method(Class<? extends List>...) of type SubClass must override or implement a supertype method ------ Here a small example: public class BaseClass { public String method(Class<? extends List>... classes) { return null; } } public class SubClass extends BaseClass { @Override public String method(Class<? extends List>... classes) { return null; } } ------ The compile errors would not apprear if the argument is not an array, so the <? extends RawType> seems to be allowed and considered, but not for arrays. ------ The oracle compiler has no problem with the example above. ------ When changing the example the following way (make List not being a raw type, List<?>), the .class file looks the same, but there are no compile errors: public class BaseClass { public String method(Class<? extends List<?>>... classes) { return null; } } public class SubClass extends BaseClass { @Override public String method(Class<? extends List<?>>... classes) { return null; } }
(In reply to Elisej Friedrich from comment #0) > ------ > When changing the example the following way (make List not being a raw type, > List<?>), the .class file looks the same, but there are no compile errors: > > > public class BaseClass { > > public String method(Class<? extends List<?>>... classes) { > return null; > } > } > > public class SubClass extends BaseClass { > > @Override > public String method(Class<? extends List<?>>... classes) { > return null; > } > } That's the proper way of coding this. I not sure that the original mixture of arrays, generics, wildcards and raw types is sufficiently well defined in JLS, such that compilers come to the same conclusion. Please don't hold your breath waiting for this issue to be resolved.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.