Repainting artifacts in Swing when doing clipping (rectangular repaint)

I’m learning Swing by reading Oracle tutorial:

For efficiency tutorial suggests to use clipping when repainting scene, for example:

private void moveSquare(int x, int y) {
    int OFFSET = 1;
    if ((squareX!=x) || (squareY!=y)) {
        // "Erasing" rectangle from old location
        // "Paining" rectangle on new location

Tutorial suggests that two repaint requests will be merged into a single repainting, because both were requested from same event handler.

An important point worth noting is that although we have invoked
repaint twice in a row in the same event handler, Swing is smart
enough to take that information and repaint those sections of the
screen all in one single paint operation. In other words, Swing will
not repaint the component twice in a row, even if that is what the
code appears to be doing.

However, when rectangle is moving fast, I’ve noticed rendering artifacts like this (left edge is not painted):

rendering artifact

If I replace two rectangular repaint(...) requests with a single global repaint() request, everything is rendered correctly.

Why two rectangular repaints cause this rendering problem? It seems to me like Java is not merging “erase” a “paint” requests into a single one.

(I’m using Oracle JDK 9.0.1)