What does a qualified name mean for a module?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

What does a qualified name mean for a module?

Jayaprakash Artanareeswaran
Hello,


The newly introduced ModuleElement has two APIs to get a module's name, namely getQualifiedName() and getSimpleName(). The JLS, though says a module only has one name.


"A module name consists of one or more Java identifiers (§3.8) separated by "."
tokens."


I also see this in the "JPMS: Modules in the Java Language and JVM":

ModuleName:
  Identifier
  ModuleName . Identifier

I am not really sure what a qualifier for a module is. In the given example

Module M.N {}

are 'M' and 'N' separate names and if so, what do they denote?

Jay

Reply | Threaded
Open this post in threaded view
|

Re: What does a qualified name mean for a module?

Alex Buckley
A module name has the same structure as a package name, so ModuleElement
has the same shape as PackageElement: each inherits getSimpleName() from
Element, and getQualifiedName() from getQualifiedName() from
QualifiedNameable.

Alex

On 6/6/2017 7:24 AM, Jayaprakash Artanareeswaran wrote:

> Hello,
>
>
> The newly introduced ModuleElement has two APIs to get a module's name, namely getQualifiedName() and getSimpleName(). The JLS, though says a module only has one name.
>
>
> "A module name consists of one or more Java identifiers (§3.8) separated by "."
> tokens."
>
>
> I also see this in the "JPMS: Modules in the Java Language and JVM":
>
> ModuleName:
>    Identifier
>    ModuleName . Identifier
>
> I am not really sure what a qualifier for a module is. In the given example
>
> Module M.N {}
>
> are 'M' and 'N' separate names and if so, what do they denote?
>
> Jay
>
Reply | Threaded
Open this post in threaded view
|

Re: What does a qualified name mean for a module?

Stephan Herrmann
On 06.06.2017 18:59, Alex Buckley wrote:
> A module name has the same structure as a package name, so ModuleElement has the same shape as PackageElement: each inherits
> getSimpleName() from Element, and getQualifiedName() from getQualifiedName() from QualifiedNameable.

Syntactically you're right, but ...

Normally, a qualified name denotes two things: a parent element and a child.
The package name "java.lang" has a qualifier "java" which denotes a top-level package
and "lang" can be used relative to that package to denote a member package etc.

For a module - say "java.base" - the qualifier "java" denotes nothing.
And hence, the simple name "base" cannot be resolved in any context.

So the question is: should ModuleElement.getSimpleName() answer the
totally useless last segment of the name, or should it answer the same
as getQualifiedName()?

Stephan

>
> Alex
>
> On 6/6/2017 7:24 AM, Jayaprakash Artanareeswaran wrote:
>> Hello,
>>
>>
>> The newly introduced ModuleElement has two APIs to get a module's name, namely getQualifiedName() and getSimpleName(). The JLS,
>> though says a module only has one name.
>>
>>
>> "A module name consists of one or more Java identifiers (§3.8) separated by "."
>> tokens."
>>
>>
>> I also see this in the "JPMS: Modules in the Java Language and JVM":
>>
>> ModuleName:
>>    Identifier
>>    ModuleName . Identifier
>>
>> I am not really sure what a qualifier for a module is. In the given example
>>
>> Module M.N {}
>>
>> are 'M' and 'N' separate names and if so, what do they denote?
>>
>> Jay
>>

Reply | Threaded
Open this post in threaded view
|

Re: What does a qualified name mean for a module?

David M. Lloyd
On 06/06/2017 12:14 PM, Stephan Herrmann wrote:

> On 06.06.2017 18:59, Alex Buckley wrote:
>> A module name has the same structure as a package name, so
>> ModuleElement has the same shape as PackageElement: each inherits
>> getSimpleName() from Element, and getQualifiedName() from
>> getQualifiedName() from QualifiedNameable.
>
> Syntactically you're right, but ...
>
> Normally, a qualified name denotes two things: a parent element and a
> child.
> The package name "java.lang" has a qualifier "java" which denotes a
> top-level package
> and "lang" can be used relative to that package to denote a member
> package etc.
>
> For a module - say "java.base" - the qualifier "java" denotes nothing.
> And hence, the simple name "base" cannot be resolved in any context.
>
> So the question is: should ModuleElement.getSimpleName() answer the
> totally useless last segment of the name, or should it answer the same
> as getQualifiedName()?

The answer to that question should apply to PackageElement too, for
identical reasons.  However, PackageElement is established API already...

