If "k instanceof String" is false aren't you're back in the same boat, assigning whatever Object it actually is to the name property?