-encoding and -source in module-info.java

Reinier Zwitserloot reinier at zwitserloot.com
Mon Jan 30 12:27:07 PST 2012


Okay. What's the inherent problem in specifying inside the JLS:

(A) The 'home' value (for the JLS8, that would be 8/1.8) has to be
supported,

(B) a mapping from version values to links to older versions of the JLS, and

(C) that a compiler may choose to compile any version listed in the mapping
according to that spec, OR emit a warning that its interpreting the source
file according to some other JLS and that this might not be what the user
wanted. The only thing left up to the compiler is which of the various JLS
versions that it supports will be used to parse and compile the file, and
that, if it's not an exact match to the source directive if present, a
warning must be emitted.


As a consequence of that specification, ONLY implementing the 'home' value
(1.8) and emitting warnings if the source directive doesn't match it, is a
valid implementation.

This is not a backdoor strategy to get incompatible changes introduced into
the JLS. It's just useful. If it wasn't, why does -source even exist in the
first place?

As Jesse Glick said, it would be fantastic if a module, either in
precompiled state (i.e. the root directory of a module-info.java and all
its related source file), as well as postcompiled state (jmod file) are
100% self-describing. They would be if this kind of meta-data is pulled
into the module itself.

NB: I'd be in favour of deprecating and then eventually removing some
exceedingly rarely used language features such as postfix array brackets
for variables and especially method declarations, i.e. public int
iReturnAnIntArray() [] {}, and doing so would be made possible by in-band
source directives, but that's not the point of this request - the point is
to let a module be self-descriptive. The fact that it does open the door on
perhaps one day deprecating existing language syntax is a mostly irrelevant
bonus.

 --Reinier Zwitserloot



On Mon, Jan 30, 2012 at 21:04, Alex Buckley <alex.buckley at oracle.com> wrote:

> The JLS is not going to define syntax for a 'source' declaration and then
> leave it up to compilers to interpret. It is bad enough that the JLS defers
> to "host system" for resolving dependences, and that will be fixed with a
> standard module system configured from the language. We're not going to
> take two steps forward, then one step back.
>
> The idea of explicit source levels _in the language_ comes up every few
> years. I assume people want to use it as a backdoor way of removing
> language features. But that is off-topic for this list.
>
>
> On 1/30/2012 8:53 AM, Reinier Zwitserloot wrote:
>
>> It might be a good idea to write a sister specification which lists
>> minimum
>> legal compiler switches and defines what a compiler is supposed to do with
>> various meta-information. This specification should go into classpath,
>> sourcepath, warning levels for -Xlint (and push -Xlint out of -X
>> territory.
>>
>
> Sounds good. Please discuss further on compiler-dev, not jigsaw-dev.
>
> Alex
>



More information about the jigsaw-dev mailing list