| Summary: | Calling an enum constructor with a lambda as parameter crashes the IDE if you forget to seperate the constants with a comma | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Marc Herschel <marc> |
| Component: | Core | Assignee: | Stephan Herrmann <stephan.herrmann> |
| Status: | VERIFIED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | daniel_megert, gayanper, manoj.palat, stephan.herrmann |
| Version: | 4.14 | ||
| Target Milestone: | 4.20 M3 | ||
| Hardware: | PC | ||
| OS: | Windows 10 | ||
| See Also: |
https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/178943 https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=9b8a5c0547986f822224e81d34bd9e666f4aa243 |
||
| Whiteboard: | |||
| Bug Depends on: | 539685 | ||
| Bug Blocks: | |||
For me it does not crash but just takes long (around 5s). ENTRY org.eclipse.ui.monitoring 4 0 2019-12-21 10:33:54.235 !MESSAGE UI freeze of 5.1s at 10:33:49.120 !SUBENTRY 1 org.eclipse.ui.monitoring 1 0 2019-12-21 10:33:54.235 !MESSAGE Sample at 10:33:50.452 (+1.332s) Thread 'main' tid=1 (RUNNABLE) !STACK 0 Stack Trace at org.eclipse.jdt.internal.compiler.parser.Scanner.<init>(Scanner.java:186) at org.eclipse.jdt.internal.compiler.parser.Scanner.<init>(Scanner.java:317) at org.eclipse.jdt.internal.compiler.parser.AbstractCommentParser.<init>(AbstractCommentParser.java:118) at org.eclipse.jdt.internal.compiler.parser.JavadocParser.<init>(JavadocParser.java:71) at org.eclipse.jdt.internal.codeassist.complete.CompletionJavadocParser.<init>(CompletionJavadocParser.java:61) at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.createJavadocParser(CompletionParser.java:5762) at org.eclipse.jdt.internal.compiler.parser.Parser.<init>(Parser.java:990) at org.eclipse.jdt.internal.codeassist.impl.AssistParser.<init>(AssistParser.java:135) at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.<init>(CompletionParser.java:191) at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.createSnapShotParser(CompletionParser.java:5566) at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.updateRecoveryState(CompletionParser.java:5723) at org.eclipse.jdt.internal.compiler.parser.Parser.resumeOnSyntaxError(Parser.java:13363) at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.resumeOnSyntaxError(CompletionParser.java:5607) at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:11943) at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:12289) at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:12246) at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse(Parser.java:10654) at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.dietParse(CompletionParser.java:5100) at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:2052) at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:136) at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:366) at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:356) at org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer.internalComputeCompletionProposals(JavaCompletionProposalComputer.java:258) at org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer.computeCompletionProposals(JavaCompletionProposalComputer.java:220) at org.eclipse.jdt.internal.ui.text.java.JavaTypeCompletionProposalComputer.computeCompletionProposals(JavaTypeCompletionProposalComputer.java:66) at org.eclipse.jdt.internal.ui.text.java.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:345) at org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:340) at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.collectProposals(ContentAssistProcessor.java:334) at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:291) at org.eclipse.jface.text.contentassist.ContentAssistant$2.lambda$0(ContentAssistant.java:2015) at org.eclipse.jface.text.contentassist.ContentAssistant$2$$Lambda$777/0x00000008016d2840.accept(Unknown Source) at java.base@14-ea/java.util.Collections$SingletonSet.forEach(Collections.java:4872) at org.eclipse.jface.text.contentassist.ContentAssistant$2.run(ContentAssistant.java:2014) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:2011) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:578) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.lambda$0(CompletionProposalPopup.java:508) at org.eclipse.jface.text.contentassist.CompletionProposalPopup$$Lambda$776/0x00000008016d3040.run(Unknown Source) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:72) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:503) at org.eclipse.jface.text.contentassist.ContentAssistant$AutoAssistListener.lambda$0(ContentAssistant.java:380) at org.eclipse.jface.text.contentassist.ContentAssistant$AutoAssistListener$$Lambda$774/0x00000008016d4c40.run(Unknown Source) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:185) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3963) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3590) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1160) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1049) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:660) at org.eclipse.ui.internal.Workbench$$Lambda$140/0x0000000800e2d440.run(Unknown Source) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:559) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:154) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:150) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) at java.base@14-ea/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base@14-ea/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base@14-ea/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base@14-ea/java.lang.reflect.Method.invoke(Method.java:564) at app//org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:657) at app//org.eclipse.equinox.launcher.Main.basicRun(Main.java:594) at app//org.eclipse.equinox.launcher.Main.run(Main.java:1465) at app//org.eclipse.equinox.launcher.Main.main(Main.java:1438) *** This bug has been marked as a duplicate of bug 530556 *** This bug is *not* fixed by the fix for bug 530556. But on top of bug 539685 the freeze no longer occurs. At that point we simply get no proposals. I'll give it a quick try, if this can be improved still, but I'm not sure we can really handle this without the ')' to close the lambda at least. *** This bug has been marked as a duplicate of bug 539685 *** New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/178943 (In reply to Eclipse Genie from comment #3) > New Gerrit change created: > https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/178943 OK, bug 539685 fixes the freeze, but here's an additional fix to produce useful proposals indeed. The missing ')' was already synthesized during recovery, just incomplete source positions prevented us from detecting the close of the lambda. With the additional change in CompletionEngine, completion inside an expression lambda finally knows the expected type! :) (see the test changes for illustration). Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/178943 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=9b8a5c0547986f822224e81d34bd9e666f4aa243 *** Bug 543617 has been marked as a duplicate of this bug. *** Verified for 4.20 M3 Version: 2021-06 (4.20)Build id: I20210518-0850 |
To reproduce it try this: - Create a class with this content ====================================================== import java.util.function.Function; public class LambdaCrash { public enum Problem { ONE(s -> s.trim()) ; private final Function<String, String> function; private Problem(Function<String, String> function) { this.function = function; } } } ====================================================== Add a second enum constant like this but don't add the comma seperating them: public enum Problem { ONE(s -> s.trim()) TWO(k -> k. ; As soon as you enter the dot the IDE freezes and will not recover again. This is really annoying if you forget the comma seperator as you have to kill Eclipse first and then restart it.