4545import jdk .nashorn .internal .runtime .JSType ;
4646import jdk .nashorn .internal .runtime .ParserException ;
4747import jdk .nashorn .internal .runtime .PropertyMap ;
48- import jdk .nashorn .internal .runtime .ScriptFunction ;
4948import jdk .nashorn .internal .runtime .ScriptObject ;
5049import jdk .nashorn .internal .runtime .ScriptRuntime ;
5150import jdk .nashorn .internal .runtime .linker .Bootstrap ;
@@ -655,7 +654,7 @@ public boolean test(final String string) {
655654 * @param replacement Replacement string.
656655 * @return String with substitutions.
657656 */
658- String replace (final String string , final String replacement , final ScriptFunction function ) throws Throwable {
657+ String replace (final String string , final String replacement , final Object function ) throws Throwable {
659658 final RegExpMatcher matcher = regexp .match (string );
660659
661660 if (matcher == null ) {
@@ -671,7 +670,7 @@ String replace(final String string, final String replacement, final ScriptFuncti
671670 sb .append (string , 0 , matcher .start ());
672671
673672 if (function != null ) {
674- final Object self = function . isStrict ( ) ? UNDEFINED : Global .instance ();
673+ final Object self = Bootstrap . isStrictCallable ( function ) ? UNDEFINED : Global .instance ();
675674 sb .append (callReplaceValue (getReplaceValueInvoker (), function , self , matcher , string ));
676675 } else {
677676 appendReplacement (matcher , string , replacement , sb );
@@ -691,7 +690,7 @@ String replace(final String string, final String replacement, final ScriptFuncti
691690 final StringBuilder sb = new StringBuilder ();
692691
693692 final MethodHandle invoker = function == null ? null : getReplaceValueInvoker ();
694- final Object self = function == null || function . isStrict ( ) ? UNDEFINED : Global .instance ();
693+ final Object self = function == null || Bootstrap . isStrictCallable ( function ) ? UNDEFINED : Global .instance ();
695694
696695 do {
697696 sb .append (string , thisIndex , matcher .start ());
@@ -807,12 +806,12 @@ private static MethodHandle getReplaceValueInvoker() {
807806 new Callable <MethodHandle >() {
808807 @ Override
809808 public MethodHandle call () {
810- return Bootstrap .createDynamicCallInvoker (String .class , ScriptFunction .class , Object .class , Object [].class );
809+ return Bootstrap .createDynamicCallInvoker (String .class , Object .class , Object .class , Object [].class );
811810 }
812811 });
813812 }
814813
815- private String callReplaceValue (final MethodHandle invoker , final ScriptFunction function , final Object self , final RegExpMatcher matcher , final String string ) throws Throwable {
814+ private String callReplaceValue (final MethodHandle invoker , final Object function , final Object self , final RegExpMatcher matcher , final String string ) throws Throwable {
816815 final Object [] groups = groups (matcher );
817816 final Object [] args = Arrays .copyOf (groups , groups .length + 2 );
818817
0 commit comments