正在加载图片...
Understanding and Analyzing Java Reflection 7:5 Reify Metasystem ofS Reffect Computational The Domain Computational The Domain System S of S System S of S Answer Questions abou Answer Questions about andor and/or Support Actions in Support Actions in the Domain the Domain and S itself (a)Computational System and its Domain (b)Reflective System and its Domain Fig.2.Computational vs.reflective computational systems. change in that selfsame behaviour and state",which allows an object to examine itself and leverage the meta-level information to figure out what to do next. Similarly,when we enable programs to avail themselves of such reflective capabilities,reflective programs will also allow the programs to observe and modify properties of their own behaviour. Thus,let a program be self-aware-this is the basic motivation of the so-called computational reflection,which is also considered as the reflection used in the area of programming languages [15]. In the rest of this section,we will introduce what computational reflection is(Section 2.1.1),what reflective abilities it supports(Section 2.1.2),and how Java reflection is derived from it(Section 2.1.3). 2.1.1 Computational Reflection.Reflection,as a concept for computational systems,dates from Brian Smith's doctoral dissertation [53].Generally,as shown in Figure 2(a),a computational system is related to a domain and it answers questions about and/or support actions in the domain [39]. As described in [39],a computational system "incorporates internal structures representing the domain.These structures include data representing entities and relations in the domain and a program describing how these data may be manipulated". A computational system S is said to be also a reflective system,as shown in Figure 2(b),if the following two conditions are satisfied: First,the system S has its own representation,known as its self-representation or metasystem, in its domain as a kind of data to be examined and manipulated. Second,the system S and its representation are causally connected:a change to the repre- sentation implies a change to the system,and vice versa. The base system S should be reified into its representation before its metasystem can operate. Then the metasystem examines and manipulates its behaviour using the reified representation.If any changes are made by the metasystem,then the effects will also be reflected in the behavior of the corresponding base system. 2.1.2 Reflective Abilities.Generally,(computational)reflection is the ability of a program to examine and modify the structure and behavior of a program at runtime [23,40].Thus,it endows the program the capabilities of self-awareness and self-adapting.These two reflective abilities are known as introspection and intercession,respectively,and both require a reification mechanism to encode a program's execution state as data first [15]. Introspection:the ability of a program to observe,and consequently,reason about its own execution state. ACM Trans.Softw.Eng.Methodol.,Vol.28,No.2,Article 7.Publication date:February 2019.Understanding and Analyzing Java Reflection 7:5 Metasystem of S The Domain of S Computational System S Reify Reflect and/or Support Actions in Answer Questions about the Domain and S itself The Domain of S Computational System S and/or Support Actions in Answer Questions about the Domain (a) Computational System and its Domain (b) Reflective System and its Domain Fig. 2. Computational vs. reflective computational systems. change in that selfsame behaviour and state”, which allows an object to examine itself and leverage the meta-level information to figure out what to do next. Similarly, when we enable programs to avail themselves of such reflective capabilities, reflective programs will also allow the programs to observe and modify properties of their own behaviour. Thus, let a program be self-aware — this is the basic motivation of the so-called computational reflection, which is also considered as the reflection used in the area of programming languages [15]. In the rest of this section, we will introduce what computational reflection is (Section 2.1.1), what reflective abilities it supports (Section 2.1.2), and how Java reflection is derived from it (Section 2.1.3). 2.1.1 Computational Reflection. Reflection, as a concept for computational systems, dates from Brian Smith’s doctoral dissertation [53]. Generally, as shown in Figure 2(a), a computational system is related to a domain and it answers questions about and/or support actions in the domain [39]. As described in [39], a computational system “incorporates internal structures representing the domain. These structures include data representing entities and relations in the domain and a program describing how these data may be manipulated”. A computational system S is said to be also a reflective system, as shown in Figure 2(b), if the following two conditions are satisfied: • First, the system S has its own representation, known as its self-representation or metasystem, in its domain as a kind of data to be examined and manipulated. • Second, the system S and its representation are causally connected: a change to the repre￾sentation implies a change to the system, and vice versa. The base system S should be reified into its representation before its metasystem can operate. Then the metasystem examines and manipulates its behaviour using the reified representation. If any changes are made by the metasystem, then the effects will also be reflected in the behavior of the corresponding base system. 2.1.2 Reflective Abilities. Generally, (computational) reflection is the ability of a program to examine and modify the structure and behavior of a program at runtime [23, 40]. Thus, it endows the program the capabilities of self-awareness and self-adapting. These two reflective abilities are known as introspection and intercession, respectively, and both require a reification mechanism to encode a program’s execution state as data first [15]. • Introspection: the ability of a program to observe, and consequently, reason about its own execution state. ACM Trans. Softw. Eng. Methodol., Vol. 28, No. 2, Article 7. Publication date: February 2019
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有