-
Bug
-
Resolution: Fixed
-
P4
-
1.4.0
-
1.5
-
generic
-
solaris_8
-
Verified
The specification for assertions is missing any description of their interaction
with the try statement. Here is a test case, from the jacks suite, that
illustrates the underlying question:
public class T {
public static void main(final String[] args) {
final int i;
try {
assert false : i=3;
} finally {
i = 5;
}
}
}
Is this code legal, or is there an assignment to a possibly assigned
final variable in the finally clause? I believe there is an error here.
The suggested JLS wording is to augment the phrase (twice) in 16.2.14
that reads
... V is definitely unassigned after the try block and V is definitely
unassigned before every return statement that belongs to the try
block, every throw statement that belongs to the tryblock, every
break statement that belongs to the try block and whose break target
contains (or is) the try statement, and every continue statement that
belongs to the try block and whose continue target contains the try
statement
to include
"and V is definitely unassigned after the last expression in every assert statement that belongs to the try block"
with the try statement. Here is a test case, from the jacks suite, that
illustrates the underlying question:
public class T {
public static void main(final String[] args) {
final int i;
try {
assert false : i=3;
} finally {
i = 5;
}
}
}
Is this code legal, or is there an assignment to a possibly assigned
final variable in the finally clause? I believe there is an error here.
The suggested JLS wording is to augment the phrase (twice) in 16.2.14
that reads
... V is definitely unassigned after the try block and V is definitely
unassigned before every return statement that belongs to the try
block, every throw statement that belongs to the tryblock, every
break statement that belongs to the try block and whose break target
contains (or is) the try statement, and every continue statement that
belongs to the try block and whose continue target contains the try
statement
to include
"and V is definitely unassigned after the last expression in every assert statement that belongs to the try block"
- relates to
-
JDK-4661694 compiler error in DU of assert arg2 when arg1 is true
- Closed
-
JDK-6499725 The idea of "V is definitely unassigned after e2" in "16.2.15 try Statements" of JLS3 is ambiguous
- Closed