[SUGGESTION]: Define aliases when importing multiple classes with same classname

David Holmes david.holmes at oracle.com
Thu Oct 16 00:02:10 UTC 2014


On 16/10/2014 2:50 AM, Paul Benedict wrote:
> Interestingly, these tickets are closed as duplicates and none link to an
> open request. Was the original was accidentally marked a dupe and closed
> too?

There's a weird cycle involving those two and

https://bugs.openjdk.java.net/browse/JDK-4478140

But there is also:

https://bugs.openjdk.java.net/browse/PLAN-444

David


>
> Cheers,
> Paul
>
> On Wed, Oct 15, 2014 at 11:30 AM, Brian Goetz <brian.goetz at oracle.com>
> wrote:
>
>> Note that this issue is not new:
>>    https://bugs.openjdk.java.net/browse/JDK-4214789
>>    https://bugs.openjdk.java.net/browse/JDK-4194542
>>
>>
>> On 10/10/2014 12:50 AM, CHAUVET Guillaume wrote:
>>
>>> Dear OpenJDK community,
>>>
>>> I would like to submit you a potential new Java feature already existing
>>> in Eiffel language : renaming classes/interfaces when importing them.
>>> The goal is to improve the clashnames resolution when importing some
>>> classes with the same classname but provided from different packages by
>>> adding a classname alias mechanism. Below, a simple use case that
>>> display how this potential new syntax :
>>>
>>> Snippet class
>>> ==================
>>> import javax.management.Query;
>>> import javax.persistence.Query as PersistenceQuery;
>>> import org.apache.lucene.search.Query as LucentQuery;
>>>
>>> public class Snippet {
>>>
>>>    private javax.persistence.Query q1;    // Direct classname resolution
>>>    private PersistenceQuery q2;        // Using alias classname of
>>> javax.persistence.Query
>>>    private Query q3;            // Using default imported class :
>>> javax.management.Query
>>>    private LucentQuery q4;        // Using alias classname of
>>> org.apache.lucene.search.Query
>>>
>>>    public PersistenceQuery getPersistence() {
>>>     return q2;
>>>    }
>>> }
>>>
>>> Caller class
>>> ==================
>>> Snippet s = new Snippet();
>>> s.getPersistence(); // return javax.persistence.Query, not the internal
>>> alias used in class definition
>>>
>>>
>>> I'm ready to involved to implement this new feature by contributing to
>>> the OpenJDK development effort.
>>>
>>> Best regards
>>>
>>>



More information about the discuss mailing list