No-arg compiler plugin

Constructors are used to initialize the states of an object. Sometimes, however, we need to have default constructors that take no arguments. The no-arg compiler plugin is used to generate no-arg constructors (the default constructors) for classes that are annotated with a particular annotation. When we have a no-arg compiler plugin enabled, a no-arg constructor is added during compile-time. The generated default constructor can only be invoked by the reflection APIs and are not accessible directly from the Kotlin code. The no-arg compiler plugin enables the CDI or the JPA to instantiate the classes, though it doesn't have any default constructors defined in the code. 

In Java, a default constructor will always be added to the compiled code by the compiler and no additional plugin is required to do this. In Kotlin, however, when we have the no-arg compiler plugin enabled, a default constructor will be added to the compiled code.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset