Community
Participate
Working Groups
Although this problem report is marked as being from recommenders.subwords, i believe this to be a JDT problem. Please reassign if this is wrong. The method QualifiedNameReference.optimizedBooleanConstant() acesses this.resolvedType.id (line 913), however either resolvedType or resolvedType.id is null in this report. Checking the rest of the class, resolvedType.id is never checked for null, whereas access to resolvedType is null-safe most of the time. Besides the access above, there is also QualifiedNameReference.generateCode(BlockScope, CodeStream, boolean) (line 396) where that field can be returned through the method postConversionType() and is then used again to access the field id. Would a few simple null checks suffice here? The following incident was reported via the automated error reporting: code: 1 plugin: org.eclipse.recommenders.subwords.rcp_2.2.0.v20150609-1848 message: Exception during code completion fingerprint: 8cc2e285 exception class: java.lang.NullPointerException exception message: - number of children: 0 java.lang.NullPointerException: null at org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference.optimizedBooleanConstant(QualifiedNameReference.java:913) at org.eclipse.jdt.internal.compiler.ast.WhileStatement.doesNotCompleteNormally(WhileStatement.java:295) at org.eclipse.jdt.internal.compiler.ast.Block.doesNotCompleteNormally(Block.java:158) at org.eclipse.jdt.internal.compiler.ast.LambdaExpression.resolveType(LambdaExpression.java:434) at org.eclipse.jdt.internal.compiler.ast.LambdaExpression.cachedResolvedCopy(LambdaExpression.java:855) at org.eclipse.jdt.internal.compiler.ast.LambdaExpression.isCompatibleWith(LambdaExpression.java:783) at org.eclipse.jdt.internal.compiler.lookup.PolyTypeBinding.isCompatibleWith(PolyTypeBinding.java:37) at org.eclipse.jdt.internal.compiler.lookup.Scope.parameterCompatibilityLevel(Scope.java:4760) at org.eclipse.jdt.internal.compiler.lookup.Scope.parameterCompatibilityLevel(Scope.java:4727) at org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:768) at org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:700) at org.eclipse.jdt.internal.compiler.lookup.Scope.getConstructor0(Scope.java:2362) at org.eclipse.jdt.internal.compiler.lookup.Scope.getConstructor(Scope.java:2325) at org.eclipse.jdt.internal.compiler.ast.Statement.findConstructorBinding(Statement.java:430) at org.eclipse.jdt.internal.compiler.ast.AllocationExpression.resolveType(AllocationExpression.java:465) at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:1020) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:641) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:309) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:551) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1188) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1301) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:590) at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:1923) at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:131) at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:357) at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:345) at org.eclipse.recommenders.internal.subwords.rcp.SubwordsSessionProcessor.initializeContext(SubwordsSessionProcessor.java:116) at org.eclipse.recommenders.completion.rcp.processable.IntelligentCompletionProposalComputer.fireInitializeContext(IntelligentCompletionProposalComputer.java:243) at org.eclipse.recommenders.completion.rcp.processable.IntelligentCompletionProposalComputer.computeCompletionProposals(IntelligentCompletionProposalComputer.java:135) at org.eclipse.jdt.internal.ui.text.java.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:333) at org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:337) at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.collectProposals(ContentAssistProcessor.java:322) at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:279) at org.eclipse.jface.text.contentassist.ContentAssistant$5.run(ContentAssistant.java:1904) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1902) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:573) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:570) at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:505) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:499) at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1720) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:180) at org.eclipse.ui.texteditor.ContentAssistAction$1.run(ContentAssistAction.java:82) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.ui.texteditor.ContentAssistAction.run(ContentAssistAction.java:80) at org.eclipse.jface.action.Action.runWithEvent(Action.java:473) at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:122) at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90) at sun.reflect.GeneratedMethodAccessor57.invoke(null:-1) at sun.reflect.DelegatingMethodAccessorImpl.invoke(null:-1) at java.lang.reflect.Method.invoke(null:-1) at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56) at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:252) at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:234) at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132) at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152) at org.eclipse.core.commands.Command.executeWithChecks(Command.java:493) at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:486) at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210) at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:286) at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:507) at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:558) at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:378) at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.access$0(KeyBindingDispatcher.java:324) at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:86) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1266) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1112) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1137) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1122) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1164) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1160) at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1581) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4781) at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:343) at org.eclipse.swt.widgets.Control.windowProc(Control.java:4662) at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:339) at org.eclipse.swt.widgets.Display.windowProc(Display.java:5050) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(OS.java:-2) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3767) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235) at sun.reflect.NativeMethodAccessorImpl.invoke0(null:-2) at sun.reflect.NativeMethodAccessorImpl.invoke(null:-1) at sun.reflect.DelegatingMethodAccessorImpl.invoke(null:-1) at java.lang.reflect.Method.invoke(null:-1) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608) at org.eclipse.equinox.launcher.Main.run(Main.java:1515) General Information: reported-by: anonymous-id: a0f6992c-b74f-47c5-9de4-f0bdb2d355eb eclipse-build-id: 4.5.0.I20150603-2000 eclipse-product: org.eclipse.epp.package.jee.product operating system: Windows8 6.2.0 (x86_64) - win32 jre-version: 1.8.0_45-b15 The following plug-ins were present on the execution stack (*): 1. org.eclipse.core.commands_3.7.0.v20150422-0725 2. org.eclipse.core.databinding.observable_1.5.0.v20150422-0725 3. org.eclipse.core.databinding_1.5.0.v20150422-0725 4. org.eclipse.core.runtime_3.11.0.v20150405-1723 5. org.eclipse.e4.core.commands_0.11.0.v20150422-0725 6. org.eclipse.e4.core.contexts_1.4.0.v20150421-2214 7. org.eclipse.e4.core.di_1.5.0.v20150421-2214 8. org.eclipse.e4.ui.bindings_0.11.0.v20150422-0725 9. org.eclipse.e4.ui.workbench_1.3.0.v20150531-1948 10. org.eclipse.e4.ui.workbench.swt_0.13.0.v20150504-0621 11. org.eclipse.equinox.app_1.3.300.v20150423-1356 12. org.eclipse.equinox.launcher_1.3.100.v20150511-1540 13. org.eclipse.jdt_3.11.0.v20150603-2000 14. org.eclipse.jdt.core_3.11.0.v20150602-1242 15. org.eclipse.jdt.ui_3.11.0.v20150527-0925 16. org.eclipse.jface_3.11.0.v20150602-1400 17. org.eclipse.jface.text_3.10.0.v20150603-1752 18. org.eclipse.recommenders.completion.rcp_2.2.0.v20150609-1848 19. org.eclipse.recommenders.subwords.rcp_2.2.0.v20150609-1848 20. org.eclipse.swt_3.104.0.v20150528-0211 21. org.eclipse.ui_3.107.0.v20150507-1945 22. org.eclipse.ui.ide.application_1.1.0.v20150422-0725 23. org.eclipse.ui.ide_3.11.0.v20150510-1749 Please note that: * Messages, stacktraces, and nested status objects may be shortened. * Bug fields like status, resolution, and whiteboard are sent back to reporters. * The list of present bundles and their respective versions was calculated by package naming heuristics. This may or may not reflect reality. Other Resources: * Report: https://dev.eclipse.org/recommenders/committers/confess/#/problems/55bb6339e4b0853a544d4fd8 * Manual: https://dev.eclipse.org/recommenders/community/confess/#/guide Thank you for your assistance. Your friendly error-reports-inbox. This bug was created on behalf of johannes.dorn@codetrails.com.
Probably similar to bug 470232? Normally, we'd really need to figure out, why a null happened in the first place, but during LambdaExpression.isCompatibleWith() it's *probably* OK to expect missing bindings. I wonder if a few methods like this should actually *catch* NPE, rather than cluttering methods which never before saw nulls with null checks that have an empty else ... Looking at this frame: at org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:768) we're probably about to report an error anyway.
Moving out, hadn't looked at it
*** Bug 506153 has been marked as a duplicate of this bug. ***
Moving out of 4.7
Bulk move out of 4.9
This problem makes some things unclickable by holding ctrl and clicking !ENTRY org.eclipse.jface.text 4 0 2020-01-14 15:01:06.281 !MESSAGE Unexpected runtime error while computing a text hover !STACK 0 java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference.optimizedBooleanConstant(QualifiedNameReference.java:931) at org.eclipse.jdt.internal.compiler.ast.WhileStatement.doesNotCompleteNormally(WhileStatement.java:309) at org.eclipse.jdt.internal.compiler.ast.Block.doesNotCompleteNormally(Block.java:168) at org.eclipse.jdt.internal.compiler.ast.LambdaExpression.resolveType(LambdaExpression.java:463) at org.eclipse.jdt.internal.compiler.ast.LambdaExpression.cachedResolvedCopy(LambdaExpression.java:974) at org.eclipse.jdt.internal.compiler.ast.LambdaExpression.internalIsCompatibleWith(LambdaExpression.java:889) at org.eclipse.jdt.internal.compiler.ast.LambdaExpression.isCompatibleWith(LambdaExpression.java:880) at org.eclipse.jdt.internal.compiler.lookup.PolyTypeBinding.isCompatibleWith(PolyTypeBinding.java:43) at org.eclipse.jdt.internal.compiler.lookup.Scope.parameterCompatibilityLevel(Scope.java:4957) at org.eclipse.jdt.internal.compiler.lookup.Scope.parameterCompatibilityLevel(Scope.java:4921) at org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:867) at org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:794) at org.eclipse.jdt.internal.compiler.lookup.Scope.getConstructor0(Scope.java:2474) at org.eclipse.jdt.internal.compiler.lookup.Scope.getConstructor(Scope.java:2437) at org.eclipse.jdt.internal.compiler.ast.Statement.findConstructorBinding(Statement.java:504) at org.eclipse.jdt.internal.compiler.ast.AllocationExpression.resolveType(AllocationExpression.java:491) at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:691) at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:1066) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:641) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:316) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:551) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1293) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1418) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:666) at org.eclipse.jdt.internal.core.hierarchy.HierarchyResolver.resolve(HierarchyResolver.java:875) at org.eclipse.jdt.internal.core.hierarchy.HierarchyResolver.resolve(HierarchyResolver.java:672) at org.eclipse.jdt.internal.core.hierarchy.HierarchyBuilder.buildSupertypes(HierarchyBuilder.java:129) at org.eclipse.jdt.internal.core.hierarchy.IndexBasedHierarchyBuilder.build(IndexBasedHierarchyBuilder.java:170) at org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.compute(TypeHierarchy.java:323) at org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.refresh(TypeHierarchy.java:1319) at org.eclipse.jdt.internal.core.CreateTypeHierarchyOperation.executeOperation(CreateTypeHierarchyOperation.java:94) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:736) at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:802) at org.eclipse.jdt.internal.core.SourceType.newSupertypeHierarchy(SourceType.java:795) at org.eclipse.jdt.internal.core.SourceType.newSupertypeHierarchy(SourceType.java:746) at org.eclipse.jdt.internal.corext.util.SuperTypeHierarchyCache.getTypeHierarchy(SuperTypeHierarchyCache.java:144) at org.eclipse.jdt.internal.corext.util.SuperTypeHierarchyCache.getTypeHierarchy(SuperTypeHierarchyCache.java:96) at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2$JavadocLookup.getTypeHierarchy(JavadocContentAccess2.java:464) at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2$JavadocLookup.getInheritedDescription(JavadocContentAccess2.java:418) at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2$JavadocLookup.getInheritedMainDescription(JavadocContentAccess2.java:312) at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.elementToHTML(JavadocContentAccess2.java:1049) at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.toHTML(JavadocContentAccess2.java:870) at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.javadoc2HTML(JavadocContentAccess2.java:788) at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.getHTMLContentFromSource(JavadocContentAccess2.java:666) at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.getHTMLContent(JavadocContentAccess2.java:538) at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo(JavadocHover.java:760) at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.internalGetHoverInfo(JavadocHover.java:678) at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo2(JavadocHover.java:670) at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:165) at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:132) at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo2(JavaEditorTextHoverProxy.java:89) at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:169)
(In reply to Stephen Crowley from comment #6) > This problem makes some things unclickable by holding ctrl and clicking You could tremendously help us by providing a reproducing project.
Is there any other way I could help? I can't share the project code publicly. How do I checkout the source to the module throwing the NPE (which is the JDT package) and build it and plug it into my current eclipse instance?
(In reply to Stephen Crowley from comment #8) > Is there any other way I could help? I can't share the project code > publicly. How do I checkout the source to the module throwing the NPE (which > is the JDT package) and build it and plug it into my current eclipse > instance? Thanks for the offer. Please have a look at https://wiki.eclipse.org/JDT_Code_Setup_Using_Oomph This will give you a JDT development environment (Eclipse installation & workspace). We are mainly interested in only one project: org.eclipse.jdt.core aka JDT/Core. Then in your main Eclipse, edit eclipse.ini to enable remote debugging, s.t. like -vmargs -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n -vmargs must be the last section in eclipse.ini. Launch this Eclipse... ... then in the JDT environment run a new debug session as Remote Java Application, see https://help.eclipse.org/2019-12/topic/org.eclipse.jdt.doc.user/tasks/task-remotejava_launch_config.htm
I managed to fix it by checking for the NPE diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java index cec0657..8ef4bc3 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java @@ -928,6 +928,9 @@ @Override public Constant optimizedBooleanConstant() { + if ( this.resolvedType == null ) { + return Constant.NotAConstant; + } switch (this.resolvedType.id) { case T_boolean : case T_JavaLangBoolean :
(In reply to Stephen Crowley from comment #10) > I managed to fix it by checking for the NPE > > diff --git > a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ > QualifiedNameReference.java > b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ > QualifiedNameReference.java > index cec0657..8ef4bc3 100644 > --- > a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ > QualifiedNameReference.java > +++ > b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ > QualifiedNameReference.java > @@ -928,6 +928,9 @@ > > @Override > public Constant optimizedBooleanConstant() { > + if ( this.resolvedType == null ) { > + return Constant.NotAConstant; > + } > switch (this.resolvedType.id) { > case T_boolean : > case T_JavaLangBoolean : Congrats, so you seem to have your dev-env up and running, and found the location. A simply null check is, however, in many cases not the solution but just some band-aid for this particular use case. So, I would be interested to learn about the elements that are currently being compiled. Can you guess any reason, why that qualified name doesn't have a resolved type? Normally, such null would signal a bug elsewhere in the compiler, but here we seem to be in the situation that speculative analysis of a lambda (before its type is known) provides a suitable "excuse" for abnormal situation. Would you now be in a position to create a reproducing example, by reconstructing the same program structure that you see in the debugger in a demo project? If so, I would love to play with it to see if I can find a safer solution.
Created attachment 281535 [details] something to do with this.body.doesNotCompleteNormally() on a Lambda expression? I think it has something to do with this.body.doesNotCompleteNormally(); I added a "return;" to the end of the lambda expression triggering the NPE and now the exception does not occur... --- Method Scope --- locals: startIndex = 0 isConstructorCall = false initializedField = null lastVisibleFieldID = -1 referenceContext = public @Override void start() { new Thread(() -> { while (eventSequence.running) { try { double t = config.getTime(tick()); if ((t >= MarketMaker.closeTime)) { if ((! stopped)) { try { System.out.println("Stopping..."); doStuff(); Thread.sleep(250); System.out.println("Simulation finished"); } catch (InterruptedException e) { e.printStackTrace(); } mainFrame.simulator.stop(); stopped = true; } } } catch (IOException e) { e.printStackTrace(); } } }).start(); }
I meant to say , putting "return;" after the end of the while statement inside the lambda expression, and before the end of the lambda expression, seems to have cured it
(In reply to Stephen Crowley from comment #12) > > --- Method Scope --- > locals: > startIndex = 0 > isConstructorCall = false > initializedField = null > lastVisibleFieldID = -1 > referenceContext = public @Override void start() { > new Thread(() -> { > while (eventSequence.running) { > try > { > double t = config.getTime(tick()); > if ((t >= MarketMaker.closeTime)) > { > if ((! stopped)) > { > try > { > System.out.println("Stopping..."); > doStuff(); > Thread.sleep(250); > System.out.println("Simulation finished"); > } > catch (InterruptedException e) > { > e.printStackTrace(); > } > mainFrame.simulator.stop(); > stopped = true; > } > } > } > catch (IOException e) > { > e.printStackTrace(); > } > } > }).start(); > } Bingo, this method suffices to reproduce the NPE. From here I can start looking for the best possible fix.
*** Bug 559038 has been marked as a duplicate of this bug. ***
*** Bug 496339 has been marked as a duplicate of this bug. ***
New Gerrit change created: https://git.eclipse.org/r/163483
(In reply to Eclipse Genie from comment #17) > New Gerrit change created: https://git.eclipse.org/r/163483 As usual I'm reluctant to mechanically adding null checks. In this case the unexpected null can be explained as follows: In my reduced version of the example, the reference eventSequence.running is unresolved, i.e., QualifiedNameReference.resolvedType is null indeed. While resolve errors will set ignoreFurtherInvestigation to true preventing NPE in downstream compilation phases, this doesn't help for cases like this, where the null deference happens in the same phase. To codify this analysis I'm not checking resolvedType != null, but binding.isValidBinding(). Theoretically, also binding could be null, but that would have a different cause and hence that's something I still want to escalate, should it ever happen. (In reply to Stephen Crowley from comment #13) > I meant to say , putting "return;" after the end of the while statement > inside the lambda expression, and before the end of the lambda expression, > seems to have cured it yes, this works around the issue, because with that return as the last statement in the block, we don't need to ask WhileStatement.doesNotCompleteNormally(). Still, I obviously don't know what exactly caused resolvedType to be null in the original example. @Stephen, once you added the 'return;' did you see any compile errors in this method? Which? Anyway the fix is simple and effective, hence proposing for RC1.
Looked at the patch and looks good to me. +1 for RC1.
Gerrit change https://git.eclipse.org/r/163483 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=b6f11a1732f11ce5a45b023441a4b452ef46f84f
(In reply to Jay Arthanareeswaran from comment #19) > Looked at the patch and looks good to me. > > +1 for RC1. thanks (In reply to Eclipse Genie from comment #20) > Gerrit change https://git.eclipse.org/r/163483 was merged to [master]. > Commit: > http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/ > ?id=b6f11a1732f11ce5a45b023441a4b452ef46f84f released to master for 4.16 RC1
Verified for 4.16 RC1 using build I20200524-1800.
(In reply to Jay Arthanareeswaran from comment #22) > Verified for 4.16 RC1 using build I20200524-1800. Meant I20200527-1800.
I bumped into this issue as well (JDT from 2020-04-27). It looks like an example to reproduce was found in the end, but I'll add mine here just for reference. pom.xml: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>test</groupId> <artifactId>test-npe</artifactId> <version>0.0.1-SNAPSHOT</version> <properties> <java.version>11</java.version> <maven.compiler.source>${java.version}</maven.compiler.source> <maven.compiler.target>${java.version}</maven.compiler.target> </properties> <dependencies> <dependency> <artifactId>reactor-netty</artifactId> <groupId>io.projectreactor.netty</groupId> <version>0.9.7.RELEASE</version> </dependency> </dependencies> </project> Main.java: import java.util.Iterator; import java.util.Map.Entry; import io.netty.channel.ChannelHandler; import io.netty.handler.ssl.SslMasterKeyHandler; import reactor.netty.channel.BootstrapHandlers; import reactor.netty.tcp.TcpClient; public class Main { public static void main(String[] args) { TcpClient tcpClient = TcpClient.create() .doOnConnect(b -> { BootstrapHandlers.updateConfiguration(b, "test", (co, ch) -> { Iterator<Entry<String, ChannelHandler>> iterator = ch.pipeline().iterator(); while (iterator.) { } }); }); } } The NPE will happen by triggering autocomplete after "iterator.".
(In reply to Pierre-Yves B. from comment #24) > I bumped into this issue as well (JDT from 2020-04-27). It looks like an > example to reproduce was found in the end, Indeed, see https://git.eclipse.org/r/#/c/163483/1/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest8.java > but I'll add mine here just for reference. > [...] > The NPE will happen by triggering autocomplete after "iterator.". Thanks, does the NPE still occur with recent builds?
(In reply to Stephan Herrmann from comment #25) > Thanks, does the NPE still occur with recent builds? For some reason I haven't received any new builds for a while. The JDT version I have installed is 3.18.450.v20200427-1819, but on the nightly update site (https://download.eclipse.org/eclipse/updates/4.16-I-builds/) I can see that 3.18.400.v20200602-1800 is the latest. It seems that the version was mistakenly bumped to 3.18.450 at some point than brought back to 3.18.400 later on, Eclipse therefore thinks I'm still on most recent. I tried uninstalling JDT to reinstall it, unfortunately, that fails, Eclipse claims that other products within the IDE depend on it. Unless you have a magical trick to sort things out, seems like I won't be able to beta test anything new and am forced to stick with older 3.18.450.v20200427-1819 until the version is bumped again.
(In reply to Pierre-Yves B. from comment #26) > (In reply to Stephan Herrmann from comment #25) > > Thanks, does the NPE still occur with recent builds? > > For some reason I haven't received any new builds for a while. The JDT > version I have installed is 3.18.450.v20200427-1819, but on the nightly > update site (https://download.eclipse.org/eclipse/updates/4.16-I-builds/) I > can see that 3.18.400.v20200602-1800 is the latest. It seems that the > version was mistakenly bumped to 3.18.450 at some point than brought back to > 3.18.400 later on, Eclipse therefore thinks I'm still on most recent. > > I tried uninstalling JDT to reinstall it, unfortunately, that fails, Eclipse > claims that other products within the IDE depend on it. > > Unless you have a magical trick to sort things out, seems like I won't be > able to beta test anything new and am forced to stick with older > 3.18.450.v20200427-1819 until the version is bumped again. Outch, this is unfortunate. I can see that on 2020-04-27 the JDT feature [1] was accidentally bumped up to 3.18.450 (this was intended for the BETA_JAVA15 branch). Right the next day, this change was reverted. Apparently, you were 'lucky' to update on the single buggy day. Still, there should be different ways to get you out of that ditch. :) Firstly, have you tried explicitly installing Eclipse SDK from the I-builds repo you mention? P2 should recognize this as a downgrade, but perhaps after waiting for the remediation process (where it counts alternative attempts 1 through 15) it should give you "downgrading" to the selected version as an option. Next, and only if the previous does not work, got to About > Installation Details > Installation History. Select a date prior to 2020-04-27 and click Revert. I'm not sure if you need to restart at that point. One way or other it should put you into a position where normal updating works again. Last, if all fails, get yourself a new Eclipse installation, it's for free :) [1] https://git.eclipse.org/c/jdt/eclipse.jdt.git/tree/org.eclipse.jdt-feature/feature.xml
(In reply to Stephan Herrmann from comment #27 > Still, there should be different ways to get you out of that ditch. :) > > Firstly, have you tried explicitly installing Eclipse SDK from the I-builds > repo you mention? P2 should recognize this as a downgrade, but perhaps after > waiting for the remediation process (where it counts alternative attempts 1 > through 15) it should give you "downgrading" to the selected version as an > option. Unfortunately this does not seem to work. When I select "Eclipse SDK", P2 suggests installing it but removing all of "Eclipse IDE for Java Developers", "Eclipse Java Development Tools", "Eclipse Platform" and "Eclipse RCP". Trying to progress any further fails with conflicts anyway. > Next, and only if the previous does not work, got to About > Installation > Details > Installation History. Select a date prior to 2020-04-27 and click > Revert. I'm not sure if you need to restart at that point. One way or other > it should put you into a position where normal updating works again. This did work, thanks! I occasionally use this revert installation feature but did not realise it kept entries from several months ago. I could literally go back to my IDE back in mid-2019 if I wanted to! My turn to be "useful": I've now installed the latest JDT now (Eclipse Java Development Tools 3.18.400.v20200603-0600), but unfortunately I'm still seeing the same error with the example I shared previously: java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference.optimizedBooleanConstant(QualifiedNameReference.java:931) at org.eclipse.jdt.internal.compiler.ast.WhileStatement.doesNotCompleteNormally(WhileStatement.java:313) at org.eclipse.jdt.internal.compiler.ast.Block.doesNotCompleteNormally(Block.java:174) at org.eclipse.jdt.internal.compiler.ast.LambdaExpression.analyzeShape(LambdaExpression.java:839) at org.eclipse.jdt.internal.compiler.ast.LambdaExpression.isPotentiallyCompatibleWith(LambdaExpression.java:862) at org.eclipse.jdt.internal.compiler.lookup.PolyTypeBinding.isPotentiallyCompatibleWith(PolyTypeBinding.java:48) at org.eclipse.jdt.internal.compiler.lookup.Scope.parameterCompatibilityLevel(Scope.java:5066) at org.eclipse.jdt.internal.compiler.lookup.Scope.parameterCompatibilityLevel(Scope.java:5032) at org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:871) at org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:798) at org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod0(Scope.java:1756) at org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod(Scope.java:1657) at org.eclipse.jdt.internal.compiler.lookup.Scope.getMethod(Scope.java:3046) at org.eclipse.jdt.internal.compiler.ast.MessageSend.findMethodBinding(MessageSend.java:1017) at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:838) at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:1082) at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:131) at org.eclipse.jdt.internal.compiler.ast.LambdaExpression.resolveType(LambdaExpression.java:458) at org.eclipse.jdt.internal.compiler.ast.ASTNode.resolvePolyExpressionArguments(ASTNode.java:718) at org.eclipse.jdt.internal.compiler.ast.MessageSend.findMethodBinding(MessageSend.java:1024) at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:838) at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:409) at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:270) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:660) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:361) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:569) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1490) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1615) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:667) at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:2280) 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:257) at org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer.computeCompletionProposals(JavaCompletionProposalComputer.java:219) 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:333) at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:289) at org.eclipse.jface.text.contentassist.AsyncCompletionProposalPopup.lambda$10(AsyncCompletionProposalPopup.java:351) at org.eclipse.jface.text.contentassist.AsyncCompletionProposalPopup$$Lambda$993/00000000D3371A20.run(Unknown Source) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) at org.eclipse.jface.text.contentassist.AsyncCompletionProposalPopup.lambda$9(AsyncCompletionProposalPopup.java:350) at org.eclipse.jface.text.contentassist.AsyncCompletionProposalPopup$$Lambda$991/00000000D4B14A20.get(Unknown Source) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1764) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1756) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)