All open plugin and explicitly open class


Its seems that all open plugin does not work with class that is already defined as open.
I have entity that I need to inherit from therefore i used open keyword. But I also want to use all open plugin because of hibernate lazy loading -so I applied all open plugin on @Entity. But it does not work. When I remove open keyword from class definition, it starts to work. As work around I can use open keyword with all class properties, but I would rather use all open plugin so my class is not flooded with open keyword. Any suggestions?


Hello. I failed to reproduce the problem with dummy code:

package my

annotation class Ann

open class Foo {
    fun foo() {}

class Bar : Foo()

Gradle build script:

plugins {
    id 'java'
    id 'org.jetbrains.kotlin.jvm' version '1.3.31'
    id "org.jetbrains.kotlin.plugin.allopen" version "1.3.31"

allOpen {

When compiling with Gradle, both Foo class and foo function are generated as open. Also, IDE shows an inspection “Redundant modality modifier” on open for the class Foo, suggesting to remove it.

Please share a self-contained code example to reproduce the problem.