@Override
    public void set(long i, Object o)
    {

        if (o == null) {
            if (ptr != 0) {
                objectLengths.setShort(i, (short) -1);
            } else {
                if (isConstant()) {
                    throw new IllegalAccessError("Constant arrays cannot be modified.");
                }
                data[(int) i] = null;
            }
        } else {
            if (ptr != 0) {
                byte[] ba = toByteArray(o);
                if (ba.length > maxObjectLength) {
                    throw new IllegalArgumentException("Object  " + o + " is too long.");
                }
                int objLen = ba.length;
                if (objLen > Short.MAX_VALUE) {
                    throw new IllegalArgumentException("Object  " + o + " is too long.");
                }
                objectLengths.setShort(i, (short) objLen);
                long offset = sizeof * i * maxObjectLength;
                for (int j = 0; j < objLen; j++) {
                    Utilities.UNSAFE.putByte(ptr + offset + sizeof * j, ba[j]);
                }
            } else {
                if (isConstant()) {
                    throw new IllegalAccessError("Constant arrays cannot be modified.");
                }
                data[(int) i] = o;
            }
        }
    }