This commit is contained in:
kunfei 2023-03-11 11:18:57 +08:00
parent 252073188e
commit c4b014a4d0
4 changed files with 14 additions and 13 deletions

View File

@ -28,9 +28,11 @@ android {
lint {
checkDependencies true
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}
dependencies {
compileOnly "com.android.tools.build:gradle:$agp_version"
api(fileTree(dir: 'lib', include: ['rhino-*.jar']))
}

View File

@ -137,9 +137,8 @@ final class ExternalScriptable implements Scriptable {
* @return the value of the property (may be null), or NOT_FOUND
*/
public synchronized Object get(int index, Scriptable start) {
Integer key = new Integer(index);
if (indexedProps.containsKey(index)) {
return indexedProps.get(key);
return indexedProps.get(index);
} else {
return NOT_FOUND;
}
@ -170,8 +169,7 @@ final class ExternalScriptable implements Scriptable {
* @return true if and only if the property was found in the object
*/
public synchronized boolean has(int index, Scriptable start) {
Integer key = new Integer(index);
return indexedProps.containsKey(key);
return indexedProps.containsKey(index);
}
/**
@ -211,7 +209,7 @@ final class ExternalScriptable implements Scriptable {
public void put(int index, Scriptable start, Object value) {
if (start == this) {
synchronized (this) {
indexedProps.put(new Integer(index), value);
indexedProps.put(index, value);
}
} else {
start.put(index, start, value);
@ -246,7 +244,7 @@ final class ExternalScriptable implements Scriptable {
* @param index the numeric index for the property
*/
public void delete(int index) {
indexedProps.remove(new Integer(index));
indexedProps.remove(index);
}
/**
@ -362,7 +360,7 @@ final class ExternalScriptable implements Scriptable {
} else {
throw Context.reportRuntimeError(
"Invalid JavaScript value of type " +
typeHint.toString());
typeHint);
}
args[0] = hint;
}

View File

@ -107,7 +107,7 @@ public final class JSAdapter implements Scriptable, Function {
public Object get(int index, Scriptable start) {
Function func = getAdapteeFunction(GET_PROP);
if (func != null) {
return call(func, new Object[] { new Integer(index) });
return call(func, new Object[] {index});
} else {
start = getAdaptee();
return start.get(index, start);
@ -128,7 +128,7 @@ public final class JSAdapter implements Scriptable, Function {
public boolean has(int index, Scriptable start) {
Function func = getAdapteeFunction(HAS_PROP);
if (func != null) {
Object res = call(func, new Object[] { new Integer(index) });
Object res = call(func, new Object[] {index});
return Context.toBoolean(res);
} else {
start = getAdaptee();
@ -154,7 +154,7 @@ public final class JSAdapter implements Scriptable, Function {
if (start == this) {
Function func = getAdapteeFunction(PUT_PROP);
if( func != null) {
call(func, new Object[] { new Integer(index), value });
call(func, new Object[] {index, value });
} else {
start = getAdaptee();
start.put(index, start, value);
@ -176,7 +176,7 @@ public final class JSAdapter implements Scriptable, Function {
public void delete(int index) {
Function func = getAdapteeFunction(DEL_PROP);
if (func != null) {
call(func, new Object[] { new Integer(index) });
call(func, new Object[] {index});
} else {
getAdaptee().delete(index);
}
@ -303,7 +303,7 @@ public final class JSAdapter implements Scriptable, Function {
// map a property id. Property id can only be an Integer or String
private Object mapToId(Object tmp) {
if (tmp instanceof Double) {
return new Integer(((Double)tmp).intValue());
return ((Double) tmp).intValue();
} else {
return Context.toString(tmp);
}

View File

@ -398,6 +398,7 @@ public final class RhinoScriptEngine extends AbstractScriptEngine
}
Scriptable scope = getRuntimeScope(context);
@SuppressWarnings("deprecation")
Script scr = cx.compileReader(scope, script, fileName, 1, null);
ret = new RhinoCompiledScript(this, scr);
} catch (Exception e) {