Fix runtime type of Array.items to prevent ClassCastException

Related to issues #568 and #1423