Skip to content

Commit b792601

Browse files
rPramlgbrail
authored andcommitted
Regexp: Do not use reflection for init
1 parent 3061029 commit b792601

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

rhino/src/main/java/org/mozilla/javascript/regexp/NativeRegExp.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public class NativeRegExp extends IdScriptableObject {
145145

146146
private static final int ANCHOR_BOL = -2;
147147

148-
public static void init(Context cx, Scriptable scope, boolean sealed) {
148+
static Object init(Context cx, Scriptable scope, boolean sealed) {
149149

150150
NativeRegExp proto = NativeRegExpInstantiator.withLanguageVersion(cx.getLanguageVersion());
151151
proto.re = compileRE(cx, "", null, false);
@@ -170,6 +170,8 @@ public static void init(Context cx, Scriptable scope, boolean sealed) {
170170
ScriptableObject.defineProperty(scope, "RegExp", ctor, ScriptableObject.DONTENUM);
171171

172172
ScriptRuntimeES6.addSymbolSpecies(cx, scope, ctor);
173+
174+
return ctor;
173175
}
174176

175177
NativeRegExp(Scriptable scope, RECompiled regexpCompiled) {

rhino/src/main/java/org/mozilla/javascript/regexp/RegExpImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ public class RegExpImpl implements RegExpProxy {
2222
@Override
2323
public void register(ScriptableObject scope, boolean sealed) {
2424
NativeRegExpStringIterator.init(scope, sealed);
25-
new LazilyLoadedCtor(
26-
scope, "RegExp", "org.mozilla.javascript.regexp.NativeRegExp", sealed, true);
25+
new LazilyLoadedCtor(scope, "RegExp", sealed, true, NativeRegExp::init);
2726
}
2827

2928
@Override

0 commit comments

Comments
 (0)