8131742: Syntactically meaningless code accepted by javac
authormcimadamore
Thu, 30 Jul 2015 13:24:35 +0100
changeset 31941 8a56abc0778a
parent 31940 e3e48135dbfc
child 31942 8ab03f64ccac
8131742: Syntactically meaningless code accepted by javac Summary: Receiver parameter logic for type annotations should be disabled when parsing lambda formals Reviewed-by: jlahoda
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java
langtools/test/tools/javac/lambda/8131742/T8131742.java
langtools/test/tools/javac/lambda/8131742/T8131742.out
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Jul 30 13:21:01 2015 +0100
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Jul 30 13:24:35 2015 +0100
@@ -2985,7 +2985,7 @@
             name = token.name();
             nextToken();
         } else {
-            if (allowThisIdent) {
+            if (allowThisIdent && !lambdaParameter) {
                 JCExpression pn = qualident(false);
                 if (pn.hasTag(Tag.IDENT) && ((JCIdent)pn).name != names._this) {
                     name = ((JCIdent)pn).name;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/8131742/T8131742.java	Thu Jul 30 13:24:35 2015 +0100
@@ -0,0 +1,9 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8131742
+ * @summary Syntactically meaningless code accepted by javac
+ * @compile/fail/ref=T8131742.out -XDrawDiagnostics T8131742.java
+ */
+class T8131742 {
+    static Runnable r = (__GAR BAGE__.this) -> { };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/8131742/T8131742.out	Thu Jul 30 13:24:35 2015 +0100
@@ -0,0 +1,4 @@
+T8131742.java:8:38: compiler.err.expected3: ',', ')', '['
+T8131742.java:8:39: compiler.err.this.as.identifier
+T8131742.java:8:43: compiler.err.expected: ';'
+3 errors