Java Reference
In-Depth Information
If a class, interface, or method, X , is declared strictfp , then X and any class, interface, meth-
od, constructor, instance initializer, static initializer or variable initializer within X is said
to be FP-strict .
Note that an annotation (§ 9.7 ) element value (§ 9.6 ) is always FP-strict, because it is
always a compile-time constant expression.
It follows that an expression is not FP-strict if and only if it is not a compile-time constant
expression and it does not appear within any declaration that has the strictfp modifier.
Within an FP-strict expression, all intermediate values must be elements of the float value
set or the double value set, implying that the results of all FP-strict expressions must be
those predicted by IEEE 754 arithmetic on operands represented using single and double
formats.
Within an expression that is not FP-strict, some leeway is granted for an implementation
to use an extended exponent range to represent intermediate results; the net effect, roughly
speaking, is that a calculation might produce “the correct answer” in situations where ex-
clusive use of the float value set or double value set might result in overflow or underflow.
15.5. Expressions and Run-Time Checks
If the type of an expression is a primitive type, then the value of the expression is of that
same primitive type.
If the type of an expression is a reference type, then the class of the referenced object, or
even whether the value is a reference to an object rather than null , is not necessarily known
at compile time. There are a few places in the Java programming language where the actual
class of a referenced object affects program execution in a manner that cannot be deduced
from the type of the expression. They are as follows:
• Method invocation (§ 15.12 ). The particular method used for an invocation o.m(...)
is chosen based on the methods that are part of the class or interface that is the type
of o . For instance methods, the class of the object referenced by the run-time value
of o participates because a subclass may override a specific method already de-
clared in a parent class so that this overriding method is invoked. (The overriding
method may or may not choose to further invoke the original overridden m meth-
od.)
• The instanceof operator (§ 15.20.2 ). An expression whose type is a reference type
may be tested using instanceof to find out whether the class of the object referenced
Search WWH ::




Custom Search