Handle the possibility that getSuperclass() returns NULL.

Thanks to libraryaddict for discovering this bug.