Double-semicolon in import statements

Jonathan Gibbons jonathan.gibbons at oracle.com
Fri Aug 2 14:04:36 PDT 2013


True,

FWIW, if we change javac such that the set of programs accepted by javac 
is changed, we have an process (currently Oracle internal) to get 
approval for such a change.   So, we would not simply change javac on a 
whim to meet the spec; we would at least have other eyes looking at the 
behavioral change to determine if it is "acceptable".

-- Jon


On 08/02/2013 02:00 PM, John Spicer wrote:
>
> On Aug 2, 2013, at 4:45 PM, Jonathan Gibbons 
> <jonathan.gibbons at oracle.com <mailto: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 
>>> <mailto:jhs at edg.com>> wrote:
>>>
>>>
>>>     On Aug 2, 2013, at 12:57 PM, Alex Buckley
>>>     <alex.buckley at oracle.com <mailto: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/9a7122fc/attachment.html 


More information about the compiler-dev mailing list