fix nullpointerexception from invalid opaque cast