Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JNAerator self-extraction does not work #38

Open
ochafik opened this issue Mar 18, 2015 · 1 comment
Open

JNAerator self-extraction does not work #38

ochafik opened this issue Mar 18, 2015 · 1 comment

Comments

@ochafik
Copy link
Member

ochafik commented Mar 18, 2015

From @leahxschmidt on December 27, 2012 7:40

To reproduce, do the following (instructions assume you are using Linux, but I've also gotten the same result on win32 with the appropriate changes):
git clone https://github.com/leahxschmidt/testjnaerator.git
cd testjnaerator
make
cd java
javac -cp test_linux.jar:. JavaTest.java
java -cp test_linux.jar:. -Djna.nosys=true JavaTest

I would expect this to run correctly, but it does not.

If I first extract the jar and manually configure the library path, it does run:
jar xf test_linux.jar
java -cp test_linux.jar:. -Djna.nosys=true -Djna.library.path=lib/linux_x64/ JavaTest

Naturally, I don't want to have to do that. I don't have this problem if I use 0.9.7, but I do with 0.10.0.

Copied from original issue: nativelibs4java/nativelibs4java#351

@ochafik
Copy link
Member Author

ochafik commented Mar 18, 2015

Hi @leahxschmidt ,

It seems I've introduced a regression for the JNA(erator) runtime, indeed, thanks for your report (forgot to update LibraryExtractor.java when I updated the extraction scheme for BridJ).
While I'm working on a fix, you might want to give the BridJ runtime a go, though:

import java.net.InetAddress;
import java.net.UnknownHostException;

import org.bridj.*;
import static org.bridj.Pointer.*;

import org.getlantern.test.*;
import org.getlantern.test.TestLibrary.*;

public class JavaTest {

    public static void main(String[] args) {

            Pointer<Integer> address = /*Pointer.*/allocateInt();
        System.out.println("before");
        int result = /*TestLibrary.*/test(address);
        System.out.println("result = " + result);
        byte[] bytes = address.getBytes();
        try {
            InetAddress inetAddress = InetAddress.getByAddress(bytes);
            System.out.println("Default gateway is " + inetAddress);
        } catch (UnknownHostException e) {
            throw new RuntimeException(e);
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant