you can try other access modifiers, such as "protected". However: if someone really wants to access your method, they can use reflections and override the modifier at run time, making it available as they see fit. They can go even further and, for example, remove the final flag and so on. Therefore, it is unsafe to assume that if you use suitable modifiers, no one will be able to access your classes.
I donβt know now, but perhaps there is an annotation that can help your library user understand that they should not use your classes (except for the public API that you provide). Maybe something similar to @depricated or something like that, but I haven't used it myself.
source share