Community
Participate
Working Groups
Using 1112, this test case is compiled and a VerifyError is thrown when executed. We should not compile it. class A { void m(int i) { switch (i) { case 0: final int j; j = 1; class Local { int k = j; } break; case 1: int k = new Local().k; } } public static void main(String[] args) { } } Run: Exception in thread "main" java.lang.VerifyError: (class: A, method: m signature: (I)V) Accessing value from uninitialized register 2 Javac 1.4 behaves the same. Only jikes properly rejects it.
What error does Jikes produce ?
Found 1 semantic error compiling "D:/temp/A.java": 12. int k = new Local().k; <-> *** Error: The variable "j" may be accessed here before having been definitely assigned a value.
Added check. Note that if offending variable is inlinable, no complaint is issued (jikes doesn't complain either), i.e. define j as: final int j = 1; Fixed.
Verified.