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

Bug 363874

Summary: IEclipseContext not injected in EclipseAdapter
Product: [Eclipse Project] Platform Reporter: Anders Forsell <aforsell1971>
Component: RuntimeAssignee: Oleg Besedin <ob1.eclipse>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: remy.suen
Version: 4.1   
Target Milestone: 4.2 M4   
Hardware: All   
OS: All   
Whiteboard:

Description Anders Forsell CLA 2011-11-15 17:06:11 EST
Build Identifier: 4.2M3

I am trying to use the Adapter service but I get a NPE in EclipseAdapter.lookupAdapterManager()
From the source code in EclipseAdapter I can see that the contextSet method is never called and that probably the constructor should take the IEclipseContext as a parameter to be injected instead.

In E4Application line 477 I can see that the EclipseAdapter is injected using:
		appContext.set(Adapter.class.getName(),
				ContextInjectionFactory.make(EclipseAdapter.class, appContext));



Reproducible: Always
Comment 1 Oleg Besedin CLA 2011-11-16 10:10:27 EST
The contextSet() was the early (pre-annotation) way to inject context, no longer supported. I changed EclipseAdapter to get context as a constructor argument.

Also it turns out that org.eclipse.e4.core.services bundle where this class resides was compiled into Java 1.4 - compatible code removing "@Inject" annotation. That again is a resedue of the early attempts to be Foundation VM compatible. That no longer makes sense as contexts & DI require Java 1.5, so I changed the minimum executable environment of this bundle to 1.5 and updated its version and build properties while I was there.

http://git.eclipse.org/c/platform/eclipse.platform.runtime.git/commit/?id=0d6b2ff6c6b06bbd13e82cd6856f72d4f988ec36
Comment 2 Oleg Besedin CLA 2011-11-16 10:12:24 EST
Anders, could you verify that this fixed the problem for you?
Comment 3 Anders Forsell CLA 2011-11-16 14:54:16 EST
I looked at your checkin and this will fix my problem. I am using milestone builds so I will work around this until 4.2M4.