I have seen some references refer to a access modifier in Java called private protected
(both words together):
private protected someMethod() {
}
One of the pages I found referring to this is here. My school lesson also referred to this access modifier (and said it exists). Using it, however, results in an error in the Java language.
I tried with both variables and methods and I'm pretty sure it doesn't exist, but I want an explanation of what happened. Was it considered, then rejected? Or did it get removed in a newer version of Java?
Edit: I am not looking for info about the protected
keyword.
Removal of the access modifier
Java did originally have the
private protected
modifier, but it was removed in JDK 1.0.2 (the first stable version, the Java 1.0 we know today). A few tutorials regarding JDK 1.0.2 (here and here) say the following:Another answer on SoftwareEngineering.SE states:
Now take a look at the Java Version History:
From this, we can conclude the tutorials regarding version 1.0.2 refer to the very first version, JDK 1.0, where the language was called Oak, but the one from SoftwareEngineering.SE refers to the first stable version, JDK 1.0.2 called Java 1.0, where it was removed.
Now if you try to search for it in the Java 1.0 documentation, you won't find it, because as mentioned earlier, it was removed in JDK 1.0.2, otherwise known as Java 1.0. This is proven again when you look at the "Last Modified" times for the link you posted. The link you posted was last modified in February of 1996. Java 1.0/JDK 1.0.2, when
private protected
was removed, was released after February of 1996, and according to the specification, August of 1996.Reason for removal
Some sources also explain the reason for
private protected
, such as this one. To quote:And the SoftwareEngineering.SE also supports this, by saying that it wasn't worth the inconsistencies and extra complexity, so it was removed early on.
Interpretation
My interpretation of all this is that maybe, back in the Oak days, both were allowed to coexist (hence the combination). Since
protected
's meaning had changed1, there may have been a need for allowingprivate
andprotected
at the same time. The introduction became too complex and wasn't worth it, and was thus dropped in the end. By the time Java 1.0/JDK 1.0.2 rolled around, it had been dropped and thus cannot be found in the documentation.1In the Oak Language Specification, Section 4.10, Access to Variables and Methods, it is noted that the default modifier was
protected
:This is quite different from what we have today, the default package access. This may have paved the way for the need of
private protected
, becauseprivate
was too restrictive andprotected
was too lenient.