public static int validateToken(CharSequence token) {
        if (token instanceof AsciiString) {
            return validateAsciiStringToken((AsciiString) token);
        }
        return validateCharSequenceToken(token);
    }
@DisabledForJreRange(max = JRE.JAVA_17) // This test is much too slow on older Java versions.
    @Test
    void headerNameValidationMustRejectAllNamesRejectedByOldAlgorithm() throws Exception {
        byte[] array = new byte[4];
        final ByteBuffer buffer = ByteBuffer.wrap(array);
        final AsciiString asciiString = new AsciiString(buffer, false);
        CharSequence charSequence = asCharSequence(asciiString);
        int i = Integer.MIN_VALUE;
        Supplier<String> failureMessageSupplier = new Supplier<String>() {
            @Override
            public String get() {
                return "validation mismatch on string '" + asciiString + "', iteration " + buffer.getInt(0);
            }
        };

        do {
            buffer.putInt(0, i);
            try {
                oldHeaderNameValidationAlgorithmAsciiString(asciiString);
            } catch (IllegalArgumentException ignore) {
                assertNotEquals(-1, validateToken(asciiString), failureMessageSupplier);
                assertNotEquals(-1, validateToken(charSequence), failureMessageSupplier);
            }
            i++;
        } while (i != Integer.MIN_VALUE);
    }