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

Bug 440154

Summary: NPE thrown in productBuild.xml > generateFeature > NativeCodeSpecificationImpl.isSatisfiedBy(NativeCodeSpecificationImpl.java:88)
Product: [Eclipse Project] PDE Reporter: Andy Thomas-Cramer <thomascramera>
Component: BuildAssignee: pde-build-inbox <pde-build-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: curtis.windatt.public
Version: 4.5   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 435407    
Bug Blocks:    
Attachments:
Description Flags
A sample set of plug-ins with an Ant build calling productBuild.xml
none
IDE log file after running ant build none

Description Andy Thomas-Cramer CLA 2014-07-22 15:09:16 EDT
A NullPointerException is occurring when we attempt to build any of our four RCP products with the Eclipse pdebuild script productBuild.xml:

	<ant antfile="${eclipse.pdebuild.scripts}/productBuild/productBuild.xml" />

I tried building on Windows 8.1, Windows Vista, and Mac OS X 10.7. All resulted in the same NPE.

This appears to be similar to Bug 435407, but initiated differently, and with different lower levels of the stack trace.

Observation: Looking at the code in NativeCodeSpecificationImpl, it looks like the exception would be thrown if null were a member of platformOSAliases. One apparent way that could happen is if null were returned by platformProps[i].get(Constants.FRAMEWORK_OS_NAME), and stuffed by the final else clause without null checking into a singleton collection. 

That said, the property org.osgi.framework.os.name appears to be defined in the IDE, with values that are included in osname.aliases, and we're running ant with "Run in the same JRE as workspace."

=== PROPERTIES ===

From Help>About Eclipse; Installation Details; Configuration:

On Win8.1:    org.osgi.framework.os.name=Windows8
On WinVista:  org.osgi.framework.os.name=WindowsVista
On Mac 10.7:  org.osgi.framework.os.name=MacOSX

=== OUTPUT ===

generateFeature:

BUILD FAILED
F:\perforce\andy_rcp_win\Orion\build.align\buildProduct.xml:390: The following error occurred while executing this line:
C:\eclipse\eclipse-4.4-luna\plugins\org.eclipse.pde.build_3.9.0.v20140415-2029\scripts\productBuild\productBuild.xml:35: The following error occurred while executing this line:
C:\eclipse\eclipse-4.4-luna\plugins\org.eclipse.pde.build_3.9.0.v20140415-2029\scripts\productBuild\productBuild.xml:69: java.lang.NullPointerException

=== LOG ===

The root exception in the Eclipse log is:

...
Caused by: java.lang.NullPointerException
	at org.eclipse.osgi.internal.resolver.NativeCodeSpecificationImpl.isSatisfiedBy(NativeCodeSpecificationImpl.java:88)
	at org.eclipse.osgi.internal.module.ResolverImpl.isResolvable(ResolverImpl.java:285)
	at org.eclipse.osgi.internal.module.ResolverImpl.resolveBundles(ResolverImpl.java:639)
	at org.eclipse.osgi.internal.module.ResolverImpl.resolve(ResolverImpl.java:477)
	at org.eclipse.osgi.internal.resolver.StateImpl.resolve(StateImpl.java:545)
	at org.eclipse.osgi.internal.resolver.StateImpl.resolve(StateImpl.java:605)
	at org.eclipse.pde.internal.build.site.PDEState.resolveState(PDEState.java:482)
	at org.eclipse.pde.internal.build.site.BuildTimeSite.getRegistry(BuildTimeSite.java:155)
	at org.eclipse.pde.internal.build.AbstractScriptGenerator.findFile(AbstractScriptGenerator.java:472)
	at org.eclipse.pde.internal.build.AbstractScriptGenerator.loadProduct(AbstractScriptGenerator.java:439)
	at org.eclipse.pde.internal.build.AbstractScriptGenerator.loadProduct(AbstractScriptGenerator.java:432)
	at org.eclipse.pde.internal.build.FeatureGenerator.initialize(FeatureGenerator.java:284)
	at org.eclipse.pde.internal.build.FeatureGenerator.generate(FeatureGenerator.java:137)
	at org.eclipse.pde.internal.build.tasks.FeatureGeneratorTask.run(FeatureGeneratorTask.java:55)
	at org.eclipse.pde.internal.build.tasks.FeatureGeneratorTask.execute(FeatureGeneratorTask.java:37)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
	at sun.reflect.GeneratedMethodAccessor210.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
	... 44 more
