Search code examples
javapackage-private

In what year was package-private visibility semantics introduced to the java language?


What is the best way I can answer similar questions?

(What year feature XXX was introduced to java?)

I have read the wiki on java version history but it is too coarse grained.

Thanks!


Solution

  • Package-private has been around since before it was Java. The original Oak had public, protected, and default (package private) visibility. Eventually private (the modern "compilation unit" private) was introduced, still before Java 1.0.

    Edit: I just checked up on this: Oak called it private, but it behaved like Java's package-private: "All classes in a particular package can use all variables and methods declared in the classes in that package, regardless of public, protected, and private declarations." (Oak 0.2 spec page 15) Anyway, the date on that would be at least 1994 (version 0.2 of the spec), probably earlier.

    Here is an interesting article on Java history.