Why does a protected android:onClick method in Activity actually work? Why does a protected android:onClick method in Activity actually work? android android

Why does a protected android:onClick method in Activity actually work?


As per "The Java™ Tutorials" :The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package


I debugged the particular implementations. The relevant portion of the code is within the Support Library using Class.getMethod().

As stated in the documentation, this method only finds public member methods and behaves correctly. For some reason, all modifiers of declared protected methods of the Activity (these are onCreate() and doClick()) are set to 1, which means these are actually public.

I could only observe this behavior creating the debug build with a Mac. So why this happens is still an open question, which I'm trying to find an answer to.