@Override public Bytes<Void> writeUtf8(String str) throws BufferOverflowException { assert singleThreadedAccess(); if (str == null) { writeStopBit(-1); return this; } try { if (Jvm.isJava9Plus()) { byte[] strBytes = extractBytes(str); byte coder = getStringCoder(str); long utfLength = AppendableUtil.findUtf8Length(strBytes, coder); writeStopBit(utfLength); appendUtf8(strBytes, 0, str.length(), coder); } else { char[] chars = extractChars(str); long utfLength = AppendableUtil.findUtf8Length(chars); writeStopBit(utfLength); appendUtf8(chars, 0, chars.length); } return this; } catch (IllegalArgumentException e) { throw new AssertionError(e); } }