-
Bug
-
Resolution: Fixed
-
P3
-
6u12
-
b51
-
x86
-
windows_vista
-
Not verified
Here is the small program
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Vector<Integer> ids = new Vector<Integer>() {
{
addElement(0);
}
};
int id = 0;
// for(int currentId : ids){ // (A)
for(int i = 0; i < ids.size(); i++) { // (B)
int currentId = ids.elementAt(i); // (B)
if(id != currentId){
ids.insertElementAt(new Integer(id), id);
System.out.println("damn");
}
}
}
}
I tried to debug this in Netbeans 6.5. If I step through the code using old-style for loop (B) the stepping works as expected.
If I use the enhanced-for loop (A), then the stepping stops at "damn" statement. Ofcourse it is not executing that statement. I guess it suppose to be hitting the closing brace after "damn".
Looks like the generated code has some wrong line number table, that is why this problem.
I used javap to get the Linenumber table attribute and it really seems to be wrong.
Main.java and Main.javap are attached.
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Vector<Integer> ids = new Vector<Integer>() {
{
addElement(0);
}
};
int id = 0;
// for(int currentId : ids){ // (A)
for(int i = 0; i < ids.size(); i++) { // (B)
int currentId = ids.elementAt(i); // (B)
if(id != currentId){
ids.insertElementAt(new Integer(id), id);
System.out.println("damn");
}
}
}
}
I tried to debug this in Netbeans 6.5. If I step through the code using old-style for loop (B) the stepping works as expected.
If I use the enhanced-for loop (A), then the stepping stops at "damn" statement. Ofcourse it is not executing that statement. I guess it suppose to be hitting the closing brace after "damn".
Looks like the generated code has some wrong line number table, that is why this problem.
I used javap to get the Linenumber table attribute and it really seems to be wrong.
Main.java and Main.javap are attached.