2

Bug ID: JDK-4194542 class name aliasing

 1 year ago
source link: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4194542
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.
neoserver,ios ssh client

JDK-4194542 class name aliasing

JDK-4194542 : class name aliasing
Related Reports
Description
Name: diC59631			Date: 12/03/98


Obviously the two below operations will not
compile in the same java file.

import java.util.Date ;
import java.sql.Date ;

It would be nice to alias one such as below:

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

Date    => java.util.Date
SqlDate => java.sql.Date

This way instead of leaving out the
import java.sql.Date line and having to
fully qualify the SQL Date class for every
usage, you'd only have to use the SqlDate
alias.

This becomes a much larger issue with package
names like:
  com.fake1.western.division.plane.Fuel ;
  com.fake2.tiger.landbased.vehicle.Fuel ;

Especially when you need to use both types of
Fuel, but can only use the shortend version
for one of them at most.

"import .. as .." is not a new concept, and
I'm surprised that it wasn't incorporated into
the language specification from the beginning.
(Review ID: 43613)
======================================================================

An alternative syntax is proposed in RFE 4478140:

import jlang=java.lang.*;
alias jlang=java.lang;

The need for an extra keyword is not clear.

###@###.### 2005-04-17 07:20:05 GMT


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK