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 238888 - [nashorn] Breakpoints in JS file ignored when debugging Java project
Summary: [nashorn] Breakpoints in JS file ignored when debugging Java project
Status: VERIFIED INVALID
Alias: None
Product: javascript
Classification: Unclassified
Component: Debugger (show other bugs)
Version: 8.0
Hardware: PC Linux
: P2 normal (vote)
Assignee: Martin Entlicher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-27 14:38 UTC by Vladimir Riha
Modified: 2019-07-10 10:31 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
sample project (19.46 KB, application/zip)
2013-11-27 14:38 UTC, Vladimir Riha
Details
IDE log (40.66 KB, text/plain)
2013-11-27 14:38 UTC, Vladimir Riha
Details
sample project - better (28.73 KB, application/zip)
2013-11-27 14:44 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-27 14:38:11 UTC
Created attachment 142641 [details]
sample project

Please check this sample project, I have JS breakpoints in test1.js file on lines:
 - 8, 51, 69, 72, 77

and no Java breakpoint, if I debug the project, none of these JS breakpoints are hit, all are ignored.

If I add line breakpoint to SampleRunner.java:51 and press Step into several times once it is hit, new editor tab (read-only) called <eval>.js is opened but without any line breakpoint (no visual marks). If I create a LB in this eval tab, its file is set to js-scripts://fs1/74b36706/%3ceval%3e.js



Product Version: NetBeans IDE Dev (Build 201311270002)
Java: 1.7.0_45; Java HotSpot(TM) Client VM 24.45-b08
Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18
System: Linux version 3.2.0-48-generic-pae running on i386; UTF-8; en_US (nb)
Comment 1 Vladimir Riha 2013-11-27 14:38:44 UTC
Created attachment 142642 [details]
IDE log
Comment 2 Vladimir Riha 2013-11-27 14:44:09 UTC
Created attachment 142643 [details]
sample project - better

I've tried to switch IDE to jdk8, no change.
Comment 3 Martin Entlicher 2014-01-07 08:21:17 UTC
The problem is in the way how do you run the JS script:

engine.eval(new FileReader("src" + System.getProperty("file.separator") + "javascript_sample" + System.getProperty("file.separator") + "test1.js"));

The JavaScript is read from some reader, which happens to read from some particular file. But to bind the evaluation string with the file is almost impossible for the debugger. It can be read from some web location, from a memory, or generated on the fly. In this case it's read from a file, but at the end, we get some script with unknown source URL, obviously. 

If you step into the script from Java code, an <eval> source is opened and breakpoints on the given locations do work fine for me. Then if you remove any Java breakpoints, the breakpoints in <eval> script do work even after NetBeans restart.

To keep the association of the script with the file, use evaluation like
String sourceFile = "src" + System.getProperty("file.separator") +
  "javascript_sample" + System.getProperty("file.separator") + "test1.js"
engine.eval("load(\""+sourceFile+"\");");
Comment 4 Vladimir Riha 2014-01-07 08:25:49 UTC
Thank you for explanation, I was afraid I was doing it wrong. I've found this way in some documentation. Breakpoints in <eval> work for me as well.
Comment 5 nightst4r 2014-10-18 01:04:01 UTC
I seem to have this problem when I set my breakpoint in a file, but I load the class resource version of the file?

Is there any way to detect that they are the same file?  Example:

library/src/com/example/library.js

I compile the library then later on I load it's class resource version since the library was compiled as a jar:

this.engine.eval(new URLReader( getClass().getResource("library.js") ));

The breakpoint in my file doesn't trigger in the embedded files execution.  

It works if I instead do: 

  File f = new File( "../library/src/com/example/library.js" );
  this.engine.put("liburl", f);
  this.engine.eval("load( liburl );";

This work around however will not work when remote debugging as the file won't be there on the target, the target will only have the compiled jar with the JS file inside the jar.
Comment 6 KGF123 2019-07-10 10:31:57 UTC
Mozilla firefox free download latest version https://foxdownload.org join this site and installing this new web browser in your mobile.