Question about Assertion
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   mandeep_singh
Posted On:   Sunday, April 23, 2006 04:38 AM

I am compiling following program. public class Speed { public static void main(String[] args) { Speed objRef=new Speed(); double speed=objRef.calcSpeed(-12.0,3.0); //double speed=objRef.calcSpeed(12.0,-3.0); //double speed=objRef.calcSpeed(12.0,2.0); //double speed=objRef.calcSpeed(12.0,0.0); System.out.println("Speed(km/h):"+speed); } private double calcSpeed(double distance,double time) { assert distance>=0.0; assert time>0.0:"Time is not a positive value:"+time; double speed=distance/time; assert speed>=0.0; return speed; } } javac -source 1.4 Speed.java F   More>>

I am compiling following program.
public class Speed
{
public static void main(String[] args)
{
Speed objRef=new Speed();
double speed=objRef.calcSpeed(-12.0,3.0);
//double speed=objRef.calcSpeed(12.0,-3.0);
//double speed=objRef.calcSpeed(12.0,2.0);
//double speed=objRef.calcSpeed(12.0,0.0);
System.out.println("Speed(km/h):"+speed);
}
private double calcSpeed(double distance,double time)
{
assert distance>=0.0;
assert time>0.0:"Time is not a positive value:"+time;
double speed=distance/time;
assert speed>=0.0;
return speed;
}
}
javac -source 1.4 Speed.java

Folloing error occurs on command prompt.
An UnExpected Error detected by HotSpot Virtual Machine:

#
# EXCEPTION_FLT_DIVIDE_BY_ZERO (0xc000008e) at pc=0x00c2aa53, pid=1368, tid=1384
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_05-b05 mixed mode, sharing)
# Problematic frame:
# j com.sun.tools.javac.jvm.Items$ImmediateItem.isPosZero(D)Z+0
#

   <<Less

Re: Question about Assertion

Posted By:   Jani_Kaarela  
Posted On:   Wednesday, April 26, 2006 07:02 AM


Whoah. Certainly not normal behavior. Try validating that your JDK installation works. Also, check out the Bug database.

Re: Question about Assertion

Posted By:   Jani_Kaarela  
Posted On:   Tuesday, April 25, 2006 03:02 AM

Surround your code with

 tags and use line breaks and spaces/tabs it to make it readable!

About | Sitemap | Contact