--
- DML
Reply | Threaded
Open this post in threaded view
|

Re: What does a qualified name mean for a module?

Michael Nascimento
It'd be quite odd if ModuleElement and PackageElement implementations of
getSimpleName() differed. Since PackageElement.getSimpleName() is around
and has defined behaviour, ModuleElement must follow it imho.

Regards,
Michael

On Tue, Jun 6, 2017 at 2:35 PM, David M. Lloyd <[hidden email]>
wrote:

> On 06/06/2017 12:14 PM, Stephan Herrmann wrote:
>
>> On 06.06.2017 18:59, Alex Buckley wrote:
>>
>>> A module name has the same structure as a package name, so ModuleElement
>>> has the same shape as PackageElement: each inherits getSimpleName() from
>>> Element, and getQualifiedName() from getQualifiedName() from
>>> QualifiedNameable.
>>>
>>
>> Syntactically you're right, but ...
>>
>> Normally, a qualified name denotes two things: a parent element and a
>> child.
>> The package name "java.lang" has a qualifier "java" which denotes a
>> top-level package
>> and "lang" can be used relative to that package to denote a member
>> package etc.
>>
>> For a module - say "java.base" - the qualifier "java" denotes nothing.
>> And hence, the simple name "base" cannot be resolved in any context.
>>
>> So the question is: should ModuleElement.getSimpleName() answer the
>> totally useless last segment of the name, or should it answer the same
>> as getQualifiedName()?
>>
>
> The answer to that question should apply to PackageElement too, for
> identical reasons.  However, PackageElement is established API already...
>
> --
> - DML
>
Reply | Threaded
Open this post in threaded view
|

Re: What does a qualified name mean for a module?

Stephan Herrmann
In reply to this post by David M. Lloyd
On 06.06.2017 19:35, David M. Lloyd wrote:

> On 06/06/2017 12:14 PM, Stephan Herrmann wrote:
>> On 06.06.2017 18:59, Alex Buckley wrote:
>>> A module name has the same structure as a package name, so ModuleElement has the same shape as PackageElement: each inherits
>>> getSimpleName() from Element, and getQualifiedName() from getQualifiedName() from QualifiedNameable.
>>
>> Syntactically you're right, but ...
>>
>> Normally, a qualified name denotes two things: a parent element and a child.
>> The package name "java.lang" has a qualifier "java" which denotes a top-level package
>> and "lang" can be used relative to that package to denote a member package etc.
>>
>> For a module - say "java.base" - the qualifier "java" denotes nothing.
>> And hence, the simple name "base" cannot be resolved in any context.
>>
>> So the question is: should ModuleElement.getSimpleName() answer the
>> totally useless last segment of the name, or should it answer the same
>> as getQualifiedName()?
>
> The answer to that question should apply to PackageElement too, for identical reasons.  However, PackageElement is established API
> already...
>

For packages it is established confusion that some say, a package
"java.lang" has a parent package "java" so that "lang" can be resolved
as a member of that parent, and others say that the structure of package
names bears no semantic significance.

For the former group the simple name of a package has significance,
for the latter it doesn't.

Both are right <sigh>

For modules there is only the latter view, there is no JLS 6.5.3.2 for modules.
But if some spec will say what a simple name of a module is, it's of course
trivial to implement (and hopefully nobody will be tempted to use that method).

Stephan

Reply | Threaded
Open this post in threaded view
|

Re: What does a qualified name mean for a module?

Alex Buckley
In reply to this post by Stephan Herrmann
On 6/6/2017 10:14 AM, Stephan Herrmann wrote:

> Normally, a qualified name denotes two things: a parent element and a
> child. The package name "java.lang" has a qualifier "java" which
> denotes a top-level package and "lang" can be used relative to that
> package to denote a member package etc.
>
> For a module - say "java.base" - the qualifier "java" denotes
> nothing. And hence, the simple name "base" cannot be resolved in any
> context.
>
> So the question is: should ModuleElement.getSimpleName() answer the
> totally useless last segment of the name, or should it answer the
> same as getQualifiedName()?

When Joe asked for feedback on this API two months ago [1], I made
essentially the same point [2], and a bug was filed [3].

Alex

[1]
http://mail.openjdk.java.net/pipermail/compiler-dev/2017-April/010896.html
[2]
http://mail.openjdk.java.net/pipermail/compiler-dev/2017-April/010905.html
[3] https://bugs.openjdk.java.net/browse/JDK-8163989