fix npe for generic types

this only changes behavior that was previously greeted with a npe time
bomb, so I am guessing it will be okay.

as an aside, I am a little surprised we don't see encoding/ decoding
come up more frequently as performance hot spots...