public abstract class FastMethodAccessor extends Object
| 构造器和说明 |
|---|
FastMethodAccessor() |
| 限定符和类型 | 方法和说明 |
|---|---|
static FastMethodAccessor |
get(Class<?> type) |
int |
getIndex(String methodName,
Class<?>... parameterTypes) |
abstract Object |
invoke(Object obj,
int methodIndex,
Object... args)
用ASM生成的类继承
FastMethodAccessor 并实现这个抽象方法
子类 invoke() 以下面的方式规避反射调用:
public Object invoke(Object obj, int methodIndex, Object... args) {
switch(methodIndex) {
case 0:
return 直接调用 this.methodNames[0] 对应的方法;
case 1:
return 直接调用 this.methodNames[1] 对应的方法;
case ...
}
throw new IllegalArgumentException("method not found: " + methodIndex);
} |
Object |
invoke(Object obj,
String methodName,
Class<?>[] parameterTypes,
Object... args) |
public abstract Object invoke(Object obj, int methodIndex, Object... args)
FastMethodAccessor 并实现这个抽象方法
子类 invoke() 以下面的方式规避反射调用:
public Object invoke(Object obj, int methodIndex, Object... args) {
switch(methodIndex) {
case 0:
return 直接调用 this.methodNames[0] 对应的方法;
case 1:
return 直接调用 this.methodNames[1] 对应的方法;
case ...
}
throw new IllegalArgumentException("method not found: " + methodIndex);
}public Object invoke(Object obj, String methodName, Class<?>[] parameterTypes, Object... args)
public static FastMethodAccessor get(Class<?> type)
Copyright © 2018. All rights reserved.