@Jvm注解解析

1、JvmStatic 应用于对象或伴生对象的属性,使其 getter 和 setter 方法成为该对象或包含伴生对象的类的静态成员,应用于对象或伴生对象的方法,使其生成象或包含伴生对象的类改静态方法。

Specifies that an additional static method needs to be generated from this element; if it's a function.If this element is a property, additional static getter/setter methods should be generated.


2、JvmOverloads 生成不含有默认值参数Java重载方法和所有的参数的重载方法;

Instructs the Kotlin compiler to generate overloads for this function that substitute default parameter values.

If a method has N parameters and M of which have default values, M overloads are generated: the first one takes N-1 parameters (all but the last one that takes a default value), the second takes N-2 parameters, and so on.


3、JvmName 改变getter和setter中的方法名

Specifies the name for the Java class or method which is generated from this element.


4、JvmField 告诉Kotlin编译器不使用“getter/setters”,直接暴露类中的属性

Instructs the Kotlin compiler not to generate getters/setters for this property and expose it as a field.

参考:

https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容