Update references from deprecated to new methods.

ScriptableObject.getProperty methods have been replaced by Scriptable.getProperty. Also remove redundant super interface Scriptable from classes which implement SymbolScriptable.
This commit is contained in:
Tony Germano 2024-09-13 00:55:25 -04:00
Родитель 872049aaae
Коммит 519cb58d71
45 изменённых файлов: 164 добавлений и 172 удалений

Просмотреть файл

@ -7,7 +7,6 @@ import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.ScriptRuntime;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.openjdk.jmh.annotations.*;
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@ -43,21 +42,21 @@ public class MathBenchmark {
try (FileReader rdr = new FileReader("testsrc/benchmarks/micro/math-benchmarks.js")) {
cx.evaluateReader(scope, rdr, "math-benchmarks.js", 1, null);
}
addConstantInts = (Function) ScriptableObject.getProperty(scope, "addConstantInts");
addIntAndConstant = (Function) ScriptableObject.getProperty(scope, "addIntAndConstant");
addTwoInts = (Function) ScriptableObject.getProperty(scope, "addTwoInts");
addConstantFloats = (Function) ScriptableObject.getProperty(scope, "addConstantFloats");
addTwoFloats = (Function) ScriptableObject.getProperty(scope, "addTwoFloats");
addStringsInLoop = (Function) ScriptableObject.getProperty(scope, "addStringsInLoop");
addMixedStrings = (Function) ScriptableObject.getProperty(scope, "addMixedStrings");
subtractInts = (Function) ScriptableObject.getProperty(scope, "subtractInts");
subtractFloats = (Function) ScriptableObject.getProperty(scope, "subtractFloats");
subtractTwoFloats = (Function) ScriptableObject.getProperty(scope, "subtractTwoFloats");
bitwiseAnd = (Function) ScriptableObject.getProperty(scope, "bitwiseAnd");
bitwiseOr = (Function) ScriptableObject.getProperty(scope, "bitwiseOr");
bitwiseLsh = (Function) ScriptableObject.getProperty(scope, "bitwiseLsh");
bitwiseRsh = (Function) ScriptableObject.getProperty(scope, "bitwiseRsh");
bitwiseSignedRsh = (Function) ScriptableObject.getProperty(scope, "bitwiseSignedRsh");
addConstantInts = (Function) Scriptable.getProperty(scope, "addConstantInts");
addIntAndConstant = (Function) Scriptable.getProperty(scope, "addIntAndConstant");
addTwoInts = (Function) Scriptable.getProperty(scope, "addTwoInts");
addConstantFloats = (Function) Scriptable.getProperty(scope, "addConstantFloats");
addTwoFloats = (Function) Scriptable.getProperty(scope, "addTwoFloats");
addStringsInLoop = (Function) Scriptable.getProperty(scope, "addStringsInLoop");
addMixedStrings = (Function) Scriptable.getProperty(scope, "addMixedStrings");
subtractInts = (Function) Scriptable.getProperty(scope, "subtractInts");
subtractFloats = (Function) Scriptable.getProperty(scope, "subtractFloats");
subtractTwoFloats = (Function) Scriptable.getProperty(scope, "subtractTwoFloats");
bitwiseAnd = (Function) Scriptable.getProperty(scope, "bitwiseAnd");
bitwiseOr = (Function) Scriptable.getProperty(scope, "bitwiseOr");
bitwiseLsh = (Function) Scriptable.getProperty(scope, "bitwiseLsh");
bitwiseRsh = (Function) Scriptable.getProperty(scope, "bitwiseRsh");
bitwiseSignedRsh = (Function) Scriptable.getProperty(scope, "bitwiseSignedRsh");
}
@TearDown(Level.Trial)

Просмотреть файл

