Correct me if I’m wrong, but I noticed recently with wildcards in Java, that…
? super T pretty much means ? accepts T
and…
? extends T generally means ? returns T.
Suppose I have a List<? extends Cat>. Is there ever a reason I’d declare this other than wanting to get a Cat out of it? Or what about LitterBox<? super Cat>? Would I ever declare such a thing unless I wanted to pass a Cat (or something that passes a Cat) into it?
So assuming that rationale holds…
Is there any way I could get Eclipse to both syntax highlight and auto-replace accepts and returns with super and extends?
Also, is there any reason besides “I’ll have to regex my code before letting other people look at it” that this may not be a great idea?
Of course there are plenty of reasons why Oracle didn’t make this a language feature, for example:
superandextendspretty much exactly capture the meaning;acceptsandreturnsin those positions don’t even have any sense; it may only be useful to imagine them there in order to help your general understanding. A typeT extends Listneither accepts, nor returns anything.