Fix for: doAccessChecks fail due to the wrong ClassCast toArray()