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.
Created attachment 142681 [details] IDE log Please add line breakpoint to try to line 11 ("foo(a)") and debug the JS file in Java Project. Once debugger stops at line 11, Variables window does not contain all variables, for instance d, nn, obj, c, fnc are missing. It looks like only the ones used in given scope are displayed File.js ========FILE START=========================== function foo(a) { print(a + 1); } (function() { var d = new Date(); var o = { "details": function() { var a = parseInt(1.2, 10); a = a * 2; foo(a); } }; print(d + ": IIFE here"); var undef; var a = 1; var nn = null; var obj = {foo:1, bar:2}; var c = 1+a; print(obj.foo); var fnc = function(){}; o.details(); print(undef); // Line breakpoint here })(); =========================FILE END================= Product Version: NetBeans IDE Dev (Build 201311280002) Java: 1.8.0-ea; Java HotSpot(TM) Client VM 25.0-b59 Runtime: Java(TM) SE Runtime Environment 1.8.0-ea-b117 System: Linux version 3.2.0-48-generic-pae running on i386; UTF-8; en_US (nb)
Created attachment 143107 [details] another case Another case: - add line breakpoint to line 18 - debug file - once LB on line 18 is hit, press Step Into - debugger stops on line 4 => Variables window contains only 2 entries: this and name. If you press Step over (so debugger is on line 5), Variables window again contains proper list of variables Product Version: NetBeans IDE Dev (Build 201312120002) Java: 1.8.0-ea; Java HotSpot(TM) Client VM 25.0-b61 Runtime: Java(TM) SE Runtime Environment 1.8.0-ea-b119 System: Linux version 3.2.0-48-generic-pae running on i386; UTF-8; en_US (nb)
In the first case IMHO this is O.K. You get the variables defined in the current frame. Of you set a lower stack frame as a current one, you get the list of variables in the anonymous function. In the second case, we're unfortunately not able to do anything with that in the debugger. The scope object, which provides information about JavaScript variables is null at this location. Therefore we do not have a way to retrieve them. I'll submit some issue for Nashorn, since it occurs pretty often that the scope is not available at the beginning of functions.
Thank you for reporting the Nashorn issue. (In reply to Martin Entlicher from comment #2) > In the first case IMHO this is O.K. You get the variables defined in the > current frame. Of you set a lower stack frame as a current one, you get the > list of variables in the anonymous function. Well if you define variable outside of the immediately invoked function expression IIFE (see code below) add line breakpoint to line with foo() call and debug the project, then these 2 variables are listed in Variables, but variables declared in the IIFE are not. Should it behave the same in both cases? var dnes = new Date(); var dnes2 = {}; (function() { var d = new Date();var x = 1; var y = {a:1, b:new Date()}; var f = function(){}; var o = { "details": function() { var a = parseInt(1.2, 10); a = a * 2; foo(a); // Line breakpoint here } }; o.details(); print(d + ": IIFE here"); var undef; var a = 1; var nn = null; var obj = {foo:1, bar:2}; var c = 1+a; print(obj.foo); var fnc = function(){}; print(undef); })();
https://bugs.openjdk.java.net/browse/JDK-8049604