Fix cache deadlock in `XposedHelpers.java` (#1723)
This commit is contained in:
parent
583be18a7b
commit
3fdc4e51c9
|
|
@ -520,16 +520,16 @@ public final class XposedHelpers {
|
||||||
* @throws NoSuchMethodError In case no suitable method was found.
|
* @throws NoSuchMethodError In case no suitable method was found.
|
||||||
*/
|
*/
|
||||||
public static Method findMethodBestMatch(Class<?> clazz, String methodName, Class<?>... parameterTypes) {
|
public static Method findMethodBestMatch(Class<?> clazz, String methodName, Class<?>... parameterTypes) {
|
||||||
var key = new MemberCacheKey.Method(clazz, methodName, parameterTypes, false);
|
|
||||||
|
|
||||||
return methodCache.computeIfAbsent(key, k -> {
|
|
||||||
// find the exact matching method first
|
// find the exact matching method first
|
||||||
try {
|
try {
|
||||||
return Optional.of(findMethodExact(k.clazz, k.name, k.parameters));
|
return findMethodExact(clazz, methodName, parameterTypes);
|
||||||
} catch (NoSuchMethodError ignored) {
|
} catch (NoSuchMethodError ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// then find the best match
|
// then find the best match
|
||||||
|
var key = new MemberCacheKey.Method(clazz, methodName, parameterTypes, false);
|
||||||
|
|
||||||
|
return methodCache.computeIfAbsent(key, k -> {
|
||||||
Method bestMatch = null;
|
Method bestMatch = null;
|
||||||
Class<?> clz = k.clazz;
|
Class<?> clz = k.clazz;
|
||||||
boolean considerPrivateMethods = true;
|
boolean considerPrivateMethods = true;
|
||||||
|
|
@ -712,7 +712,7 @@ public final class XposedHelpers {
|
||||||
|
|
||||||
return constructorCache.computeIfAbsent(key, k -> {
|
return constructorCache.computeIfAbsent(key, k -> {
|
||||||
try {
|
try {
|
||||||
Constructor<?> constructor = clazz.getDeclaredConstructor(parameterTypes);
|
Constructor<?> constructor = k.clazz.getDeclaredConstructor(k.parameters);
|
||||||
constructor.setAccessible(true);
|
constructor.setAccessible(true);
|
||||||
return Optional.of(constructor);
|
return Optional.of(constructor);
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
|
|
@ -749,16 +749,16 @@ public final class XposedHelpers {
|
||||||
* <p>See {@link #findMethodBestMatch(Class, String, Class...)} for details.
|
* <p>See {@link #findMethodBestMatch(Class, String, Class...)} for details.
|
||||||
*/
|
*/
|
||||||
public static Constructor<?> findConstructorBestMatch(Class<?> clazz, Class<?>... parameterTypes) {
|
public static Constructor<?> findConstructorBestMatch(Class<?> clazz, Class<?>... parameterTypes) {
|
||||||
var key = new MemberCacheKey.Constructor(clazz, parameterTypes, false);
|
|
||||||
|
|
||||||
return constructorCache.computeIfAbsent(key, k -> {
|
|
||||||
// find the exact matching constructor first
|
// find the exact matching constructor first
|
||||||
try {
|
try {
|
||||||
return Optional.of(findConstructorExact(k.clazz, k.parameters));
|
return findConstructorExact(clazz, parameterTypes);
|
||||||
} catch (NoSuchMethodError ignored) {
|
} catch (NoSuchMethodError ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// then find the best match
|
// then find the best match
|
||||||
|
var key = new MemberCacheKey.Constructor(clazz, parameterTypes, false);
|
||||||
|
|
||||||
|
return constructorCache.computeIfAbsent(key, k -> {
|
||||||
Constructor<?> bestMatch = null;
|
Constructor<?> bestMatch = null;
|
||||||
Constructor<?>[] constructors = k.clazz.getDeclaredConstructors();
|
Constructor<?>[] constructors = k.clazz.getDeclaredConstructors();
|
||||||
for (Constructor<?> constructor : constructors) {
|
for (Constructor<?> constructor : constructors) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue