Search code examples
javadecompilinglegacylegacy-code

In what version of Java did assigning false to an integer become invalid?


I have the following legacy code from what looks to be a Java 1.1 library:

int colon_index = false;

for(int i = 0; i < params_split.length; ++i) {
    int colon_index = params_split[i].indexOf(":");
    if (colon_index > 0) {
        // ...
    }
}

It appears to be assigning false to a variable of type int. This is decompiled code, so it's also possible the IntelliJ decompiler has made a mistake.

I've checked release notes for old versions, but haven't been able to spot this change yet.

Assuming this was correct at some point in Java's history, in what version of Java did this syntax stop being valid?


Solution

  • You can't trust decompiled code. Originally, it would've been int colon_index = 0

    Check out this answer for more details.