Analytical reflection source (a)

    Reflection source system as follows:

    View source from the class of the contact, this content is not that much.   

    First look at the package under official given class:

    

Further, it is not too difficult relative logic. Interpret it from the timeline view. Since it is a reflection, then bore the brunt of the Reflection

    This is to determine the properties of a modified reflecting object. 

    Determining whether the packet is consistent, for the operation of the associated class loader.

    Determining whether the subclass.

    Registration required filtration properties and methods.

    Locally registered property or method needs to be filtered.

    Filtration or filtration properties required.

    Call sensitive, should be used as safety-related.

Executed when the class is loaded static block, which is made visible in some processing Class.class, System.class. Reflection on this point is all screenshots results. By viewing its class diagram, it does not know as a subclass of an abstract or implement, so all of its operations on a reflection achieved by simultaneously dependent. Some of the major categories on which it relies have: Modify.class, Method.class, Field.class, Class.class. Then look Modify.class

    The official explanation of the general meaning of the authority is to provide a mechanism based on jvm version of the java bytecode attributes for a particular modification to the inverse solution out. . .

    Static faster operation made necessary preparation.

    It should be modified determining some relevant class or an object in the address number has a result in the form of additional strings on.

    For the hex code for a particular address several jvm version of the inverse solution of the corresponding secondary bar code.

    Since this is related to memory, so give full stick out. 

    Some modifiers java language, most of them used, there is no standard. We can see almost all have a STRICT modifier, but also that they did not come into contact with. But it seems basic introductory course when talked about, because there are fewer natural forget not the end of the contact. Since then read the constitution of all Modify.class. I can see it primarily as a supporting role. Provide support for a number of other operations. The operations associated methods and properties. The flag for their rights.

   然后看看Method.class和Field.class:  回顾类依赖和结构关系,可以知道它们都作为了  AccessibleObject抽象的实现,可以共同看一下AccessibleObject.class,其实现了接口AnnotatedElement接口:

    

    这便是该几口提供的抽象,需要注意的是,属性和方法都遵循该抽象规范,并且该抽象为顶层抽象。 然后回溯看一看AccessibleObjec.class:

    需要注意的是,虽然它作为了多个关键类的实现,但是其本身被没有被设置为抽象标签。  可以猜测的是其对于子类并没有向下提供抽象,并且是将高一层的抽象都实现了的。其子类的提供给的抽象在逻辑上一个补充,并提供的抽象。。 

    比较重要的 一个 超类接口的 实现。

    由于当时写了注释,便一路向下:

    这个方法依然是作为抽象接口的实现的一个补充。 

    后面的很多内容反射工厂有关。  至此该类已看完。  其关键的抽象方法都已贴出,并且其作为Method与Field的超类,本身也代表了该二者的一些属性与标准。 

    然后就可以看看Field了:

    这里读出的信息有:get 和 set 方法是 pojo的题中之意。 

    这是其构造,在明白不过。需要注意的是,它作为一个普通类的子类,因此它具备它父类所具有的一些属性和行为。 看完Feild,然后了解一下 Method,看起类结构依赖图:  其在  AccessibleObject类的基础上进行了一层抽象,即Executable,为Method提供整体框架。 同时实现了Member接口:

    发现该接口原来是作为了逻辑而存在,整个一空壳。。 接下来看Executable,其名称容易让人误解为一个抽象接口,但实际为一个抽象类。 

    其方法一览图如上,清晰命了。  

    其构造,跟Field的构造有异曲同工之妙。 

    可以知道反射可以对类中的行为进行执行,意思为执行的处理,可以说是比较关键的,而其实际执行的方法为:MethodAccess的Invoke方法。 追进去看,经过一段比较曲折的调用之后,其实际到了  sun包下的一些类中的方法。 关于Method的源码就解读到这。  因为其抽象  Executable所做的功能已经比较健全,因此当时看的时候并没有提供关于Method.class的相关源码 。最后了解一下上面提到的一个反射工厂:ReflectionFactory

    就是这里了,做了与sun包的嫁衣。    其中  NativeMethodAccessorImpl  位于sun包下,其实际处理了Invoke ()方法 。 。

    对于方法,构造方法,属性类实例的方法。  意思为  关于  这些包装类的实例方法 。  并不是指类的实例化的意思。 



原文链接

Guess you like

Origin www.cnblogs.com/swanyf/p/10944955.html