-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
1.1.2
-
sparc
-
solaris_2.5
Name: ngC57085 Date: 04/18/97
Java compiler (JDK1.1.2) does not execute constant expressions
while compile condition expression.
JLS (14.19) says:
"
A while statement can complete normally iff at least one of the following
is true:
The while statement is reachable and the condition expression is not
a constant expression with value true.
There is a reachable break statement that exits the while statement.
"
A while statement cannot complete normally if the condition expression
is a constant expression with value true.
Test stmt14104, where condition expression is a constant expression with
value true, is compiled successfully by JDK1.1.2 instead of error message.
> javac112 stmt14104.java
>
------------------------stmt14104--------------
import java.io.PrintStream;
public class stmt14104 {
public static void main(String argv[]) {
System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
}
public static int run(String argv[],PrintStream out) {
int a1 = 1;
int a2 = 1;
int a3 = 1;
final boolean b = true;
a1 = 2;
while (b) {
a2++;
}
a3 = 2;
return 2/*STATUS_FAILED*/;
}
}
--------------------------------------
And test stmt14104a, where condition expression is literal true,
is not compiled by JDK1.1.2.
> javac112 stmt14104a.java
stmt14104a.java:15: Statement not reached.
a3 = 2;
^
1 error
>
------------------------stmt14104a--------------
import java.io.PrintStream;
public class stmt14104a {
public static void main(String argv[]) {
System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
}
public static int run(String argv[],PrintStream out) {
int a1 = 1;
int a2 = 1;
int a3 = 1;
a1 = 2;
while (true) {
a2++;
}
a3 = 2;
return 2/*STATUS_FAILED*/;
}
}
--------------------------------------
======================================================================