Basically, because of type erasure you cannot have overloaded methods using different Optional types. So test(Optional<A> a); is the same method as test(Optional<B> b);
I think you can define the types to get around it, but that is messy and a PITA. For example, class OptionalA extends Optional<A>.