Reflection


Reflection

Reflection is a set of programming languages and library features in a fixed program in runtime. Kotlin reflects to use of classes, members, functions and constructors, etc. Kotlin provides an over-drop style using the Java Reflection API. Standard Java reflection Constructor is available in Kotlin and works perfectly with its code.

Features of Reflection are as follows:

  • This provides access to properties and males
  • Kotlin reflection has some additional features to java reflection.
  • Kotlin reflection helps access the JVM code through a language

The Class References

To get a class reference in legally known runtime, use the Class Reference Operator. In addition, a mention of a class is available from the events of class; such references are known as border class remarks. With examples, you earn the exact type of expression that conform the object complement to the tradition.

The Function References

We have an active mention of all the named functions defined in kotlin. The function name can do this previously, : operator. These functional references can be used as parameters to other functions. In the case of overload functions, we can specify the type of function or determine it from content.

The Property references

We will obtain the property references that run with:: the operator. If a class of a class is advertised, then your own is advertising, then the class name:: must specify the operator. This property reference allows us to consider an asset of property; we will get with functions or modify it with the set function.

The Constructor references

A Class Constructors' remarks are similar to methods and property references, and these references can be used as a function to provide that kind of object. However, these uses are rare.