From Angelika Langer's generic FAQ:
Eliding type parameters.
When the compiler finds the definition of a generic type or method, it removes all occurrences of the type parameters and replaces them by their leftmost bound, or type Object if no bound had been specified.
Edit: As I understood in this case leftmost bound means what it means literally i.e farthest to the left in the list of bounds. I want to understand why was this policy chosen?
In this case "leftmost" is not technical terminology. It literally means "farthest to the left". It simply means that when the type parameter has several bounds (restrictions) like this:
T extends Callable<Long> & Runnable
the compiler replaces all occurances of the type parameter T
with the bound that is farthest to the left (in this case that's Callable<Long>
):
Meaning that, as in Angelika's example, this:
private T task1, task2;
is replaced with this:
private Callable task1, task2;
There is no reason. They just need to pick one. The whole thing sucks. It's like asking which one of your children you want to save. You want to save all, duh. But they don't let you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With