Feature Request: Import As (e.g. import java.sql.Connection as SqlConnection)

Behrang Saeedzadeh behrangsa at gmail.com
Sun Apr 17 02:36:41 UTC 2016


Hi all,

It is good to see that lots of people like this idea. Syntax wise, I agree
with Christoph, it can be done even without introducing a new keyword.

But these days there are more clashes with annotations, classes, and
interfaces of the same name that might be used in a single file.

For example (hypothetically) an @Serialize for JSON and an @Serialize for
XML in the same file. Similarly, @Ignore, @Transient, etc.


Best regards,
Behrang Saeedzadeh

On 2 April 2016 at 08:41, Remi Forax <forax at univ-mlv.fr> wrote:

> I think the oldest bug related to this feature is
>   https://bugs.openjdk.java.net/browse/JDK-4194542
>
> The bug was reported against the 1.2 :)
>
> Rémi
> (i'm getting old)
>
> ----- Mail original -----
> > De: "Jonathan Gibbons" <jonathan.gibbons at oracle.com>
> > À: discuss at openjdk.java.net
> > Envoyé: Vendredi 1 Avril 2016 21:30:17
> > Objet: Re: Feature Request: Import As (e.g. import java.sql.Connection
> as     SqlConnection)
> >
> > Without commenting on the merits of the suggestion, I note this is not a
> > new request.
> > See JDK-7166917: Importing packages and classes with alias
> > https://bugs.openjdk.java.net/browse/JDK-7166917
> >
> > -- Jon
> >
> > On 03/31/2016 09:33 PM, Behrang Saeedzadeh wrote:
> > > Hi all,
> > >
> > > Any thoughts on this feature? I think it should be relatively simple to
> > > implement and considering these days an app might use various types of
> data
> > > storage as well as queues, etc. it is very likely for two classes with
> the
> > > same name but from different packages need to be used in a given class.
> > >
> > > This could be extended to imported static methods too, because
> sometimes
> > > their names are ambiguous if they are not prefixed with their
> respective
> > > classes.
> > >
> > > import static java.lang.String.format as stringFormat;
> > > // or
> > > import static java.lang.String.format as sformat;
> > > // or
> > > import static java.lang.String.format as formats;
> > >
> > > Best regards,
> > > Behrang Saeedzadeh
> >
> >
>


More information about the discuss mailing list