Not quite related to this patch per-se, but this check would not work for very large objects since the JVM would be able to load everything into an array.
Second, I think the compressed data would usually also be identical so we could check the compressed data first and only decompress and check the real data if that fails.