Re: [Ikvm-developers] RXTX already loaded in another classloader
Brought to you by:
jfrijters
|
From: Jim R. <jr...@er...> - 2008-05-25 14:30:42
|
Jeroen,
Very nice workaround:
// problems on ARM/GNU Classpath with StackWalking - System.loadLibrary(
"rxtxSerial" );
// call Runtime.getRuntime().loadLibrary(libname,
RXTXCommDriver.class.getClassLoader()); instead
try {
java.lang.reflect.Method m =
Runtime.class.getDeclaredMethod("loadLibrary", new Class[]
{String.class, ClassLoader.class});
m.setAccessible(true);
m.invoke(Runtime.getRuntime(), new Object[] {"rxtxSerial",
RXTXCommDriver.class.getClassLoader()});
} catch ( Exception any ) {
any.printStackTrace();
}
So is this actually a GNU Classpath problem? If so, I'll report it as
an error over there.
Thanks again,
Jim
Jeroen Frijters wrote:
> Jim,
>
> I've thought of another possible workaround. Try replacing the explicit loadLibrary invocations with this:
>
> java.lang.reflect.Method m = Runtime.class.getDeclaredMethod("loadLibrary0", Class.class, String.class);
> m.setAccessible(true);
> m.invoke(Runtime.getRuntime(), gnu.io.RXTXVersion.class, "rxtxSerial");
>
> This bypasses the stack walk and should cause the right class loader to be used.
>
> Regards,
> Jeroen
>
>> -----Original Message-----
>> From: Jim Redman [mailto:jr...@er...]
>> Sent: Saturday, May 24, 2008 01:58
>> To: Jeroen Frijters
>> Cc: ikv...@li...
>> Subject: Re: [Ikvm-developers] RXTX already loaded in another
>> classloader
>>
>> Jeroen,
>>
>> Ubuntu 8.04 seems to work fine, and idea? Need an NSLU2?
>>
>> Jim
>>
>> $ mono -V
>> Mono JIT compiler version 1.9.1 (tarball) Copyright (C) 2002-2007
>> Novell, Inc and Contributors. www.mono-project.com
>> TLS: __thread
>> GC: Included Boehm (with typed GC)
>> SIGSEGV: altstack
>> Notifications: epoll
>> Architecture: x86
>> Disabled: none
>>
>> Serial Port Name "/dev/ttyS0"
>> [17:48:28.42017 main] loadLibrary: ./librxtxSerial.so, class loader:
>> ikvm.runtime.AssemblyClassLoader@1C86FBC0
>> [17:48:28.45922 main] Library loaded: ./librxtxSerial.so, handle =
>> 0x82BB8B8
>> [17:48:28.46045 main] Calling JNI_OnLoad on: ./librxtxSerial.so
>> Experimental: JNI_OnLoad called.
>> [17:48:28.55074 main] JNI_OnLoad returned: 0x00010002
>> [17:48:28.55595 main] loadLibrary: ./librxtxSerial.so, class loader:
>> ikvm.runtime.AssemblyClassLoader@1C86FBC0
>> [17:48:28.55716 main] Library was already loaded: ./librxtxSerial.so
>> [17:48:28.56624 main] Linking native method:
>> gnu/io/RXTXVersion.nativeGetVersion()Ljava/lang/String;, class loader =
>> ikvm.runtime.AssemblyClassLoader@1C86FBC0, short =
>> Java_gnu_io_RXTXVersion_nativeGetVersion, long =
>> Java_gnu_io_RXTXVersion_nativeGetVersion__, args = 8
>> [17:48:28.56725 main] Native method
>> gnu/io/RXTXVersion.nativeGetVersion()Ljava/lang/String; found in
>> library
>> 0x82BB8B8 (short)
>> Stable Library
>> =========================================
>> Native lib Version = RXTX-2.1-7
>> Java lib Version = RXTX-2.1-7
>> [17:48:28.58707 main] Linking native method:
>> gnu/io/RXTXCommDriver.getDeviceDirectory()Ljava/lang/String;, class
>> loader = ikvm.runtime.AssemblyClassLoader@1C86FBC0, short =
>> Java_gnu_io_RXTXCommDriver_getDeviceDirectory, long =
>> Java_gnu_io_RXTXCommDriver_getDeviceDirectory__, args = 8
>> [17:48:28.58783 main] Native method
>> gnu/io/RXTXCommDriver.getDeviceDirectory()Ljava/lang/String; found in
>> library 0x82BB8B8 (short)
>> [17:48:28.60276 main] Linking native method:
>> gnu/io/RXTXCommDriver.testRead(Ljava/lang/String;I)Z, class loader =
>> ikvm.runtime.AssemblyClassLoader@1C86FBC0, short =
>> Java_gnu_io_RXTXCommDriver_testRead, long =
>> Java_gnu_io_RXTXCommDriver_testRead__Ljava_lang_String_2I, args = 16
>> [17:48:28.60363 main] Native method
>> gnu/io/RXTXCommDriver.testRead(Ljava/lang/String;I)Z found in library
>> 0x82BB8B8 (short)
>> [17:48:28.61671 main] Linking native method:
>> gnu/io/RXTXCommDriver.registerKnownPorts(I)Z, class loader =
>> ikvm.runtime.AssemblyClassLoader@1C86FBC0, short =
>> Java_gnu_io_RXTXCommDriver_registerKnownPorts, long =
>> Java_gnu_io_RXTXCommDriver_registerKnownPorts__I, args = 12
>> [17:48:28.61753 main] Native method
>> gnu/io/RXTXCommDriver.registerKnownPorts(I)Z found in library 0x82BB8B8
>> (short)
>> [17:48:28.67625 main] loadLibrary: ./librxtxSerial.so, class loader:
>> ikvm.runtime.AssemblyClassLoader@1C86FBC0
>> [17:48:28.67697 main] Library was already loaded: ./librxtxSerial.so
>> [17:48:28.70450 main] loadLibrary: ./librxtxSerial.so, class loader:
>> ikvm.runtime.AssemblyClassLoader@1C86FBC0
>> [17:48:28.70527 main] Library was already loaded: ./librxtxSerial.so
>> [17:48:28.70724 main] Linking native method:
>> gnu/io/RXTXPort.Initialize()V, class loader =
>> ikvm.runtime.AssemblyClassLoader@1C86FBC0, short =
>> Java_gnu_io_RXTXPort_Initialize, long =
>> Java_gnu_io_RXTXPort_Initialize__, args = 8 [17:48:28.70800 main]
>> Native method gnu/io/RXTXPort.Initialize()V found in library 0x82BB8B8
>> (short)
>> [17:48:28.71311 main] Linking native method:
>> gnu/io/RXTXPort.open(Ljava/lang/String;)I, class loader =
>> ikvm.runtime.AssemblyClassLoader@1C86FBC0, short =
>> Java_gnu_io_RXTXPort_open, long =
>> Java_gnu_io_RXTXPort_open__Ljava_lang_String_2, args = 12
>> [17:48:28.71390 main] Native method
>> gnu/io/RXTXPort.open(Ljava/lang/String;)I found in library 0x82BB8B8
>> (short)
>> [17:48:28.75709 Thread-3] Linking native method:
>> gnu/io/RXTXPort.eventLoop()V, class loader =
>> ikvm.runtime.AssemblyClassLoader@1C86FBC0, short =
>> Java_gnu_io_RXTXPort_eventLoop, long =
>> Java_gnu_io_RXTXPort_eventLoop__, args = 8
>> [17:48:28.75821 Thread-3] Native method gnu/io/RXTXPort.eventLoop()V
>> found in library 0x82BB8B8 (short)
>> [17:48:28.78065 main] Linking native method:
>> gnu/io/RXTXPort.nativeSetSerialPortParams(IIII)Z, class loader =
>> ikvm.runtime.AssemblyClassLoader@1C86FBC0, short =
>> Java_gnu_io_RXTXPort_nativeSetSerialPortParams, long =
>> Java_gnu_io_RXTXPort_nativeSetSerialPortParams__IIII, args = 24
>> [17:48:28.78149 main] Native method
>> gnu/io/RXTXPort.nativeSetSerialPortParams(IIII)Z found in library
>> 0x82BB8B8 (short)
>>
>> Jeroen Frijters wrote:
>>> Jim Redman wrote:
>>>> This seems to highlight another difference. On Debian/ARM I have
>>>> 1.9.1, on FC8 1.2.6, which doesn't seem to support the app.config -
>>>> or I'm doing it wrong.
>>>>
>>>> Here's the Debian output:
>>>>
>>>> Serial Port Name "/dev/ttyUSB0"
>>>> [07:29:07.27525 main] loadLibrary: /home/MIX_CMIX/librxtxSerial.so,
>>>> class loader: null
>>> [...]
>>>> [07:29:08.14348 main] loadLibrary: /home/MIX_CMIX/librxtxSerial.so,
>>>> class loader: ikvm.runtime.AssemblyClassLoader@BE18F840
>>> The first attempt was made by the null class loader, which is very
>> unlikely, because the bootstrap classes don't know about this library.
>> So it looks very likely that it is a stack walking issue.
>>> You could try working around it by moving the first loadLibrary call
>> around.
>>> I don't really know how to help you debug the issue and since I don't
>> have a Debian/ARM system I can't debug it myself either.
>>> It would help if you could try it with Mono 1.9.1 on an x86 Linux and
>> see if that also has the problem, because then it would be easier to
>> track down.
>>> Regards,
>>> Jeroen
>> --
>> Jim Redman
>> (505) 662 5156 x85
>> http://www.ergotech.com
--
Jim Redman
(505) 662 5156 x85
http://www.ergotech.com
|