Consider the following code snippet, I stumpled upon after some refactoring, when checkin why the build server reported a broken build but it was fine in my IDE:
<
I would say it is a compiler bug in the particular version of the Java 7 compiler that you are using.
The earlier text is a field, and it is legal for the text local declared in the for statement to shadow a field.
Then we look at what the for loop means. According to the JLS,
for (String text : text) {...}
is equivalent to
for (Iterator #i = text.iterator(); #i.hasNext(); ) {
String text = (String) #i.next();
...
}
As you can see the inner text is not in-scope for the text.iterator() expression.
I tried searching the Oracle Java Bugs Database, but couldn't find anything that matched this scenario.