This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 134816 - Hover-variable evaluation not correctly resolving name collisions
Summary: Hover-variable evaluation not correctly resolving name collisions
Status: CLOSED FIXED
Alias: None
Product: debugger
Classification: Unclassified
Component: Java (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: Martin Entlicher
URL:
Keywords:
Depends on: 154556 154560
Blocks:
  Show dependency tree
 
Reported: 2008-05-11 01:19 UTC by briandeacon
Modified: 2010-04-29 09:39 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description briandeacon 2008-05-11 01:19:34 UTC
Given the following in a jsp:
     <%! int x = 42; %>
     <% int x = 22; %>
     <%= x %>

When hovering over the last x, the value incorrectly displays as 42.
Comment 1 Petr Jiricka 2008-09-24 10:28:29 UTC
Confirmed, I can reproduce in the latest 6.5 build. Here are the steps I used:

1. Create a new web application (GlassFish v2 is the target server)
2. Paste the code above to index.jsp
3. Set a breakpoint on the line with <%= x %>
4. Debug the application. Application will stop on the breakpoint
5. Hover over the last x
=> displays 42, should be 22.

Looking at the servlet code generated from the JSP, it looks like this:

public final class index_jsp extends ... {

  int x = 42; 
  ...

  public void _jspService(HttpServletRequest request, HttpServletResponse response) throws ... {
    ...
    int x = 22; 
    ...
    out.print( x );
    ...
  }

}

Looks like the debugger incorrectly evaluates the variable from the object scope, rather than the method scope. Cc'ing
Martin - he may have some clue. Thanks.
Comment 2 Matthew Bohm 2008-11-13 01:28:42 UTC
Yup, reproducible.
Comment 3 Matthew Bohm 2008-11-27 09:14:15 UTC
mentlicher, can you provide any tips for this one?
Comment 4 Martin Entlicher 2008-11-27 09:18:46 UTC
I've tried this in Java debugger and it works fine.
Comment 5 Matthew Bohm 2008-12-02 00:29:43 UTC
mentlicher, are you saying you are seeing a different result when you attempt the steps provided, or rather that it
passes a similar test that uses Java only without JSP?
Comment 6 Martin Entlicher 2008-12-02 17:09:34 UTC
I wrote a Java code that masked a field with a local variable and run it under Java debugger. No JSPs.
The local variable was displayed with the correct value and also tooltip on it had the correct value.

I'm not familiar with what JSP does with that, but since it works in Java the search for the bug should be started in
JSP debugger.
Comment 7 Matthew Bohm 2008-12-10 02:33:51 UTC
JspToolTipAnnotation line 145 is:

Variable v = d.evaluate(text);

The v being returned has a value of 42, so the problem appears to be in the jpda debugger area. (I tried to get further
but don't know enough in that area.) 

Reassigning to debuggerjpda.
Comment 8 Matthew Bohm 2008-12-10 02:35:26 UTC
If the problem is indeed found to belong to web.debug somehow, please reassign back to me. Thanks.
Comment 9 Martin Entlicher 2008-12-10 16:29:06 UTC
Fixed in changeset:   111329:ae67afd362a9
http://hg.netbeans.org/main/rev/ae67afd362a9
Comment 10 Quality Engineering 2008-12-11 16:57:35 UTC
Integrated into 'main-golden', will be available in build *200812111401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/ae67afd362a9
User: mentlicher@netbeans.org
Log: #134816 - First test whether the identifier is a local variable, then try to find a field.
Comment 11 Quality Engineering 2010-04-29 09:39:33 UTC
Verified ... and Closing all issues resolved into NetBeans 6.7 and earlier.