public final int getAndSet(int newValue) {
        if (newValue < 0) {
            throw new IllegalArgumentException("new value " + newValue + " < 0");
        }
        return INDEX_UPDATER.getAndSet(this, newValue) & Integer.MAX_VALUE;
    }
@Test
    void testGetAndSet() {
        int get = i1.getAndSet(100);
        assertEquals(0, get);
        assertEquals(100, i1.get());

        try {
            i1.getAndSet(-1);
        } catch (IllegalArgumentException expected) {
            assertThat(expected.getMessage(), allOf(containsString("new value"), containsString("< 0")));
        }
    }