Calling protected static methods


Is there a way to call a protected static method from a derived class in kotlin?

I am extending android.widget.LinearLayout and I’d like to call protected static int[] mergeDrawableStates from android.view.View (LinearLayout extends View, but not directly).


Yes, this is known problem. Fill free to vote this issue (also there is a temporary workaround)


The workaround is to create an intermediary class in java with either:   - a non-static method forwarding the call to the protected static method   - a public static method forwarding the call to the protected static method. I have used that workaround in the past, but was looking for something better.

For this particular case, I ended up duplicating the functionality of the static method (it’s static and didn’t need to be inside View, and it’s only a few lines long).

Another obvious workaround is to use reflection to call it.