假设我有一个这样定义的枚举类(改编自java 文档)
package com.example.planetExample;
public enum Planet {
MERCURY (3.303e+23, 2.4397e6){
public double surfaceGravity() {
return 42;
}
},
VENUS (4.869e+24, 6.0518e6);
private final double mass; // in kilograms
private final double radius; // in meters
Planet(double mass, double radius) {
this.mass = mass;
this.radius = radius;
}
// universal gravitational constant (m3 kg-1 s-2)
public static final double G = 6.67300E-11;
double surfaceGravity() {
return G * mass / (radius * radius);
}
}
现在,我想使用 XPosed 挂钩surfaceGravity
已被 MERCURY 覆盖的函数(而不是下面定义的通用函数)。我怎样才能访问该功能?
我试过findAndHookMethod("com.example.planetExample.Planet", lpparam.classLoader, "surfaceGravity", [etc])
了,但是那个只挂钩了 Planet 类定义的一般表面重力,而不是 MERCURY 定义的那个。如果我尝试com.example.planetExample.Planet$MERCURY
或com.example.planetExample.Planet.MERCURY
,我会收到来自 XPosed 的错误,即找不到该函数surfaceGravity
。
有没有办法使用 XPosed 来挂钩这个函数?