jacoco and System.exit

216 views
Skip to first unread message

Harry Terzian

unread,
Dec 12, 2012, 8:40:24 AM12/12/12
to jac...@googlegroups.com
Hello,

I have the following example code, i have also attached a png file with the colourings of two runs, one with myclass.method(1) and the other with myclass.method(3)
When system.exit(anything) is called, the whole function mymethod, is coloured as red. When reading the shutdown hook documentation it says that:

The Java virtual machine shuts down in response to two kinds of events:
  • The program exits normally, when the last non-daemon thread exits or when the exit (equivalently,System.exit) method is invoked, or
  • The virtual machine is terminated in response to a user interrupt, such as typing ^C, or a system-wide event, such as user logoff or system shutdown.

However the execution data probably not getting recorded. Is this a known limitation?
 

public class MyClass {

public static void main(String[] args) {
MyClass myclass = new MyClass();
myclass.mymethod(1);
}
void mymethod(int b) {
if(b == 3) {
System.runFinalization();
System.exit(0);
} else {
b = 3;
}
}
}



Systemexit.png

Marc R. Hoffmann

unread,
Dec 12, 2012, 4:05:44 PM12/12/12
to jac...@googlegroups.com
Hi,

this is the same known limitation as for implicit exceptions: As
System.exit() will never return the subsequent probe can never be executed.

Best regards,
-marc

On 12.12.12 14:40, Harry Terzian wrote:
> Hello,
>
> I have the following example code, i have also attached a png file with
> the colourings of two runs, one with myclass.method(1) and the other
> with myclass.method(3)
> When system.exit(anything) is called, the whole function mymethod, is
> coloured as red. When reading the shutdown hook documentation it says that:
>
> The Java virtual machine /shuts down/ in response to two kinds of
> events:
>
> * The program /exits/ normally, when the last non-daemon thread
> exits or when the |exit|
> <http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#exit(int)> (equivalently,|System.exit|
> <http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#exit(int)>)
> method is invoked, or
>
> * The virtual machine is /terminated/ in response to a user

Harry Terzian

unread,
Dec 13, 2012, 4:48:30 AM12/13/12
to jac...@googlegroups.com
Okay, thanks,

Regards,
Harry Terzian
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages