| Start |
|---|
| Referencing a class To obtain a reference to a |
| Inter-operating with Java reflection To obtain a Java's The latter example will be optimized by the compiler to not allocate an intermediate |
| Referencing a function Functions are first-class citizens in Kotlin. You can obtain a reference on it using double colons and then pass it to another function: |
| Getting values of all properties of a class Given One can get hold of all properties of a class: Running this code will cause an exception to be thrown. Property The helper function and it's usage might look like this: Another approach is to make private properties accessible using reflection: |
| Setting values of all properties of a class As an example we want to set all string properties of a sample class Getting mutable properties builds on getting all properties, filtering mutable properties by type. We also need to check visibility, as reading private properties results in run time exception. To set all RemarksReflection is a mechanism to introspect language constructs (classes and functions) at the runtime. When targeting JVM platform, runtime reflection features are distributed in separate JAR: |
Read Article
https://develop.horje.com/learn/1434/reference