[1.7.x] Fixed #22436: More careful checking on method ref'ce serialization