JDK-6427783 : E4X support is missing from Sun's Mozilla JavaScript implementation
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: javax.script
  • Affected Version: 6
  • Priority: P5
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-05-19
  • Updated: 2012-12-14
  • Resolved: 2011-05-17
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.
JDK 7
7 b126Fixed
Related Reports
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
The JSR-223 interface is great, an excellent addition to Java.  And the inclusion of the Mozilla JavaScript is a great choice as well.  But to leave out the E4X feature really reduces the utility of JavaScript in this day and age, when running Java outside of a browser.  So much of today's software is based on XML and to make it nearly impossible for a JavaScript script to create and parse XML is a severe oversight.


JUSTIFICATION :
The JSR-223 scripting languages are going to be used to extend the functionality of Java written applications.  And since so many applications use XML natively, the scripts that extend the applications need an easy way to access XML.  E4X is an excellent solution and the Mozilla folks have already solved the problem for you.  Leaving it out really limits the utility of the Sun version of JavaScript.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When you have this in your Mozilla JavaScript script:

   var msg = <a><b></b><a>

you should get an XML object in your script.

ACTUAL -
When you run that script through Sun's version of Mozilla JavaScript you get:

javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "XML" is not defined. (<Unknown source>#43) in <Unknown source> at line number 43


CUSTOMER SUBMITTED WORKAROUND :
I downloaded the source to see if I could create a parrallel implementation using the real Rhino JavaScript.  It appears to me that Sun seriously modified the Mozilla source so it does not appear there is an easy work around.

Comments
EVALUATION See also CR 6980447 - updating rhino in jdk7. With the latest Rhino code, e4x uses DOM3 and so does not require XMLbeans.
23-11-2010

EVALUATION There are two reasons why E4X was not included in Mustang: 1. Footprint - Rhino uses XBeans.jar to implement E4X which is bigger in size than Rhino itself. 2. Stability of the E4X implementation.
22-05-2006