Add check for Array type in doc.canonicalize to avoid segfaulting
Throw TypeErrors in java #canonicalize and allow one or two parameter form, too.
Merge pull request #991 from larskanis/dont-segfault-in-canonicalize

Add check for Array type in doc.canonicalize to avoid segfaulting when called with wrong type.