[prev in list] [next in list] [prev in thread] [next in thread]
List: rxtx
Subject: Re: [Rxtx] 64 bit
From: Nate <nate () n4te ! com>
Date: 2009-11-28 7:55:59
Message-ID: 7d6ffee60911272355p73e526a0t5c10a7fc4d0f6663 () mail ! gmail ! com
[Download RAW message or body]
Hi Ivan,
2009/11/27 Ivan Maidanski <ivmai@mail.ru>:
> Hi!
> Nate <nate@n4te.com> wrote:
> > 2009/11/26 Ivan Maidanski <ivmai@mail.ru>:
> > > Nate <nate@n4te.com> wrote:
> > > > What do you think about supporting both 32 bit and 64 bit DLLs, with
> > > > the correct one chosen at runtime? This way I don't need two separate
> > > > versions of my app.
> > >
> > > I think it would be good. I think this should be implemented as follows:
> > > - in RXTXVersion add package-scope static method loadLibrary(String basename) \
> > > which if sun.arch.data.model property is defined and equals "64" then first \
> > > tries to load basename+"64" library otherwize (if not 64 or failed) loads \
> > > basename one (so this would be backward compatible);
> > > - replace all System.loadLibrary() calls (in all classes) with \
> > > RXTXVersion.loadLibrary();
> > > - fix the corresponding building scripts to produce DLLs suffixed with "64" for \
> > > 64-bit targets (optionally, if needed).
> >
> > Please see the attached patch for the Java changes. I didn't update
> > the build scripts, I'm fine with just renaming the libs myself for
> > now. After some thought, I decided since the sun.arch.data.model
> > property is unreliable, being Sun JVM specific, so I settled on
> > loading the 32-bit lib by default and trying the 64-bit lib if that
> > fails.
>
> I don't think this property is unreliable (if set by a JVM). And, AFAIK, some other \
> JVMs also set it.
I meant unreliable in that the property isn't defined by the JVM spec,
so may not be available in all JVMs. This means even if it is false,
64-bit must be tried before absolute failure.
> The code looks like what I meant except that, I think, it would be better to to try \
> to load basename+64 first if that property is set to 64.
Sure. Here is how I would write it, with clarity in mind:
static void loadLibrary (String baseName) {
if (System.getProperty("sun.arch.data.model", "").equals("64")) {
try {
System.loadLibrary(baseName + "64");
} catch (UnsatisfiedLinkError ex64) {
try {
System.loadLibrary(baseName);
} catch (UnsatisfiedLinkError ignored) {
throw ex64;
}
}
} else {
try {
System.loadLibrary(baseName);
} catch (UnsatisfiedLinkError ex32) {
try {
System.loadLibrary(baseName + "64");
} catch (UnsatisfiedLinkError ignored) {
throw ex32;
}
}
}
}
-Nate
> >
> > The patch also sets "devel" to false in RXTXCommDriver. I strongly
> > believe a third party library should not be hardcoded to dump to
> > System.out, especially when nothing is wrong. If I want to dump the
> > rxtx version to System.out, I can write one line of code to do so
> > (ASCII art is certainly not needed).
> >
> > -Nate
> >
> > ATTACHMENT: application/x-patch (nativeLib.patch)
>
>
_______________________________________________
Rxtx mailing list
Rxtx@qbang.org
http://mailman.qbang.org/mailman/listinfo/rxtx
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic