Double-semicolon in import statements
John Spicer
jhs at edg.com
Fri Aug 2 10:25:28 PDT 2013
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");
>> }
>> }
>>
More information about the compiler-dev
mailing list