Menu

#648 empty if/else statement incorrectly handled

patched
closed-duplicate
emitter (227)
5
2002-08-19
2002-08-18
Anonymous
No

I have the following statement in my code:

<pre>
if (target.getPackage().getPackageName().equals(source.getPackageName())) {
addNewImport(target);
}
else if (target.getPackage().getPackageName().equals(destination.getPackageName())) {

}
else {
addNewImport(target);
}
</pre>

As you can see, there is an empty if statement. When I compile and run this under the latest version of jikes, my unit tests fail. Under the previous version of jikes and javac 1.4, it works fine. I'm pretty certain this is a jikes bug because when I put a print statement in the "else if", the bug disappears.

<pre>
if (target.getPackage().getPackageName().equals(source.getPackageName())) {
addNewImport(target);
}
else if (target.getPackage().getPackageName().equals(destination.getPackageName())) {
System.out.println("If I put a print statement here, the bugs go away and the program behaves just as with previous versions of jikes.");
}
else {
addNewImport(target);
}
</pre>

Discussion

  • Eric Blake

    Eric Blake - 2002-08-19
    • labels: 105 --> emitter
    • assigned_to: nobody --> ebblake
    • status: open --> closed-duplicate
     
  • Eric Blake

    Eric Blake - 2002-08-19

    Yet another duplicate.

     

Log in to post a comment.

MongoDB Logo MongoDB