On more than one occasion I have found myself desiring a variable visibility that is not possible in Java. I wanted certain members to be visible within their own class and
I suppose they want to avoid the added complexity by having a non-linear access hierarchy.
You should have control over your package, so simply don't call these protected methods there.
(By the way, protected
is not quite the same as sub-class and package
, as non-static protected methods (if not in the same package) can't be called on arbitrary objects of the declaring class, but only on objects of the subclass the code is in. (You can see this on Object.clone()
, which can only be called by the class whose object is being cloned.))