3

Bug ID: JDK-4214789 Extend import to allow renaming of imported type

 1 year ago
source link: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4214789
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

JDK-4214789 Extend import to allow renaming of imported type

JDK-4214789 : Extend import to allow renaming of imported type
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 1.2.0,1.3.0,1.4.1,1.4.2
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,linux,windows_2000
  • CPU: generic,x86
  • Submitted: 1999-02-25
  • Updated: 2006-11-21

  • Resolved: 2006-11-21

Related Reports
Duplicate :  
Description
Name: igT44549			Date: 02/24/99


If a compilation unit needs to import two types residing in 
different packages but with the same name, then each reference 
to at least one of the types must be fully qualified.

To prevent client developers from having to fully qualify names,
library developers should make each importable type name unique,
defeating one of the goals of the package mechanism.

A compile-time mechanism to allow renaming of modules on import 
would prevent this.  For example:

import java.util.Date;
import java.sql.Date as SQLDate;

The ability to rename on import would not obfuscate source code, 
since a reader needs to review the module import declarations
anyway to know the origin of the types being used.  It would 
simplify code that uses different types with the same name. 

This enhancement should require only minimal changes to the 
compiler and to javadoc.
(Review ID: 48501)
======================================================================

Comments

WORK AROUND

Name: igT44549 Date: 02/24/99

Without such a feature, each importable type should be given a name that is unique across all importable types. This requires that each type name include a product-specific prefix, at a minimum. ======================================================================

28-07-2004

EVALUATION

This is not an unreasonable request, though hardly essential. The occasional use of fully qualified names is not an undue burden (unless the library really reuses the same simple names right and left, which is bad style).

In any event, it doesn't pass the bar of price/performance for a language change.

gilad.bracha@eng 1999-12-22

22-12-1999


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK