I have this problem too with C# .netmodule
I patched the version (0.7.0 I think) and I proposed the patch to Rick.
and this bundle to test it (I will put it online)
Didier
PS: Do I add an entry in JIRA ?
========================
Richard S. Hall wrote :
Didier,
It sounds like an interesting hack, but it is not something that I
think should be in the core at this time. Wait until I get back and
remind me of this and we can have some more discussions on it.
In fact, the hack is super light
The bundle to test it is attached in the mail
The felix.enable.netmodule property can deactivate the hack
Felix.java: line 3110
// Get native library entry names for module library sources.
R4LibraryHeader[] libraryHeaders =
Util.parseLibraryStrings(
m_logger,
Util.parseDelimitedString(
(String) headerMap.get(Constants.BUNDLE_NATIVECODE),
","));
R4Library[] libraries = new R4Library[libraryHeaders.length];
for (int i = 0; i < libraries.length; i++)
{
libraries[i] = new R4Library(
m_logger, m_cache, id, revision,
getProperty(Constants.FRAMEWORK_OS_NAME),
getProperty(Constants.FRAMEWORK_PROCESSOR),
libraryHeaders[i]);
}
// install netmodule
String
enableNetmoduleProperty=System.getProperty("felix.enable.netmodule");
if(enableNetmoduleProperty!=null &&
(enableNetmoduleProperty.equals("yes") ||
enableNetmoduleProperty.equals("true"))) {
for (int i = 0; i < libraries.length; i++) {
if(libraryHeaders[i].getName().endsWith(".netmodule")){
libraries[i].install();
}
}
}
R4Library.java: added method
/**
* <p>
* Installs the specified library.
* </p>
* @param path the path of the library that is being requested.
* @return a file system path to the specified library.
**/
public boolean install()
{
if (m_header != null)
{
// Check to see if the library matches.
boolean osOkay = checkOS(m_header.getOSNames());
boolean procOkay = checkProcessor(m_header.getProcessors());
if (osOkay && procOkay)
{
try {
//
System.out.println("R4Library.install():"+m_header.getName());
return m_cache.getArchive(m_bundleId)
.findLibrary(m_revision, m_header.getName())!=null;
} catch (Exception ex) {
m_logger.log(Logger.LOG_ERROR, "R4Library: Error
installing library.", ex);
}
}
}
return false;
}
-> richard
Didier Donsez wrote:
Rick
I try to write a bundle using JNI with .NET (C#)
I started from this simple example:
the paper "Experience in integrating Java with C# and .NET" by Judith
Bishop, R. Nigel Horspool and Basil Worrall
http://www.cs.uvic.ca/~nigelh/Publications/ccpe03.pdf
and the source provided by KoriFrancis ("Using C# from Java through
JNI just got a little easier to understand", 16 Feb 2006)
http://www.codeproject.com/useritems/javacsharp.asp
Both the C# netmodule and the c++ dll compliled using the MC++ header
must be in the main directory for this to work. If the netmodule is not
there then an exception will the crashed the VM.
I set the bundle manifest with
Bundle-NativeCode:
win32/winxp/CSharpHelloWorld.netmodule;win32/winxp/HelloWorld.dll;
osname=WindowsXP;
processor=x86
However, the VM crashes
In fact the .dll library is installed into the bundle<id>/lib dir by
the
method
org.apache.felix.framework.cache.DefaultBundleArchive.findLibraryUnchecked(int
revision, String libName) when it is invoked (indirectly) by the method
System.loadLibrary(libName).
but .netmodule files are never extracted for the jarfile and copied into
the same dir as the library .dll
If I copy manually the .netmodule in the the same dir as the library
.dll
the bundle works well !
Could you fix that ?
Can I propose a solution ?
For instance, extract all .netmodule during the private
DefaultBundleArchive.preprocessBundleJar(int revision, File revisionDir)
method invocation !
Remark: .netmodule files could not be loaded by a System.loadLibrary()
since they are not DLL
--
---------------------------------------------------------
Didier DONSEZ
Laboratoire LSR, Institut Imag, Universite Joseph Fourier
Bat. C, 220 rue de la Chimie, Domaine Universitaire
BP 53, 38041 Grenoble Cedex 9, France
GPS : lat 45°11'38.3"N, lon 05°46'14.7"E, alt 223m
http://www-adele.imag.fr/users/Didier.Donsez/map/map.html
Tel : +33 4 76 63 55 49 Fax : +33 4 76 63 55 50
mailto:[EMAIL PROTECTED]
URL: http://www-adele.imag.fr/users/Didier.Donsez
---------------------------------------------------------