In a method I have this:

```
int x = 0
if (isA()) {
    x = 1;
} else if (isB()) {
    x = 2;
}

if (x != 0) {
    doLater(() -> showErrorMessage(x)); // compile error here
}

// no more reference to 'x' here

```

I don't understand why it produces compilation error. The error says that `x` is not final or effectively-final, so it can't be accessed from the lambda body. There is no modification to `x` after the `doLater` call, so the value of `x` is actually already determined when `doLater` is called.

I am guessing that the answer to this question is because `x` is not qualified to be called an effectively-final variable. However, I want to know what the reason is.

Can't the compiler just create a temporary final variable, effectively making the code like:

```
if (x != 0) {
    final int final_x = x;
    doLater(() -> showErrorMessage(final_x));
}

```

and everything still work the same?