Bug 384458 - debug shows value of variable in another scope
Summary: debug shows value of variable in another scope
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 4.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.3 M2   Edit
Assignee: Michael Rennie CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
: 377620 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-07-06 07:34 EDT by Bug Menot CLA
Modified: 2012-08-24 17:57 EDT (History)
3 users (show)

See Also:


Attachments
related screenshot (21.32 KB, image/png)
2012-07-06 07:46 EDT, Bug Menot CLA
no flags Details
proposed fix (1.65 KB, patch)
2012-08-20 14:54 EDT, Samrat Dhillon CLA
Michael_Rennie: iplog+
Michael_Rennie: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bug Menot CLA 2012-07-06 07:34:23 EDT
Build Identifier: Version: Juno Release Build id: 20120614-1722

If you have variables with same name in class and it's static method (class variable must be static too), and you stopped on breakpoint in this method and you want to see method's variable value, class's variable will be shown.

Reproducible: Always

Steps to Reproduce:
1. create a project with one class with this code:
public class Main {
	static String[] a = new String[] { "0", "1", "2" };
	public static void main(String[] args) {
		int[] a = new int[] { 101, 102 };
		System.err.println(a[1]);
	}
}
2. add breakpoint on println line
3. debug the project as java application
4. When debug will stop on breakpoint, try to inspect a's value.

this will show value of class's scope a, but we definitely need value from method's scope.
Comment 1 Bug Menot CLA 2012-07-06 07:46:26 EDT
Created attachment 218379 [details]
related screenshot
Comment 2 Samrat Dhillon CLA 2012-08-20 14:54:53 EDT
Created attachment 220073 [details]
proposed fix

Basically modified the findVariable method in JDIStackFrame class. The intended modification is to give preference in the search criteria to a Local variable when there are multiple variables with the same name in the stack frame.
Comment 3 Michael Rennie CLA 2012-08-24 17:02:59 EDT
*** Bug 377620 has been marked as a duplicate of this bug. ***
Comment 4 Michael Rennie CLA 2012-08-24 17:46:02 EDT
Comment on attachment 220073 [details]
proposed fix

The patch works as expected, thanks Samrat!