public class Reflection extends Object implements Serializable
| Constructor and Description |
|---|
Reflection() |
| Modifier and Type | Method and Description |
|---|---|
Object |
getByArray(Object array,
int index)
得到数组中的某个元素
|
Object |
getProperty(Object owner,
String fieldName)
得到某个对象的公共属性
|
Object |
getStaticProperty(String className,
String fieldName)
得到某类的静态公共属性
|
Object |
invokeMethod(Object owner,
String methodName,
Object[] args)
执行某对象方法
|
Object |
invokeMethod(Object owner,
String methodName,
Object[] args,
Class[] argsClass)
执行某对象方法
|
Object |
invokeStaticMethod(String className,
String methodName,
Object[] args)
执行某类的静态方法
|
boolean |
isInstance(Object obj,
Class cls)
判断是不是某个类的实例
|
Object |
newInstance(String className,
Object... args)
新建实例
|
public Object invokeStaticMethod(String className, String methodName, Object[] args) throws Exception
className - 类名methodName - 方法名args - 参数数组Exception - 异常public Object newInstance(String className, Object... args) throws Exception
className - 类名args - 构造函数的参数Exception - 异常public Object invokeMethod(Object owner, String methodName, Object[] args) throws Exception
owner - 对象methodName - 方法名args - 参数Exception - 异常public Object invokeMethod(Object owner, String methodName, Object[] args, Class[] argsClass) throws Exception
owner - 对象methodName - 方法名args - 参数argsClass - 参数Exception - 异常public Object getProperty(Object owner, String fieldName) throws Exception
owner - ownerfieldName - fieldNameException - 异常public Object getStaticProperty(String className, String fieldName) throws Exception
className - 类名fieldName - 属性名Exception - 异常public boolean isInstance(Object obj, Class cls)
obj - 实例cls - 类Copyright © 2017. All rights reserved.