code: static void formatMessage(final StringBuilder buffer, final String messagePattern,
              final Object[] arguments, final int argCount) {
          if (messagePattern == null || arguments == null || argCount == 0) {
              buffer.append(messagePattern);
              return;
          }
          int escapeCounter = 0;
          int currentArgument = 0;
          int i = 0;
          final int len = messagePattern.length();
          for (; i < len - 1; i++) { // last char is excluded from the loop
              final char curChar = messagePattern.charAt(i);
              if (curChar == ESCAPE_CHAR) {
                  escapeCounter++;
              } else {
                  if (isDelimPair(curChar, messagePattern, i)) { // looks ahead one char
                      i++;
  
                      // write escaped escape chars
                      writeEscapedEscapeChars(escapeCounter, buffer);
  
                      if (isOdd(escapeCounter)) {
                          // i.e. escaped: write escaped escape chars
                          writeDelimPair(buffer);
                      } else {
                          // unescaped
                          writeArgOrDelimPair(arguments, argCount, currentArgument, buffer);
                          currentArgument++;
                      }
                  } else {
                      handleLiteralChar(buffer, escapeCounter, curChar);
                  }
                  escapeCounter = 0;
              }
          }
          handleRemainingCharIfAny(messagePattern, len, buffer, escapeCounter, i);
      }
docs: Replace placeholders in the given messagePattern with arguments.
  
  @param buffer the buffer to write the formatted message into
  @param messagePattern the message pattern containing placeholders.
  @param arguments      the arguments to be used to replace placeholders.