cuba-platform / cuba

CUBA Platform is a high level framework for enterprise applications development
https://www.cuba-platform.com
Apache License 2.0
1.34k stars 219 forks source link

Message key bug for Kotlin enums with additional methods #3156

Closed alexbudarov closed 3 years ago

alexbudarov commented 3 years ago

Environment

Description of the bug or enhancement

see attached project: kenum2.zip

If you create enum in Kotlin with additional overridden methods, you can observe glitch with localized messages in running application:

enum class TaxType(private val id: String) : EnumClass<String> {
    VAT("V") {
        override fun someMethod(): String = "Hello A"
    },

    NO_TAX("N") {
        override fun someMethod(): String = "Hello B"
    },
    SIMPLIFIED("S") {
        override fun someMethod(): String = "Hello S"
    };

    override fun getId() = id

    abstract fun someMethod() :String

    companion object {

        @JvmStatic
        fun fromId(id: String): TaxType? = TaxType.values().find { it.id == id }
    }
}

image

Message keys are formed in a strange way.

klaus7 commented 3 years ago

The problem is probably the com.haulmont.cuba.core.sys.AbstractMessages#enumSubclassPattern

artemglinov commented 3 years ago

The actual changeset in branch "master" is here: https://github.com/cuba-platform/cuba/commit/f7e52f58269a527cdcb3144c5552b1a67be325e2.