CHAPTER 16: Definite Assignment Previous
Previous
Java Language
Java Language
Index
Index
Next
Next

16.1 Definite Assignment and Expressions

16.1.1 Boolean Constant Expressions , 16.1.2 Boolean-valued Expressions , 16.1.3 The Boolean Operator && , 16.1.4 The Boolean Operator || , 16.1.5 The Boolean Operator ! , 16.1.6 The Boolean Operator & , 16.1.7 The Boolean Operator | , 16.1.8 The Boolean Operator ^ , 16.1.9 The Boolean Operator == , 16.1.10 The Boolean Operator != , 16.1.11 The Boolean Operator ? : , 16.1.12 The Conditional Operator ? : , 16.1.13 Boolean Assignment Expressions , 16.1.14 Other Assignment Expressions , 16.1.15 Operators ++ and -- , 16.1.16 Other Expressions


16.1.1 Boolean Constant Expressions

V is definitely assigned after any constant expression whose value is true when false. V is definitely assigned after any constant expression whose value is false when true.

A constant expression whose value is true never has the value false , and a constant expression whose value is false never has the value true , these definitions are vacuously satisfied. They are helpful in analyzing expressions involving the boolean operators && , || , and ! ( S16.1.3, S16.1.4, S16.1.5).


16.1.2 Boolean-valued Expressions

For every boolean-valued expression:


16.1.3 The Boolean Operator &&


16.1.4 The Boolean Operator ||


16.1.5 The Boolean Operator !


16.1.6 The Boolean Operator &


16.1.7 The Boolean Operator |


16.1.8 The Boolean Operator ^


16.1.9 The Boolean Operator ==


16.1.10 The Boolean Operator !=

The rules for a != b are identical to the rules for a ^ b (S16.1.8).


16.1.11 The Boolean Operator ? :

Suppose that b and c are boolean-valued expressions.


16.1.12 The Conditional Operator ? :

Suppose that b and c are expressions that are not boolean-valued.


16.1.13 Boolean Assignment Expressions

Suppose that an assignment expression a = b, a &= b, a |= b, or a ^= b is boolean- valued.

Note that if a is V and V is not definitely assigned before a compound assignment such as a &= b, then a compile-time error will necessarily occur. The rules stated above include the disjunct "a is V" so that V will be considered to have been definitely assigned at later points in the code. Including the disjunct "a is V" does not affect the binary decision as to whether a program is acceptable or will result in a compile-time error, but it affects how many different points in the code may be regarded as erroneous, and so in practice it can improve the quality of error reporting.


16.1.14 Other Assignment Expressions

Suppose that an assignment expression a = b, a += b, a -= b, a *= b, a /= b, a %= b, a <<= b, a >>= b, a >>>= b, a &= b, a |= b, or a ^= b is not boolean-valued.


16.1.15 Operators ++ and --


16.1.16 Other Expressions

If an expression is not boolean-valued and is not a conditional-operator expression or assignment expression, the following rules apply:

For any immediate subexpression y of an expression x, V is definitely assigned before y iff V is definitely assigned before x or one of the following situations is true:



Top© 1996 Sun Microsystems, Inc. All rights reserved.