[java] Cast type parameter values to object on _set_f implementations. Closes #2835