Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 578401

Summary: [parser] StackOverflowError with invalid source parsed with kind K_MODULE_INFO
Product: [Eclipse Project] JDT Reporter: Mateusz Matela <mateusz.matela>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 4.22   
Target Milestone: ---   
Hardware: PC   
OS: Windows NT   
Whiteboard:
Attachments:
Description Flags
sample code causing problem
none
log with full stack trace none

Description Mateusz Matela CLA 2022-01-26 18:54:16 EST
Created attachment 287907 [details]
sample code causing problem

Noticed while experimenting with custom preview contents in the formatter settings window. After pasting some invalid code with switch statements (see attached source.java), StackOverflowError occurred.
I'll attach the full logs in a separate file, here's a repeating fragment of the stacktrace:

	at org.eclipse.jdt.internal.compiler.parser.Scanner.disambiguateYieldWithLookAhead(Scanner.java:5227)
	at org.eclipse.jdt.internal.compiler.parser.Scanner.disambiguatedRestrictedIdentifierYield(Scanner.java:5318)
	at org.eclipse.jdt.internal.compiler.parser.Scanner.internalScanIdentifierOrKeyword(Scanner.java:3905)
	at org.eclipse.jdt.internal.compiler.parser.Scanner.scanIdentifierOrKeyword(Scanner.java:3228)
	at org.eclipse.jdt.internal.compiler.parser.Scanner.getNextToken0(Scanner.java:1967)
	at org.eclipse.jdt.internal.compiler.parser.Scanner.getNextToken(Scanner.java:1407)
	at org.eclipse.jdt.internal.compiler.parser.Scanner$VanguardParser.parse(Scanner.java:4899)
	at org.eclipse.jdt.internal.compiler.parser.Scanner$ScanContextDetector.getScanContext(Scanner.java:4985)
	at org.eclipse.jdt.internal.compiler.parser.Scanner.getScanContext(Scanner.java:3030)
	at org.eclipse.jdt.internal.compiler.parser.Scanner.resetTo(Scanner.java:3017)
	at org.eclipse.jdt.internal.compiler.parser.Scanner.resetTo(Scanner.java:2991)
	at org.eclipse.jdt.internal.compiler.parser.Scanner.resetTo(Scanner.java:2988)
	at org.eclipse.jdt.internal.compiler.parser.Scanner.disambiguateYieldWithLookAhead(Scanner.java:5227)

Turns out the formatter was trying to guess what kind of source was pasted into the preview panel so it invoked the parser with different kinds and the error occurred with K_MODULE_INFO.
Comment 1 Mateusz Matela CLA 2022-01-26 18:55:06 EST
Created attachment 287908 [details]
log with full stack trace
Comment 2 Mateusz Matela CLA 2022-01-26 19:20:48 EST

*** This bug has been marked as a duplicate of bug 577220 ***