changeset 48434:7807f935382e datum

use non-final instead of non_final
author vromero
date Fri, 08 Dec 2017 13:43:00 -0500
parents 61ec0ccc1d5b
children e3b7341fd0d4
files src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java src/jdk.compiler/share/classes/com/sun/tools/javac/parser/Tokens.java src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java test/langtools/tools/javac/datum/CheckDatumMembersAccess.java test/langtools/tools/javac/datum/Neg02.java test/langtools/tools/javac/datum/Neg02.out
diffstat 7 files changed, 27 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Dec 07 22:06:34 2017 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Dec 08 13:43:00 2017 -0500
@@ -2797,7 +2797,6 @@
             case STATIC      : flag = Flags.STATIC; break;
             case TRANSIENT   : flag = Flags.TRANSIENT; break;
             case FINAL       : flag = Flags.FINAL; break;
-            case NON_FINAL   : flag = Flags.NON_FINAL; break;
             case ABSTRACT    : flag = Flags.ABSTRACT; break;
             case NATIVE      : flag = Flags.NATIVE; break;
             case VOLATILE    : flag = Flags.VOLATILE; break;
@@ -2806,6 +2805,19 @@
             case MONKEYS_AT  : flag = Flags.ANNOTATION; break;
             case DEFAULT     : checkSourceLevel(Feature.DEFAULT_METHODS); flag = Flags.DEFAULT; break;
             case ERROR       : flag = 0; nextToken(); break;
+            case IDENTIFIER  : {
+                if (token.name() == names.non && peekToken(0, TokenKind.SUB, TokenKind.FINAL)) {
+                    Token tokenSub = S.token(1);
+                    Token tokenFinal = S.token(2);
+                    if (token.endPos == tokenSub.pos && tokenSub.endPos == tokenFinal.pos) {
+                        flag = Flags.NON_FINAL;
+                        nextToken();
+                        nextToken();
+                        break;
+                    }
+                }
+                break loop;
+            }
             default: break loop;
             }
             if ((flags & flag) != 0) error(token.pos, "repeated.modifier");
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/Tokens.java	Thu Dec 07 22:06:34 2017 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/Tokens.java	Fri Dec 08 13:43:00 2017 -0500
@@ -134,7 +134,6 @@
         ENUM("enum", Tag.NAMED),
         EXTENDS("extends"),
         FINAL("final"),
-        NON_FINAL("non_final"),
         FINALLY("finally"),
         FLOAT("float", Tag.NAMED),
         FOR("for"),
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java	Thu Dec 07 22:06:34 2017 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java	Fri Dec 08 13:43:00 2017 -0500
@@ -215,6 +215,7 @@
     public final Name record;
     public final Name where;
     public final Name guard;
+    public final Name non;
 
     public final Name.Table table;
 
@@ -387,6 +388,7 @@
         record = fromString("record");
         where = fromString("where");
         guard = fromString("$guard");
+        non = fromString("non");
     }
 
     protected Name.Table createTable(Options options) {
--- a/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java	Thu Dec 07 22:06:34 2017 +0100
+++ b/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java	Fri Dec 08 13:43:00 2017 -0500
@@ -236,7 +236,6 @@
         // Modifiers keywords
         ABSTRACT(TokenKind.ABSTRACT, XDECL1 | XMODIFIER),  //  abstract
         FINAL(TokenKind.FINAL, XDECL1 | XMODIFIER),  //  final
-        NONFINAL(TokenKind.NON_FINAL, XDECL1 | XMODIFIER),  //  final
         NATIVE(TokenKind.NATIVE, XDECL1 | XMODIFIER),  //  native
         STATIC(TokenKind.STATIC, XDECL1 | XMODIFIER),  //  static
         STRICTFP(TokenKind.STRICTFP, XDECL1 | XMODIFIER),  //  strictfp
--- a/test/langtools/tools/javac/datum/CheckDatumMembersAccess.java	Thu Dec 07 22:06:34 2017 +0100
+++ b/test/langtools/tools/javac/datum/CheckDatumMembersAccess.java	Fri Dec 08 13:43:00 2017 -0500
@@ -43,7 +43,7 @@
 
     abstract record abtractDatum(int AbstractFieldToSearchFor) {}
 
-    record Datum(int AbstractFieldToSearchFor, int newField, non_final int nonFinalField) {}
+    record Datum(int AbstractFieldToSearchFor, int newField, non-final int nonFinalField) {}
 
     public static void main(String args[]) throws Throwable {
         new CheckDatumMembersAccess().run();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/datum/Neg02.java	Fri Dec 08 13:43:00 2017 -0500
@@ -0,0 +1,9 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary smoke negative test for datum classes
+ * @compile/fail/ref=Neg02.out -XDrawDiagnostics Neg02.java
+ */
+
+public class Neg02 {
+    record R(non_final int x);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/datum/Neg02.out	Fri Dec 08 13:43:00 2017 -0500
@@ -0,0 +1,2 @@
+Neg02.java:8:23: compiler.err.expected: token.identifier
+1 error