JDK-8044798 : API for debugging Nashorn
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 8u20
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-06-04
  • Updated: 2014-07-29
  • Resolved: 2014-06-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
8u20 b20Fixed 9Fixed
In order to prevent from incompatible changes, that would break nashorn debugging, please create debugger API classes, or classify existing classes as debugger API.
It does not have to be a public API as such, but standardized classes, that will not change in an incompatible way in the future.

For the debugger, it's much more easy and much faster to access field values, than to invoke method calls. Therefore, it's best in form of fields, where possible.

For the debugging purposes we use following classes, methods and fields:
  and it's methods: "valueInfo()", "valueInfos()", "eval()", "valueAsString()"
  and it's fields: "key", "expandable", "valueAsObject", "valueAsString"
  we rely on that an instance of this class is in "source" static field of every compiled script class
  and it's fields: "name", "hash", "data"
  and fields "array", "url" in classes implementing jdk.nashorn.internal.runtime.Source$Data
  and it's methods: "invoke()", "construct()", "getGenericInvoker()", "getGenericConstructor()"
  and it's fields "member", "clazz"
And we rely on that the compiled scripts are in classes, whose canonical path starts with:
Verified with regtests 8u20 b23 on all platforms.

I understand, that MethodHandle is out of scope. Regarding "url" field, this is not a problem. I just need "url" field to be available when there is an associated URL.

Quick comments: * We can't guarantee fields of JDK class java.lang.invoke.MethodHandle. * There are two subtypes implementing Source.Data - RawData, URLData. - only URLData has "url" field. RawData does not - because it loads from source that has no associated URL as such (like reading from a string). But both have "array" field that holds source as character data.