Method Name and Class Name are not covered? Why?

390 views
Skip to first unread message

Echo

unread,
Nov 24, 2017, 2:20:07 AM11/24/17
to JaCoCo and EclEmma Users
Hi, All. When i use jacoco to run the code, the report seems incorrect and makes me confused. 
1. About the class name line.
As you can see in the picture, the first line in HelloTest is red and the first line in the Hello isn't red. But both classes have been executed. 
2.About the method name line.
In Hello class, line 3 is green while line 9 doesn't have any color. Is it because line 3 is INIT Method. 


Regrads
Echo

Marc Hoffmann

unread,
Nov 24, 2017, 10:13:43 AM11/24/17
to jac...@googlegroups.com

Hi Echo,

Case 1: This is the implicit default constructor added by the Java compiler. As the HelloTest is probably never instantiated this line is red.

Case 2: I don't have an explanation here. What exact compiler version are you using (Eclipse)? Can you please provide the corresponding class file for further analysis?

Regards,
-marc

--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/ac8f339e-ce47-4de9-9017-d86a3e421639%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

 

Echo

unread,
Nov 25, 2017, 3:05:32 AM11/25/17
to JaCoCo and EclEmma Users
Hi Marc
Case 1: "As the HelloTest is probably never instantiated this line is red". The line is red because HelloTest Class is never Instantiated. So why Hello Line doesn't have any color(red or green)? 
Case 2: All the constructor function is green or red. But the normal function line doesn't have any color. 
About the version: I use both eclipse(eclemma) and ant to check the phenomenon. The corresponding file are in the attachment 


在 2017年11月24日星期五 UTC+8下午11:13:43,Marc R. Hoffmann写道:
HelloTest.java
Hello.java
HelloTest.class
Hello.class

Evgeny Mandrikov

unread,
Nov 27, 2017, 5:50:51 PM11/27/17
to JaCoCo and EclEmma Users
Hi Echo,

Eclipse EclEmma plugin ( http://www.eclemma.org/ ) is based on JaCoCo library ( http://www.eclemma.org/jacoco/index.html ) that takes information about lines from bytecode. And bytecode is generated by a Java compiler.

Decompilation of your class files by command "javap -v -p" shows that "Hello.class" has following constructor and method and lines associated with them (output of command was trimmed to leave only relevant information):

  public Hello();
      LineNumberTable:
       line 3 
       line 4 
       line 5 
       line 6


  public void testGoto(int);
      LineNumberTable:
        line 10
        line 11
        line 12
        line 13
        line 15

and "HelloTest.class" has following constructor and method and lines associated with them:

  public HelloTest();
      LineNumberTable:
        line 1

  public static void main(java.lang.String[]);
      LineNumberTable:
        line 4
        line 5

From there you can see that compiler :
  • did not saved in bytecode numbers of lines with method names and that's why they all are not highlighted
  • line number of "public class HelloTest" has been saved as line of implicitly generated constructor, which is never called, and that's why it is highlighted as red
  • there is no implicitly generated constructor in "public class Hello" and that's why this line is not highlighted
  • line number of "public Hello(){" has been saved as line of explicit non-generated constructor, which is called, and that's why it is highlighted as green
All in all - there is no any "phenomenon", EclEmma shows lines that are saved in bytecode by compiler.

Regards,
Evgeny

Echo

unread,
Nov 28, 2017, 2:02:25 AM11/28/17
to JaCoCo and EclEmma Users
Hi Evgeny
Thank you for your help! ! You are right!!!
Regards,
Echo

在 2017年11月28日星期二 UTC+8上午6:50:51,Evgeny Mandrikov写道:
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages