Bug 8832 - Sanity check error (internal error) when unused variables inside initializers
Summary: Sanity check error (internal error) when unused variables inside initializers
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P1 normal (vote)
Target Milestone: 2.0 M3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-01-31 09:57 EST by Philipe Mulet CLA
Modified: 2002-08-20 18:49 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2002-01-31 09:57:12 EST
Build 20020125

When compiling the following test case, the compiler reports an incorrect error
revealing an internal bug:

package p2;
public class X {
	int field = 0;
	{
		int i;
		int k;
	}
	X() {
		int j = 0;
		field = 1;
		if (field == 1) System.out.println("SUCCESS");
	}
	public static void main(String[] arguments) {
		new X();
	}
}

---
----------
1. ERROR in ...\p2\X.java (at line 3)
	public class X {
	             ^
SANITY CHECK: Invalid attribute for local variable k
----------
Comment 1 Philipe Mulet CLA 2002-01-31 10:00:58 EST
This only occurs when asking local variable attributes, and this is due to the 
fact that the variables <i> and <k> ids are colliding with <j> (ok since in 
different scopes). However, when exiting the block scope(exitUserScope) for the 
initializer, unused variables are not removed from the visible variables list.

Then later on in the constructor body (since initializers are inlined inside 
constructors), this interferes with normal visible variables debug attribute 
generation, since the unused ones have same indexes as legite ones.

Fixed by ensuring the visible variables are properly flushed (even if unused).
Comment 2 Philipe Mulet CLA 2002-08-20 18:49:15 EDT
Backporting it to 1.0 for jck1.3a compliance.