For the life of me I can't figure out why I can't find the thread where I once asked about Type Witnesses and was instructed that they used to be marginally useful, but for reasons I don't remember have become just a Trivia Answer in Java 8 and beyond and we can pretty much forget about them as long as we don't freak out when we see them on exams or in older code.
They are mentioned in the 816/819 Sybex book, in that context...one answer choice to a mock question is:
Helper.<NullPointerException>printException( new NullPointerException ("D") );
Option D uses an odd syntax by explicitly listing the type, but you should be able to recognize it as acceptable.
Is that what I should be remembering?
"When you stick a <Classname> between the . after the name of a class (for calling a static method) or the reference and the name of the method you are calling from it, that's this old thing called a Type Witness. It used to be marginally useful, but for reasons you don't need to know if you don't care for trivia, you basically don't need them anymore in Java 8. Don't freak out if you see them in older code or on an exam"?
If your goal is to get through life without getting lost in all the ugly details, then yes, you can mostly forget about type witnesses in Java. They are only very rarely useful, and even when they are, you can usually get rid of them by introducing intermediate variables to help Java's automatic type inference:
(Yes, I'm aware that Comparator also has the static reverseOrder() method that can be used instead of naturalOrder().reversed(), but for sake of argument let's pretend it doesn't exist.)
It's still nice to know about type witnesses in general though. Languages that have better runtime support for generics (such as C#) make hefty use of type witnesses (although I'm not sure they're called that way in those languages). Here's an example: