Compiling Java 9

Jonathan Gibbons jonathan.gibbons at oracle.com
Wed Nov 16 22:39:14 UTC 2016



On 11/16/2016 02:34 PM, Stephan Herrmann wrote:
> On 11/16/2016 11:19 PM, Jonathan Gibbons wrote:
>>
>>
>> On 11/16/2016 02:08 PM, Stephan Herrmann wrote:
>>> On 11/16/2016 10:02 PM, Alex Buckley wrote:
>>>> - If you lex 'package', then the sequence must parse as the first 
>>>> alternative.
>>>> - If you don't lex 'package', but rather lex 'import', then parsing 
>>>> is ambiguous until you've looked ahead to lex either 'open',
>>>> 'module', or a keyword that can start TypeDeclaration. [Ignoring 
>>>> annotations for simplicity.]
>>>> - If you lexed 'open' or module', then the sequence must parse as 
>>>> the second alternative; if you lexed anything else, then the
>>>> sequence must parse as the first alternative.
>>>
>>> I just tried this:
>>>
>>> ---8<---
>>> import open.module;
>>>
>>> module foo {
>>> }
>>> ---8<---
>>>
>>> According to lang-vm this should be legal. The import statement
>>> contains restricted keywords in positions where they cannot be 
>>> keywords.
>>> => Parsing should succeed.
>>> javac rejects this, which supports your explanation that lexical 
>>> lookahead
>>> should suffice to recognize a ModuleDeclaration.
>>>
>>> Which one will it be?
>>>
>>> Stephan
>>>
>>
>> I suspect you're not using the latest javac.
>
> 9-ea-142 gives a syntax error:
>
> module-info.java:3: error: class, interface, or enum expected
>
> I'm downloading 9-ea-144 as we speak.
>

9-ea-144 probably won't be good enough. You will need a build of the 
jigsaw/jake forest,
coming soon.

>
>> Your example works for me, after I also create a class called 
>> open.module that I can
>> import.
>
> Thanks, so restricted keywords now follow the same rules throughout 
> the file.
> Sounds good.
>
> And with your explanation (previous post) I'm confident that javac's 
> implementation
> and what I had in mind are congruent.
>
> Still curious how a spec will faithfully capture this :)

:-)

>
> Stephan
>



More information about the jigsaw-dev mailing list