Bug 546097 - [content assist] Content Assist takes very long/aborts
Summary: [content assist] Content Assist takes very long/aborts
Status: VERIFIED DUPLICATE of bug 539685
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.11   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 4.20 M3   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-03 16:40 EDT by Brian Newby CLA
Modified: 2021-05-26 02:44 EDT (History)
5 users (show)

See Also:


Attachments
Here is the thread dump when it locks up. (25.31 KB, text/plain)
2019-04-04 15:00 EDT, Brian Newby CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Newby CLA 2019-04-03 16:40:53 EDT
I have verified that on a Mac and Windows machines that if I create/modify a java class with an enum and lambda, using content assist will crash eclipse.  Here is some sample code:

import java.util.concurrent.Callable;


public class TestClass
{
	public enum TestEnum
	{
		ENUM1(() -> //remove this comment and use content assist ),
		ENUM2(() -> );

		private Callable<Object> callable;

		private TestEnum(Callable<Object> callable)
		{
			this.callable = callable;
		}

	}
}

If you remove "//remove this comment and use content assist" and launch content assist (ctrl+space), eclipse will get in some indefinite loop and consume max cpu.
Comment 1 Dani Megert CLA 2019-04-04 05:39:14 EDT
How does the crash look like? Anything in the .log? Do you have a crash report?

On my machine it does not crash but it takes more than 5 seconds and sometimes an error dialog pops up saying the completion took too long.
Comment 2 Brian Newby CLA 2019-04-04 12:16:31 EDT
It doesn't crash.  I just keeps running.  I have to kill the app manually.  I don't see anything in the logs except when I start the app it prints out some startup info.
Comment 3 Dani Megert CLA 2019-04-04 12:18:34 EDT
(In reply to Brian Newby from comment #2)
> It doesn't crash.
Why did you write it then?
Comment 4 Brian Newby CLA 2019-04-04 13:32:42 EDT
That is my fault I should have said it locks up eclipse to where it is unusable.  Then I have to force kill the application.
Comment 5 Andrey Loskutov CLA 2019-04-04 13:33:51 EDT
(In reply to Brian Newby from comment #4)
> That is my fault I should have said it locks up eclipse to where it is
> unusable.  Then I have to force kill the application.

Instead of killing, please first run jstack and attach the thread dump here.
Comment 6 Brian Newby CLA 2019-04-04 15:00:46 EDT
Created attachment 278149 [details]
Here is the thread dump when it locks up.

I deleted the comment and started content assist after "ENUM1(() -> "
Comment 7 Jay Arthanareeswaran CLA 2019-09-09 00:58:17 EDT
The recovery goes into an infinite loop between Parser#parse() and Parser#resumeOnSyntaxError(). Not sure what it takes to fix but will revisit later.
Comment 8 Stephan Herrmann CLA 2019-09-09 13:34:58 EDT
Enum plus lambda => Parser in infinite loop

Sounds exactly like bug 539685.

*** This bug has been marked as a duplicate of bug 539685 ***
Comment 9 Stephan Herrmann CLA 2021-04-27 17:52:46 EDT
Here's a test demonstrating that we get suitable proposals now: https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=bc061ab235fc554c2c5ab1a0746361f46ed36ffa
Comment 10 Eclipse Genie CLA 2021-04-28 10:40:01 EDT Comment hidden (obsolete)
Comment 11 Jay Arthanareeswaran CLA 2021-05-26 02:44:33 EDT
I can't help but notice the completion is not particularly useful in the following case:

ENUM1(() -> |,
ENUM2(() -> );

However, if I have a trailing ')', then things are much better.

ENUM1(() -> |),
ENUM2(() -> );

The most natural cases below are also working:

ENUM1(() -> |
ENUM1(()-> |)
Comment 12 Jay Arthanareeswaran CLA 2021-05-26 02:44:48 EDT
Verified for 4.20 RC1 with build I20210525-1800