Java – use @ hide to hide methods / classes in annotations
I'm developing a library (jar) for Android. The situation I encounter is that I want my classes or methods to be accessible only in my library, but not outside my library Using the no modifier will make this class accessible in this package, but I'm in a situation where I can't use this class without the public modifier because using the no modifier will make it inaccessible in other packages I don't want For example,
public class Globals { public static String thisDeviceAddress; public static String thisDeviceIP; public static String thisDeviceName = ""; }
This course can be seen everywhere The problem is that I want it to be accessible in the library I'm developing, but not outside the library I already know that using the @ hide annotation will solve the problem For example:
/** * @hide */ class Globals { public static String thisDeviceAddress; public static String thisDeviceIP; public static String thisDeviceName = ""; }
I searched a lot with Google, but I couldn't find a way to implement @ hide Only use @ hide without library and no hidden classes So please give me proper guidance Any libraries to use? Any way to solve this problem?
Solution
There is no way to hide public classes and methods This is the Java language specification. You can't break it