Reflection API

FLX language, it’s virtual machine, FLX Lisp interpreter, and all of its computational features are implemented and based on using Kotlin and JVM. To provide a mechanism to extend FLX capabilities and functionality, FLX provides a simple reflection API consisting of the following functions:

  1. FLX provides a dedicated Class object that is actually just a Java class.
  2. Class.forName function returns a Java class for the specified fully qualified class name.
  3. Class.new function creates an instance of the given Java class. If the constructor of the class takes parameters they can be provided as arguments for this function.
  4. invoke function calls the function (e.g. setName) specified by its name and with parameters given as function arguments. In the example, function setName has only one parameter of type String.
  5. getProperty obtains the specified property of the given object. The property is specified by its name.
  6. setProperty sets the value of the specified property of the given object. The property is specified by its name.
  7. getClass returns the Java class of the given object.
  8. isInstance checks if the given object is instance of the class.

Implementation of FLX Reflection API naturally is based on Java’s Reflection API.

FLX’s Search Forms Picker provides means for obtaining Java class forms to be added to code in visual code editor:

  1. Type the fully qualified class name e.g. java.lang.String.
  2. If a Java class with the typed name exists it will be provided as a Java Class form.