hg: lambda/lambda/langtools: Fix: generalize parser treatment of keyword as identifiers

bitter_fox bitterfoxc at gmail.com
Sat Jan 12 02:42:29 PST 2013


Hi, Maurizio.

Thank you for your fix.

However there is a new problem. It is about package private enum.
The compiler has to consider it as a declaration of package private enum:

package enum E
{
    ...
}

However the compiler considers it as a declaration of package and makes a
compiler error.

I think the condition expression for PACKAGE ... in
JavacParser#parseCompilationUnit would be such as:

JavacParser.java
@@ -2692,7 +2692,7 @@
             mods = modifiersOpt(true);

         if (token.kind == PACKAGE) {
-            if (peekToken(EXT_IDENTIFIER)) {
+            if (peekToken(EXT_IDENTIFIER) && !(allowPackageModifier &&
peekToken(ENUM))) {
                 seenPackage = true;
                 if (mods != null) {
                     checkNoMods(mods.flags);

or

@@ -2692,7 +2692,7 @@
             mods = modifiersOpt(true);

         if (token.kind == PACKAGE) {
-            if (peekToken(EXT_IDENTIFIER)) {
+            if (peekToken(EXT_IDENTIFIER, DOT) ||
peekToken(EXT_IDENTIFIER, SEMI)) {
                 seenPackage = true;
                 if (mods != null) {
                     checkNoMods(mods.flags);

Regards,
bitter_fox


2013/1/9 <maurizio.cimadamore at oracle.com>

> Changeset: 867db5e69121
> Author:    mcimadamore
> Date:      2013-01-09 11:43 +0100
> URL:
> http://hg.openjdk.java.net/lambda/lambda/langtools/rev/867db5e69121
>
> Fix: generalize parser treatment of keyword as identifiers
>
> ! src/share/classes/com/sun/tools/javac/parser/JavacParser.java
> ! src/share/classes/com/sun/tools/javac/parser/Tokens.java
> ! test/tools/javac/lambda/WarnUnderscoreAsIdent.java
> ! test/tools/javac/lambda/WarnUnderscoreAsIdent.out
>
>
>


More information about the lambda-dev mailing list