< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java

Print this page
rev 60625 : 8237041: AssertionError in parsing
Summary: Avoid parser crash for deeply nested classes without closing braces, improve error recovery for classes without an opening brace.
Reviewed-by: TBD

*** 442,452 **** } else { log.error(DiagnosticFlag.SYNTAX, diagPos, errorKey); } } S.errPos(pos); ! if (token.pos == errorPos) { //check for a possible infinite loop in parsing: Assert.check(count++ < RECOVERY_THRESHOLD); } else { count = 0; errorPos = token.pos; --- 442,452 ---- } else { log.error(DiagnosticFlag.SYNTAX, diagPos, errorKey); } } S.errPos(pos); ! if (token.pos == errorPos && token.kind != EOF) { //check for a possible infinite loop in parsing: Assert.check(count++ < RECOVERY_THRESHOLD); } else { count = 0; errorPos = token.pos;
*** 4046,4055 **** --- 4046,4057 ---- if (token.pos <= endPosTable.errorEndPos) { // error recovery skip(false, true, false, false); if (token.kind == LBRACE) nextToken(); + else + return List.nil(); } ListBuffer<JCTree> defs = new ListBuffer<>(); while (token.kind != RBRACE && token.kind != EOF) { defs.appendList(classOrInterfaceOrRecordBodyDeclaration(className, isInterface, isRecord)); if (token.pos <= endPosTable.errorEndPos) {
< prev index next >