- Kotlin for Enterprise Applications using Java EE
- Raghavendra Rao K
- 159字
- 2021-06-10 18:49:29
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.
推薦閱讀
- 云原生Spring實(shí)戰(zhàn)
- Xamarin.Forms Projects
- 深度學(xué)習(xí):算法入門(mén)與Keras編程實(shí)踐
- 程序員修煉之道:通向務(wù)實(shí)的最高境界(第2版)
- 深入RabbitMQ
- 響應(yīng)式架構(gòu):消息模式Actor實(shí)現(xiàn)與Scala、Akka應(yīng)用集成
- Babylon.js Essentials
- HTML5秘籍(第2版)
- Android傳感器開(kāi)發(fā)與智能設(shè)備案例實(shí)戰(zhàn)
- Hands-On Neural Network Programming with C#
- App Inventor少兒趣味編程動(dòng)手做
- Mastering OAuth 2.0
- 超好玩的Scratch 3.5少兒編程
- C++ Windows Programming
- 機(jī)器人ROS開(kāi)發(fā)實(shí)踐