Visibility scope project/module

There is no such an access modifier in jdk, but kotlin comes with internal modifier, which does precisely what you want: the class becomes public within the module, but is not accessible outside of the module.

For detailed explanation of differences between modifiers in Java and Kotlin refer to Fragmented podcast's episode #101 - "Learning Kotlin – visibility modifiers, internal modifier, modules", as well as the official docs.


Not until Java 9. The Java 9 module system solves this exact problem. Another answer mentions Kotlin internal scope, but a) the OP didn’t ask for a Kotlin solution, and b) I’ve found the Kotlin internal scope not playing well with IntelliJ, which is ironical considering that JetBrains created both.