Bug 26134

Summary: JACKS - VerifyError running invalid code
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.1   
Target Milestone: 2.1 M4   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Olivier Thomann CLA 2002-11-13 13:07:31 EST
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.
Comment 1 Philipe Mulet CLA 2002-11-14 08:53:27 EST
What error does Jikes produce ?
Comment 2 Olivier Thomann CLA 2002-11-14 08:57:57 EST
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.
Comment 3 Philipe Mulet CLA 2002-11-20 07:40:02 EST
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.
Comment 4 David Audel CLA 2002-12-17 10:19:19 EST
Verified.