Java Reference
In-Depth Information
15.2. Variables as Values
If an expression denotes a variable, and a value is required for use in further evaluation,
then the value of that variable is used. In this context, if the expression denotes a variable
or a value, we may speak simply of the value of the expression.
If the value of a variable of type float or double is used in this manner, then value set conver-
sion (§ 5.1.13 ) is applied to the value of the variable.
15.3. Type of an Expression
If an expression denotes a variable or a value, then the expression has a type known at
compile time. The rules for determining the type of an expression are explained separately
below for each kind of expression.
The value of an expression is assignment compatible (§ 5.2 ) with the type of the expression,
unless heap pollution (§ 4.12.2 ) occurs.
Likewise, the value stored in a variable is always compatible with the type of the variable,
unless heap pollution occurs.
In other words, the value of an expression whose type is T is always suitable for assignment
to a variable of type T .
Note that an expression whose type is a class type F that is declared final is guaranteed to
have a value that is either a null reference or an object whose class is F itself, because final
types have no subclasses.
15.4. FP-strict Expressions
If the type of an expression is float or double , then there is a question as to what value set
4.2.3 ) the value of the expression is drawn from. This is governed by the rules of value
set conversion (§ 5.1.13 ); these rules in turn depend on whether or not the expression is FP-
strict .
Every compile-time constant expression (§ 15.28 ) is FP-strict.
If an expression is not a compile-time constant expression, then consider all the class de-
clarations, interface declarations, and method declarations that contain the expression. If
any such declaration bears the strictfp modifier (§ 8.1.1.3 , § 8.4.3.5 , § 9.1.1.2 ), then the ex-
pression is FP-strict.
Search WWH ::




Custom Search