18

Reflection and Metadata

Embed Size (px)

Citation preview

Page 1: Reflection and Metadata
Page 2: Reflection and Metadata

Reflection

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

Page 3: Reflection and Metadata

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

Page 4: Reflection and Metadata

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

Page 5: Reflection and Metadata

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

Page 6: Reflection and Metadata

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

Page 7: Reflection and Metadata

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

Page 8: Reflection and Metadata

Purpose

Tools.

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

Page 9: Reflection and Metadata

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

Page 10: Reflection and Metadata

Metadata

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

Page 11: Reflection and Metadata

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

Page 12: Reflection and Metadata

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

Page 13: Reflection and Metadata

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

Page 14: Reflection and Metadata

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

Page 15: Reflection and Metadata

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

Page 16: Reflection and Metadata

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

Page 17: Reflection and Metadata

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

Page 18: Reflection and Metadata

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