@ -7,7 +7,6 @@ import java.util.concurrent.TimeUnit;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.tools.shell.Global;
import org.openjdk.jmh.annotations.*;
@ -72,7 +71,7 @@ public class ObjectBenchmark {
@OperationsPerInvocation(1000)
@SuppressWarnings("unused")
public void createFields(FieldTestState state) {
Function create = (Function) ScriptableObject.getProperty(state.scope, "createObject");
Function create = (Function) Scriptable.getProperty(state.scope, "createObject");
create.call(state.cx, state.scope, null, new Object[] {count, state.strings, state.ints});
}
@ -80,11 +79,11 @@ public class ObjectBenchmark {
@OperationsPerInvocation(1000)
@SuppressWarnings("unused")
public void accessFields(FieldTestState state) {
Function create = (Function) ScriptableObject.getProperty(state.scope, "createObject");
Function create = (Function) Scriptable.getProperty(state.scope, "createObject");
Object o =
create.call(
state.cx, state.scope, null, new Object[] {1, state.strings, state.ints});
Function access = (Function) ScriptableObject.getProperty(state.scope, "accessObject");
Function access = (Function) Scriptable.getProperty(state.scope, "accessObject");
access.call(
state.cx, state.scope, null, new Object[] {count, o, state.strings, state.ints});
}
@ -93,11 +92,11 @@ public class ObjectBenchmark {
@OperationsPerInvocation(1000)
@SuppressWarnings("unused")
public void iterateFields(FieldTestState state) {
Function create = (Function) ScriptableObject.getProperty(state.scope, "createObject");
Function create = (Function) Scriptable.getProperty(state.scope, "createObject");
Object o =
create.call(
state.cx, state.scope, null, new Object[] {1, state.strings, state.ints});
Function iterate = (Function) ScriptableObject.getProperty(state.scope, "iterateObject");
Function iterate = (Function) Scriptable.getProperty(state.scope, "iterateObject");
iterate.call(state.cx, state.scope, null, new Object[] {count, o});
}
@ -105,12 +104,11 @@ public class ObjectBenchmark {
@OperationsPerInvocation(1000)
@SuppressWarnings("unused")
public void ownKeysFields(FieldTestState state) {
Function create = (Function) ScriptableObject.getProperty(state.scope, "createObject");
Function create = (Function) Scriptable.getProperty(state.scope, "createObject");
Object o =
create.call(
state.cx, state.scope, null, new Object[] {1, state.strings, state.ints});
Function iterate =
(Function) ScriptableObject.getProperty(state.scope, "iterateOwnKeysObject");
Function iterate = (Function) Scriptable.getProperty(state.scope, "iterateOwnKeysObject");
iterate.call(state.cx, state.scope, null, new Object[] {count, o});
}
@ -118,11 +116,11 @@ public class ObjectBenchmark {
@OperationsPerInvocation(1000)
@SuppressWarnings("unused")
public void deleteFields(FieldTestState state) {
Function create = (Function) ScriptableObject.getProperty(state.scope, "createObject");
Function create = (Function) Scriptable.getProperty(state.scope, "createObject");
Object o =
create.call(
state.cx, state.scope, null, new Object[] {1, state.strings, state.ints});
Function delete = (Function) ScriptableObject.getProperty(state.scope, "deleteObject");
Function delete = (Function) Scriptable.getProperty(state.scope, "deleteObject");
delete.call(
state.cx, state.scope, null, new Object[] {count, o, state.strings, state.ints});
}

Просмотреть файл

@ -7,7 +7,6 @@ import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.ScriptRuntime;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.openjdk.jmh.annotations.*;
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@ -35,11 +34,11 @@ public class PropertyBenchmark {
new FileReader("testsrc/benchmarks/micro/property-benchmarks.js")) {
cx.evaluateReader(scope, rdr, "property-benchmarks.js", 1, null);
}
create = (Function) ScriptableObject.getProperty(scope, "createObject");
create = (Function) Scriptable.getProperty(scope, "createObject");
createFieldByField =
(Function) ScriptableObject.getProperty(scope, "createObjectFieldByField");
getName = (Function) ScriptableObject.getProperty(scope, "getName");
check = (Function) ScriptableObject.getProperty(scope, "check");
(Function) Scriptable.getProperty(scope, "createObjectFieldByField");
getName = (Function) Scriptable.getProperty(scope, "getName");
check = (Function) Scriptable.getProperty(scope, "check");
object = create.call(cx, scope, null, new Object[] {"testing"});
}

Просмотреть файл

@ -6,7 +6,6 @@ import java.util.concurrent.TimeUnit;
import org.mozilla.javascript.Callable;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.openjdk.jmh.annotations.*;
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@ -18,7 +17,7 @@ public class V8Benchmark {
Scriptable scope;
Callable getFunc(String name) {
Object f = ScriptableObject.getProperty(scope, name);
Object f = Scriptable.getProperty(scope, name);
if (!(f instanceof Callable)) {
throw new RuntimeException("Benchmark function " + name + " not found");
}

Просмотреть файл

@ -7,7 +7,6 @@
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
/**
* Example of controlling the JavaScript execution engine.
@ -57,7 +56,7 @@ public class Control {
System.out.println("obj.b[1] == " + b.get(1, b));
// Should print {a:1, b:["x", "y"]}
Function fn = (Function) ScriptableObject.getProperty(obj, "toString");
Function fn = (Function) Scriptable.getProperty(obj, "toString");
System.out.println(fn.call(cx, scope, obj, new Object[0]));
} finally {
Context.exit();

Просмотреть файл

@ -31,16 +31,16 @@ public class CounterTest {
Scriptable testCounter = cx.newObject(scope, "Counter");
Object count = ScriptableObject.getProperty(testCounter, "count");
Object count = Scriptable.getProperty(testCounter, "count");
System.out.println("count = " + count);
count = ScriptableObject.getProperty(testCounter, "count");
count = Scriptable.getProperty(testCounter, "count");
System.out.println("count = " + count);
ScriptableObject.callMethod(testCounter, "resetCount", new Object[0]);
System.out.println("resetCount");
count = ScriptableObject.getProperty(testCounter, "count");
count = Scriptable.getProperty(testCounter, "count");
System.out.println("count = " + count);
} finally {
Context.exit();

Просмотреть файл

@ -188,7 +188,7 @@ public class RhinoScriptEngine extends AbstractScriptEngine implements Compilabl
localThis = Context.toObject(thiz, scope);
}
Object f = ScriptableObject.getProperty(localThis, name);
Object f = Scriptable.getProperty(localThis, name);
if (f == Scriptable.NOT_FOUND) {
throw new NoSuchMethodException(name);
}
@ -306,7 +306,7 @@ public class RhinoScriptEngine extends AbstractScriptEngine implements Compilabl
if (m.getDeclaringClass() == Object.class) {
continue;
}
Object methodObj = ScriptableObject.getProperty(scope, m.getName());
Object methodObj = Scriptable.getProperty(scope, m.getName());
if (!(methodObj instanceof Callable)) {
return true;
}

Просмотреть файл

@ -547,14 +547,14 @@ public class Dim {
} else if (name.equals("__parent__")) {
result = scriptable.getParentScope();
} else {
result = ScriptableObject.getProperty(scriptable, name);
result = Scriptable.getProperty(scriptable, name);
if (result == ScriptableObject.NOT_FOUND) {
result = Undefined.instance;
}
}
} else {
int index = ((Integer) id).intValue();
result = ScriptableObject.getProperty(scriptable, index);
result = Scriptable.getProperty(scriptable, index);
if (result == ScriptableObject.NOT_FOUND) {
result = Undefined.instance;
}

Просмотреть файл

@ -363,16 +363,16 @@ public class Global extends ImporterTopLevel {
public String[] getPrompts(Context cx) {
if (ScriptableObject.hasProperty(this, "prompts")) {
Object promptsJS = ScriptableObject.getProperty(this, "prompts");
Object promptsJS = Scriptable.getProperty(this, "prompts");
if (promptsJS instanceof Scriptable) {
Scriptable s = (Scriptable) promptsJS;
if (ScriptableObject.hasProperty(s, 0) && ScriptableObject.hasProperty(s, 1)) {
Object elem0 = ScriptableObject.getProperty(s, 0);
Object elem0 = Scriptable.getProperty(s, 0);
if (elem0 instanceof Function) {
elem0 = ((Function) elem0).call(cx, this, s, new Object[0]);
}
prompts[0] = Context.toString(elem0);
Object elem1 = ScriptableObject.getProperty(s, 1);
Object elem1 = Scriptable.getProperty(s, 1);
if (elem1 instanceof Function) {
elem1 = ((Function) elem1).call(cx, this, s, new Object[0]);
}
@ -616,7 +616,7 @@ public class Global extends ImporterTopLevel {
if (args[L - 1] instanceof Scriptable) {
params = (Scriptable) args[L - 1];
--L;
Object envObj = ScriptableObject.getProperty(params, "env");
Object envObj = Scriptable.getProperty(params, "env");
if (envObj != Scriptable.NOT_FOUND) {
if (envObj == null) {
environment = new String[0];
@ -632,11 +632,11 @@ public class Global extends ImporterTopLevel {
String key;
if (keyObj instanceof String) {
key = (String) keyObj;
val = ScriptableObject.getProperty(envHash, key);
val = Scriptable.getProperty(envHash, key);
} else {
int ikey = ((Number) keyObj).intValue();
key = Integer.toString(ikey);
val = ScriptableObject.getProperty(envHash, ikey);
val = Scriptable.getProperty(envHash, ikey);
}
if (val == ScriptableObject.NOT_FOUND) {
val = Undefined.instance;
@ -645,16 +645,16 @@ public class Global extends ImporterTopLevel {
}
}
}
Object wdObj = ScriptableObject.getProperty(params, "dir");
Object wdObj = Scriptable.getProperty(params, "dir");
if (wdObj != Scriptable.NOT_FOUND) {
wd = new File(ScriptRuntime.toString(wdObj));
}
Object inObj = ScriptableObject.getProperty(params, "input");
Object inObj = Scriptable.getProperty(params, "input");
if (inObj != Scriptable.NOT_FOUND) {
in = toInputStream(inObj);
}
outObj = ScriptableObject.getProperty(params, "output");
outObj = Scriptable.getProperty(params, "output");
if (outObj != Scriptable.NOT_FOUND) {
out = toOutputStream(outObj);
if (out == null) {
@ -662,7 +662,7 @@ public class Global extends ImporterTopLevel {
out = outBytes;
}
}
errObj = ScriptableObject.getProperty(params, "err");
errObj = Scriptable.getProperty(params, "err");
if (errObj != Scriptable.NOT_FOUND) {
err = toOutputStream(errObj);
if (err == null) {
@ -670,7 +670,7 @@ public class Global extends ImporterTopLevel {
err = errBytes;
}
}
Object addArgsObj = ScriptableObject.getProperty(params, "args");
Object addArgsObj = Scriptable.getProperty(params, "args");
if (addArgsObj != Scriptable.NOT_FOUND) {
Scriptable s = Context.toObject(addArgsObj, getTopLevelScope(thisObj));
addArgs = cx.getElements(s);

Просмотреть файл

@ -648,7 +648,7 @@ public class Main {
Object result = unhandled.get(0);
String msg = "Unhandled rejected promise: " + Context.toString(result);
if (result instanceof Scriptable) {
Object stack = ScriptableObject.getProperty((Scriptable) result, "stack");
Object stack = Scriptable.getProperty((Scriptable) result, "stack");
if (stack != null && stack != Scriptable.NOT_FOUND) {
msg += '\n' + Context.toString(stack);
}

Просмотреть файл

@ -43,7 +43,7 @@ class XMLCtor extends IdFunctionObject {
for (int i = 1; i <= MAX_INSTANCE_ID; ++i) {
int id = super.getMaxInstanceId() + i;
String name = getInstanceIdName(id);
Object value = ScriptableObject.getProperty(source, name);
Object value = Scriptable.getProperty(source, name);
if (value == Scriptable.NOT_FOUND) {
continue;
}

Просмотреть файл

@ -12,7 +12,6 @@ import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.ScriptRuntime;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.Undefined;
import org.mozilla.javascript.xml.XMLObject;
@ -772,7 +771,7 @@ class XMLList extends XMLObjectImpl implements Function {
if (sobj != null) {
thisObj = sobj;
if (!(sobj instanceof XMLObject)) {
func = ScriptableObject.getProperty(sobj, methodName);
func = Scriptable.getProperty(sobj, methodName);
}
}
}

Просмотреть файл

@ -189,7 +189,7 @@ public class AbstractEcmaObjectOperations {
7. If IsConstructor(S) is true, return S.
8. Throw a TypeError exception.
*/
Object constructor = ScriptableObject.getProperty(s, "constructor");
Object constructor = Scriptable.getProperty(s, "constructor");
if (constructor == Scriptable.NOT_FOUND || Undefined.isUndefined(constructor)) {
return defaultConstructor;
}
@ -197,7 +197,7 @@ public class AbstractEcmaObjectOperations {
throw ScriptRuntime.typeErrorById(
"msg.arg.not.object", ScriptRuntime.typeof(constructor));
}
Object species = ScriptableObject.getProperty((Scriptable) constructor, SymbolKey.SPECIES);
Object species = Scriptable.getProperty((Scriptable) constructor, SymbolKey.SPECIES);
if (species == Scriptable.NOT_FOUND || species == null || Undefined.isUndefined(species)) {
return defaultConstructor;
}

Просмотреть файл

@ -372,12 +372,12 @@ final class Arguments extends IdScriptableObject {
return;
}
Object newValue = getProperty(desc, "value");
Object newValue = Scriptable.getProperty(desc, "value");
if (newValue == NOT_FOUND) return;
replaceArg(index, newValue);
if (isFalse(getProperty(desc, "writable"))) {
if (isFalse(Scriptable.getProperty(desc, "writable"))) {
removeArg(index);
}
}

Просмотреть файл

@ -177,9 +177,9 @@ public class ArrayLikeAbstractOperations {
// same as NativeArray::getElem, but without converting NOT_FOUND to undefined
static Object getRawElem(Scriptable target, long index) {
if (index > Integer.MAX_VALUE) {
return ScriptableObject.getProperty(target, Long.toString(index));
return Scriptable.getProperty(target, Long.toString(index));
}
return ScriptableObject.getProperty(target, (int) index);
return Scriptable.getProperty(target, (int) index);
}
public static long toSliceIndex(double value, long length) {

Просмотреть файл

@ -47,7 +47,7 @@ public class BaseFunction extends IdScriptableObject implements Function {
obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed);
// The "GeneratorFunction" name actually never appears in the global scope.
// Return it here so it can be cached as a "builtin"
return ScriptableObject.getProperty(scope, GENERATOR_FUNCTION_CLASS);
return Scriptable.getProperty(scope, GENERATOR_FUNCTION_CLASS);
}
public BaseFunction() {}
@ -95,7 +95,7 @@ public class BaseFunction extends IdScriptableObject implements Function {
*/
@Override
public boolean hasInstance(Scriptable instance) {
Object protoProp = ScriptableObject.getProperty(this, "prototype");
Object protoProp = Scriptable.getProperty(this, "prototype");
if (protoProp instanceof Scriptable) {
return ScriptRuntime.jsDelegatesTo(instance, (Scriptable) protoProp);
}

Просмотреть файл

@ -141,9 +141,7 @@ public final class ES6Generator extends IdScriptableObject {
delegee = null;
// Return a result to the original generator
return resumeLocal(
cx,
scope,
ScriptableObject.getProperty(nextResult, ES6Iterator.VALUE_PROPERTY));
cx, scope, Scriptable.getProperty(nextResult, ES6Iterator.VALUE_PROPERTY));
}
// Otherwise, we have a normal result and should continue
return nextResult;

Просмотреть файл

@ -350,11 +350,11 @@ final class EqualObjectGraphs {
private static Object getValue(final Scriptable s, final Object id) {
if (id instanceof Symbol) {
return ScriptableObject.getProperty(s, (Symbol) id);
return Scriptable.getProperty(s, (Symbol) id);
} else if (id instanceof Integer) {
return ScriptableObject.getProperty(s, (Integer) id);
return Scriptable.getProperty(s, (Integer) id);
} else if (id instanceof String) {
return ScriptableObject.getProperty(s, (String) id);
return Scriptable.getProperty(s, (String) id);
} else {
throw new ClassCastException();
}

Просмотреть файл

@ -866,7 +866,7 @@ public abstract class IdScriptableObject extends ScriptableObject implements IdF
ScriptableObject current = getOwnPropertyDescriptor(cx, key);
checkPropertyChange(name, current, desc);
int attr = (info >>> 16);
Object value = getProperty(desc, "value");
Object value = Scriptable.getProperty(desc, "value");
if (value != NOT_FOUND && ((attr & READONLY) == 0 || (attr & PERMANENT) == 0)) {
Object currentValue = getInstanceIdValue(id);
if (!sameValue(value, currentValue)) {
@ -888,7 +888,7 @@ public abstract class IdScriptableObject extends ScriptableObject implements IdF
ScriptableObject current = getOwnPropertyDescriptor(cx, key);
checkPropertyChange(name, current, desc);
int attr = prototypeValues.getAttributes(id);
Object value = getProperty(desc, "value");
Object value = Scriptable.getProperty(desc, "value");
if (value != NOT_FOUND && (attr & READONLY) == 0) {
Object currentValue = prototypeValues.get(id);
if (!sameValue(value, currentValue)) {

Просмотреть файл

@ -121,7 +121,7 @@ public class InterfaceAdapter {
} else {
Scriptable s = (Scriptable) target;
String methodName = method.getName();
Object value = ScriptableObject.getProperty(s, methodName);
Object value = Scriptable.getProperty(s, methodName);
if (value == Scriptable.NOT_FOUND) {
// We really should throw an error here, but for the sake of
// compatibility with JavaAdapter we silently ignore undefined

Просмотреть файл

@ -74,7 +74,7 @@ public class IteratorLikeIterable implements Iterable<Object>, Closeable {
// This will throw if "val" is not an object.
// "getObjectPropNoWarn" won't, so do this as follows.
Object doneval =
ScriptableObject.getProperty(
Scriptable.getProperty(
ScriptableObject.ensureScriptable(val), ES6Iterator.DONE_PROPERTY);
if (doneval == Scriptable.NOT_FOUND) {
doneval = Undefined.instance;

Просмотреть файл

@ -285,10 +285,10 @@ public final class JavaAdapter implements IdFunctionCall {
for (int i = 0; i != ids.length; ++i) {
if (!(ids[i] instanceof String)) continue;
String id = (String) ids[i];
Object value = ScriptableObject.getProperty(obj, id);
Object value = Scriptable.getProperty(obj, id);
if (value instanceof Function) {
Function f = (Function) value;
int length = ScriptRuntime.toInt32(ScriptableObject.getProperty(f, "length"));
int length = ScriptRuntime.toInt32(Scriptable.getProperty(f, "length"));
if (length < 0) {
length = 0;
}
@ -508,7 +508,7 @@ public final class JavaAdapter implements IdFunctionCall {
}
public static Function getFunction(Scriptable obj, String functionName) {
Object x = ScriptableObject.getProperty(obj, functionName);
Object x = Scriptable.getProperty(obj, functionName);
if (x == Scriptable.NOT_FOUND) {
// This method used to swallow the exception from calling
// an undefined method. People have come to depend on this

Просмотреть файл

@ -947,7 +947,7 @@ public class NativeArray extends IdScriptableObject implements List {
}
}
Object iteratorProp = ScriptableObject.getProperty(items, SymbolKey.ITERATOR);
Object iteratorProp = Scriptable.getProperty(items, SymbolKey.ITERATOR);
if (!(items instanceof NativeArray)
&& (iteratorProp != Scriptable.NOT_FOUND)
&& !Undefined.isUndefined(iteratorProp)) {
@ -1114,7 +1114,7 @@ public class NativeArray extends IdScriptableObject implements List {
return ((Number) lengthFunc.call(cx, obj, obj, ScriptRuntime.emptyArgs)).longValue();
}
Object len = ScriptableObject.getProperty(obj, "length");
Object len = Scriptable.getProperty(obj, "length");
if (len == Scriptable.NOT_FOUND) {
// toUint32(undefined) == 0
return 0;
@ -1706,7 +1706,7 @@ public class NativeArray extends IdScriptableObject implements List {
// First, look for the new @@isConcatSpreadable test as per ECMAScript 6 and up
if (val instanceof Scriptable) {
final Object spreadable =
ScriptableObject.getProperty((Scriptable) val, SymbolKey.IS_CONCAT_SPREADABLE);
Scriptable.getProperty((Scriptable) val, SymbolKey.IS_CONCAT_SPREADABLE);
if ((spreadable != Scriptable.NOT_FOUND) && !Undefined.isUndefined(spreadable)) {
// If @@isConcatSpreadable was undefined, we have to fall back to testing for an
// array.
@ -1871,7 +1871,7 @@ public class NativeArray extends IdScriptableObject implements List {
for (int i = (int) start; i < length; i++) {
Object val = na.dense[i];
if (val == NOT_FOUND && proto != null) {
val = ScriptableObject.getProperty(proto, i);
val = Scriptable.getProperty(proto, i);
}
if (val != NOT_FOUND && ScriptRuntime.shallowEq(val, compareTo)) {
return Long.valueOf(i);
@ -1923,7 +1923,7 @@ public class NativeArray extends IdScriptableObject implements List {
for (int i = (int) start; i >= 0; i--) {
Object val = na.dense[i];
if (val == NOT_FOUND && proto != null) {
val = ScriptableObject.getProperty(proto, i);
val = Scriptable.getProperty(proto, i);
}
if (val != NOT_FOUND && ScriptRuntime.shallowEq(val, compareTo)) {
return Long.valueOf(i);
@ -1949,7 +1949,8 @@ public class NativeArray extends IdScriptableObject implements List {
Object compareTo = args.length > 0 ? args[0] : Undefined.instance;
Scriptable o = ScriptRuntime.toObject(cx, scope, thisObj);
long len = ScriptRuntime.toLength(new Object[] {getProperty(thisObj, "length")}, 0);
long len =
ScriptRuntime.toLength(new Object[] {Scriptable.getProperty(thisObj, "length")}, 0);
if (len == 0) return Boolean.FALSE;
long k;
@ -1970,7 +1971,7 @@ public class NativeArray extends IdScriptableObject implements List {
for (int i = (int) k; i < len; i++) {
Object elementK = na.dense[i];
if (elementK == NOT_FOUND && proto != null) {
elementK = ScriptableObject.getProperty(proto, i);
elementK = Scriptable.getProperty(proto, i);
}
if (elementK == NOT_FOUND) {
elementK = Undefined.instance;

Просмотреть файл

@ -300,7 +300,7 @@ final class NativeDate extends IdScriptableObject {
return null;
}
}
Object toISO = ScriptableObject.getProperty(o, toISOString);
Object toISO = Scriptable.getProperty(o, toISOString);
if (toISO == NOT_FOUND) {
throw ScriptRuntime.typeErrorById(
"msg.function.not.found.in",

Просмотреть файл

@ -117,7 +117,7 @@ final class NativeError extends IdScriptableObject {
}
static void installCause(NativeObject options, NativeError obj) {
Object cause = ScriptableObject.getProperty(options, "cause");
Object cause = Scriptable.getProperty(options, "cause");
if (cause != NOT_FOUND) {
ScriptableObject.putProperty(obj, "cause", cause);
obj.setAttributes("cause", DONTENUM);
@ -290,14 +290,14 @@ final class NativeError extends IdScriptableObject {
}
private static Object js_toString(Scriptable thisObj) {
Object nameObj = ScriptableObject.getProperty(thisObj, "name");
Object nameObj = Scriptable.getProperty(thisObj, "name");
String name;
if (nameObj == NOT_FOUND || Undefined.isUndefined(nameObj)) {
name = "Error";
} else {
name = ScriptRuntime.toString(nameObj);
}
Object msgObj = ScriptableObject.getProperty(thisObj, "message");
Object msgObj = Scriptable.getProperty(thisObj, "message");
String msg;
if (msgObj == NOT_FOUND || Undefined.isUndefined(msgObj)) {
msg = "";
@ -315,10 +315,10 @@ final class NativeError extends IdScriptableObject {
private static String js_toSource(Context cx, Scriptable scope, Scriptable thisObj) {
// Emulation of SpiderMonkey behavior
Object name = ScriptableObject.getProperty(thisObj, "name");
Object message = ScriptableObject.getProperty(thisObj, "message");
Object fileName = ScriptableObject.getProperty(thisObj, "fileName");
Object lineNumber = ScriptableObject.getProperty(thisObj, "lineNumber");
Object name = Scriptable.getProperty(thisObj, "name");
Object message = Scriptable.getProperty(thisObj, "message");
Object fileName = Scriptable.getProperty(thisObj, "fileName");
Object lineNumber = Scriptable.getProperty(thisObj, "lineNumber");
StringBuilder sb = new StringBuilder();
sb.append("(new ");

Просмотреть файл

@ -96,10 +96,9 @@ public class NativeGlobal implements Serializable, IdFunctionCall {
with the 'name' property set to the name of the error.
*/
Scriptable nativeError =
ScriptableObject.ensureScriptable(ScriptableObject.getProperty(scope, "Error"));
ScriptableObject.ensureScriptable(Scriptable.getProperty(scope, "Error"));
Scriptable nativeErrorProto =
ScriptableObject.ensureScriptable(
ScriptableObject.getProperty(nativeError, "prototype"));
ScriptableObject.ensureScriptable(Scriptable.getProperty(nativeError, "prototype"));
for (TopLevel.NativeErrors error : TopLevel.NativeErrors.values()) {
if (error == TopLevel.NativeErrors.Error) {

Просмотреть файл

@ -255,14 +255,14 @@ public final class NativeJSON extends ScriptableObject {
int keyInt = 0;
if (key instanceof String) {
keyString = (String) key;
value = getProperty(holder, keyString);
value = Scriptable.getProperty(holder, keyString);
} else {
keyInt = ((Number) key).intValue();
value = getProperty(holder, keyInt);
value = Scriptable.getProperty(holder, keyInt);
}
if (value instanceof Scriptable && hasProperty((Scriptable) value, "toJSON")) {
Object toJSON = getProperty((Scriptable) value, "toJSON");
Object toJSON = Scriptable.getProperty((Scriptable) value, "toJSON");
if (toJSON instanceof Callable) {
value =
callMethod(
@ -276,7 +276,7 @@ public final class NativeJSON extends ScriptableObject {
} else if (value instanceof BigInteger) {
Scriptable bigInt = ScriptRuntime.toObject(state.cx, state.scope, value);
if (hasProperty(bigInt, "toJSON")) {
Object toJSON = getProperty(bigInt, "toJSON");
Object toJSON = Scriptable.getProperty(bigInt, "toJSON");
if (toJSON instanceof Callable) {
value =
callMethod(

Просмотреть файл

@ -31,7 +31,7 @@ import java.util.Objects;
* @see NativeJavaPackage
* @see NativeJavaClass
*/
public class NativeJavaObject implements Scriptable, SymbolScriptable, Wrapper, Serializable {
public class NativeJavaObject implements SymbolScriptable, Wrapper, Serializable {
private static final long serialVersionUID = -6948590651130498591L;

Просмотреть файл

@ -174,7 +174,7 @@ public class NativeObject extends IdScriptableObject implements Map {
if (thisObj == null) {
throw ScriptRuntime.notFunctionError(null);
}
Object toString = ScriptableObject.getProperty(thisObj, "toString");
Object toString = Scriptable.getProperty(thisObj, "toString");
if (!(toString instanceof Callable)) {
throw ScriptRuntime.notFunctionError(toString);
}

Просмотреть файл

@ -616,7 +616,7 @@ public class NativePromise extends ScriptableObject {
}
Scriptable sresolution = ScriptableObject.ensureScriptable(resolution);
Object thenObj = ScriptableObject.getProperty(sresolution, "then");
Object thenObj = Scriptable.getProperty(sresolution, "then");
if (!(thenObj instanceof Callable)) {
return promise.fulfillPromise(cx, scope, resolution);
}

Просмотреть файл

@ -474,7 +474,7 @@ final class NativeString extends IdScriptableObject {
Scriptable arg0 = (Scriptable) args[0];
if (reProxy.isRegExp(arg0)) {
if (ScriptableObject.isTrue(
ScriptableObject.getProperty(arg0, SymbolKey.MATCH))) {
Scriptable.getProperty(arg0, SymbolKey.MATCH))) {
throw ScriptRuntime.typeErrorById(
"msg.first.arg.not.regexp",
String.class.getSimpleName(),

Просмотреть файл

@ -12,7 +12,7 @@ import java.io.Serializable;
* This class implements the object lookup required for the <code>with</code> statement. It simply
* delegates every action to its prototype except for operations on its parent.
*/
public class NativeWith implements Scriptable, SymbolScriptable, IdFunctionCall, Serializable {
public class NativeWith implements SymbolScriptable, IdFunctionCall, Serializable {
private static final long serialVersionUID = 1L;
static void init(Scriptable scope, boolean sealed) {

Просмотреть файл

@ -1125,7 +1125,7 @@ public class ScriptRuntime {
// Wrapped Java objects won't have "toSource" and will report
// errors for get()s of nonexistent name, so use has() first
if (ScriptableObject.hasProperty(obj, "toSource")) {
Object v = ScriptableObject.getProperty(obj, "toSource");
Object v = Scriptable.getProperty(obj, "toSource");
if (v instanceof Function) {
Function f = (Function) v;
return toString(f.call(cx, scope, obj, emptyArgs));
@ -1471,7 +1471,7 @@ public class ScriptRuntime {
for (; ; ) {
Scriptable parent = scope.getParentScope();
if (parent == null) {
nsObject = ScriptableObject.getProperty(scope, DEFAULT_NS_TAG);
nsObject = Scriptable.getProperty(scope, DEFAULT_NS_TAG);
if (nsObject == Scriptable.NOT_FOUND) {
return null;
}
@ -1488,11 +1488,11 @@ public class ScriptRuntime {
public static Object getTopLevelProp(Scriptable scope, String id) {
scope = ScriptableObject.getTopLevelScope(scope);
return ScriptableObject.getProperty(scope, id);
return Scriptable.getProperty(scope, id);
}
public static Function getExistingCtor(Context cx, Scriptable scope, String constructorName) {
Object ctorVal = ScriptableObject.getProperty(scope, constructorName);
Object ctorVal = Scriptable.getProperty(scope, constructorName);
if (ctorVal instanceof Function) {
return (Function) ctorVal;
}
@ -1698,14 +1698,14 @@ public class ScriptRuntime {
if (obj instanceof XMLObject) {
result = ((XMLObject) obj).get(cx, elem);
} else if (isSymbol(elem)) {
result = ScriptableObject.getProperty(obj, (Symbol) elem);
result = Scriptable.getProperty(obj, (Symbol) elem);
} else {
StringIdOrIndex s = toStringIdOrIndex(elem);
if (s.stringId == null) {
int index = s.index;
result = ScriptableObject.getProperty(obj, index);
result = Scriptable.getProperty(obj, index);
} else {
result = ScriptableObject.getProperty(obj, s.stringId);
result = Scriptable.getProperty(obj, s.stringId);
}
}
@ -1741,7 +1741,7 @@ public class ScriptRuntime {
public static Object getObjectProp(Scriptable obj, String property, Context cx) {
Object result = ScriptableObject.getProperty(obj, property);
Object result = Scriptable.getProperty(obj, property);
if (result == Scriptable.NOT_FOUND) {
if (cx.hasFeature(Context.FEATURE_STRICT_MODE)) {
Context.reportWarning(
@ -1765,7 +1765,7 @@ public class ScriptRuntime {
if (sobj == null) {
throw undefReadError(obj, property);
}
Object result = ScriptableObject.getProperty(sobj, property);
Object result = Scriptable.getProperty(sobj, property);
if (result == Scriptable.NOT_FOUND) {
return Undefined.instance;
}
@ -1798,7 +1798,7 @@ public class ScriptRuntime {
}
public static Object getObjectIndex(Scriptable obj, int index, Context cx) {
Object result = ScriptableObject.getProperty(obj, index);
Object result = Scriptable.getProperty(obj, index);
if (result == Scriptable.NOT_FOUND) {
result = Undefined.instance;
}
@ -2054,7 +2054,7 @@ public class ScriptRuntime {
firstXMLObject = xmlObj;
}
} else {
result = ScriptableObject.getProperty(withObj, name);
result = Scriptable.getProperty(withObj, name);
if (result != Scriptable.NOT_FOUND) {
// function this should be the target object of with
thisObj = withObj;
@ -2076,7 +2076,7 @@ public class ScriptRuntime {
} else {
// Can happen if Rhino embedding decided that nested
// scopes are useful for what ever reasons.
result = ScriptableObject.getProperty(scope, name);
result = Scriptable.getProperty(scope, name);
if (result != Scriptable.NOT_FOUND) {
thisObj = scope;
break;
@ -2116,7 +2116,7 @@ public class ScriptRuntime {
if (cx.useDynamicScope) {
scope = checkDynamicScope(cx.topCallScope, scope);
}
return ScriptableObject.getProperty(scope, name);
return Scriptable.getProperty(scope, name);
}
/**
@ -2263,7 +2263,7 @@ public class ScriptRuntime {
public static Scriptable toIterator(
Context cx, Scriptable scope, Scriptable obj, boolean keyOnly) {
if (ScriptableObject.hasProperty(obj, NativeIterator.ITERATOR_PROPERTY_NAME)) {
Object v = ScriptableObject.getProperty(obj, NativeIterator.ITERATOR_PROPERTY_NAME);
Object v = Scriptable.getProperty(obj, NativeIterator.ITERATOR_PROPERTY_NAME);
if (!(v instanceof Callable)) {
throw typeErrorById("msg.invalid.iterator");
}
@ -2343,7 +2343,7 @@ public class ScriptRuntime {
throw typeErrorById("msg.not.iterable", toString(x.obj));
}
Object iterator = ScriptableObject.getProperty(x.obj, SymbolKey.ITERATOR);
Object iterator = Scriptable.getProperty(x.obj, SymbolKey.ITERATOR);
if (!(iterator instanceof Callable)) {
throw typeErrorById("msg.not.iterable", toString(x.obj));
}
@ -2374,7 +2374,7 @@ public class ScriptRuntime {
if (x.enumType == ENUMERATE_VALUES_IN_ORDER) {
return enumNextInOrder(x, cx);
}
Object v = ScriptableObject.getProperty(x.iterator, "next");
Object v = Scriptable.getProperty(x.iterator, "next");
if (!(v instanceof Callable)) return Boolean.FALSE;
Callable f = (Callable) v;
try {
@ -2416,7 +2416,7 @@ public class ScriptRuntime {
}
private static Boolean enumNextInOrder(IdEnumeration enumObj, Context cx) {
Object v = ScriptableObject.getProperty(enumObj.iterator, ES6Iterator.NEXT_METHOD);
Object v = Scriptable.getProperty(enumObj.iterator, ES6Iterator.NEXT_METHOD);
if (!(v instanceof Callable)) {
throw notFunctionError(enumObj.iterator, ES6Iterator.NEXT_METHOD);
}
@ -2424,12 +2424,11 @@ public class ScriptRuntime {
Scriptable scope = enumObj.iterator.getParentScope();
Object r = f.call(cx, scope, enumObj.iterator, emptyArgs);
Scriptable iteratorResult = toObject(cx, scope, r);
Object done = ScriptableObject.getProperty(iteratorResult, ES6Iterator.DONE_PROPERTY);
Object done = Scriptable.getProperty(iteratorResult, ES6Iterator.DONE_PROPERTY);
if (done != Scriptable.NOT_FOUND && toBoolean(done)) {
return Boolean.FALSE;
}
enumObj.currentId =
ScriptableObject.getProperty(iteratorResult, ES6Iterator.VALUE_PROPERTY);
enumObj.currentId = Scriptable.getProperty(iteratorResult, ES6Iterator.VALUE_PROPERTY);
return Boolean.TRUE;
}
@ -2593,7 +2592,7 @@ public class ScriptRuntime {
if (thisObj == null) {
throw undefCallError(obj, String.valueOf(elem));
}
value = ScriptableObject.getProperty(thisObj, (Symbol) elem);
value = Scriptable.getProperty(thisObj, (Symbol) elem);
} else {
StringIdOrIndex s = toStringIdOrIndex(elem);
@ -2606,7 +2605,7 @@ public class ScriptRuntime {
throw undefCallError(obj, String.valueOf(elem));
}
value = ScriptableObject.getProperty(thisObj, s.index);
value = Scriptable.getProperty(thisObj, s.index);
}
if (!(value instanceof Callable)) {
@ -2649,9 +2648,9 @@ public class ScriptRuntime {
throw undefCallError(obj, property);
}
Object value = ScriptableObject.getProperty(thisObj, property);
Object value = Scriptable.getProperty(thisObj, property);
if (!(value instanceof Callable)) {
Object noSuchMethod = ScriptableObject.getProperty(thisObj, "__noSuchMethod__");
Object noSuchMethod = Scriptable.getProperty(thisObj, "__noSuchMethod__");
if (noSuchMethod instanceof Callable)
value = new NoSuchMethodShim((Callable) noSuchMethod, property);
}
@ -4640,7 +4639,7 @@ public class ScriptRuntime {
}
Object[] result = new Object[len];
for (int i = 0; i < len; i++) {
Object elem = ScriptableObject.getProperty(object, i);
Object elem = Scriptable.getProperty(object, i);
result[i] = (elem == Scriptable.NOT_FOUND) ? Undefined.instance : elem;
}
return result;

Просмотреть файл

@ -106,7 +106,7 @@ public interface Scriptable {
* @param start the object in which the lookup began
* @return true if and only if the named property is found in the object
* @see org.mozilla.javascript.Scriptable#get(String, Scriptable)
* @see org.mozilla.javascript.ScriptableObject#getProperty(Scriptable, String)
* @see org.mozilla.javascript.Scriptable#getProperty(Scriptable, String)
*/
boolean has(String name, Scriptable start);
@ -123,7 +123,7 @@ public interface Scriptable {
* @param start the object in which the lookup began
* @return true if and only if the indexed property is found in the object
* @see org.mozilla.javascript.Scriptable#get(int, Scriptable)
* @see org.mozilla.javascript.ScriptableObject#getProperty(Scriptable, int)
* @see org.mozilla.javascript.Scriptable#getProperty(Scriptable, int)
*/
boolean has(int index, Scriptable start);

Просмотреть файл

@ -52,7 +52,7 @@ import org.mozilla.javascript.debug.DebuggableObject;
* @author Norris Boyd
*/
public abstract class ScriptableObject
implements Scriptable, SymbolScriptable, Serializable, DebuggableObject, ConstProperties {
implements SymbolScriptable, Serializable, DebuggableObject, ConstProperties {
private static final long serialVersionUID = 2829861078851942586L;
@ -789,7 +789,7 @@ public abstract class ScriptableObject
} else {
methodName = "valueOf";
}
Object v = getProperty(object, methodName);
Object v = Scriptable.getProperty(object, methodName);
if (!(v instanceof Function)) continue;
Function fun = (Function) v;
if (cx == null) {
@ -1056,7 +1056,7 @@ public abstract class ScriptableObject
String className = proto.getClassName();
// check for possible redefinition
Object existing = getProperty(getTopLevelScope(scope), className);
Object existing = Scriptable.getProperty(getTopLevelScope(scope), className);
if (existing instanceof BaseFunction) {
Object existingProto = ((BaseFunction) existing).getPrototypeProperty();
if (existingProto != null && clazz.equals(existingProto.getClass())) {
@ -1640,11 +1640,11 @@ public abstract class ScriptableObject
fslot = new AccessorSlot(slot);
slot = fslot;
}
Object getter = getProperty(desc, "get");
Object getter = Scriptable.getProperty(desc, "get");
if (getter != NOT_FOUND) {
fslot.getter = new AccessorSlot.FunctionGetter(getter);
}
Object setter = getProperty(desc, "set");
Object setter = Scriptable.getProperty(desc, "set");
if (setter != NOT_FOUND) {
fslot.setter = new AccessorSlot.FunctionSetter(setter);
}
@ -1654,7 +1654,7 @@ public abstract class ScriptableObject
// Replace a non-base slot with a regular slot
slot = new Slot(slot);
}
Object value = getProperty(desc, "value");
Object value = Scriptable.getProperty(desc, "value");
if (value != NOT_FOUND) {
slot.value = value;
} else if (existing == null) {
@ -1749,11 +1749,11 @@ public abstract class ScriptableObject
}
protected void checkPropertyDefinition(ScriptableObject desc) {
Object getter = getProperty(desc, "get");
Object getter = Scriptable.getProperty(desc, "get");
if (getter != NOT_FOUND && getter != Undefined.instance && !(getter instanceof Callable)) {
throw ScriptRuntime.notFunctionError(getter);
}
Object setter = getProperty(desc, "set");
Object setter = Scriptable.getProperty(desc, "set");
if (setter != NOT_FOUND && setter != Undefined.instance && !(setter instanceof Callable)) {
throw ScriptRuntime.notFunctionError(setter);
}
@ -1767,10 +1767,10 @@ public abstract class ScriptableObject
if (!isExtensible()) throw ScriptRuntime.typeErrorById("msg.not.extensible");
} else {
if (isFalse(current.get("configurable", current))) {
if (isTrue(getProperty(desc, "configurable")))
if (isTrue(Scriptable.getProperty(desc, "configurable")))
throw ScriptRuntime.typeErrorById("msg.change.configurable.false.to.true", id);
if (isTrue(current.get("enumerable", current))
!= isTrue(getProperty(desc, "enumerable")))
!= isTrue(Scriptable.getProperty(desc, "enumerable")))
throw ScriptRuntime.typeErrorById(
"msg.change.enumerable.with.configurable.false", id);
boolean isData = isDataDescriptor(desc);
@ -1779,21 +1779,25 @@ public abstract class ScriptableObject
// no further validation required for generic descriptor
} else if (isData && isDataDescriptor(current)) {
if (isFalse(current.get("writable", current))) {
if (isTrue(getProperty(desc, "writable")))
if (isTrue(Scriptable.getProperty(desc, "writable")))
throw ScriptRuntime.typeErrorById(
"msg.change.writable.false.to.true.with.configurable.false",
id);
if (!sameValue(getProperty(desc, "value"), current.get("value", current)))
if (!sameValue(
Scriptable.getProperty(desc, "value"),
current.get("value", current)))
throw ScriptRuntime.typeErrorById(
"msg.change.value.with.writable.false", id);
}
} else if (isAccessor && isAccessorDescriptor(current)) {
if (!sameValue(getProperty(desc, "set"), current.get("set", current)))
if (!sameValue(
Scriptable.getProperty(desc, "set"), current.get("set", current)))
throw ScriptRuntime.typeErrorById(
"msg.change.setter.with.configurable.false", id);
if (!sameValue(getProperty(desc, "get"), current.get("get", current)))
if (!sameValue(
Scriptable.getProperty(desc, "get"), current.get("get", current)))
throw ScriptRuntime.typeErrorById(
"msg.change.getter.with.configurable.false", id);
} else {
@ -1845,7 +1849,7 @@ public abstract class ScriptableObject
}
protected int applyDescriptorToAttributeBitset(int attributes, ScriptableObject desc) {
Object enumerable = getProperty(desc, "enumerable");
Object enumerable = Scriptable.getProperty(desc, "enumerable");
if (enumerable != NOT_FOUND) {
attributes =
ScriptRuntime.toBoolean(enumerable)
@ -1853,7 +1857,7 @@ public abstract class ScriptableObject
: attributes | DONTENUM;
}
Object writable = getProperty(desc, "writable");
Object writable = Scriptable.getProperty(desc, "writable");
if (writable != NOT_FOUND) {
attributes =
ScriptRuntime.toBoolean(writable)
@ -1861,7 +1865,7 @@ public abstract class ScriptableObject
: attributes | READONLY;
}
Object configurable = getProperty(desc, "configurable");
Object configurable = Scriptable.getProperty(desc, "configurable");
if (configurable != NOT_FOUND) {
attributes =
ScriptRuntime.toBoolean(configurable)
@ -1990,7 +1994,7 @@ public abstract class ScriptableObject
*/
public static Scriptable getClassPrototype(Scriptable scope, String className) {
scope = getTopLevelScope(scope);
Object ctor = getProperty(scope, className);
Object ctor = Scriptable.getProperty(scope, className);
Object proto;
if (ctor instanceof BaseFunction) {
proto = ((BaseFunction) ctor).getPrototypeProperty();
@ -2154,7 +2158,7 @@ public abstract class ScriptableObject
* @since 1.7R3
*/
public static <T> T getTypedProperty(Scriptable s, int index, Class<T> type) {
Object val = getProperty(s, index);
Object val = Scriptable.getProperty(s, index);
if (val == Scriptable.NOT_FOUND) {
val = null;
}
@ -2194,7 +2198,7 @@ public abstract class ScriptableObject
* @since 1.7R3
*/
public static <T> T getTypedProperty(Scriptable s, String name, Class<T> type) {
Object val = getProperty(s, name);
Object val = Scriptable.getProperty(s, name);
if (val == Scriptable.NOT_FOUND) {
val = null;
}
@ -2432,7 +2436,7 @@ public abstract class ScriptableObject
* @param args the arguments for the call
*/
public static Object callMethod(Context cx, Scriptable obj, String methodName, Object[] args) {
Object funObj = getProperty(obj, methodName);
Object funObj = Scriptable.getProperty(obj, methodName);
if (!(funObj instanceof Function)) {
throw ScriptRuntime.notFunctionError(obj, methodName);
}

Просмотреть файл

@ -101,7 +101,7 @@ public class TopLevel extends IdScriptableObject {
public void cacheBuiltins(Scriptable scope, boolean sealed) {
ctors = new EnumMap<>(Builtins.class);
for (Builtins builtin : Builtins.values()) {
Object value = ScriptableObject.getProperty(this, builtin.name());
Object value = Scriptable.getProperty(this, builtin.name());
if (value instanceof BaseFunction) {
ctors.put(builtin, (BaseFunction) value);
} else if (builtin == Builtins.GeneratorFunction) {
@ -114,7 +114,7 @@ public class TopLevel extends IdScriptableObject {
}
errors = new EnumMap<>(NativeErrors.class);
for (NativeErrors error : NativeErrors.values()) {
Object value = ScriptableObject.getProperty(this, error.name());
Object value = Scriptable.getProperty(this, error.name());
if (value instanceof BaseFunction) {
errors.put(error, (BaseFunction) value);
}

Просмотреть файл

@ -329,7 +329,7 @@ public class Require extends BaseFunction {
moduleScript.getScript().exec(cx, executionScope);
executeOptionalScript(postExec, cx, executionScope);
return ScriptRuntime.toObject(
cx, nativeScope, ScriptableObject.getProperty(moduleObject, "exports"));
cx, nativeScope, Scriptable.getProperty(moduleObject, "exports"));
}
private static void executeOptionalScript(

Просмотреть файл

@ -56,7 +56,7 @@ public abstract class ModuleSourceProviderBase implements ModuleSourceProvider,
private ModuleSource loadFromPathArray(String moduleId, Scriptable paths, Object validator)
throws IOException {
final long llength = ScriptRuntime.toUint32(ScriptableObject.getProperty(paths, "length"));
final long llength = ScriptRuntime.toUint32(Scriptable.getProperty(paths, "length"));
// Yeah, I'll ignore entries beyond Integer.MAX_VALUE; so sue me.
int ilength = llength > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) llength;

Просмотреть файл

@ -14,7 +14,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.UniqueTag;
/**
@ -150,7 +149,7 @@ public class ScriptableOutputStream extends ObjectOutputStream {
Object result = scope;
while (st.hasMoreTokens()) {
String s = st.nextToken();
result = ScriptableObject.getProperty((Scriptable) result, s);
result = Scriptable.getProperty((Scriptable) result, s);
if (result == null || !(result instanceof Scriptable)) break;
}
return result;

Просмотреть файл

@ -614,7 +614,7 @@ public abstract class NativeTypedArrayView<T> extends NativeArrayBufferView
return Undefined.instance;
}
return getProperty(thisObj, (int) k);
return Scriptable.getProperty(thisObj, (int) k);
}
private Scriptable typedArraySpeciesCreate(

Просмотреть файл

@ -46,7 +46,7 @@ public abstract class XMLLib {
// Ensure lazily initialization of real XML library instance
// which is done on first access to XML property
ScriptableObject.getProperty(so, "XML");
Scriptable.getProperty(so, "XML");
return (XMLLib) so.getAssociatedValue(XML_LIB_KEY);
}

Просмотреть файл

@ -12,7 +12,6 @@ import org.mozilla.javascript.Callable;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Script;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
public class Bug482203Test {
@ -27,7 +26,7 @@ public class Bug482203Test {
script.exec(cx, scope);
int counter = 0;
for (; ; ) {
Object cont = ScriptableObject.getProperty(scope, "c");
Object cont = Scriptable.getProperty(scope, "c");
if (cont == null) {
break;
}
@ -35,7 +34,7 @@ public class Bug482203Test {
((Callable) cont).call(cx, scope, scope, new Object[] {null});
}
assertEquals(counter, 5);
assertEquals(Double.valueOf(3), ScriptableObject.getProperty(scope, "result"));
assertEquals(Double.valueOf(3), Scriptable.getProperty(scope, "result"));
}
}
@ -50,7 +49,7 @@ public class Bug482203Test {
cx.executeScriptWithContinuations(script, scope);
int counter = 0;
for (; ; ) {
Object cont = ScriptableObject.getProperty(scope, "c");
Object cont = Scriptable.getProperty(scope, "c");
if (cont == null) {
break;
}
@ -58,7 +57,7 @@ public class Bug482203Test {
cx.resumeContinuation(cont, scope, null);
}
assertEquals(counter, 5);
assertEquals(Double.valueOf(3), ScriptableObject.getProperty(scope, "result"));
assertEquals(Double.valueOf(3), Scriptable.getProperty(scope, "result"));
}
}
}

Просмотреть файл

@ -72,7 +72,7 @@ public class IterableTest {
@Override
public Object get(Symbol key, Scriptable start) {
if (SymbolKey.ITERATOR.equals(key)) {
return ScriptableObject.getProperty(
return Scriptable.getProperty(
ScriptableObject.getArrayPrototype(scope), SymbolKey.ITERATOR);
}
throw new IllegalStateException();

Просмотреть файл

@ -102,7 +102,7 @@ public class PrimitiveTypeScopeResolutionTest {
}
public Object readPropFoo(final Scriptable s) {
return ScriptableObject.getProperty(s, "foo");
return Scriptable.getProperty(s, "foo");
}
}

Просмотреть файл

@ -79,9 +79,9 @@ public class WrapFactoryTest {
cx.evaluateString(scope, script, "", 1, null);
// evaluate result
assertEquals(result, ScriptableObject.getProperty(scope, "result"));
assertEquals(mapResult, ScriptableObject.getProperty(scope, "mapResult"));
assertEquals(getResult, ScriptableObject.getProperty(scope, "getResult"));
assertEquals(result, Scriptable.getProperty(scope, "result"));
assertEquals(mapResult, Scriptable.getProperty(scope, "mapResult"));
assertEquals(getResult, Scriptable.getProperty(scope, "getResult"));
}
}
}