Bug 426445 - unable to load native code in fragment
Summary: unable to load native code in fragment
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Framework (show other bugs)
Version: 3.10.0 Luna   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: Luna M6   Edit
Assignee: Thomas Watson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-23 06:30 EST by Simon Bernard CLA
Modified: 2014-01-27 09:53 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Bernard CLA 2014-01-23 06:30:12 EST
I have a plugin with fragments (for OS specific native code).[1]

Fragments contains 2 native libraries. (jnlua5.1 and lua5.1)
We use Bundle-NativeCode attribute.[2]

Since Luna, it seems those libraries is no more accessible:
java.lang.UnsatisfiedLinkError: no lua5.1 in java.library.path
(It works well with eclipse from Indigo to Kepler)

I try to have a look to the code, but it changes a lot :).

I see in ClassPathManager, that findLibrary returns the good path in Kepler, but returns null on Luna.


(I set this bug as critical, sry if it's not the good severity, maybe problems come from us)

[1]http://git.eclipse.org/c/koneki/org.eclipse.koneki.ldt.git/tree/plugins/com.naef.jnlua-lua51
[2]http://git.eclipse.org/c/koneki/org.eclipse.koneki.ldt.git/tree/plugins/com.naef.jnlua.linux64-lua51/META-INF/MANIFEST.MF
Comment 1 Simon Bernard CLA 2014-01-23 07:06:22 EST
In our product built on Luna, when I go on Help/About/Installation Details/Configuration I get this exception : 

Declaration is invalid: osgi.native; native.paths:List<String>="lib/libjnlua5.1.so,lib/liblua5.1.so"; filter:="(|(&))"

I suspect there are a syntax error which is no more tolerate in our MANIFEST.
Comment 2 Thomas Watson CLA 2014-01-23 08:59:41 EST
You are correct, but I think you should at least add the osname=Linux to your Bundle-NativeCode:

Bundle-NativeCode: lib/libjnlua5.1.so ; lib/liblua5.1.so; osname=Linux

I will have to consult with the specification a bit, for some reason I thought osname and processor were required attributes for Bundle-NativeCode.
Comment 3 Simon Bernard CLA 2014-01-23 09:12:55 EST
I take a look to the OSGI specification [1] and it seems that at least one parameter is mandatory : 

Bundle-NativeCode ::= nativecode ( ',' nativecode )* ( ’,’ optional) ?
nativecode ::= path ( ';' path )* ( ';' parameter )+
optional ::= ’*’

I add a parameter in my fragment on the Bundle-NativeCode attribute to test that:
Bundle-NativeCode: lib/libjnlua5.1.so ; lib/liblua5.1.so; processor = x86_64
And it works.

So Luna Equinox respect the OSGI specification 5, but it is not backward compatible about that. I don't know if it's really a bug. (I change the severity to normal)

I have a question about the way we should fix that on our side.[2]
We already filter with Eclipse-PlatformFilter attribute:
Eclipse-PlatformFilter: (&(osgi.os=linux)(osgi.arch=x86_64))

What should I add a parameter/filter in Bundle-NativeCode ? it seems really superfluous as we already use Eclipse-PlatformFilter.

[1]http://www.osgi.org/Download/Release5
[2]http://git.eclipse.org/c/koneki/org.eclipse.koneki.ldt.git/tree/plugins/com.naef.jnlua.linux64-lua51/META-INF/MANIFEST.MF
Comment 4 Thomas Watson CLA 2014-01-23 12:42:40 EST
(In reply to Simon Bernard from comment #3)
> I have a question about the way we should fix that on our side.[2]
> We already filter with Eclipse-PlatformFilter attribute:
> Eclipse-PlatformFilter: (&(osgi.os=linux)(osgi.arch=x86_64))
> 
> What should I add a parameter/filter in Bundle-NativeCode ? it seems really
> superfluous as we already use Eclipse-PlatformFilter.
> 

I suggest you add both osname and processor attributes in order to be portable across other framework implementations.  Eclipse-PlatformFilter is equinox specific and not honored by other frameworks.  Unfortunately you also likely need Eclipse-PlatformFilter in order to be provisioned correctly by p2 in Eclipse since p2 keys provisioning decisions off Eclipse-PlatformFilter.
Comment 5 Simon Bernard CLA 2014-01-24 08:42:37 EST
I do what you suggest, now it works.
Should I close the bug or the backward compatibility problem is a real problem ?
Comment 6 Thomas Watson CLA 2014-01-24 09:22:05 EST
(In reply to Simon Bernard from comment #5)
> I do what you suggest, now it works.
> Should I close the bug or the backward compatibility problem is a real
> problem ?

I'm leaving this open until we get clarification in the core R6 spec.  You are correct that the grammar currently requires at least one attribute.  But that attribute could be anything I think and we would still create invalid filters if you specified an unknown attribute since only the known attributes are used to transform the header into an osgi.native requirement.
Comment 7 Thomas Watson CLA 2014-01-27 09:53:16 EST
Added new testcase:

http://git.eclipse.org/c/equinox/rt.equinox.framework.git/commit/?id=d608ce5718b027204c2c71b3ebcd54888d837128

Released fix:

http://git.eclipse.org/c/equinox/rt.equinox.framework.git/commit/?id=5e9ed65eafe8ba01bab4a16b9919b350cc4fcdcb

I could have fixed this a number of ways, but I went with a simple approach of checking the filter for the clause to see if it is simply "(&)" and if so then replace it with a filter (osgi.native.osname=*) which should match on any OS.

I'm marking as fixed with the assumption that the OSGi R6 specification will be clarified to allow no attributes on Bundle-NativeCode.  Even if they don't allow that I think we need to be protective here incase some unrecognized attribute is used.