15.6.3
Evaluation Respects Parentheses and Precedence
EXPRESSIONS
static int loseBig() throws Exception {
throw new Exception("Shuffle off to Buffalo!");
}
}
always prints:
java.lang.Exception: Shuffle off to Buffalo!
and not:
java.lang.ArithmeticException: / by zero
since no part of the division operation, including signaling of a divide by zero
exception, may appear to occur before the invocation of
loseBig
 completes, even
though the implementation may be able to detect or infer that the division opera 
tion would certainly result in a divide by zero exception.
15.6.3   Evaluation Respects Parentheses and Precedence
That is too weighty a subject to be discussed parenthetically . . .
 John Stuart Mill,
On Liberty
 (1869), Chapter IV
Java implementations must respect the order of evaluation as indicated explicitly
by parentheses and implicitly by operator precedence. An implementation may
not take advantage of algebraic identities such as the associative law to rewrite
expressions into a more convenient computational order unless it can be proven
that the replacement expression is equivalent in value and in its observable side
effects, even in the presence of multiple threads of execution (using the thread
execution model in  17), for all possible computational values that might be
involved.
In the case of floating point calculations, this rule applies also for infinity and
not a number (NaN) values. For example,
!(x
 may not be rewritten as
x>=y
,
because these expressions have different values if either
x
 or
y
 is NaN.
Specifically, floating point calculations that appear to be mathematically asso 
ciative are unlikely to be computationally associative. Such computations must
not be naively reordered. For example, it is not correct for a Java compiler to
rewrite
4.0*x*0.5
 as
2.0*x
; while roundoff happens not to be an issue here,
there are large values of
x
 for which the first expression produces infinity (because
of overflow) but the second expression produces a finite result.
So, for example, the test program:
308






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved