From c4b014a4d00095c692936bf73f1b98ecf6ae995c Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 11 Mar 2023 11:18:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rhino/build.gradle | 4 +++- .../java/com/script/rhino/ExternalScriptable.java | 12 +++++------- rhino/src/main/java/com/script/rhino/JSAdapter.java | 10 +++++----- .../java/com/script/rhino/RhinoScriptEngine.java | 1 + 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/rhino/build.gradle b/rhino/build.gradle index db83629b2..983f9719b 100644 --- a/rhino/build.gradle +++ b/rhino/build.gradle @@ -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'])) } \ No newline at end of file diff --git a/rhino/src/main/java/com/script/rhino/ExternalScriptable.java b/rhino/src/main/java/com/script/rhino/ExternalScriptable.java index 66d286dbf..808aa62f0 100644 --- a/rhino/src/main/java/com/script/rhino/ExternalScriptable.java +++ b/rhino/src/main/java/com/script/rhino/ExternalScriptable.java @@ -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; } diff --git a/rhino/src/main/java/com/script/rhino/JSAdapter.java b/rhino/src/main/java/com/script/rhino/JSAdapter.java index 0cb47aafd..5c1955ba4 100644 --- a/rhino/src/main/java/com/script/rhino/JSAdapter.java +++ b/rhino/src/main/java/com/script/rhino/JSAdapter.java @@ -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); } diff --git a/rhino/src/main/java/com/script/rhino/RhinoScriptEngine.java b/rhino/src/main/java/com/script/rhino/RhinoScriptEngine.java index 28eb31354..0f110e7a1 100644 --- a/rhino/src/main/java/com/script/rhino/RhinoScriptEngine.java +++ b/rhino/src/main/java/com/script/rhino/RhinoScriptEngine.java @@ -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) {