public void set(int n, Constant cst) {
    throwIfImmutable();

    boolean cat2 = (cst != null) && cst.isCategory2();

    if (n < 1) {
      throw new IllegalArgumentException("n < 1");
    }

    if (cat2) {
      // Storing a category-2 entry nulls out the next index.
      if (n == (entries.length - 1)) {
        throw new IllegalArgumentException("(n == size - 1) && " + "cst.isCategory2()");
      }
      entries[n + 1] = null;
    }

    if ((cst != null) && (entries[n] == null)) {
      /*
       * Overwriting the second half of a category-2 entry nulls out
       * the first half.
       */
      Constant prev = entries[n - 1];
      if ((prev != null) && prev.isCategory2()) {
        entries[n - 1] = null;
      }
    }

    entries[n] = cst;
  }
Sets the entry at the given index.

@param n {@code >= 1, < size();} which entry
@param cst {@code null-ok;} the constant to store
android/android_framework/dex-maker/src/main/java/com/android/dx/rop/cst/StdConstantPool.java