I feel having a generic return value that isn't influenced by the inputs is a bad idea.  It is particularly prone to issues where return value is not actually a D, but something else. I also know there was a bug in the Java compiler around this at one stage (specifically a mismatch between the way the eclipse compiler and java compiler handled them).  I recommend having Class<D> as one of the arguments, and then using class.cast() rather the (D) to handle the cast out (and also checking the result and returning null if it doesn't match).