Feature request: aliasing classes at import
Behrang Saeedzadeh
behrangsa at gmail.com
Sat Jul 9 19:02:04 PDT 2011
Hi,
For a long time it was not very common to encounter a situation in
which two classes with the same name but in different packages had to
be imported and used frequently in the same file. In fact till
recently the only case I used to encounter every now and then was when
I had to import java.util.Date and java.sql.Date in the same class.
However recently it's more likely to encounter a situation like this.
Some libraries have annotations and classes that use the same name.
Also some APIs such as Eclipse EMF use class names (e.g. Package) that
clash with Java class names and there are cases that both of them
should be used frequently and using FQ names makes the source code
very verbose and ugly.
It would be nice to be able to import a class under a desired name at
import time, e.g.:
import java.util.Date : UDate;
import java.sql.Date : SDate;
Some other languages support this feature and I think it's a small
coin-scale feature that would be nice to be added to Java. What do you
think?
Cheers,
Behrang Saeedzadeh
http://www.behrang.org
More information about the jdk8-dev
mailing list