[core] Check cast before returning from hooker (#696)
This commit is contained in:
parent
efa42a4eb0
commit
a694d2bc73
|
|
@ -20,17 +20,17 @@
|
||||||
|
|
||||||
package de.robv.android.xposed;
|
package de.robv.android.xposed;
|
||||||
|
|
||||||
|
import java.lang.reflect.Executable;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Member;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
|
|
||||||
public class LspHooker {
|
public class LspHooker {
|
||||||
private final XposedBridge.AdditionalHookInfo additionalInfo;
|
private final XposedBridge.AdditionalHookInfo additionalInfo;
|
||||||
private final Member method;
|
private final Executable method;
|
||||||
private final Method backup;
|
private final Method backup;
|
||||||
|
|
||||||
public LspHooker(XposedBridge.AdditionalHookInfo info, Member origin, Method backup) {
|
public LspHooker(XposedBridge.AdditionalHookInfo info, Executable origin, Method backup) {
|
||||||
this.additionalInfo = info;
|
this.additionalInfo = info;
|
||||||
this.method = origin;
|
this.method = origin;
|
||||||
this.backup = backup;
|
this.backup = backup;
|
||||||
|
|
@ -118,8 +118,15 @@ public class LspHooker {
|
||||||
// return
|
// return
|
||||||
if (param.hasThrowable())
|
if (param.hasThrowable())
|
||||||
throw param.getThrowable();
|
throw param.getThrowable();
|
||||||
else
|
else {
|
||||||
return param.getResult();
|
var result = param.getResult();
|
||||||
|
if (method instanceof Method) {
|
||||||
|
var returnType = ((Method) method).getReturnType();
|
||||||
|
if (!returnType.isPrimitive())
|
||||||
|
return returnType.cast(result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue