Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Preceeding if block leads to partial instruction coverage on while statement (ECJ only) #505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
Loading
from

Conversation

Godin
Copy link
Member

@Godin Godin commented May 4, 2017

While inserting compiler specific tests in our validation tests it turned out that for ECJ we get different coverage results for a while block when there is a preceeding if/else block.

Test target:

Test verification:

assertLine("whilefalse", isJDKCompiler ? ICounter.FULLY_COVERED

@Godin
Copy link
Member

Godin commented Mar 28, 2017

To me this looks like artifact of ECJ compiler:
given

class Fun {
  void fun(boolean b) {
    if (b) {
      System.out.println("then");
    } else {
      System.out.println("else");
    }

    while (b) { // line 9
      System.out.println("while");
    }
  }
}

ECJ 4.6.2 generates

    Code:
      stack=2, locals=2, args_size=2
         0: iload_1
         1: ifeq          15
         4: getstatic     #13                 // Field java/lang/System.out:Ljava/io/PrintStream;
         7: ldc           #19                 // String then
         9: invokevirtual #21                 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
        12: goto          34
        15: getstatic     #13                 // Field java/lang/System.out:Ljava/io/PrintStream;
        18: ldc           #27                 // String else
        20: invokevirtual #21                 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
        23: goto          34
        26: getstatic     #13                 // Field java/lang/System.out:Ljava/io/PrintStream;
        29: ldc           #29                 // String while
        31: invokevirtual #21                 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
        34: iload_1
        35: ifne          26
        38: return
      LineNumberTable:
        line 3: 0
        line 4: 4
        line 5: 12
        line 6: 15
        line 9: 23
        line 10: 26
        line 9: 34
        line 12: 38

where goto on a path from else branch is explicitly marked as belonging to a line of while statement. And so @marchof I'm wondering why you labeled this as "bug"?

@marchof
Copy link
Member Author

marchof commented Mar 28, 2017

@Godin I created this issue as a reminder to follow-up your observation without further investigation. My assumption was this is an issue on our side (like #321). So we can close this. Thanks for looking into it!

@marchof marchof closed this Mar 28, 2017
@marchof marchof added declined: otherproject 👽 This issue should be reported to other project and removed type: bug 🐛 Something isn't working labels Mar 28, 2017
@Godin
Copy link
Member

Godin commented Mar 28, 2017

@marchof in fact I did this investigation prior to #503 (comment) , excuse me for a scarce comment. And my proposal in #504 (comment) was to preserve test of this interesting case maybe even with detailed explanation of why this happens at least to be able to refer to it in case of questions like "why such coverage is shown".

@Godin
Copy link
Member

Godin commented May 4, 2017

@marchof I'd like to reopen this as a request for enhancement:

As was said earlier - case is quite interesting and IMO deserves place in our validation tests.

Furthermore in a filter for finally, I've got second example when GOTO instruction should be ignored specifically for ECJ to avoid partial coverage. So maybe we can simply ignore all GOTO instructions, not counting corner cases of infinite loops while (true) ; and for (;;) ; ?

@marchof marchof added type: enhancement and removed declined: otherproject 👽 This issue should be reported to other project labels May 4, 2017
@marchof
Copy link
Member Author

marchof commented May 4, 2017

@Godin Interesting idea to remove all GOTOs. We can now easily add a filter for this and see what our regression tests say 😎

@Godin Godin reopened this May 4, 2017
@Godin Godin force-pushed the issue-505 branch 3 times, most recently from 301d4cc to 431d0f0 Compare May 5, 2017 07:06
@Godin
Copy link
Member

Godin commented May 5, 2017

@marchof unfortunately I completely forgot that break and continue statements are compiled into GOTO 😞 , so that unlikely we'll be able to implement filter here. Most likely this also means that not safe to ignore GOTO in filter for finally. And anyway I wanna at least re-add case described here to validation tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.