Wayne Meissner wrote:
Hmm. Given that JRuby already uses asm, it could use this approach + an
asm generated subclass that includes the Library interface if it is
available at runtime.
Its a lot simpler if JNA just drops the requirement that the passed in
class doesn't extends Library, assuming that doesn't break anything.
The real question is, why are you guys doing this in java, instead of
directly in ruby or python code?
Well, there is a bit of Java code yet in JRuby and Jython :) In general,
the reason I'm using JNA is to provide core class methods like
File#chmod for example. File, being a core class, is implemented
entirely in Java...and so it's simplest if I just have a normal Java
method on a normal Java interface I can call to chmod for it. Since
there are at least three ways to implement chmod right now (shelling
out, using Java 6 permission APIs, or using JNA), I want to put them
behind an interface and select them based on availability of libraries
or APIs. That means using a single interface.
Philip's suggestion unfortunately doesn't help me produce a compilable
JRuby that doesn't directly reference JNA, since the JNAPosix still
requires JNA to be present and I don't want to have conditional builds
for "with JNA" and "without JNA". I want to be able to drop JNA into a
lib dir and have JRuby start using it, or work using the kludgy
implementations when JNA isn't available.
I agree that removing the "extends Library" requirement would be
easiest. Make JNA do the magic :)
- Charlie