changeset 48133:3b1ef48862cf

8185983: Javac should reject TypeArguments on field access expression Reviewed-by: mcimadamore
author vromero
date Mon, 27 Nov 2017 10:40:42 -0500
parents cd2764b618b9
children c1437939b0d8
files src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java test/langtools/tools/javac/T8185983/RejectTypeArgsOnSelectTest.java test/langtools/tools/javac/T8185983/RejectTypeArgsOnSelectTest.out
diffstat 3 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Nov 27 17:04:33 2017 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Nov 27 10:40:42 2017 -0500
@@ -1319,6 +1319,9 @@
                         break loop;
                     case DOT:
                         nextToken();
+                        if (token.kind == TokenKind.IDENTIFIER && typeArgs != null) {
+                            return illegal();
+                        }
                         int oldmode = mode;
                         mode &= ~NOPARAMS;
                         typeArgs = typeArgumentsOpt(EXPR);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/T8185983/RejectTypeArgsOnSelectTest.java	Mon Nov 27 10:40:42 2017 -0500
@@ -0,0 +1,12 @@
+/*
+ * @test  /nodynamiccopyright/
+ * @bug 8185983
+ * @summary Javac should reject TypeArguments on field access expression
+ * @compile/fail/ref=RejectTypeArgsOnSelectTest.out -XDrawDiagnostics RejectTypeArgsOnSelectTest.java
+ */
+
+import java.util.*;
+
+class RejectTypeArgsOnSelectTest {
+    Iterator<RejectTypeArgsOnSelectTest> nullIter = Collections.<RejectTypeArgsOnSelectTest>EMPTY_LIST.iterator();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/T8185983/RejectTypeArgsOnSelectTest.out	Mon Nov 27 10:40:42 2017 -0500
@@ -0,0 +1,2 @@
+RejectTypeArgsOnSelectTest.java:11:104: compiler.err.illegal.start.of.expr
+1 error