Name: ngC57085 Date: 06/25/99
Java compiler jdk1.3H successfully compiles next jck tests,
checking definitely assigned variable after a try statement:
lang/DASG/dasg107/dasg10702m021/dasg10702m021.html
lang/DASG/dasg107/dasg10702m111/dasg10702m111.html
lang/DASG/dasg107/dasg10702m311/dasg10702m311.html
while error messages should be reported. The execution of compiled
class causes the java.lang.VerifyError.
>java -version
java version "1.3"
Classic VM (build JDK-1.3-H, green threads, sunwjit)
> javac -d . dasg10702m021.java
> java javasoft.sqe.tests.lang.dasg107.dasg10702m021.dasg10702m021
Exception in thread "main" java.lang.VerifyError: (class: javasoft/sqe/tests/lang/dasg107/dasg10702m021/dasg10702m021, method: run signature: ([Ljava/lang/String;Ljava/io/PrintStream;)I) Accessing value from uninitialized register 5
The oldjavac reports the error message.
> oldjavac -d . dasg10702m021.java
dasg10702m021.java:26: Variable i may not have been initialized.
out.println(i);
^
1 error
-----------------dasg10702m021.java------------------
package javasoft.sqe.tests.lang.dasg107.dasg10702m021;
import java.io.PrintStream;
class E1 extends Exception {}
class E2 extends Exception {}
public class dasg10702m021 {
public static void main(String argv[]) {
System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
}
public static int run(String argv[], PrintStream out) {
boolean t = true;
E1 se1 = new E1();
E2 se2 = new E2();
{
int i;
try {
if (t) {
throw se1;
}
} catch (E1 e) { i = 0; }
out.println(i);
}
out.println("Error : there should be compile-time errors");
return 2/*STATUS_FAILED*/;
}
}
-----------------------------------------------------
-----------------dasg10702m111.java------------------
package javasoft.sqe.tests.lang.dasg107.dasg10702m111;
import java.io.PrintStream;
class E1 extends Exception {}
class E2 extends Exception {}
public class dasg10702m111 {
public static void main(String argv[]) {
System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
}
public static int run(String argv[], PrintStream out) {
boolean t = true;
E1 se1 = new E1();
E2 se2 = new E2();
{
int i;
try {
if (t) {
i = 0;
throw se1;
} else {
throw se2;
}
} catch (E1 e) {} catch (E2 e) { i = 0; }
out.println(i);
}
out.println("Error : there should be compile-time errors");
return 2/*STATUS_FAILED*/;
}
}
-----------------------------------------------------
-----------------dasg10702m311.java------------------
package javasoft.sqe.tests.lang.dasg107.dasg10702m311;
import java.io.PrintStream;
class E1 extends Exception {}
class E2 extends Exception {}
public class dasg10702m311 {
public static void main(String argv[]) {
System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
}
public static int run(String argv[], PrintStream out) {
boolean t = true;
E1 se1 = new E1();
E2 se2 = new E2();
{
int i;
try {
i = 0;
if (t) throw se1; else throw se2;
} catch (E1 e) {} catch (E2 e) { i = 0; }
out.println(i);
}
out.println("Error : there should be compile-time errors");
return 2/*STATUS_FAILED*/;
}
}
----------------------------------------------------
======================================================================
- duplicates
-
JDK-4240487 dasg10702m[021,111,311].html: JLS16.2.13 no definitely assigned val after try
- Closed