8301374: NullPointerException in MemberEnter.checkReceiver

Reviewed-by: jlahoda
This commit is contained in:
Vicente Romero 2023-02-14 18:59:37 +00:00
parent 5b2d430131
commit ca73f7e80f
3 changed files with 16 additions and 2 deletions
src/jdk.compiler/share/classes/com/sun/tools/javac/parser
test/langtools/tools/javac/lambda/8131742

@ -3723,6 +3723,11 @@ public class JavacParser implements Parser {
JCExpression pn = qualident(false);
if (pn.hasTag(Tag.IDENT) && ((JCIdent)pn).name != names._this) {
name = ((JCIdent)pn).name;
} else if (lambdaParameter && type == null) {
// we have a lambda parameter that is not an identifier this is a syntax error
type = pn;
name = names.empty;
reportSyntaxError(pos, Errors.Expected(IDENTIFIER));
} else {
if (allowThisIdent) {
if ((mods.flags & Flags.VARARGS) != 0) {

@ -1,9 +1,17 @@
/*
* @test /nodynamiccopyright/
* @bug 8131742
* @bug 8131742 8301374
* @summary Syntactically meaningless code accepted by javac
* @compile/fail/ref=T8131742.out -XDrawDiagnostics T8131742.java
*/
class T8131742 {
static Runnable r = (__GAR BAGE__.this) -> { };
interface F {
void apply(E e);
}
enum E {
ONE
}
F f = (E.ONE) -> {};
}

@ -1,2 +1,3 @@
T8131742.java:8:39: compiler.err.this.as.identifier
1 error
T8131742.java:16:12: compiler.err.expected: token.identifier
2 errors