- Kotlin for Enterprise Applications using Java EE
- Raghavendra Rao K
- 200字
- 2021-06-10 18:49:29
The all-open compiler plugin
When we define a class or declare a data member, it is final by default in Kotlin. We declare classes as final to make them non-extendable. Similarly, we make functions final so that they can't be overridden. Fields are declared as final to prevent the value from changing once it is initialized.
The Aspect-Oriented Programming (AOP) library and the Reflection API require classes to be non-final. These frameworks create proxy objects, so the classes and member variables have to be open and accessible.
The all-open compiler plugin makes sure Kotlin complies with the requirements of these libraries and frameworks when dealing with proxy objects. It makes classes and member variables that have specific annotations accessible to create proxy objects without explicitly specifying the open keyword in the code.
Let's take a look at an example of how we can use an all-open compiler plugin. When we are dealing with the CDI framework, we need classes that are annotated with specific annotations, such as @Inject or @Dependent, to make them open and accessible. Let's look at the all-open plugin support for both Maven and Gradle.
- iOS Game Programming Cookbook
- Mastering ServiceStack
- 前端跨界開(kāi)發(fā)指南:JavaScript工具庫(kù)原理解析與實(shí)戰(zhàn)
- 零基礎(chǔ)學(xué)Scratch少兒編程:小學(xué)課本中的Scratch創(chuàng)意編程
- Java技術(shù)手冊(cè)(原書(shū)第7版)
- C語(yǔ)言程序設(shè)計(jì)
- 單片機(jī)應(yīng)用技術(shù)
- Python算法從菜鳥(niǎo)到達(dá)人
- 小型編譯器設(shè)計(jì)實(shí)踐
- OpenCV with Python Blueprints
- 零基礎(chǔ)學(xué)C語(yǔ)言(升級(jí)版)
- Java Web開(kāi)發(fā)實(shí)例大全(基礎(chǔ)卷) (軟件工程師開(kāi)發(fā)大系)
- scikit-learn Cookbook(Second Edition)
- 深入淺出Python數(shù)據(jù)分析
- Wearable:Tech Projects with the Raspberry Pi Zero