Make synchronized wrappers of generic methods generic the same way it is done with delegate invokes. Fixes #12727.