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

Importing packages and classes with alias

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 7
    • Fix Version/s: None
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux

      Description

      A DESCRIPTION OF THE REQUEST :
      Import-clause should support syntax to import packages and classes with alias:

      import java.awt.* as gui;
      import java.io.File as MyFile;



      JUSTIFICATION :
      Currently using *-syntax to import multiple packages you quickly lose picture what is imported from where.
      Using class-specific import clutters the source files with lots of unnecessary rows.

      Both current ways suffer from classes with same names in different imported packages (e.g. java.util.List and java.awt.List)

      Importing with alias keeps it always clear where the class came from and similarly named classes are not a problem (e.g. gui.List and containers.List)

      Impact of this change is solely limited to compiler and binaries are exactly the same. Current syntax can still be used so there is no drawback of adding this feature.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Import:
      import java.awt.* as gui;
      import java.io.File as MyFile;
      Usage:
      new gui.Button();
      new MyFile();


      ACTUAL -
      importing with alias is currently not possible

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: