-
Enhancement
-
Resolution: Duplicate
-
P5
-
None
-
5.0
-
x86
-
windows_xp
A DESCRIPTION OF THE REQUEST :
You should be able to get a Package object for any class. You should also be able to specify Package objects as constants (available to annotations) through syntax like "com.mypackage.MyClass.class.package" or "com.mypackage.package".
JUSTIFICATION :
The ability to specify packages would allow annotations to specify packages. In particular, I would like to see a feature like @VisibleTo((Class|Package)+) and @VisibleToSubPackagesOf(Package+) as ways of sharing default access classes and members with other classes and packages (without making them public or protected). This would very neatly solve a problem that we've had since the beginning. I've been thinking about this problem for the last 9 years or so and this is the best idea I've come up with because it is Java simple. I hope we can fix this serious lacking simply like this...
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Ability to reference Package objects easily through the Java language and through annotations.
ACTUAL -
Feature does not exist.
CUSTOMER SUBMITTED WORKAROUND :
No easy workaround. Package objects are not consistently available for classes and there is no way to access them directly in the language or through annotations. The @VisibleTo*() annotations I'd like to see are not possible at all right now.
You should be able to get a Package object for any class. You should also be able to specify Package objects as constants (available to annotations) through syntax like "com.mypackage.MyClass.class.package" or "com.mypackage.package".
JUSTIFICATION :
The ability to specify packages would allow annotations to specify packages. In particular, I would like to see a feature like @VisibleTo((Class|Package)+) and @VisibleToSubPackagesOf(Package+) as ways of sharing default access classes and members with other classes and packages (without making them public or protected). This would very neatly solve a problem that we've had since the beginning. I've been thinking about this problem for the last 9 years or so and this is the best idea I've come up with because it is Java simple. I hope we can fix this serious lacking simply like this...
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Ability to reference Package objects easily through the Java language and through annotations.
ACTUAL -
Feature does not exist.
CUSTOMER SUBMITTED WORKAROUND :
No easy workaround. Package objects are not consistently available for classes and there is no way to access them directly in the language or through annotations. The @VisibleTo*() annotations I'd like to see are not possible at all right now.
- duplicates
-
JDK-5043025 Access to Field, Method and Constructor without the use of Strings
-
- Closed
-