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 238934 - [nashorn] Not all global variables are listed in Variables view
Summary: [nashorn] Not all global variables are listed in Variables view
Status: REOPENED
Alias: None
Product: javascript
Classification: Unclassified
Component: Debugger (show other bugs)
Version: 8.0
Hardware: PC Linux
: P3 normal (vote)
Assignee: Martin Entlicher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-28 14:27 UTC by Vladimir Riha
Modified: 2014-07-08 15:03 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
IDE log (60.31 KB, text/plain)
2013-11-28 14:27 UTC, Vladimir Riha
Details
another case (2.04 KB, application/javascript)
2013-12-12 15:22 UTC, Vladimir Riha
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Riha 2013-11-28 14:27:00 UTC
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)
Comment 1 Vladimir Riha 2013-12-12 15:22:53 UTC
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)
Comment 2 Martin Entlicher 2014-01-09 16:45:19 UTC
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.
Comment 3 Vladimir Riha 2014-01-13 09:34:22 UTC
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); 
    
})();
Comment 4 Martin Entlicher 2014-07-08 15:03:42 UTC
https://bugs.openjdk.java.net/browse/JDK-8049604