weikipeng / javacpp

Automatically exported from code.google.com/p/javacpp
GNU General Public License v2.0
0 stars 0 forks source link

Eliminate dependency on libjvm.so when not required #33

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.following the LegacyLibrary example on front page;
2.readelf -d linux-x86_64/libjniLegacyLibrary.so shows
  it dependend on libjvm.so

What is the expected output? What do you see instead?
Can we make the libjvm.so dependency optional? I think many JNI so
does not call into JVM, so we can remove libjvm.so?
I guess this could make the result libjniLegacyLibrary.so target much wider 
versions of the JVM.

What version of the product are you using? On what operating system?
HEAD, linux

Please provide any additional information below.

Original issue reported on code.google.com by james.fa...@gmail.com on 27 May 2013 at 8:54

GoogleCodeExporter commented 9 years ago
Does Linux actually complain if it can't find libjvm.so even when we're not 
using any functions from it?

Original comment by samuel.a...@gmail.com on 27 May 2013 at 9:01

GoogleCodeExporter commented 9 years ago
Linux does not complain when there is no libjvm.so.

What i did is generate/compile with
"java -cp javacpp.jar -D platform.name=generic LegacyLibrary", which skip the 
libjvm.so
parts in Builder.java. Then i rename the generic directory to linux-x86_64 and 
run with
"java -cp javacpp.jar LegacyLibrary".

Most JNI interface function are exposed via pointer to function pointer table, 
so i guess as long as we use only thoses function indirectly via the function 
table, there is no need to link to libjvm.so.

Original comment by james.fa...@gmail.com on 28 May 2013 at 1:27

GoogleCodeExporter commented 9 years ago
But we do have to link with libjvm.so to resolves functions like 
JNI_CreateJavaVM(), when we need it. But yes, Linux does complain if it can't 
find libjvm.so... I see. We should add some logic to not link unless needed 
then.

Original comment by samuel.a...@gmail.com on 31 May 2013 at 9:29

GoogleCodeExporter commented 9 years ago
I've made some changes that should fix this issue here:
http://code.google.com/p/javacpp/source/detail?r=81a627b83de1e76d491297299265a76
736f747fd
Please let me know if that looks acceptable, thanks!

Original comment by samuel.a...@gmail.com on 15 Jun 2013 at 5:02

GoogleCodeExporter commented 9 years ago
I've included those changes in version 0.6. This issue should be fixed, but 
please let me know if this is not the case! Thanks!

Original comment by samuel.a...@gmail.com on 15 Sep 2013 at 1:34