Feature request: aliasing classes at import

Ivan Krylov Ivan.Krylov at oracle.com
Thu Jul 14 16:51:51 PDT 2011


I would not limit this than just to class names but rather expand idea 
of selective alliasing to methods and fields.

just my 0.02

On 7/10/11 6:02 AM, Behrang Saeedzadeh wrote:
> 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