JavaTM 2 Platform
Standard Ed. 5.0

类 java.lang.reflect.Method
的使用

使用 Method 的软件包
java.lang 提供利用 Java 编程语言进行程序设计的基础类。 
java.lang.annotation 为 Java 编程语言注释设施提供库支持。 
java.lang.reflect 提供类和接口,以获取关于类和对象的反射信息。 
 

java.langMethod 的使用
 

返回 Methodjava.lang 中的方法
 Method Class.getDeclaredMethod(String name, Class... parameterTypes)
          返回一个 Method 对象,该对象反映此 Class 对象所表示的类或接口的指定已声明方法。
 Method[] Class.getDeclaredMethods()
          返回 Method 对象的一个数组,这些对象反映此 Class 对象表示的类或接口声明的所有方法,包括公共、保护、默认(包)访问和私有方法,但不包括继承的方法。
 Method Class.getEnclosingMethod()
          如果此 Class 对象表示某一方法中的一个本地或匿名类,则返回 Method 对象,它表示基础类的立即封闭方法。
 Method Class.getMethod(String name, Class... parameterTypes)
          返回一个 Method 对象,它反映此 Class 对象所表示的类或接口的指定公共成员方法。
 Method[] Class.getMethods()
          返回一个包含某些 Method 对象的数组,这些对象反映此 Class 对象所表示的类或接口(包括那些由该类或接口声明的以及从超类和超接口继承的那些的类或接口)的公共 member 方法。
 

java.lang.annotationMethod 的使用
 

返回 Methodjava.lang.annotation 中的方法
 Method AnnotationTypeMismatchException.element()
          返回类型不正确的元素的 Method 对象。
 

参数类型为 Methodjava.lang.annotation 中的构造方法
AnnotationTypeMismatchException(Method element, String foundType)
          构造针对指定的注释类型元素和找到的数据类型的 AnnotationTypeMismatchException。
 

java.lang.reflectMethod 的使用
 

参数类型为 Methodjava.lang.reflect 中的方法
 Object InvocationHandler.invoke(Object proxy, Method method, Object[] args)
          在代理实例上处理方法调用并返回结果。
 


JavaTM 2 Platform
Standard Ed. 5.0

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java 2 SDK SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策