Merge "Fix ClassCastException from toArray()."