-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.0.2
-
sparc
-
generic
Name: ###@###.### Date: 09/05/96
a variable is not considered as definitely assigned after
the boolean operator != when true. Meanwhile, in one case it
is definitely assigned after its left operand when true and
after its right operand when true. In the other case, vice
versa, it is definitely assigned after the left operand when
false and after the right operand when false. This contradicts
the following assertions:
The rules for a != b are identical to the rules for a ^ b.
(Java Language Specification, section 16.1.10)
V is definitely assigned after a ^ b when true iff at least
one of the following is true:
- V is definitely assigned after b.
- V is definitely assigned after a when true and V is definitely
assigned after b when true.
- V is definitely assigned after a when false and V is definitely
assigned after b when false.
(Java Language Specification, section 16.1.8)
Test: compilation of the following test
public class test
{
public static void main(String argv[])
{
boolean b;
boolean r = false;
boolean t = true;
if ((t && (b = r)) != (t && (b = t)))
r = b;
System.out.println(r);
if ((r || (b = r)) != (r || (b = t)))
r = b;
System.out.println(r);
}
}
produces such diagnostics:
novo40% javac test.java
test.java:10: Variable b may not have been initialized.
r = b;
^
test.java:13: Variable b may not have been initialized.
r = b;
^
2 errors
======================================================================
- duplicates
-
JDK-1266777 inability of detection of definite assignment after the boolean
- Closed