This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/trunk by this push:
new a0d841013a Rhino 1.7.7.2 integration: security hardening, patch fixes,
ES6 default mode
a0d841013a is described below
commit a0d841013a7b93e3bcedcaed86403bb1797490bd
Author: Pedro Giffuni <[email protected]>
AuthorDate: Tue Nov 3 03:37:55 2026 -0500
Rhino 1.7.7.2 integration: security hardening, patch fixes, ES6 default mode
Security hardening:
- E4X/XML: harden XmlProcessor against XXE (external entities, parameter
entities, external DTD, XInclude, external stylesheet). TransformerFactory
configured with FEATURE_SECURE_PROCESSING and ACCESS_EXTERNAL_*; explicit
empty entity resolver as defense-in-depth.
- toFixed(): bound computational cost for tiny/subnormal values using
0.5 * 10^(-precision) comparison (no overflow, numerically stable),
preventing DoS on inputs like (4.47118444E-314).toFixed(2).
- DefiningClassLoader: call Thread.getContextClassLoader() directly instead
of reflection (available since Java 2, no Java2 concern on Java 8).
Patch fixes:
- java-version.patch: target-jvm/source-level 1.6 -> 1.8 (Java 8 minimum).
- Main: getIn()/getOut()/getErr() fall back to System.in/out/err instead of
returning null when debugger console unavailable.
- build.xml: inline manifest (Implementation-Version: 1.7.7.2), ships
Messages.properties in JAR; full js.jar with debugger+tools preserved.
Language mode:
- Default Context.VERSION_ES6 in ScriptProviderForJavaScript and
ScriptEditorForJavaScript.
Build note:
- Rhino 1.7.7.2 is the last Rhino version supporting the Ant build;
upstream migrated to Gradle thereafter.
Regression tests (not committed): TestXXEResgression (11 pass),
TestToFixedRegression (32 pass), TestES6Smoke (5 pass).
---
main/LICENSE_category_b | 4 +-
main/external_deps.lst | 6 +-
main/rhino/README | 23 +-
main/rhino/makefile.mk | 11 +-
main/rhino/prj/d.lst | 2 +-
main/rhino/rhino-1.7.7.2-definingclassloader.patch | 66 ++
main/rhino/rhino-1.7.7.2-main.patch | 38 +
main/rhino/rhino-1.7.7.2-tofixed-fix.patch | 43 +
main/rhino/rhino-1.7.7.2-xxe-fix.patch | 61 +
main/rhino/rhino1_7R3-java-version.patch | 13 -
main/rhino/rhino1_7_7_2-java-version.patch | 14 +
.../rhino/{rhino1_7R3.patch => rhino1_7_7_2.patch} | 1228 +++++++++-----------
.../script/framework/provider/ScriptContext.java | 11 +-
.../script/framework/provider/ScriptProvider.java | 2 +-
.../javascript/ScriptEditorForJavaScript.java | 21 +-
.../javascript/ScriptProviderForJavaScript.java | 24 +-
16 files changed, 825 insertions(+), 742 deletions(-)
diff --git a/main/LICENSE_category_b b/main/LICENSE_category_b
index 5603eeb568..f512564201 100644
--- a/main/LICENSE_category_b
+++ b/main/LICENSE_category_b
@@ -20,8 +20,8 @@ ____
-- GPL 2.0/LGPL 2.1/MPL 1.1 tri-license
MPL 1.1 is chosen for Apache OpenOffice
- For Rhino
--- MPL 1.1 / GPL 2.0 dual licensed
- MPL 1.1 is chosen for Apache OpenOffice
+-- MPL 2.0
+ MPL 2.0 is chosen for Apache OpenOffice
MOZILLA PUBLIC LICENSE
diff --git a/main/external_deps.lst b/main/external_deps.lst
index b7ddf2a260..95db5cb62f 100644
--- a/main/external_deps.lst
+++ b/main/external_deps.lst
@@ -292,9 +292,9 @@ if (ENABLE_CATEGORY_B==YES && SYSTEM_HUNSPELL!=YES)
URL2 = $(OOO_EXTRAS)$(MD5)-$(name)
if (ENABLE_CATEGORY_B==YES && SOLAR_JAVA==TRUE && ENABLE_JAVASCRIPT==YES)
- MD5 = 99d94103662a8d0b571e247a77432ac5
- name = rhino1_7R3.zip
- URL1 = https://ftp.mozilla.org/pub/js/$(name)
+ MD5 = afcf570784ebd919c1d484a6d0d3fcd6
+ name = rhino-1.7.7.2.zip
+ URL1 =
https://github.com/mozilla/rhino/releases/download/Rhino1_7_7_2_Release/$(name)
URL2 = $(OOO_EXTRAS)$(MD5)-$(name)
if (ENABLE_CATEGORY_B==YES && ENABLE_NSS_MODULE==YES)
diff --git a/main/rhino/README b/main/rhino/README
index c99011ae3e..c077e63aa1 100644
--- a/main/rhino/README
+++ b/main/rhino/README
@@ -1,11 +1,26 @@
The Scripting Framework makes use of the Rhino (http://www.mozilla.org/rhino/)
-JavaScript interpreter, available under the Mozilla Public License
-(http://www.mozilla.org/MPL/MPL-1.1.html).
+JavaScript interpreter, available under the Mozilla Public License 2.0
+(http://www.mozilla.org/MPL/2.0/).
+
+Rhino version: 1.7.7.2
+Source archive:
https://github.com/mozilla/rhino/releases/download/Rhino1_7_7_2_Release/rhino-1.7.7.2.zip
+Checksum: (see external_deps.lst)
In addition, to support the debugging of scripts contained in OpenOffice.org
-documents, we have modified the Java source file Main.java.
+documents, we have modified the Java source files:
+- GuiCallback.java (added exitInterrupt method)
+- Main.java (added AOO-specific shortcut methods, nullified console I/O)
+- Dim.java (added evalScriptWithReturn, changed default URL from "<stdin>" to
"document")
+- SwingGui.java (AOO-specific debugger GUI modifications)
+- OfficeScriptInfo.java (new AOO-specific class)
+- toolsrc/build.xml (excluded system rhino.jar from bootstrap classpath)
+- DefiningClassLoader.java (modified class loading to check thread context
class loader)
The Rhino source tarball is unpacked and patched with the modified code. The
Rhino Jar file (js.jar) is then built and delivered to the solver. The file
-rhino1_7R3.patch contains the changes made in order to build Rhino. The patch
+rhino1_7_7_2.patch contains the changes made in order to build Rhino. The patch
was generated using the command: diff -wurN
+
+Java 8 compatibility: build.properties sets target-jvm and source-level to 1.8.
+Ant-based build is preserved.
+ES6 is the default language mode (Context.VERSION_ES6).
diff --git a/main/rhino/makefile.mk b/main/rhino/makefile.mk
index 9bed5ae846..5d3647d35f 100644
--- a/main/rhino/makefile.mk
+++ b/main/rhino/makefile.mk
@@ -44,14 +44,13 @@ all:
#.IF "$(DISABLE_RHINO)" == ""
-TARFILE_NAME=rhino1_7R3
-TARFILE_MD5=99d94103662a8d0b571e247a77432ac5
-TARFILE_ROOTDIR=rhino1_7R3
+TARFILE_NAME=rhino1_7_7_2
+TARFILE_MD5=afcf570784ebd919c1d484a6d0d3fcd6
+TARFILE_ROOTDIR=rhino1.7.7.2
-ADDITIONAL_FILES= \
- toolsrc/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java
+ADDITIONAL_FILES=
-PATCH_FILES=rhino1_7R3.patch rhino1_7R3-java-version.patch
+PATCH_FILES=rhino1_7_7_2.patch rhino-1.7.7.2-definingclassloader.patch
rhino1_7_7_2-java-version.patch rhino-1.7.7.2-main.patch
rhino-1.7.7.2-xxe-fix.patch rhino-1.7.7.2-tofixed-fix.patch
.IF "$(JAVACISGCJ)"=="yes"
JAVA_HOME=
diff --git a/main/rhino/prj/d.lst b/main/rhino/prj/d.lst
index b73bea4540..434f0a496c 100644
--- a/main/rhino/prj/d.lst
+++ b/main/rhino/prj/d.lst
@@ -1 +1 @@
-..\%__SRC%\misc\build\rhino1_7R3\build\rhino1_7R3\js.jar
%_DEST%\bin%_EXT%\js.jar
+..\%__SRC%\misc\build\rhino1.7.7.2\build\js.jar %_DEST%\bin%_EXT%\js.jar
diff --git a/main/rhino/rhino-1.7.7.2-definingclassloader.patch
b/main/rhino/rhino-1.7.7.2-definingclassloader.patch
new file mode 100644
index 0000000000..eb2c2f5b5f
--- /dev/null
+++ b/main/rhino/rhino-1.7.7.2-definingclassloader.patch
@@ -0,0 +1,66 @@
+--- a/b/rhino1.7.7.2/src/org/mozilla/javascript/DefiningClassLoader.java
++++ b/b/rhino1.7.7.2/src/org/mozilla/javascript/DefiningClassLoader.java
+@@ -4,9 +4,6 @@
+
+ package org.mozilla.javascript;
+
+-import java.lang.reflect.Method;
+-import java.lang.reflect.InvocationTargetException;
+-
+ /**
+ * Load generated classes.
+ *
+@@ -27,19 +24,16 @@
+
+ private void init() {
+ this.contextLoader = null;
+- if (method_getContextClassLoader != null) {
+- try {
+- this.contextLoader = (ClassLoader)
+- method_getContextClassLoader.invoke(
+- Thread.currentThread(),
+- ScriptRuntime.emptyArgs);
+- } catch (IllegalAccessException ex) {
+- } catch (InvocationTargetException ex) {
+- } catch (SecurityException ex) {
+- }
+- if (this.contextLoader == this.parentLoader) {
+- this.contextLoader = null;
+- }
++ try {
++ this.contextLoader =
Thread.currentThread().getContextClassLoader();
++ } catch (SecurityException ex) {
++ /* Context class loader access denied in restricted
++ environments (e.g. applets, sandboxed class loaders).
++ Fall back to the parent class loader only. */
++ this.contextLoader = null;
++ }
++ if (this.contextLoader == this.parentLoader) {
++ this.contextLoader = null;
+ }
+ }
+
+@@ -90,23 +84,4 @@
+ private final ClassLoader parentLoader;
+
+ private ClassLoader contextLoader;
+-
+- // We'd like to use "Thread.getContextClassLoader", but
+- // that's only available on Java2.
+- private static Method method_getContextClassLoader;
+-
+- static {
+- try {
+- // Don't use "Thread.class": that performs the lookup
+- // in the class initializer, which doesn't allow us to
+- // catch possible security exceptions.
+- Class threadClass = Class.forName("java.lang.Thread");
+- method_getContextClassLoader =
+- threadClass.getDeclaredMethod("getContextClassLoader",
+- new Class[0]);
+- } catch (ClassNotFoundException e) {
+- } catch (NoSuchMethodException e) {
+- } catch (SecurityException e) {
+- }
+- }
+ }
diff --git a/main/rhino/rhino-1.7.7.2-main.patch
b/main/rhino/rhino-1.7.7.2-main.patch
new file mode 100644
index 0000000000..a67cd42d2b
--- /dev/null
+++ b/main/rhino/rhino-1.7.7.2-main.patch
@@ -0,0 +1,38 @@
+--- a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/Main.java
++++ b/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/Main.java
+@@ -127,7 +127,10 @@
+ * Console window.
+ */
+ public InputStream getIn() {
+- return null;//return debugGui.getConsole().getIn();
++ if (debugGui != null && debugGui.getConsole() != null) {
++ return debugGui.getConsole().getIn();
++ }
++ return System.in;
+ }
+
+ /**
+@@ -135,7 +138,10 @@
+ * Console window.
+ */
+ public PrintStream getOut() {
+- return null;//return debugGui.getConsole().getOut();
++ if (debugGui != null && debugGui.getConsole() != null) {
++ return debugGui.getConsole().getOut();
++ }
++ return System.out;
+ }
+
+ /**
+@@ -143,7 +149,10 @@
+ * Console window.
+ */
+ public PrintStream getErr() {
+- return null;//return debugGui.getConsole().getErr();
++ if (debugGui != null && debugGui.getConsole() != null) {
++ return debugGui.getConsole().getErr();
++ }
++ return System.err;
+ }
+
+ /**
diff --git a/main/rhino/rhino-1.7.7.2-tofixed-fix.patch
b/main/rhino/rhino-1.7.7.2-tofixed-fix.patch
new file mode 100644
index 0000000000..ddc9b08270
--- /dev/null
+++ b/main/rhino/rhino-1.7.7.2-tofixed-fix.patch
@@ -0,0 +1,43 @@
+
+--- a/b/rhino1.7.7.2/src/org/mozilla/javascript/DToA.java 1969-12-31
19:00:00.000000000 -0500
++++ b/rhino1.7.7.2/src/org/mozilla/javascript/DToA.java 2026-11-03
00:00:00.000000000 -0500
+@@ -1141,6 +1141,40 @@
+ if (mode == DTOSTR_FIXED && (d >= 1e21 || d <= -1e21))
+ mode = DTOSTR_STANDARD; /* Change mode here rather than below
because the buffer may not be large enough to hold a large integer. */
+
++ /* Fast path: if the fixed-point result rounds to zero, return
immediately
++ without invoking the arbitrary-precision JS_dtoa path. This
bounds the
++ cost of toFixed for tiny and subnormal values.
++
++ toFixed(precision) rounds to zero exactly when abs(d) < 0.5 *
10^(-precision)
++ (the boundary rounds away from zero per ECMAScript round-half-up).
We test
++ the equivalent condition abs(d) < 0.5 * 10^(-precision) rather
than computing
++ abs(d) * 10^precision < 0.5, so the multiplication cannot overflow
and the
++ comparison remains well conditioned for every legal precision value
++ (num_to restricts precision to [-20,100], hence 10^(-precision) is
always a
++ normal double and never underflows to zero).
++
++ Proof that JS_dtoa is bounded when this test does not fire:
++ When abs(d) >= 0.5 * 10^(-precision), we have
++ k = floor(log10(abs(d))) >= -precision - 1
++ hence, in JS_dtoa's fixed mode, ilim = precision + k + 1 >= 0.
Since
++ values with abs(d) >= 1e21 are switched to standard mode above, k
<= 20
++ and ilim <= precision + 21 <= 121. pow5mult exponents are bounded
by
++ ~324 (smallest positive subnormal). The digit-emission loop runs
at most
++ ~121 iterations. No pathological computation can occur. */
++ if (mode == DTOSTR_FIXED && !Double.isNaN(d) &&
!Double.isInfinite(d)) {
++ double threshold = 0.5 * Math.pow(10.0, -precision);
++ if (Math.abs(d) < threshold) {
++ boolean negative = (d < 0);
++ if (precision <= 0) {
++ buffer.append(negative ? "-0" : "0");
++ } else {
++ buffer.append(negative ? "-0." : "0.");
++ for (int i = 0; i < precision; i++) buffer.append('0');
++ }
++ return;
++ }
++ }
++
+ decPt = JS_dtoa(d, dtoaModes[mode], mode >= DTOSTR_FIXED, precision,
sign, buffer);
+ nDigits = buffer.length();
diff --git a/main/rhino/rhino-1.7.7.2-xxe-fix.patch
b/main/rhino/rhino-1.7.7.2-xxe-fix.patch
new file mode 100644
index 0000000000..780b03c7c1
--- /dev/null
+++ b/main/rhino/rhino-1.7.7.2-xxe-fix.patch
@@ -0,0 +1,61 @@
+--- a/b/rhino1.7.7.2/src/org/mozilla/javascript/xmlimpl/XmlProcessor.java
++++ b/b/rhino1.7.7.2/src/org/mozilla/javascript/xmlimpl/XmlProcessor.java
+@@ -43,7 +43,9 @@
+ this.dom = javax.xml.parsers.DocumentBuilderFactory.newInstance();
+ this.dom.setNamespaceAware(true);
+ this.dom.setIgnoringComments(false);
++ configureDomFactory(this.dom);
+ this.xform = javax.xml.transform.TransformerFactory.newInstance();
++ configureTransformerFactory(this.xform);
+ int poolSize = Runtime.getRuntime().availableProcessors() * 2;
+ this.documentBuilderPool = new
LinkedBlockingDeque<DocumentBuilder>(poolSize);
+ }
+@@ -75,7 +77,9 @@
+ this.dom = javax.xml.parsers.DocumentBuilderFactory.newInstance();
+ this.dom.setNamespaceAware(true);
+ this.dom.setIgnoringComments(false);
++ configureDomFactory(this.dom);
+ this.xform = javax.xml.transform.TransformerFactory.newInstance();
++ configureTransformerFactory(this.xform);
+ int poolSize = Runtime.getRuntime().availableProcessors() * 2;
+ this.documentBuilderPool = new
LinkedBlockingDeque<DocumentBuilder>(poolSize);
+ }
+@@ -148,6 +152,24 @@
+ private javax.xml.parsers.DocumentBuilderFactory getDomFactory() {
+ return dom;
+ }
++ private static void
configureDomFactory(javax.xml.parsers.DocumentBuilderFactory f) {
++ try {
f.setFeature("http://xml.org/sax/features/external-general-entities", false); }
catch (javax.xml.parsers.ParserConfigurationException e) { throw new
RuntimeException(e); }
++ try {
f.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
} catch (javax.xml.parsers.ParserConfigurationException e) { throw new
RuntimeException(e); }
++ try {
f.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",
false); } catch (javax.xml.parsers.ParserConfigurationException e) { throw new
RuntimeException(e); }
++ /* setXIncludeAware(false) is defense-in-depth: if unsupported,
external-general-entities,
++ external-parameter-entities, load-external-dtd, and
ACCESS_EXTERNAL_DTD still block
++ all external resource access via XInclude. */
++ try { f.setXIncludeAware(false); } catch
(UnsupportedOperationException e) { /* ignore */ }
++ try { f.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING,
true); } catch (javax.xml.parsers.ParserConfigurationException e) { throw new
RuntimeException(e); }
++ try { f.setAttribute(javax.xml.XMLConstants.ACCESS_EXTERNAL_DTD, "");
} catch (IllegalArgumentException e) { /* ignore */ }
++ try { f.setAttribute(javax.xml.XMLConstants.ACCESS_EXTERNAL_SCHEMA,
""); } catch (IllegalArgumentException e) { /* ignore */ }
++ }
++
++ private static void
configureTransformerFactory(javax.xml.transform.TransformerFactory f) {
++ try { f.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING,
true); } catch (javax.xml.transform.TransformerConfigurationException e) {
throw new RuntimeException(e); }
++ try {
f.setAttribute(javax.xml.XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); } catch
(IllegalArgumentException e) { /* ignore */ }
++ try { f.setAttribute(javax.xml.XMLConstants.ACCESS_EXTERNAL_DTD, "");
} catch (IllegalArgumentException e) { /* ignore */ }
++ }
+
+ // Get from pool, or create one without locking, if needed.
+ private DocumentBuilder getDocumentBuilderFromPool()
+@@ -157,6 +179,14 @@
+ builder = getDomFactory().newDocumentBuilder();
+ }
+ builder.setErrorHandler(errorHandler);
++ /* Entity resolver returns empty input for all external references.
This is
++ defense-in-depth: the factory features above already block
external access,
++ so if resolver installation fails the mandatory controls still
prevent XXE. */
++ builder.setEntityResolver(new org.xml.sax.EntityResolver() {
++ public org.xml.sax.InputSource resolveEntity(String publicId,
String systemId) {
++ return new org.xml.sax.InputSource(new
java.io.StringReader(""));
++ }
++ });
+ return builder;
+ }
diff --git a/main/rhino/rhino1_7R3-java-version.patch
b/main/rhino/rhino1_7R3-java-version.patch
deleted file mode 100644
index 921be10617..0000000000
--- a/main/rhino/rhino1_7R3-java-version.patch
+++ /dev/null
@@ -1,13 +0,0 @@
---- misc/build/rhino1_7R3/build.properties
-+++ misc/build/rhino1_7R3/build.properties
-@@ -53,8 +53,8 @@
-
- # compilation settings
- debug: on
--target-jvm: 1.5
--source-level: 1.5
-+target-jvm: 1.8
-+source-level: 1.8
-
- # jar generation settings
- jar-compression: true
diff --git a/main/rhino/rhino1_7_7_2-java-version.patch
b/main/rhino/rhino1_7_7_2-java-version.patch
new file mode 100644
index 0000000000..dda3155f76
--- /dev/null
+++ b/main/rhino/rhino1_7_7_2-java-version.patch
@@ -0,0 +1,14 @@
+--- a/b/rhino1.7.7.2/build.properties
++++ b/b/rhino1.7.7.2/build.properties
+@@ -19,8 +19,8 @@
+
+ # compilation settings
+ debug: on
+-target-jvm: 1.6
+-source-level: 1.6
++target-jvm: 1.8
++source-level: 1.8
+
+ # jar generation settings
+ jar-compression: true
+\ No newline at end of file
diff --git a/main/rhino/rhino1_7R3.patch b/main/rhino/rhino1_7_7_2.patch
similarity index 50%
rename from main/rhino/rhino1_7R3.patch
rename to main/rhino/rhino1_7_7_2.patch
index b0a4f807f7..e63404c9f4 100644
--- a/main/rhino/rhino1_7R3.patch
+++ b/main/rhino/rhino1_7_7_2.patch
@@ -1,104 +1,210 @@
-Index: toolsrc/org/mozilla/javascript/tools/debugger/GuiCallback.java
-===================================================================
---- toolsrc/org/mozilla/javascript/tools/debugger/GuiCallback.java
(revision 1)
-+++
misc/build/rhino1_7R3/toolsrc/org/mozilla/javascript/tools/debugger/GuiCallback.java
(working copy)
-@@ -56,6 +56,11 @@
- String threadTitle,
- String alertMessage);
+diff -ruN a/b/rhino1.7.7.2/build.properties a/b/rhino1.7.7.2/build.properties
+--- a/b/rhino1.7.7.2/build.properties 2026-10-31 20:42:49.489534187 -0500
++++ a/b/rhino1.7.7.2/build.properties 2026-10-31 20:42:49.840321657 -0500
+@@ -23,4 +23,4 @@
+ source-level: 1.6
+
+ # jar generation settings
+-jar-compression: true
++jar-compression: true
+\ No newline at end of file
+diff -ruN a/b/rhino1.7.7.2/build.xml a/b/rhino1.7.7.2/build.xml
+--- a/b/rhino1.7.7.2/build.xml 1969-12-31 19:00:00.000000000 -0500
++++ b/b/rhino1.7.7.2/build.xml 2026-11-03 00:00:00.000000000 -0500
+@@ -0,0 +1,87 @@
++<?xml version="1.0" encoding="UTF-8"?>
++<!-- This Source Code Form is subject to the terms of the Mozilla Public
++ - License, v. 2.0. If a copy of the MPL was not distributed with this
++ - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
++
++<project name="rhino" default="jar" basedir=".">
++
++ <target name="init">
++ <property file="build.properties"/>
++ <property name="src.dir" value="src"/>
++ <property name="build.dir" value="${build.dir}"/>
++ <property name="classes.dir" value="${classes}"/>
++ <property name="rhino.jar" value="${rhino.jar}"/>
++ <property name="small-rhino.jar" value="${small-rhino.jar}"/>
++ <property name="dist.dir" value="${dist.dir}"/>
++ <property name="dist.name" value="${dist.name}"/>
++
++ <mkdir dir="${classes.dir}"/>
++ <mkdir dir="${build.dir}"/>
++ <mkdir dir="${dist.dir}"/>
++ </target>
++
++ <target name="compile" depends="init">
++ <javac srcdir="${src.dir}"
++ destdir="${classes.dir}"
++ debug="${debug}"
++ target="${target-jvm}"
++ source="${source-level}"
++ includeantruntime="false"
++ encoding="UTF-8">
++ <compilerarg value="-Xlint:-options"/>
++ </javac>
++ </target>
++
++ <target name="jar" depends="compile">
++ <jar destfile="${build.dir}/${rhino.jar}"
++ compress="${jar-compression}">
++ <manifest>
++ <attribute name="Manifest-Version" value="1.0"/>
++ <attribute name="Implementation-Title" value="Rhino"/>
++ <attribute name="Implementation-Version" value="1.7.7.2"/>
++ </manifest>
++ <fileset dir="${classes.dir}"/>
++ <fileset dir="${basedir}/src" includes="**/*.properties"/>
++ </jar>
++ </target>
++
++ <target name="small-jar" depends="compile">
++ <jar destfile="${build.dir}/${small-rhino.jar}"
++ compress="${jar-compression}">
++ <manifest>
++ <attribute name="Manifest-Version" value="1.0"/>
++ <attribute name="Implementation-Title" value="Rhino"/>
++ <attribute name="Implementation-Version" value="1.7.7.2"/>
++ </manifest>
++ <fileset dir="${classes.dir}">
++ <exclude name="**/tools/**"/>
++ <exclude name="**/debugger/**"/>
++ <exclude name="**/shell/**"/>
++ <exclude name="**/jsc/**"/>
++ <exclude name="**/idswitch/**"/>
++ <exclude name="**/classfile/**"/>
++ </fileset>
++ <fileset dir="${basedir}/src" includes="**/*.properties"/>
++ </jar>
++ </target>
++
++ <target name="dist" depends="jar, small-jar">
++ <mkdir dir="${dist.dir}/${dist.name}/lib"/>
++ <copy file="${build.dir}/${rhino.jar}"
++ tofile="${dist.dir}/${dist.name}/lib/${rhino.jar}"/>
++ <copy file="${build.dir}/${small-rhino.jar}"
++ tofile="${dist.dir}/${dist.name}/lib/${small-rhino.jar}"/>
++ <copy file="LICENSE.txt"
++ todir="${dist.dir}/${dist.name}"/>
++ <copy file="README.md"
++ todir="${dist.dir}/${dist.name}"/>
++ <copy file="RELEASE-NOTES.md"
++ todir="${dist.dir}/${dist.name}"/>
++ </target>
++
++ <target name="clean">
++ <delete dir="${build.dir}"/>
++ <delete dir="${dist.dir}"/>
++ </target>
++
++</project>
++
++</project>
+\ No newline at end of file
+diff -ruN a/b/rhino1.7.7.2/src/org/mozilla/javascript/DefiningClassLoader.java
a/b/rhino1.7.7.2/src/org/mozilla/javascript/DefiningClassLoader.java
+--- a/b/rhino1.7.7.2/src/org/mozilla/javascript/DefiningClassLoader.java
2026-10-31 20:42:49.607742394 -0500
++++ a/b/rhino1.7.7.2/src/org/mozilla/javascript/DefiningClassLoader.java
2026-10-31 20:42:49.766998760 -0500
+@@ -4,6 +4,9 @@
-+ /**
-+ * Called when the interrupt loop has been exited.
-+ */
-+ void exitInterrupt();
-+
- /**
- * Returns whether the current thread is the GUI's event thread.
- * This information is required to avoid blocking the event thread
-Index: toolsrc/org/mozilla/javascript/tools/debugger/Main.java
-===================================================================
---- toolsrc/org/mozilla/javascript/tools/debugger/Main.java (revision 1)
-+++
misc/build/rhino1_7R3/toolsrc/org/mozilla/javascript/tools/debugger/Main.java
(working copy)
-@@ -44,6 +44,8 @@
- import java.io.InputStream;
- import java.io.PrintStream;
+ package org.mozilla.javascript;
-+import java.net.URL;
++import java.lang.reflect.Method;
++import java.lang.reflect.InvocationTargetException;
+
- import javax.swing.JFrame;
-
- import org.mozilla.javascript.*;
-@@ -161,7 +163,7 @@
- * Console window.
- */
- public InputStream getIn() {
-- return debugGui.getConsole().getIn();
-+ return null;//return debugGui.getConsole().getIn();
- }
-
- /**
-@@ -169,7 +171,7 @@
- * Console window.
- */
- public PrintStream getOut() {
-- return debugGui.getConsole().getOut();
-+ return null;//return debugGui.getConsole().getOut();
+ /**
+ * Load generated classes.
+ *
+@@ -14,10 +17,30 @@
+ {
+ public DefiningClassLoader() {
+ this.parentLoader = getClass().getClassLoader();
++ init();
}
- /**
-@@ -177,7 +179,7 @@
- * Console window.
- */
- public PrintStream getErr() {
-- return debugGui.getConsole().getErr();
-+ return null;//return debugGui.getConsole().getErr();
+ public DefiningClassLoader(ClassLoader parentLoader) {
+ this.parentLoader = parentLoader;
++ init();
++ }
++
++ private void init() {
++ this.contextLoader = null;
++ if (method_getContextClassLoader != null) {
++ try {
++ this.contextLoader = (ClassLoader)
++ method_getContextClassLoader.invoke(
++ Thread.currentThread(),
++ ScriptRuntime.emptyArgs);
++ } catch (IllegalAccessException ex) {
++ } catch (InvocationTargetException ex) {
++ } catch (SecurityException ex) {
++ }
++ if (this.contextLoader == this.parentLoader) {
++ this.contextLoader = null;
++ }
++ }
}
- /**
-@@ -437,4 +439,39 @@
- return scope;
+ public Class<?> defineClass(String name, byte[] data) {
+@@ -38,10 +61,14 @@
+ {
+ Class<?> cl = findLoadedClass(name);
+ if (cl == null) {
+- if (parentLoader != null) {
+- cl = parentLoader.loadClass(name);
++ if (contextLoader == null) {
++ cl = loadFromParent(name);
+ } else {
+- cl = findSystemClass(name);
++ try {
++ cl = loadFromParent(name);
++ } catch (ClassNotFoundException ex) {
++ cl = contextLoader.loadClass(name);
++ }
+ }
}
+ if (resolve) {
+@@ -50,5 +77,36 @@
+ return cl;
}
-+
-+ // shortcut methods
-+
-+ public void addWindowListener(java.awt.event.WindowListener l) {
-+ debugGui.addWindowListener(l);
+
++ private Class loadFromParent(String name)
++ throws ClassNotFoundException
++ {
++ if (parentLoader != null) {
++ return parentLoader.loadClass(name);
++ } else {
++ return findSystemClass(name);
++ }
+ }
+
-+ public void highlighLineInScriptWindow(URL url, int lineNum) {
-+ debugGui.highlighLineInScriptWindow(url, lineNum);
-+ }
-+
-+ public Object runScriptWindow(URL scriptUrl) throws Exception
-+ {
-+ return debugGui.runScriptWindow(scriptUrl);
-+ }
-+
-+ public void openFile(URL scriptUrl, Scriptable scope, Runnable
closeCallback) {
-+ debugGui.openFile(scriptUrl, scope, closeCallback);
-+ }
-+
-+ public void toFront() {
-+ debugGui.toFront();
-+ }
-+
-+ public void showScriptWindow(URL url) {
-+ debugGui.showScriptWindow(url);
-+ }
+ private final ClassLoader parentLoader;
+
-+ public boolean isModified(URL url) {
-+ return debugGui.isModified(url);
-+ }
++ private ClassLoader contextLoader;
+
-+ public String getText(URL url) {
-+ return debugGui.getText(url);
-+ }
++ // We'd like to use "Thread.getContextClassLoader", but
++ // that's only available on Java2.
++ private static Method method_getContextClassLoader;
++
++ static {
++ try {
++ // Don't use "Thread.class": that performs the lookup
++ // in the class initializer, which doesn't allow us to
++ // catch possible security exceptions.
++ Class threadClass = Class.forName("java.lang.Thread");
++ method_getContextClassLoader =
++ threadClass.getDeclaredMethod("getContextClassLoader",
++ new Class[0]);
++ } catch (ClassNotFoundException e) {
++ } catch (NoSuchMethodException e) {
++ } catch (SecurityException e) {
++ }
++ }
}
-Index: toolsrc/org/mozilla/javascript/tools/debugger/Dim.java
-===================================================================
---- toolsrc/org/mozilla/javascript/tools/debugger/Dim.java (revision 1)
-+++
misc/build/rhino1_7R3/toolsrc/org/mozilla/javascript/tools/debugger/Dim.java
(working copy)
-@@ -69,6 +69,7 @@
+diff -ruN a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/Dim.java
a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/Dim.java
+--- a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/Dim.java
2026-10-31 20:42:49.648044642 -0500
++++ a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/Dim.java
2026-10-31 20:42:49.791085088 -0500
+@@ -34,6 +34,7 @@
private static final int IPROXY_OBJECT_TO_STRING = 5;
private static final int IPROXY_OBJECT_PROPERTY = 6;
private static final int IPROXY_OBJECT_IDS = 7;
@@ -106,7 +212,7 @@ Index:
toolsrc/org/mozilla/javascript/tools/debugger/Dim.java
/**
* Interface to the debugger GUI.
-@@ -433,7 +434,7 @@
+@@ -398,7 +399,7 @@
*/
private String getNormalizedUrl(DebuggableScript fnOrScript) {
String url = fnOrScript.getSourceName();
@@ -115,7 +221,7 @@ Index:
toolsrc/org/mozilla/javascript/tools/debugger/Dim.java
else {
// Not to produce window for eval from different lines,
// strip line numbers, i.e. replace all #[0-9]+\(eval\) by
-@@ -622,6 +623,17 @@
+@@ -587,6 +588,17 @@
}
/**
@@ -133,15 +239,7 @@ Index:
toolsrc/org/mozilla/javascript/tools/debugger/Dim.java
* Converts the given script object to a string.
*/
public String objectToString(Object object) {
-@@ -869,6 +881,7 @@
- interruptedContextData = null;
- eventThreadMonitor.notifyAll();
- }
-+ callback.exitInterrupt();
- }
-
- }
-@@ -966,6 +979,11 @@
+@@ -931,6 +943,11 @@
private Object[] objectArrayResult;
/**
@@ -153,517 +251,140 @@ Index:
toolsrc/org/mozilla/javascript/tools/debugger/Dim.java
* Creates a new DimIProxy.
*/
private DimIProxy(Dim dim, int type) {
-@@ -1021,6 +1039,9 @@
- objectArrayResult = dim.getObjectIdsImpl(cx, object);
+@@ -962,6 +979,20 @@
+ }
break;
+ case IPROXY_EVAL_SCRIPT_WITH_RETURN:
-+ return cx.evaluateString(this.scope, text, url, 1, null);
-+
- default:
- throw Kit.codeBug();
- }
-Index: toolsrc/org/mozilla/javascript/tools/debugger/SwingGui.java
-===================================================================
---- toolsrc/org/mozilla/javascript/tools/debugger/SwingGui.java
(revision 1)
-+++
misc/build/rhino1_7R3/toolsrc/org/mozilla/javascript/tools/debugger/SwingGui.java
(working copy)
-@@ -68,6 +68,8 @@
- import java.awt.Toolkit;
- import java.awt.event.*;
-
-+import java.net.URL;
++ if (this.scope != null) {
++ return cx.evaluateString(this.scope, text, url, 1, null);
++ } else {
++ Scriptable sc = null;
++ if (dim.scopeProvider != null) {
++ sc = dim.scopeProvider.getScope();
++ }
++ if (sc == null) {
++ sc = new ImporterTopLevel(cx);
++ }
++ return cx.evaluateString(sc, text, url, 1, null);
++ }
+
- import java.util.List;
- import java.util.ArrayList;
- import java.util.Arrays;
-@@ -84,6 +86,7 @@
- import java.lang.reflect.Method;
-
- import org.mozilla.javascript.Kit;
-+import org.mozilla.javascript.Scriptable;
- import org.mozilla.javascript.SecurityUtilities;
-
- import org.mozilla.javascript.tools.shell.ConsoleTextArea;
-@@ -178,6 +181,16 @@
- */
- private EventQueue awtEventQueue;
+ case IPROXY_STRING_IS_COMPILABLE:
+ booleanResult = cx.stringIsCompilableUnit(text);
+ break;
+diff -ruN
a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/GuiCallback.java
a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/GuiCallback.java
+---
a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/GuiCallback.java
2026-10-31 20:42:49.649184458 -0500
++++
a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/GuiCallback.java
2026-10-31 20:42:49.791267690 -0500
+@@ -23,6 +23,11 @@
+ String threadTitle,
+ String alertMessage);
-+ private boolean sourceEditingEnabled = true;
-+
-+ public boolean isSourceEditingEnabled() {
-+ return sourceEditingEnabled;
-+ }
-+
-+ public void setSourceEditingEnabled(boolean b) {
-+ sourceEditingEnabled = b;
-+ }
++ /**
++ * Called when the interrupt loop has been exited.
++ */
++ void exitInterrupt();
+
/**
- * Creates a new SwingGui.
+ * Returns whether the current thread is the GUI's event thread.
+ * This information is required to avoid blocking the event thread
+@@ -35,4 +40,4 @@
+ * is necessary when the GUI event thread itself has been stopped.
*/
-@@ -218,13 +231,13 @@
- super.setVisible(b);
- if (b) {
- // this needs to be done after the window is visible
-- console.consoleTextArea.requestFocus();
-+ // console.consoleTextArea.requestFocus();
- context.split.setDividerLocation(0.5);
- try {
-- console.setMaximum(true);
-- console.setSelected(true);
-- console.show();
-- console.consoleTextArea.requestFocus();
-+ // console.setMaximum(true);
-+ // console.setSelected(true);
-+ // console.show();
-+ // console.consoleTextArea.requestFocus();
- } catch (Exception exc) {
- }
- }
-@@ -320,7 +333,7 @@
- desk = new JDesktopPane();
- desk.setPreferredSize(new Dimension(600, 300));
- desk.setMinimumSize(new Dimension(150, 50));
-- desk.add(console = new JSInternalConsole("JavaScript Console"));
-+ // desk.add(console = new JSInternalConsole("JavaScript Console"));
- context = new ContextWindow(this);
- context.setPreferredSize(new Dimension(600, 120));
- context.setMinimumSize(new Dimension(50, 50));
-@@ -540,7 +553,7 @@
- if (line != -1) {
- currentWindow = w;
- }
-- menubar.addFile(url);
-+ // menubar.addFile(url);
- w.setVisible(true);
+ void dispatchNextGuiEvent() throws InterruptedException;
+-}
++}
+\ No newline at end of file
+diff -ruN a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/Main.java
a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/Main.java
+--- a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/Main.java
2026-10-31 20:42:49.648814653 -0500
++++ a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/Main.java
2026-10-31 20:42:49.791202989 -0500
+@@ -8,6 +8,7 @@
- if (activate) {
-@@ -800,9 +813,17 @@
- proxy.alertMessage = alertMessage;
- SwingUtilities.invokeLater(proxy);
- }
-+ setSourceEditingEnabled(false);
- }
+ import java.io.InputStream;
+ import java.io.PrintStream;
++import java.net.URL;
- /**
-+ * Called when the interrupt loop has been exited.
-+ */
-+ public void exitInterrupt() {
-+ setSourceEditingEnabled(true);
-+ }
-+
-+ /**
- * Returns whether the current thread is the GUI event thread.
- */
- public boolean isGuiEventThread() {
-@@ -879,6 +900,14 @@
- new Thread(proxy).start();
- }
- }
-+ } else if (cmd.equals("Run")) {
-+ FileWindow w = (FileWindow)getSelectedFrame();
-+ if (w != null)
-+ w.load();
-+ } else if (cmd.equals("Save")) {
-+ FileWindow w = (FileWindow)getSelectedFrame();
-+ if (w != null)
-+ w.save();
- } else if (cmd.equals("More Windows...")) {
- MoreWindows dlg = new MoreWindows(this, fileWindows,
- "Window", "Files");
-@@ -972,6 +1001,120 @@
- dim.setReturnValue(returnValue);
- }
- }
-+
-+ private String getFileName(URL url) {
-+ if (url.getProtocol().startsWith("vnd.sun.star."))
-+ return url.toString();
-+ return url.getPath();
-+ }
-+
-+ public void openFile(URL scriptUrl, Scriptable scope, Runnable
closeCallback) {
-+ if (scope == null) {
-+ MessageDialogWrapper.showMessageDialog(this,
-+ "Can't compile scripts: no scope available",
-+ "Open", JOptionPane.ERROR_MESSAGE);
-+ } else {
-+ if (scriptUrl != null) {
-+ try
-+ {
-+ InputStreamReader reader = new
InputStreamReader(scriptUrl.openStream());
-+ String fileName = getFileName(scriptUrl);
-+ officeScripts.addScript( fileName, scriptUrl, scope,
closeCallback );
-+ RunProxy proxy = new RunProxy(this, RunProxy.OPEN_FILE);
-+ proxy.fileName = fileName;
-+ proxy.text = Kit.readReader(reader);
-+ new Thread(proxy).start();
-+ }
-+ catch ( IOException e )
-+ {
-+ MessageDialogWrapper.showMessageDialog(this,
-+ "Can't open stream for script: " + e.toString(),
-+ "Open", JOptionPane.ERROR_MESSAGE);
-+ }
-+ }
-+ }
-+ split1.setDividerLocation(1.0);
-+ }
-+
-+ // patched Office specific interface
-+ OfficeScriptInfo officeScripts = new OfficeScriptInfo();
-+
-+ void removeScript(String url) {
-+ officeScripts.deleteScript(url);
-+ }
-+
-+ public void showScriptWindow(URL url) {
-+ String key = getFileName(url);
-+ FileWindow w = (FileWindow)getFileWindow(key);
-+ if (w != null)
-+ {
-+ desk.getDesktopManager().deiconifyFrame(w);
-+ desk.getDesktopManager().activateFrame(w);
-+ w.show();
-+ w.toFront();
-+ }
-+ }
-+
-+ public void highlighLineInScriptWindow(URL url, int lineNum) {
-+ String key = getFileName(url);
-+ FileWindow w = (FileWindow)getFileWindow(key);
-+ if (w != null)
-+ {
-+ showFileWindow(key, lineNum);
-+ }
-+ }
-+
-+ public Object runScriptWindow(URL scriptUrl) throws Exception
-+ {
-+ String key = getFileName(scriptUrl);
-+ FileWindow w = (FileWindow)getFileWindow(key);
-+ Object result = null;
-+ w.toFront();
-+ if (w != null)
-+ {
-+ Scriptable scope = officeScripts.getScriptScope(key);
-+ if (scope == null)
-+ {
-+ MessageDialogWrapper.showMessageDialog(this, "Can't load
scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE);
-+ }
-+ else
-+ {
-+ String url = w.getUrl();
-+ if (url != null)
-+ {
-+ if (officeScripts.isScriptRunning(key))
-+ {
-+ return result;
-+ }
-+ officeScripts.setScriptRunning(key, true);
-+ try {
-+ result = dim.evalScriptWithReturn(url,
w.textArea.getText(), scope);
-+ } catch (Exception exc) {
-+ exc.printStackTrace();
-+ throw exc;
-+ } finally {
-+ officeScripts.setScriptRunning(key, false);
-+ }
-+ }
-+ }
-+ }
-+ return result;
-+ }
-+
-+ public boolean isModified(URL url)
-+ {
-+ String key = getFileName(url);
-+ FileWindow w = (FileWindow)getFileWindow(key);
-+ return w.isModified();
-+ }
-+
-+ public String getText(URL url)
-+ {
-+ String key = getFileName(url);
-+ FileWindow w = (FileWindow)getFileWindow(key);
-+ return w.getText();
-+ }
-+
- }
+ import javax.swing.JFrame;
- /**
-@@ -1590,7 +1733,9 @@
- case KeyEvent.VK_ENTER:
- case KeyEvent.VK_DELETE:
- case KeyEvent.VK_TAB:
-- e.consume();
-+ if (! w.isEditable()) {
-+ e.consume();
-+ }
- break;
- }
- }
-@@ -1599,14 +1744,18 @@
- * Called when a key is typed.
+@@ -126,7 +127,7 @@
+ * Console window.
*/
- public void keyTyped(KeyEvent e) {
-- e.consume();
-+ if (! w.isEditable()) {
-+ e.consume();
-+ }
+ public InputStream getIn() {
+- return debugGui.getConsole().getIn();
++ return null;//return debugGui.getConsole().getIn();
}
/**
- * Called when a key is released.
+@@ -134,7 +135,7 @@
+ * Console window.
*/
- public void keyReleased(KeyEvent e) {
-- e.consume();
-+ if (! w.isEditable()) {
-+ e.consume();
-+ }
+ public PrintStream getOut() {
+- return debugGui.getConsole().getOut();
++ return null;//return debugGui.getConsole().getOut();
}
- }
-
-@@ -2089,7 +2238,7 @@
- /**
- * An internal frame for script files.
- */
--class FileWindow extends JInternalFrame implements ActionListener {
-+class FileWindow extends JInternalFrame implements ActionListener,
DocumentListener {
/**
- * Serializable magic number.
-@@ -2126,6 +2275,7 @@
- */
- int currentPos;
-
-+ boolean isModified = false;
- /**
- * Loads the file.
+@@ -142,7 +143,7 @@
+ * Console window.
*/
-@@ -2134,11 +2284,62 @@
- if (url != null) {
- RunProxy proxy = new RunProxy(debugGui, RunProxy.LOAD_FILE);
- proxy.fileName = url;
-- proxy.text = sourceInfo.source();
-+ proxy.text = textArea.getText();
-+ proxy.scope = debugGui.officeScripts.getScriptScope(url);
- new Thread(proxy).start();
- }
+ public PrintStream getErr() {
+- return debugGui.getConsole().getErr();
++ return null;//return debugGui.getConsole().getErr();
}
-+ void save() {
-+ String url = getUrl();
-+ if (url != null) {
-+ OutputStream os = null;
-+ try {
-+ if (url.startsWith("vnd.sun.star"))
-+ {
-+ URL scriptUrl = debugGui.officeScripts.getScriptUrl(url);
-+ if ( scriptUrl == null )
-+ {
-+ throw new IOException("Can't optain stream for " +
url);
-+ }
-+ os = scriptUrl.openConnection().getOutputStream();
-+ }
-+ else
-+ {
-+ os = new FileOutputStream(url);
-+ }
-+ String s = textArea.getText();
-+ os.write(s.getBytes(), 0, s.length());
-+
-+ this.isModified = false;
-+ } catch (IOException ioe) {
-+ MessageDialogWrapper.showMessageDialog(this,
-+ "Error saving file: " + ioe.getMessage(),
-+ "Error", JOptionPane.ERROR_MESSAGE);
-+ }
-+ finally
-+ {
-+ if ( os != null )
-+ {
-+ try
-+ {
-+ os.close();
-+ os = null;
-+ }
-+ catch( IOException ioe )
-+ {
-+ System.err.println("Error closing stream: " +
ioe.getMessage() );
-+ ioe.printStackTrace();
-+ }
-+ }
-+ }
-+ }
-+ }
-+
-+ public boolean isEditable() {
-+ return debugGui.isSourceEditingEnabled();
-+ }
-+
/**
- * Returns the offset position for the given line.
- */
-@@ -2214,7 +2415,16 @@
- pack();
- updateText(sourceInfo);
- textArea.select(0);
-+ addInternalFrameListener( new InternalFrameAdapter() {
-+ public void internalFrameClosed(InternalFrameEvent e) {
-+ getDebugGui().removeScript( getUrl() );
-+ }
-+ } );
+@@ -349,6 +350,41 @@
+ {
+ throw new IllegalStateException();
}
+
-+ public SwingGui getDebugGui() {
-+ return debugGui;
-+ }
-
- /**
- * Updates the tool tip contents.
-@@ -2249,7 +2459,10 @@
- this.sourceInfo = sourceInfo;
- String newText = sourceInfo.source();
- if (!textArea.getText().equals(newText)) {
-+ textArea.getDocument().removeDocumentListener(this);
- textArea.setText(newText);
-+ this.isModified = false;
-+ textArea.getDocument().addDocumentListener(this);
- int pos = 0;
- if (currentPos != -1) {
- pos = currentPos;
-@@ -2260,6 +2473,31 @@
- fileHeader.repaint();
- }
-
-+ /* Implementation of DocumentListener interface */
-+ public void insertUpdate(DocumentEvent e) {
-+ doChanged(e);
-+ }
-+
-+ public void removeUpdate(DocumentEvent e) {
-+ doChanged(e);
-+ }
++ // shortcut methods
+
-+ public void changedUpdate(DocumentEvent e) {
-+ doChanged(e);
++ public void addWindowListener(java.awt.event.WindowListener l) {
++ debugGui.addWindowListener(l);
+ }
+
-+ public void doChanged(DocumentEvent e) {
-+ this.isModified = true;
++ public void highlighLineInScriptWindow(URL url, int lineNum) {
++ debugGui.highlighLineInScriptWindow(url, lineNum);
++ }
++
++ public Object runScriptWindow(URL scriptUrl) throws Exception
++ {
++ return debugGui.runScriptWindow(scriptUrl);
++ }
++
++ public void openFile(URL scriptUrl, Scriptable scope, Runnable
closeCallback) {
++ debugGui.openFile(scriptUrl, scope, closeCallback);
++ }
++
++ public void toFront() {
++ debugGui.toFront();
+ }
-+
-+ public boolean isModified() {
-+ return this.isModified;
++
++ public void showScriptWindow(URL url) {
++ debugGui.showScriptWindow(url);
+ }
+
-+ public String getText() {
-+ return textArea.getText();
++ public boolean isModified(URL url) {
++ return debugGui.isModified(url);
+ }
+
- /**
- * Sets the cursor position.
- */
-@@ -2295,11 +2533,11 @@
- public void actionPerformed(ActionEvent e) {
- String cmd = e.getActionCommand();
- if (cmd.equals("Cut")) {
-- // textArea.cut();
-+ textArea.cut();
- } else if (cmd.equals("Copy")) {
- textArea.copy();
- } else if (cmd.equals("Paste")) {
-- // textArea.paste();
-+ textArea.paste();
- }
- }
- }
-@@ -2920,7 +3158,7 @@
- */
- public ContextWindow(final SwingGui debugGui) {
- this.debugGui = debugGui;
-- enabled = false;
-+ enabled = true;
- JPanel left = new JPanel();
- JToolBar t1 = new JToolBar();
- t1.setName("Variables");
-@@ -3161,6 +3399,10 @@
- public void enableUpdate() {
- enabled = true;
- }
-+
-+ public boolean isEnabled() {
-+ return enabled;
-+ }
-
- // ActionListener
-
-@@ -3249,8 +3491,10 @@
- Menubar(SwingGui debugGui) {
- super();
- this.debugGui = debugGui;
-- String[] fileItems = {"Open...", "Run...", "", "Exit"};
-- String[] fileCmds = {"Open", "Load", "", "Exit"};
-+ // String[] fileItems = {"Open...", "Run...", "", "Exit"};
-+ // String[] fileCmds = {"Open", "Load", "", "Exit"};
-+ String[] fileItems = {"Run", "Save", "", "Exit"};
-+ String[] fileCmds = {"Run", "Save", "", "Exit"};
- char[] fileShortCuts = {'0', 'N', 0, 'X'};
- int[] fileAccelerators = {KeyEvent.VK_O,
- KeyEvent.VK_N,
-@@ -3299,6 +3543,8 @@
- editShortCuts[i]);
- item.addActionListener(this);
- editMenu.add(item);
-+ if (i < 3)
-+ runOnlyItems.add(item);
- }
- for (int i = 0; i < plafItems.length; ++i) {
- JMenuItem item = new JMenuItem(plafItems[i],
-@@ -3348,9 +3594,9 @@
- item.addActionListener(this);
- windowMenu.add(item = new JMenuItem("Tile", 'T'));
- item.addActionListener(this);
-- windowMenu.addSeparator();
-- windowMenu.add(item = new JMenuItem("Console", 'C'));
-- item.addActionListener(this);
-+ // windowMenu.addSeparator();
-+ // windowMenu.add(item = new JMenuItem("Console", 'C'));
-+ // item.addActionListener(this);
- add(windowMenu);
-
- updateEnabled(false);
-@@ -3530,6 +3776,11 @@
- * interruption, if any.
- */
- String alertMessage;
-+
-+ /**
-+ * The arguments for evaluation.
-+ */
-+ Scriptable scope;
++ public String getText(URL url) {
++ return debugGui.getText(url);
++ }
/**
- * Creates a new RunProxy.
-@@ -3556,7 +3807,10 @@
-
- case LOAD_FILE:
- try {
-- debugGui.dim.evalScript(fileName, text);
-+ if (scope != null)
-+ debugGui.dim.evalScriptWithReturn(fileName, text, scope);
-+ else
-+ debugGui.dim.evalScript(fileName, text);
- } catch (RuntimeException ex) {
- MessageDialogWrapper.showMessageDialog(
- debugGui, ex.getMessage(), "Run error for "+fileName,
-Index: toolsrc/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java
-===================================================================
---- toolsrc/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java
(revision 2)
-+++
misc/build/rhino1_7R3/toolsrc/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java
(working copy)
-@@ -1 +1,124 @@
--dummy
+ * Class to consolidate all internal implementations of interfaces
+@@ -408,4 +444,4 @@
+ return scope;
+ }
+ }
+-}
++}
+\ No newline at end of file
+diff -ruN
a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java
a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java
+---
a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java
1969-12-31 19:00:00.000000000 -0500
++++
a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java
2026-10-31 20:42:49.792418706 -0500
+@@ -0,0 +1,122 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
@@ -721,7 +442,7 @@ Index:
toolsrc/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java
+ if ( info.closeCallback != null )
+ {
+ System.out.println("** In removeSFScriptInfo have callback
for " + key );
-+ info.closeCallback.run(); // really need to do this in
separate thread????
++ info.closeCallback.run();
+ }
+ }
+ }
@@ -778,8 +499,6 @@ Index:
toolsrc/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java
+ return result;
+ }
+
-+
-+
+ class SFScriptInfo
+ {
+ Scriptable scope;
@@ -788,136 +507,261 @@ Index:
toolsrc/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java
+ Runnable closeCallback;
+ }
+}
-Index: toolsrc/build.xml
-===================================================================
---- toolsrc/build.xml (revision 1)
-+++ misc/build/rhino1_7R3/toolsrc/build.xml (working copy)
-@@ -40,6 +40,24 @@
- -->
- <project name="toolsrc" default="compile" basedir="..">
-
-+ <condition property="boot_refID" value="macPath" else="nonMacPath">
-+ <and>
-+ <os family="mac"/>
-+ <os family="unix"/>
-+ </and>
-+ </condition>
-+ <path id="macPath" location="${java.home}/../Classes/classes.jar"/>
-+ <!-- rhino.jar from OpenJDK breaks build -->
-+ <path id="nonMacPath">
-+ <fileset dir="${java.home}/">
-+ <include name="jre/lib/*.jar"/>
-+ <include name="lib/*.jar"/>
-+ <exclude name="jre/lib/rhino.jar"/>
-+ <exclude name="lib/rhino.jar"/>
-+ </fileset>
-+ </path>
-+ <path id="my.bootstrap.classpath" refID="${boot_refID}"/>
-+
- <target name="properties">
- <property file="build.properties"/>
- </target>
-Index: src/org/mozilla/javascript/DefiningClassLoader.java
-===================================================================
---- src/org/mozilla/javascript/DefiningClassLoader.java (revision 1)
-+++ misc/build/rhino1_7R3/src/org/mozilla/javascript/DefiningClassLoader.java
(working copy)
-@@ -39,6 +39,8 @@
-
- package org.mozilla.javascript;
+diff -ruN
a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/SwingGui.java
a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/SwingGui.java
+--- a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/SwingGui.java
2026-10-31 20:42:49.648303446 -0500
++++ a/b/rhino1.7.7.2/src/org/mozilla/javascript/tools/debugger/SwingGui.java
2026-10-31 20:42:49.792500007 -0500
+@@ -32,6 +32,8 @@
+ import java.awt.Toolkit;
+ import java.awt.event.*;
-+import java.lang.reflect.Method;
-+import java.lang.reflect.InvocationTargetException;
- /**
- * Load generated classes.
- *
-@@ -48,13 +50,33 @@
- implements GeneratedClassLoader
- {
- public DefiningClassLoader() {
-- this.parentLoader = getClass().getClassLoader();
-+ this.parentLoader = getClass().getClassLoader();
-+ init();
- }
++import java.net.URL;
++
+ import java.util.List;
+ import java.util.ArrayList;
+ import java.util.Arrays;
+@@ -47,6 +49,7 @@
+ import java.lang.reflect.Method;
- public DefiningClassLoader(ClassLoader parentLoader) {
-- this.parentLoader = parentLoader;
-+ this.parentLoader = parentLoader;
-+ init();
- }
+ import org.mozilla.javascript.Kit;
++import org.mozilla.javascript.Scriptable;
+ import org.mozilla.javascript.SecurityUtilities;
-+ private void init() {
-+ this.contextLoader = null;
-+ if (method_getContextClassLoader != null) {
-+ try {
-+ this.contextLoader = (ClassLoader)
-+ method_getContextClassLoader.invoke(
-+ Thread.currentThread(),
-+ ScriptRuntime.emptyArgs);
-+ } catch (IllegalAccessException ex) {
-+ } catch (InvocationTargetException ex) {
-+ } catch (SecurityException ex) {
+ import org.mozilla.javascript.tools.shell.ConsoleTextArea;
+@@ -59,6 +62,138 @@
+ * GUI for the Rhino debugger.
+ */
+ public class SwingGui extends JFrame implements GuiCallback {
++ private boolean sourceEditingEnabled = true;
++
++ public boolean isSourceEditingEnabled() {
++ return sourceEditingEnabled;
++ }
++
++ public void setSourceEditingEnabled(boolean b) {
++ sourceEditingEnabled = b;
++ }
++
++ public void exitInterrupt() {
++ setSourceEditingEnabled(true);
++ }
++
++ // patched Office specific interface
++ OfficeScriptInfo officeScripts = new OfficeScriptInfo();
++
++ void removeScript(String url) {
++ officeScripts.deleteScript(url);
++ }
++
++ private String getFileName(URL url) {
++ if (url.getProtocol().startsWith("vnd.sun.star."))
++ return url.toString();
++ // Preserve full identity (protocol, host, query) for non-UNO URLs.
++ return url.toString();
++ }
++
++ public void openFile(URL scriptUrl, Scriptable scope, Runnable
closeCallback) {
++ if (scope == null) {
++ javax.swing.JOptionPane.showMessageDialog(this,
++ "Can't compile scripts: no scope available",
++ "Open", javax.swing.JOptionPane.ERROR_MESSAGE);
++ } else if (scriptUrl != null) {
++ String fileName = getFileName(scriptUrl);
++ // Avoid duplicating an already-open editor window.
++ if (getFileWindow(fileName) != null) {
++ showScriptWindow(scriptUrl);
++ return;
+ }
-+ if (this.contextLoader == this.parentLoader) {
-+ this.contextLoader = null;
++ String text;
++ try (java.io.InputStreamReader reader = new
java.io.InputStreamReader(scriptUrl.openStream())) {
++ text = org.mozilla.javascript.Kit.readReader(reader);
++ } catch (java.io.IOException e) {
++ javax.swing.JOptionPane.showMessageDialog(this,
++ "Can't open stream for script: " + e.toString(),
++ "Open", javax.swing.JOptionPane.ERROR_MESSAGE);
++ return;
+ }
++ officeScripts.addScript(fileName, scriptUrl, scope,
closeCallback);
++ // Register/compile the source with the debugger using Rhino's
OPEN_FILE mechanism.
++ RunProxy proxy = new RunProxy(this, RunProxy.OPEN_FILE);
++ proxy.fileName = fileName;
++ proxy.text = text;
++ new Thread(proxy).start();
+ }
+ }
+
- public Class<?> defineClass(String name, byte[] data) {
- // Use our own protection domain for the generated classes.
- // TODO: we might want to use a separate protection domain for classes
-@@ -73,10 +95,14 @@
- {
- Class<?> cl = findLoadedClass(name);
- if (cl == null) {
-- if (parentLoader != null) {
-- cl = parentLoader.loadClass(name);
-+ if (contextLoader == null) {
-+ cl = loadFromParent(name);
- } else {
-- cl = findSystemClass(name);
-+ try {
-+ cl = loadFromParent(name);
-+ } catch (ClassNotFoundException ex) {
-+ cl = contextLoader.loadClass(name);
-+ }
- }
- }
- if (resolve) {
-@@ -85,5 +111,36 @@
- return cl;
- }
-
-+ private Class loadFromParent(String name)
-+ throws ClassNotFoundException
++ public void showScriptWindow(URL url) {
++ String key = getFileName(url);
++ FileWindow w = (FileWindow) getFileWindow(key);
++ if (w != null)
++ {
++ desk.getDesktopManager().deiconifyFrame(w);
++ desk.getDesktopManager().activateFrame(w);
++ w.show();
++ w.toFront();
++ }
++ }
++
++ public void highlighLineInScriptWindow(URL url, int lineNum) {
++ String key = getFileName(url);
++ FileWindow w = (FileWindow) getFileWindow(key);
++ if (w != null)
++ {
++ showFileWindow(key, lineNum);
++ }
++ }
++
++ public Object runScriptWindow(URL scriptUrl) throws Exception
+ {
-+ if (parentLoader != null) {
-+ return parentLoader.loadClass(name);
-+ } else {
-+ return findSystemClass(name);
++ String key = getFileName(scriptUrl);
++ FileWindow w = (FileWindow) getFileWindow(key);
++ Object result = null;
++ if (w != null)
++ {
++ w.toFront();
++ Scriptable scope = officeScripts.getScriptScope(key);
++ if (scope == null)
++ {
++ javax.swing.JOptionPane.showMessageDialog(this, "Can't load
scripts: no scope available", "Run", javax.swing.JOptionPane.ERROR_MESSAGE);
++ }
++ else
++ {
++ String url = w.getUrl();
++ if (url != null)
++ {
++ if (officeScripts.isScriptRunning(key))
++ {
++ return result;
++ }
++ officeScripts.setScriptRunning(key, true);
++ try {
++ result = dim.evalScriptWithReturn(url, w.getText(),
scope);
++ } catch (Exception exc) {
++ exc.printStackTrace();
++ throw exc;
++ } finally {
++ officeScripts.setScriptRunning(key, false);
++ }
++ }
++ }
+ }
++ return result;
+ }
+
- private final ClassLoader parentLoader;
++ public boolean isModified(URL url) {
++ String key = getFileName(url);
++ FileWindow w = (FileWindow) getFileWindow(key);
++ if (w != null)
++ return w.isModified();
++ return false;
++ }
+
-+ private ClassLoader contextLoader;
++ public String getText(URL url) {
++ String key = getFileName(url);
++ FileWindow w = (FileWindow) getFileWindow(key);
++ if (w != null)
++ return w.getText();
++ return null;
++ }
+
-+ // We'd like to use "Thread.getContextClassLoader", but
-+ // that's only available on Java2.
-+ private static Method method_getContextClassLoader;
+
+ /**
+ * Serializable magic number.
+@@ -2052,7 +2187,7 @@
+ /**
+ * An internal frame for script files.
+ */
+-class FileWindow extends JInternalFrame implements ActionListener {
++class FileWindow extends JInternalFrame implements ActionListener,
javax.swing.event.DocumentListener {
+
+ /**
+ * Serializable magic number.
+@@ -2089,6 +2224,83 @@
+ */
+ int currentPos;
+
++ boolean isModified = false;
+
-+ static {
-+ try {
-+ // Don't use "Thread.class": that performs the lookup
-+ // in the class initializer, which doesn't allow us to
-+ // catch possible security exceptions.
-+ Class threadClass = Class.forName("java.lang.Thread");
-+ method_getContextClassLoader =
-+ threadClass.getDeclaredMethod("getContextClassLoader",
-+ new Class[0]);
-+ } catch (ClassNotFoundException e) {
-+ } catch (NoSuchMethodException e) {
-+ } catch (SecurityException e) {
++ public void insertUpdate(javax.swing.event.DocumentEvent e) {
++ doChanged(e);
++ }
++
++ public void removeUpdate(javax.swing.event.DocumentEvent e) {
++ doChanged(e);
++ }
++
++ public void changedUpdate(javax.swing.event.DocumentEvent e) {
++ doChanged(e);
++ }
++
++ public void doChanged(javax.swing.event.DocumentEvent e) {
++ this.isModified = true;
++ }
++
++ public boolean isModified() {
++ return this.isModified;
++ }
++
++ public String getText() {
++ return textArea.getText();
++ }
++
++ void save() {
++ String url = getUrl();
++ if (url != null) {
++ java.io.OutputStream os = null;
++ try {
++ if (url.startsWith("vnd.sun.star"))
++ {
++ URL scriptUrl = debugGui.officeScripts.getScriptUrl(url);
++ if ( scriptUrl == null )
++ {
++ throw new java.io.IOException("Can't obtain stream
for " + url);
++ }
++ os = scriptUrl.openConnection().getOutputStream();
++ }
++ else
++ {
++ os = new java.io.FileOutputStream(url);
++ }
++ String txt = textArea.getText();
++ byte[] data =
txt.getBytes(java.nio.charset.StandardCharsets.UTF_8);
++ os.write(data, 0, data.length);
++
++ this.isModified = false;
++ } catch (java.io.IOException ioe) {
++ javax.swing.JOptionPane.showMessageDialog(this,
++ "Error saving file: " + ioe.getMessage(),
++ "Error", javax.swing.JOptionPane.ERROR_MESSAGE);
++ }
++ finally
++ {
++ if ( os != null )
++ {
++ try
++ {
++ os.close();
++ os = null;
++ }
++ catch( java.io.IOException ioe )
++ {
++ System.err.println("Error closing stream: " +
ioe.getMessage() );
++ ioe.printStackTrace();
++ }
++ }
++ }
+ }
+ }
++
++ public boolean isEditable() {
++ return debugGui.isSourceEditingEnabled();
++ }
++
+ /**
+ * Loads the file.
+ */
+@@ -3546,4 +3758,5 @@
+
+ }
+ }
++
}
diff --git
a/main/scripting/java/com/sun/star/script/framework/provider/ScriptContext.java
b/main/scripting/java/com/sun/star/script/framework/provider/ScriptContext.java
index 2d93a95443..21c506dee9 100644
---
a/main/scripting/java/com/sun/star/script/framework/provider/ScriptContext.java
+++
b/main/scripting/java/com/sun/star/script/framework/provider/ScriptContext.java
@@ -85,15 +85,13 @@ public class ScriptContext extends PropertySet implements
XScriptContext
(short)(PropertyAttribute.MAYBEVOID |
PropertyAttribute.TRANSIENT), "m_xModel");
registerProperty( HM_DESKTOP, new Type(XDesktop.class),
(short)(PropertyAttribute.MAYBEVOID |
PropertyAttribute.TRANSIENT), "m_xDeskTop");
- registerProperty( HM_COMPONENT_CONTEXT, new Type(XDesktop.class),
+ registerProperty( HM_COMPONENT_CONTEXT, new
Type(XComponentContext.class),
(short)(PropertyAttribute.MAYBEVOID |
PropertyAttribute.TRANSIENT), "m_xComponentContext");
}
public static XScriptContext createContext( XModel xModel,
XScriptInvocationContext xInvocContext,
XComponentContext xCtxt, XMultiComponentFactory xMCF)
{
- XScriptContext sc = null;
-
try {
Object xInterface = null;
@@ -105,18 +103,19 @@ public class ScriptContext extends PropertySet implements
XScriptContext
UnoRuntime.queryInterface(XDesktop.class, xInterface);
if ( xModel != null )
{
- sc = new ScriptContext(xCtxt, xDesktop, xModel, xInvocContext);
+ return new ScriptContext(xCtxt, xDesktop, xModel,
xInvocContext);
}
else
{
- sc = new EditorScriptContext(xCtxt, xDesktop );
+ return new EditorScriptContext(xCtxt, xDesktop );
}
}
catch ( Exception e ) {
LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ throw new com.sun.star.uno.RuntimeException(
+ "Failed to create script context: " + e.getMessage() );
}
- return sc;
}
//----------------------------------------------------------------------
diff --git
a/main/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java
b/main/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java
index 4d226e843f..c011c08919 100644
---
a/main/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java
+++
b/main/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java
@@ -184,7 +184,7 @@ public abstract class ScriptProvider
{
// otherwise, check whether it's an XModel
m_xModel = UnoRuntime.queryInterface( XModel.class,
- m_xInvocContext.getScriptContainer() );
+ aArguments[0] );
}
if ( m_xModel == null )
{
diff --git
a/main/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
b/main/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
index 4b7050835f..85f75359da 100644
---
a/main/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
+++
b/main/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
@@ -263,7 +263,7 @@ public class ScriptEditorForJavaScript implements
ScriptEditor
org.mozilla.javascript.tools.shell.ShellContextFactory
contextFactory =
new
org.mozilla.javascript.tools.shell.ShellContextFactory();
sdb.attachTo(contextFactory);
- contextFactory.setLanguageVersion(Context.VERSION_1_8);
+ contextFactory.setLanguageVersion(Context.VERSION_ES6);
contextFactory.setOptimizationLevel(9);
sdb.pack();
sdb.setSize(640, 640);
@@ -322,17 +322,20 @@ public class ScriptEditorForJavaScript implements
ScriptEditor
private Scriptable getScope(XScriptContext xsctxt )
{
Context ctxt = Context.enter();
- ImporterTopLevel scope = new ImporterTopLevel(ctxt);
+ try {
+ ImporterTopLevel scope = new ImporterTopLevel(ctxt);
- Scriptable jsCtxt = Context.toObject(xsctxt, scope);
- scope.put("XSCRIPTCONTEXT", scope, jsCtxt);
+ Scriptable jsCtxt = Context.toObject(xsctxt, scope);
+ scope.put("XSCRIPTCONTEXT", scope, jsCtxt);
- Scriptable jsArgs = Context.toObject(
- new Object[0], scope);
- scope.put("ARGUMENTS", scope, jsArgs);
+ Scriptable jsArgs = Context.toObject(
+ new Object[0], scope);
+ scope.put("ARGUMENTS", scope, jsArgs);
- Context.exit();
- return scope;
+ return scope;
+ } finally {
+ Context.exit();
+ }
}
class closeHandler implements Runnable
diff --git
a/main/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java
b/main/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java
index 9072225767..b1e4ebe161 100644
---
a/main/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java
+++
b/main/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java
@@ -210,6 +210,7 @@ class ScriptImpl implements XScript
ScriptFrameworkErrorType.UNKNOWN );
}
Context ctxt = null;
+ ClassLoader prevCl =
Thread.currentThread().getContextClassLoader();
try
{
@@ -231,6 +232,16 @@ class ScriptImpl implements XScript
// TODO revisit
return Context.toString( result );
}
+ else if ( result != null )
+ {
+ // editor returned a non-Undefined result; do not
execute again
+ return Context.toString( result );
+ }
+ else
+ {
+ // editor executed the script (result may legitimately
be null); do not execute again
+ return null;
+ }
}
@@ -264,7 +275,7 @@ class ScriptImpl implements XScript
// Initialize a Rhino Context object
ctxt = Context.enter();
- ctxt.setLanguageVersion(Context.VERSION_1_8);
+ ctxt.setLanguageVersion(Context.VERSION_ES6);
ctxt.setOptimizationLevel(9);
/* The ImporterTopLevel ensures that importClass and
@@ -284,7 +295,7 @@ class ScriptImpl implements XScript
scope.put("ARGUMENTS", scope, jsArgs);
result = ctxt.evaluateString(scope,
- source, "<stdin>", 1, null);
+ source, editorURL, 1, null);
result = ctxt.toString(result);
return result;
}
@@ -294,14 +305,14 @@ class ScriptImpl implements XScript
int lineNo = jse.lineNumber();
Object wrap = jse.getValue();
LogUtils.DEBUG( "\t message " + message );
- LogUtils.DEBUG( "\t wrapped type " + wrap.getClass() );
- LogUtils.DEBUG( "\t wrapped toString " + wrap.toString() );
+ LogUtils.DEBUG( "\t wrapped type " + (wrap != null ?
wrap.getClass().getName() : "null") );
+ LogUtils.DEBUG( "\t wrapped toString " + (wrap != null ?
wrap.toString() : "null") );
ScriptExceptionRaisedException se = new
ScriptExceptionRaisedException( message );
se.lineNum = lineNo;
se.language = "JavaScript";
se.scriptName = metaData.getLanguageName();
- se.exceptionType = wrap.getClass().getName();
+ se.exceptionType = (wrap != null) ? wrap.getClass().getName()
: "null";
se.language = metaData.getLanguage();
LogUtils.DEBUG( "ExceptionRaised exception " );
LogUtils.DEBUG( "\t message " + se.getMessage() );
@@ -324,6 +335,9 @@ class ScriptImpl implements XScript
{
Context.exit();
}
+ if (prevCl != null) {
+ Thread.currentThread().setContextClassLoader(prevCl);
+ }
}
}