retValue.getClass().getName() will always return the runtime type of the object and not the class name of the parameter type.
If you want to grab the parameter class, there's no other way than to use your first solution. (That is, pass the class object explicitly.)