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.
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.
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.
Yup, reproducible.
mentlicher, can you provide any tips for this one?
I've tried this in Java debugger and it works fine.
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?
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.
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.
If the problem is indeed found to belong to web.debug somehow, please reassign back to me. Thanks.
Fixed in changeset: 111329:ae67afd362a9 http://hg.netbeans.org/main/rev/ae67afd362a9
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.
Verified ... and Closing all issues resolved into NetBeans 6.7 and earlier.