diff --git a/rhino/src/main/java/org/mozilla/javascript/ScriptRuntime.java b/rhino/src/main/java/org/mozilla/javascript/ScriptRuntime.java index 4f7c2fb09c..9edefaf67d 100644 --- a/rhino/src/main/java/org/mozilla/javascript/ScriptRuntime.java +++ b/rhino/src/main/java/org/mozilla/javascript/ScriptRuntime.java @@ -188,7 +188,7 @@ public static ScriptableObject initSafeStandardObjects( NativeArrayIterator.init(scope, sealed); NativeStringIterator.init(scope, sealed); - getRegExpProxy(cx).register(scope, sealed); + registerRegExp(cx, scope, sealed); NativeJavaObject.init(scope, sealed); NativeJavaMap.init(scope, sealed); @@ -298,6 +298,13 @@ public static ScriptableObject initSafeStandardObjects( return scope; } + private static void registerRegExp(Context cx, ScriptableObject scope, boolean sealed) { + RegExpProxy regExpProxy = getRegExpProxy(cx); + if (regExpProxy != null) { + regExpProxy.register(scope, sealed); + } + } + public static ScriptableObject initStandardObjects( Context cx, ScriptableObject scope, boolean sealed) { ScriptableObject s = initSafeStandardObjects(cx, scope, sealed); diff --git a/rhino/src/main/java/org/mozilla/javascript/regexp/NativeRegExpStringIterator.java b/rhino/src/main/java/org/mozilla/javascript/regexp/NativeRegExpStringIterator.java index 46454cec2b..1974040952 100644 --- a/rhino/src/main/java/org/mozilla/javascript/regexp/NativeRegExpStringIterator.java +++ b/rhino/src/main/java/org/mozilla/javascript/regexp/NativeRegExpStringIterator.java @@ -19,6 +19,13 @@ public final class NativeRegExpStringIterator extends ES6Iterator { private static final long serialVersionUID = 1L; private static final String ITERATOR_TAG = "RegExpStringIterator"; + private Scriptable regexp; + private String string; + private boolean global; + private boolean fullUnicode; + private boolean nextDone; + private Object next = null; + public static void init(ScriptableObject scope, boolean sealed) { ES6Iterator.init(scope, sealed, new NativeRegExpStringIterator(), ITERATOR_TAG); } @@ -101,11 +108,4 @@ private Object regExpExec(Context cx, Scriptable scope) { protected String getTag() { return ITERATOR_TAG; } - - private Scriptable regexp; - private String string; - private boolean global; - private boolean fullUnicode; - private boolean nextDone; - private Object next = null; }