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

Bug 340508

Summary: NPE in BindingCopies.isUserBinding
Product: [Eclipse Project] e4 Reporter: Thomas Schindl <tom.schindl>
Component: UIAssignee: Paul Webster <pwebster>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jessev, pwebster, remy.suen
Version: unspecified   
Target Milestone: 4.1 M7   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Avoid the init call v01 none

Description Thomas Schindl CLA 2011-03-20 11:02:22 EDT
We are not properly intializing the BindingSystem in a pure e4 application:

org.eclipse.e4.core.di.InjectionException: java.lang.NullPointerException
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:828)
	at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:108)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:310)
	at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:237)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:153)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:90)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:64)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:53)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:231)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:120)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	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:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Caused by: java.lang.NullPointerException
	at org.eclipse.e4.ui.bindings.internal.BindingCopies.isUserBinding(BindingCopies.java:64)
	at org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon.createBinding(BindingProcessingAddon.java:247)
	at org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon.defineBinding(BindingProcessingAddon.java:212)
	at org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon.defineBindingTable(BindingProcessingAddon.java:202)
	at org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon.defineBindingTables(BindingProcessingAddon.java:185)
	at org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon.init(BindingProcessingAddon.java:86)
	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.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	... 23 more
Comment 1 Thomas Schindl CLA 2011-03-20 17:23:42 EDT
... and because we are at it. This class is violating one of the highest design principles we've defined: Singleons and statics are evil!

If there should be only one of this BindingCopies in a running instance I think we should push the thing into the IEclipseContext from the MApplication but we need to get rid of those statics!
Comment 2 Paul Webster CLA 2011-03-20 17:37:58 EDT
Tom, this was a temporary class to get Keys preference page started.

Jesse, I'll try and look at your patch tonight, but we have to get this bug fixed asap ... Please remove the init() calls from within head, and replace them with something like:

list getUserBindings() {
  if (userBindings==null) {
    userBindings = new list;
  }
  return userBindings;
}

PW
Comment 3 Paul Webster CLA 2011-03-20 22:46:07 EDT
Created attachment 191591 [details]
Avoid the init call v01
Comment 4 Paul Webster CLA 2011-03-20 22:47:02 EDT
Released to HEAD
Comment 5 Thomas Schindl CLA 2011-03-21 00:27:38 EDT
Paul, is there a defect to remove this class completely or to get rid of the statics in it?
Comment 6 Paul Webster CLA 2011-03-21 08:45:43 EDT
To remove it completely: bug 335985

PW
Comment 7 Jesse CLA 2011-03-21 10:47:01 EDT
BindingCopies was temporary...and yes I know, it's a VERY bad design decision. It's been completely removed in https://bugs.eclipse.org/bugs/show_bug.cgi?id=335985 but as it stands right now, only the default scheme will work.