code: public static Slice reverse(Slice utf8)
      {
          int length = utf8.length();
          Slice reverse = Slices.allocate(length);
  
          int forwardPosition = 0;
          int reversePosition = length;
          while (forwardPosition < length) {
              int codePointLength = lengthOfCodePointSafe(utf8, forwardPosition);
  
              // backup the reverse pointer
              reversePosition -= codePointLength;
              if (reversePosition < 0) {
                  // this should not happen
                  throw new InvalidUtf8Exception("UTF-8 is not well formed");
              }
              // copy the character
              copyUtf8SequenceUnsafe(utf8, forwardPosition, reverse, reversePosition, codePointLength);
  
              forwardPosition += codePointLength;
          }
          return reverse;
      }
docs: Reverses the slice code point by code point.
  <p>
  Note: Invalid UTF-8 sequences are copied directly to the output.