Why sentence (1) did not return <Object>? Since <Object> works as shown in point (2), why <? extends Object> instead?
This is the best question of the three. I think the / Eclipse compiler does not want to assume that Object necessarily a type T , which is derived between String and Integer , so it is safe. As noted in @ bringer128 , String and Integer also implement Serializable and Comparable - so these types are also candidates for the intended type of method.
It is worth noting that the following code gives a compiler error of "illegal type startup":
GenericMethodInference.<? extends Object>test1("Hello", new Integer(1));
This is due to the fact that it is not valid for specifying a template as a parameter of a method type. Thus, the fact that you see that in the tooltip is related to the subtleties of the compiler / Eclipse means for reporting this information - he only determined that T is within its boundaries, and not what it is.
Remember that the implementation of Java generics is intended solely for the convenience of programmers. Once compiled into bytecode, type erasure will get rid of any T concept. Therefore, when checking, the compiler needs to make sure that a valid T can be inferred, but it is not necessary what it is.
why does sentence (3) produce <Object> instead of <? extends Object>?
Because in this case, the fact that a List<Object> is passed where the expected List<T> is expected tells the compiler that T exactly Object .
Since the sentence (4) uses the same variable, why is the 2nd type captured by the generated event, although the parameter used has the same variable d?
It is not safe for the compiler to assume that d actually refers to the same object, even between parameter evaluations. For example:
test4(d,(d = new ArrayList<String>()));
In this case, a List<Integer> will be passed to the first parameter, and List<String> to the second - as from d . Since this scenario is possible, it is easier for the compiler to play safely.