Use class eq checking instead of reflection as getCanonicalName has a large overhead