This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
I think, your question is why the first one gives the type erasure related error while the first one does not. The answer is that when you compile the second code ie..
compiler generates the corresponding bite code as follows -
In this case, you can see that all the type information was erased and T was converted to Object.... Now think of the first code mentioned by you.. ie
In this case, you are using instance of operator on T. Java compiler did not give this as an option and declared this an error due to obvious reasons that converting (my instanceof T) to (my instanceof Object) after compilation would have confused many developers as they could have been doing it thinking a type safe operation but it wold have not been.