Comment 1 Andy Thomas-Cramer CLA 2014-07-22 15:16:09 EDT
I just noticed bug 427523 offers a potential explanation that would fit our situation. All of our apps include at least one plug-in that has a Bundle-NativeCode in the manifest with multiple osname entries.
Comment 2 Andy Thomas-Cramer CLA 2014-07-22 16:40:45 EDT
This is probably a duplicate of Bug 427523, which itself has been marked a duplicate of Bug 435407. Sorry I didn't see the former.
Comment 3 Andy Thomas-Cramer CLA 2014-10-08 14:39:59 EDT
Created attachment 247728 [details]
A sample set of plug-ins with an Ant build calling productBuild.xml

Still occurs in 4.4.1, despite the fix to Bug 438652. Attached is a small sample application with an ant build. 

The ant build is build.myapp/buildProduct.xml. Modify its first property "my.platform" to point to an Eclipse platform with the delta pack. 

The plugin simple-plugin-with-nativecode is copied from bug 438652, with a modified MANIFEST.MF.

First I built *without* a dependency from myapp to simple-plugin-with-nativecode. The build completed successfully. (Launching the built application doesn't show a UI, but that's a separate matter.)

The build failed when I added the dependency from myapp to "simple-plugin-with-native-code", in myapp's MANIFEST.MF and myapp.product files. 

I'm attaching the IDE's .log file next.

The console showed the following:

Buildfile: F:\andy\java\eclipse\bug 440154\build.myapp\buildProduct.xml

clean:
      [delete] Deleting directory F:\andy\java\eclipse\bug 440154\build.myapp\buildDirectory

refresh:
        [echo] Eclipse refresh starting

build:
       [mkdir] Created dir: F:\andy\java\eclipse\bug 440154\build.myapp\buildDirectory

main:

preBuild:

preSetup:

checkLocalMaps:

getMapFiles:

postSetup:

checkLocalBase:

getBaseComponents:

processRepos:

generateFeature:

fetch:

generateFeature:

BUILD FAILED
F:\andy\java\eclipse\bug 440154\build.myapp\buildProduct.xml:41: The following error occurred while executing this line:
F:\eclipse\eclipse-4-4-luna-SR1\plugins\org.eclipse.pde.build_3.9.0.v20140415-2029\scripts\productBuild\productBuild.xml:39: The following error occurred while executing this line:
F:\eclipse\eclipse-4-4-luna-SR1\plugins\org.eclipse.pde.build_3.9.0.v20140415-2029\scripts\productBuild\productBuild.xml:69: java.lang.NullPointerException

Total time: 670 milliseconds
Comment 4 Andy Thomas-Cramer CLA 2014-10-08 14:42:00 EDT
Created attachment 247729 [details]
IDE log file after running ant build

Note: choose Run As>Ant Build..., then on the "Edit Configuration" dialog, on the JRE tab, choose "Run in the same JRE as the workspace".
Comment 5 Andy Thomas-Cramer CLA 2014-10-10 18:15:20 EDT
Appears to be fixed in 4.4.1 after all as part of Bug 43865.

Comment#3 is incorrect - it does *not* still occur in 4.4.1. I had installed extensions from e4 updates at http://download.eclipse.org/e4/updates/0.16. Two of these overwrite 4.4.1 plug-ins with 4.4.0 versions:
* Eclipse 4 - 3.x bridge
* Eclipse 4 - Model Spy

Without these extensions, the build works correctly, and this defect does not occur.

Marking resolved.