Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6424492

Make Package objects consistent and expose through Java language

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 5.0
    • specification
    • 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.

            abuckley Alex Buckley
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: