ReadyTalk / avian

[INACTIVE] Avian is a lightweight virtual machine and class library designed to provide a useful subset of Java's features, suitable for building self-contained applications.

Home Page:https://readytalk.github.io/avian/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JNA initialization issue

Zubnix opened this issue · comments

zubzub@zubnix ~/git/avian/build/linux-x86_64 (master) $ ./avian -jar /home/zubzub/git/westmalle/bootstrap/target/bootstrap-1.0.0-SNAPSHOT.jar
global main INFO Starting Westmalle:
Arguments:
java/lang/ExceptionInInitializerError
at org/westmalle/wayland/nativ/NativeModule. (line 40)
at org/westmalle/wayland/DaggerApplication$Builder.build (line 204)
at org/westmalle/wayland/DaggerApplication.create (line 128)
at org/westmalle/wayland/bootstrap/Boot.main (line 51)
caused by: java/lang/NullPointerException
at com/sun/jna/Native.getTempDir (line 1026)
at com/sun/jna/Native.removeTemporaryFiles (line 1043)
at com/sun/jna/Native.loadNativeDispatchLibrary (line 652)
at com/sun/jna/Native. (line 131)
at org/westmalle/wayland/nativ/NativeModule. (line 40)
at org/westmalle/wayland/DaggerApplication$Builder.build (line 204)
at org/westmalle/wayland/DaggerApplication.create (line 128)
at org/westmalle/wayland/bootstrap/Boot.main (line 51)`

Steps to reproduce (on x86_64, linux):

  • Checkout latest avian from git
  • run make
  • Checkout my project ( git@github.com:Zubnix/westmalle.git ) & build it with maven mvn install
  • run avian with the resulting project jar

Hi. Thanks for the report and the instructions for reproducing the issue. I don't have time at the moment to look at it closely, but my first thought is that you'll probably need to build against the OpenJDK class library to make JNA work. I'm guessing there's stuff missing from the default Avian class library that JNA needs, and even if we fix this specific problem there will be others.

Is it possible for you to use the OpenJDK class library when building Avian (as described in README.md)? If so, please try that. Otherwise, I can take a closer look this weekend.

ok dicej, I will try that and report the result.

A bit off topic, but does avian support embedded minimal stripped build using openjdk?

Yes, you can minify the openjdk classpath along with your code using proguard, and embed the result in avian. The catch is that, having not been designed with anything but monolithic presence on the system in mind, openjdk doesn't minify very well.

Hi @Zubnix,

Did the OpenJDK class library work for you? I reproduced your issue this afternoon using the default Avian class library, and I fixed it by setting the "user.name" system property in java-lang.cpp. Then I ran into another issue which I fixed by setting the "java.vm.name" property. Then I ran into a NoClassDefFoundError for java.net.URISyntaxException which I fixed by adding a simple implementation of that class. Then I ran into "java/lang/NoSuchMethodError: deleteOnExit ()V not found in java/io/File" and decided to give up there.

Like I said before, there's probably a lot of stuff JNA relies on that Avian's built-in class library doesn't provide, and it's hard to tell how much work it will be to add all those things. So if the OpenJDK or Android class libraries work for your app, that's probably the best choice.

@dicej

Thanks for the effort! I did not try it myself due to lack of time this weekend. Judging by your attempt, it does look like JNA requires quite an extensive set of classes.

I will try with the openjdk build and I will also look if there exists a 'minimal'/jme JNA release(?)

Should avian work with an openjdk8 build or are there some known gotchas I should look out for?

Yes, it should work with OpenJDK 8, but it hasn't been extensively tested with 8 yet, so please do report any issues you find. The only known issue I'm aware of at the moment involves lamdbas and ahead-of-time compilation, which should addressed by #454 once it's merged.

I'm going to close this as the original issue is understood/not fixable.

I'm not going to have enough time in the near future to build openjdk 8 myself as my distro doesn't support it (yet). I've heard of reliable sources that it works. That's good enough for me. :)