Double-semicolon in import statements
John Spicer
jhs at edg.com
Fri Aug 2 14:00:27 PDT 2013
On Aug 2, 2013, at 4:45 PM, Jonathan Gibbons <jonathan.gibbons at oracle.com> wrote:
> In general, it is better/simpler to change javac to conform to the spec. (Except when it is not.)
Well, you sure can't argue with that statement :-)
It is unfortunate that, in the example given, if the user swaps what look like import declarations with a redundant semicolon the code changes from being invalid to valid (or vice-versa if the code began in the other sequence).
John.
>
> -- Jon
>
> On 08/02/2013 11:36 AM, Jeremy Manson wrote:
>> Just out of my own curiosity, who decides whether to change the spec or javac?
>>
>> Jeremy
>>
>>
>> On Fri, Aug 2, 2013 at 10:25 AM, John Spicer <jhs at edg.com> wrote:
>>
>> On Aug 2, 2013, at 12:57 PM, Alex Buckley <alex.buckley at oracle.com> wrote:
>>
>> > Nope, the production is:
>> >
>> > CompilationUnit:
>> > PackageDeclarationopt ImportDeclarationsopt TypeDeclarationsopt
>> >
>> > So that's a javac bug. (And a reason for minimizing undue flexibility in the language in the first place.)
>>
>> I'm generally happier to ban things like extra semicolons, but it seems to me that "import x.y;;" should be allowed regardless of what follows.
>>
>> FWIW, out front end does give the appropriate error, the rules just seem odd to me.
>>
>> John.
>>
>> >
>> > Alex
>> >
>> > On 8/1/2013 12:59 PM, Jeremy Manson wrote:
>> >> Alex,
>> >>
>> >> What about the following, which also compiles? Can you
>> >> have ImportDeclaration TypeDeclaration ImportDeclaration?
>> >>
>> >> import java.util.HashMap;;
>> >> import java.util.LinkedList;
>> >>
>> >> public class Semicolon {
>> >> public static void main(String[] args) {
>> >> System.out.println("This program should not compile");
>> >> }
>> >> }
>> >>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20130802/4b2c0008/attachment.html
More information about the compiler-dev
mailing list