JvmOverloads annotation for class primary constructor

后端 未结 1 1432
春和景丽
春和景丽 2021-01-01 09:54

Why is it prohibited to autogenerate many constructors visible to Java from class primary constructor with default params likes this?

@JvmOverloads
class Vid         


        
相关标签:
1条回答
  • 2021-01-01 10:34

    It's not prohibited, you are just applying @JvmOverloads to the wrong target. The proper way to annotate primary constructor is to explicitly specify constructor keyword with @JvmOverloads before:

    class Video @JvmOverloads constructor(
        private val id: Long,
        val ownerId: Long,
        var title: String? = null,
        var imgLink: String? = null,
        var videoLink: String? = null,
        var description: String? = null,
        var created: Date? = null,
        var accessKey: String? = null,
        var duration: Long? = null,
        var views: Long? = null,
        var comments: Long? = null
    ) : Entity
    
    0 讨论(0)
提交回复
热议问题