Assuming you are talking about the implementation in the Java8 Optional, you missed a part of the method signature:
As I read it, this signature says that the method returns a T, or else throws an X (it declares that it will throw an exception of type X). The provided Supplier, however, can return any subclass of X. For example, if we fill in some of those parameters, this would be valid:
whereas with the other approach (using Supplier<X> instead), the Supplier's type and the type of exception declared as thrown much match up.
Unfortunately, that's about as much as I can puzzle out. I can't think of any scenario where you could get the compiler to infer something like the above, or where it would be meaningful. You can throw and catch super classes of an exception just fine already... Hmmm...
Oh, right! Of course. I had missed that, so my own explanation kinda hit the point (that there might be some other X while ? represented a subclass). Phew, sanity restored, I believe you hit the nail on the head