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

Bug 346528

Summary: Odd resolution reports for BNC failures
Product: [Eclipse Project] Equinox Reporter: Jeff McAffer <jeffmcaffer>
Component: FrameworkAssignee: Thomas Watson <tjwatson>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.7   
Target Milestone: Juno M1   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
example case that shows the problem
none
patch none

Description Jeff McAffer CLA 2011-05-19 15:11:30 EDT
If you have a fragment that has both Eclipse-PlatformFilter and Bundle-NativeCode headers the framework reports a number of odd resolution problems.  Depending on how/when you run the log output includes entries like 

Missing host Bundle-NativeCode_0.0.0   (happens on first/clean run)
Missing host null_0.0.0     (happens on subsequent runs)

These resolution reports happen when some other problem is logged in a given session.

Some thoughts:
- Given that we have platform filters on these bundles, their BNC should not even be considered.  The bundle is known to not applicable if the filter fails.

- If we do have a BNC failure the report should say something more specific about "no applicable Bundle-NativeCode configuration" or some such

- The reported resolution problems should be consistent from run to run.

I'll try to put together a simple test case to demonstrate the problem and attach it here.
Comment 1 Jeff McAffer CLA 2011-05-19 15:56:43 EDT
Created attachment 196168 [details]
example case that shows the problem

attached is a simple plugin project that has a bnc and platform filter.  When run on a system that does not match (e.g., I ran this on a Mac but the bnc and filter identified windows) the first time you get,

!MESSAGE Bundle bnc.test_1.0.0.qualifier [1] was not resolved.
!SUBENTRY 2 bnc.test 2 0 2011-05-19 15:44:32.739
!MESSAGE Missing host Bundle-NativeCode_0.0.0.

(note the "Bundle-NativeCode" in the last message)

The second time you run (without -clean or clearing the config area) you get

!MESSAGE Bundle bnc.test_1.0.0.qualifier [1] was not resolved.
!SUBENTRY 2 bnc.test 2 0 2011-05-19 15:45:44.752
!MESSAGE Missing host null_0.0.0.

(note the "null" in the last message)

No where in the log output do you get anything talking about the platform filters not matching.

To help in running the project has a .launch file.  You should just be able to run that.

If you then delete the BNC line in the manifest you get a helpful message saying that that the platform filter did not match but...

- that log entry is duplicated
- the log alos contains the somewhat distracting stacktrace as follows

!ENTRY bnc.test 4 0 2011-05-19 15:52:18.181
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: The bundle "bnc.test_1.0.0.qualifier [2]" could not be resolved. Reason: Platform filter did not match: (osgi.os="win32")
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1327)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1311)
	at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:323)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:389)
	at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1130)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)

That trace is not adding any value and likely distracts log readers from the real problems.
Comment 2 Thomas Watson CLA 2011-05-20 15:10:59 EDT
Created attachment 196249 [details]
patch

Thi issue is that the MessageHelper.getResolutionFailureMessage defaults to a HostSpecification for everything other than ImportPackageSpecification and BundleSpecification which is not correct.  This patch handles NativeCodeSpecification and GenericSpecification.

This patch simply fixes this part of the bug.  Nothing is done to consider the Eclipse-PlatformFilter first.  IMO both are valid reasons for the bundle to be unresolved.  Not sure why Eclipse-PlatformFilter would take priority over Bundle-NativeCode.
Comment 3 Thomas Watson CLA 2011-07-01 09:19:52 EDT
Patch released.