Java内省与反思 [英] Java introspection and reflection

查看:89
本文介绍了Java内省与反思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以解释Java反射和内省的用法吗?当我们需要同时使用它们时?

解决方案

反思(取自 oracle java tutorial




反射通常是由程序使用,这些程序需要能够检查或修改在Java虚拟机中运行的应用程序的运行时行为。这是一个相对高级的功能,只能由掌握语言基础知识的开发人员使用。考虑到这一点,反射是一种强大的技术,可以使应用程序执行本来不可能的操作。




内省(摘自 sun java beans tutorial的存档



< blockquote>

Introspection是分析bean的设计模式以显示bean的属性,事件和方法的自动过程。此过程控制bean操作和属性的发布和发现。


Introspection使用反射,Introspection和Reflection之间的关系可以看作类似于JavaBeans和其他Java类。



查看反思与反思可能值得一试。 :对象暴露,详细介绍了性能和使用情况。请注意,该文章已于1998年过时。



希望这会有所帮助。


Can any one explain the use of Java reflection and introspection? When we need to use both?

解决方案

Reflection (taken from oracle java tutorial)

Reflection is commonly used by programs which require the ability to examine or modify the runtime behavior of applications running in the Java virtual machine. This is a relatively advanced feature and should be used only by developers who have a strong grasp of the fundamentals of the language. With that caveat in mind, reflection is a powerful technique and can enable applications to perform operations which would otherwise be impossible.

Introspection (taken from archive of sun java beans tutorial)

Introspection is the automatic process of analyzing a bean's design patterns to reveal the bean's properties, events, and methods. This process controls the publishing and discovery of bean operations and properties.

Introspection uses reflection, the relationship between Introspection and Reflection can be seen as similar to JavaBeans and other Java classes.

It might be worth while to look at "Reflection & Introspection: Objects Exposed" where it goes into detail regarding perfomance and usage. Please note that the article is outdated, 1998.

Hope this helps.

这篇关于Java内省与反思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