Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.5
-
None
-
None
-
Patch
Description
If you have code like these:
def tt
If you want use Autocompletion for the Object tt a NPE occurs:
Exception in thread "AutoAssist Delay" org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException: Cannot invoke method getMethods() on null object)
at org.eclipse.swt.SWT.error(SWT.java:3563)
at org.eclipse.swt.SWT.error(SWT.java:3481)
at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:178)
at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:118)
at org.eclipse.swt.widgets.Display.syncExec(Display.java:4097)
at org.eclipse.jface.text.contentassist.ContentAssistant$AutoAssistListener.showAssist(ContentAssistant.java:343)
at org.eclipse.jface.text.contentassist.ContentAssistant$AutoAssistListener.run(ContentAssistant.java:255)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException: Cannot invoke method getMethods() on null object
at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
at org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:103)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:79)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:66)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:165)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod0(ScriptBytecodeAdapter.java:193)
at org.codehaus.groovy.eclipse.core.types.impl.JavaElementCategoryLookup.mapCategory(JavaElementCategoryLookup.groovy:94)
at org.codehaus.groovy.eclipse.core.types.impl.JavaElementCategoryLookup.this$3$mapCategory(JavaElementCategoryLookup.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:56)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:599)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:903)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:75)
at org.codehaus.groovy.eclipse.core.types.impl.JavaElementCategoryLookup.<init>(JavaElementCategoryLookup.groovy:30)
at org.codehaus.groovy.eclipse.codeassist.completion.GroovyCompletionProcessor.createMemberLookup(GroovyCompletionProcessor.java:195)
at org.codehaus.groovy.eclipse.codeassist.completion.CodeCompletionProcessor.computeCompletionProposals(CodeCompletionProcessor.java:110)
at org.codehaus.groovy.eclipse.editor.contentAssist.ContentAssistProcessorSet.computeCompletionProposals(ContentAssistProcessorSet.java:63)
at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1759)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:478)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:475)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:410)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:404)
at org.eclipse.jface.text.contentassist.ContentAssistant$2.run(ContentAssistant.java:354)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3659)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3296)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
at org.eclipse.equinox.launcher.Main.main(Main.java:1148)
The error occurs at org.codehaus.groovy.eclipse.core.types.impl.JavaElementCategoryLookup.mapCategory(JavaElementCategoryLookup.groovy:94)
There isnt a Null-Check.
If you change
def methods = type.getMethods()
into
def methods = (!type)? []: type.getMethods()
all works fine again.