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
  • 27,872
  • 21
  • 103
  • 189
dumazy
  • 12,758
  • 12
  • 60
  • 107

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
  • 27,872
  • 21
  • 103
  • 189