1

I have a Kotlin class that extends a Java class.

Kotlin

class MyKotlinClass: MyJavaClass() {

    companion object {
        const val STATUS_SUB = 1
    }
}

Java

public abstract class MyJavaClass {

    public static final int STATUS_SUPER = 0

}

How can I access the super class field through the kotlin subclass?

Kotlin

when(status) {
    MyKotlinClass.STATUS_SUPER -> something()
    MyKotlinClass.STATUS_SUB -> somethingElse()
}

Is this possible? It says "unresolved reference: STATUS_SUPER" Would it be possible without using MyJavaClass.STATUS_SUPER?

Adam Arold
  • 29,285
  • 22
  • 112
  • 207
dumazy
  • 13,857
  • 12
  • 66
  • 113

1 Answers1

2

Try

MyJavaClass.STATUS_SUPER

Since STATUS_SUPER is not a member of MyKotlinClass you won't be able to access it.

Adam Arold
  • 29,285
  • 22
  • 112
  • 207