Reflection and Metadata

Preview:

Citation preview

Reflection

Michal Pıse (CTU in Prague) Object Programming Lect. 12: Reflection and Metadata December 14, 2010 2 / 10

Terminology

Introspection—self-representation can be queried.

Intercession—self-representation can be changed.

Michal Pıse (CTU in Prague) Object Programming Lect. 12: Reflection and Metadata December 14, 2010 3 / 10

Terminology

Introspection—self-representation can be queried.

Intercession—self-representation can be changed.

Michal Pıse (CTU in Prague) Object Programming Lect. 12: Reflection and Metadata December 14, 2010 3 / 10

Terminology (II)

Structural reflection—concerned with structure.

Behavioral reflection—concerned with execution.

Michal Pıse (CTU in Prague) Object Programming Lect. 12: Reflection and Metadata December 14, 2010 4 / 10

Terminology (II)

Structural reflection—concerned with structure.

Behavioral reflection—concerned with execution.

Michal Pıse (CTU in Prague) Object Programming Lect. 12: Reflection and Metadata December 14, 2010 4 / 10

Reflection in Object Languages

Everything is an object.

Michal Pıse (CTU in Prague) Object Programming Lect. 12: Reflection and Metadata December 14, 2010 5 / 10

Purpose

Tools.

Michal Pıse (CTU in Prague) Object Programming Lect. 12: Reflection and Metadata December 14, 2010 6 / 10

Alternative

Source code

Byte code

AST

Custom represenation

Michal Pıse (CTU in Prague) Object Programming Lect. 12: Reflection and Metadata December 14, 2010 7 / 10

Metadata

Michal Pıse (CTU in Prague) Object Programming Lect. 12: Reflection and Metadata December 14, 2010 8 / 10

What Is Metadata?

Field and method names

Class names

Various modifiers

Even type information

More or less anything that is not compiled into binary

Michal Pıse (CTU in Prague) Object Programming Lect. 12: Reflection and Metadata December 14, 2010 9 / 10

What Is Metadata?

Field and method names

Class names

Various modifiers

Even type information

More or less anything that is not compiled into binary

Michal Pıse (CTU in Prague) Object Programming Lect. 12: Reflection and Metadata December 14, 2010 9 / 10

What Is Metadata?

Field and method names

Class names

Various modifiers

Even type information

More or less anything that is not compiled into binary

Michal Pıse (CTU in Prague) Object Programming Lect. 12: Reflection and Metadata December 14, 2010 9 / 10

What Is Metadata?

Field and method names

Class names

Various modifiers

Even type information

More or less anything that is not compiled into binary

Michal Pıse (CTU in Prague) Object Programming Lect. 12: Reflection and Metadata December 14, 2010 9 / 10

What Is Metadata?

Field and method names

Class names

Various modifiers

Even type information

More or less anything that is not compiled into binary

Michal Pıse (CTU in Prague) Object Programming Lect. 12: Reflection and Metadata December 14, 2010 9 / 10

Is Metadata Used Outside of Source Code?

Yes

Whenever we are referring to a class we are supplying it with anadditional information

Why don’t we include metadata in the source code? Is it possible?

Michal Pıse (CTU in Prague) Object Programming Lect. 12: Reflection and MetadataDecember 14, 2010 10 / 10

Is Metadata Used Outside of Source Code?

Yes

Whenever we are referring to a class we are supplying it with anadditional information

Why don’t we include metadata in the source code? Is it possible?

Michal Pıse (CTU in Prague) Object Programming Lect. 12: Reflection and MetadataDecember 14, 2010 10 / 10

Is Metadata Used Outside of Source Code?

Yes

Whenever we are referring to a class we are supplying it with anadditional information

Why don’t we include metadata in the source code? Is it possible?

Michal Pıse (CTU in Prague) Object Programming Lect. 12: Reflection and MetadataDecember 14, 2010 10 / 10

Recommended