Bug 1112012 - java-1.8.0-openjdk on aarch64 returns the wrong path for -ljvm
java-1.8.0-openjdk on aarch64 returns the wrong path for -ljvm
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: pl (Show other bugs)
rawhide
aarch64 Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Petr Pisar
Fedora Extras Quality Assurance
:
Depends On:
Blocks: ARM64/F-ExcludeArch-aarch64
  Show dependency treegraph
 
Reported: 2014-06-22 14:06 EDT by Peter Robinson
Modified: 2014-06-27 01:33 EDT (History)
7 users (show)

See Also:
Fixed In Version: pl-6.6.6-3.fc21
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-06-25 04:17:32 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
build log of pl package with extra debug (320.81 KB, text/plain)
2014-06-22 14:06 EDT, Peter Robinson
no flags Details
Patch for rawhide (1.50 KB, patch)
2014-06-24 23:51 EDT, Yaakov Selkowitz
no flags Details | Diff

  None (edit)
Description Peter Robinson 2014-06-22 14:06:48 EDT
Created attachment 911170 [details]
build log of pl package with extra debug

When a java program (such as pl) runs "java JavaConfig --libs-only-L" java on aarch64  returns:

 -L/usr/java/packages/lib/aarch64 -L/lib -L/usr/lib -L/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.5.aarch64/jre/lib/aarch64 -L/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.5.aarch64/jre/lib/aarch64/server 

Whereas libjvm is actually in 

/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.5.aarch64/jre/lib/aarch64/client/libjvm.so

and hence it can't be found.

NVR: java-1.8.0-openjdk-1.8.0.5-11.b13.fc21

All other platforms (arm32,i686,x86_64,ppc,s390) have libjvm installed in re/lib/aarch64/server rather than jre/lib/aarch64/client
Comment 1 Omair Majid 2014-06-22 20:50:10 EDT
This is a bug in JavaConfig, a custom script supplied with pl.

It contains this snippet:

 78     value = value + ":" +
 79       home + filesep + "lib" + filesep + architecture + ":" +
 80       home + filesep + "lib" + filesep + architecture + filesep + "server";

That's really hardcoding jre/lib/aarch64 and jre/lib/aarch64/server, without checking if either one of those exist. Most architectures have a "server" dir, so this works.

It's not correct to assume the location of the libjvm.so: there's no requirement for "server". Some architectures have both "client" and "server" variants of libjvm.so and some have only one.

Reassigning to pl.
Comment 2 Petr Pisar 2014-06-23 07:53:03 EDT
So after two and half years, there is still no programmatic way how to get paths to JVM libraries (bug #740762)? It's very sad that the OpenJDK developers are such selfish and cannot distribute any pkg-config file allowing to integrate JVM into other code.

Could you tell me, how can I determine which path to use for which platform?
Comment 3 Omair Majid 2014-06-23 10:43:37 EDT
(In reply to Petr Pisar from comment #2)
> So after two and half years, there is still no programmatic way how to get
> paths to JVM libraries (bug #740762)?

Sorry, somehow that fell through the cracks :(

> It's very sad that the OpenJDK
> developers are such selfish and cannot distribute any pkg-config file
> allowing to integrate JVM into other code.

I am going to ping folks to follow up with this.

> Could you tell me, how can I determine which path to use for which platform?

Perhaps the simplest way for now would be to modify JavaConfig.java to check if each

home + filesep + "lib" + filesep + architecture + filesep + "server"

home + filesep + "lib" + filesep + architecture + filesep + "client"

exists before adding it to the library path? And prefer "server" if both exist?
Comment 4 Deepak Bhole 2014-06-23 11:51:29 EDT
(In reply to Petr Pisar from comment #2)
> So after two and half years, there is still no programmatic way how to get
> paths to JVM libraries (bug #740762)? It's very sad that the OpenJDK
> developers are such selfish and cannot distribute any pkg-config file
> allowing to integrate JVM into other code.
> 

You are speaking as though the developers already have a solution and are just too lazy to release or, as though they have loads of free time and are wasting it instead of doing this.

There are issues with implementing a pkg config like system for a multi-vendor multi-version software piece like the JDK. 

Even if we do it for Fedora, all other distros will have to use the system. They will have to apply a similar system for proprietary JDKs as well (which are unlikely to implement a packages solution) because if it is only half implemented, upstream projects are not going to adopt such a system.

Calling people lazy and then expecting that to motivate them into doing what you want is not going to help your cause.

> Could you tell me, how can I determine which path to use for which platform?
Comment 5 Petr Pisar 2014-06-24 01:48:54 EDT
(In reply to Deepak Bhole from comment #4)
> You are speaking as though the developers already have a solution and are
> just too lazy to release or, as though they have loads of free time and are
> wasting it instead of doing this.
> 
I'm telling that because inability to come with a small file in a 2.5 years shows there is something very wrong with JDK development.

However if it's such a hard problem, do you think that third-party software packager, like me, will be able to solve the problem on their side? And each packager again and again for each his package? Therefore I believe the only viable approach is to solve it on JDK/OpenJDK/IcedTea side.

> There are issues with implementing a pkg config like system for a
> multi-vendor multi-version software piece like the JDK. 
>
What? If the file is provided by vendor with each version separately, then the implementation is matter of opaque internals you don't have to bother.

If you talk about distribution-level solution, I'm really curious how distributor made java(1) or javac(1) tools or classpath directory lists available to the user? With your argumentation they would never managed it. The pkg-config file is just yet another instance of the same problem. And they do that without upstream help.
 
> Even if we do it for Fedora, all other distros will have to use the system.

If the job were done on OpenJDK site, other distros would just use it because it would come with the upstream.

> They will have to apply a similar system for proprietary JDKs as well (which
> are unlikely to implement a packages solution) because if it is only half
> implemented, upstream projects are not going to adopt such a system.
> 
I don't understand the obsession with proprietary implementations and their relation to OpenJDK. There are myriads of differences between JDK implementation. Adding a file which does not break any specification nor API is a no-go?
Comment 6 Deepak Bhole 2014-06-24 11:16:02 EDT
(In reply to Petr Pisar from comment #5)
> (In reply to Deepak Bhole from comment #4)
> > You are speaking as though the developers already have a solution and are
> > just too lazy to release or, as though they have loads of free time and are
> > wasting it instead of doing this.
> > 
> I'm telling that because inability to come with a small file in a 2.5 years
> shows there is something very wrong with JDK development.
> 
> However if it's such a hard problem, do you think that third-party software
> packager, like me, will be able to solve the problem on their side? And each
> packager again and again for each his package? Therefore I believe the only
> viable approach is to solve it on JDK/OpenJDK/IcedTea side.
> 
> > There are issues with implementing a pkg config like system for a
> > multi-vendor multi-version software piece like the JDK. 
> >
> What? If the file is provided by vendor with each version separately, then
> the implementation is matter of opaque internals you don't have to bother.
> 
> If you talk about distribution-level solution, I'm really curious how
> distributor made java(1) or javac(1) tools or classpath directory lists
> available to the user? With your argumentation they would never managed it.
> The pkg-config file is just yet another instance of the same problem. And
> they do that without upstream help.
>  

So you are suggesting using alternatives for a pkg-config file? Hmm, interesting. I have never seen it being done but you're right, it is possible.

> > Even if we do it for Fedora, all other distros will have to use the system.
> 
> If the job were done on OpenJDK site, other distros would just use it
> because it would come with the upstream.
> 

Fair enough.

> > They will have to apply a similar system for proprietary JDKs as well (which
> > are unlikely to implement a packages solution) because if it is only half
> > implemented, upstream projects are not going to adopt such a system.
> > 
> I don't understand the obsession with proprietary implementations and their
> relation to OpenJDK. There are myriads of differences between JDK
> implementation. Adding a file which does not break any specification nor API
> is a no-go?

It is not a question of obsession. If I am an upstream developer who wants to link to libjvm, why would I use pkg config if I know that 2 of 3 (IBM/Oracle vs OpenJDK) JDKs do not support that system?
Comment 7 Yaakov Selkowitz 2014-06-24 23:51:26 EDT
Created attachment 911909 [details]
Patch for rawhide

(In reply to Omair Majid from comment #3)
> Perhaps the simplest way for now would be to modify JavaConfig.java to check
> if each
> 
> home + filesep + "lib" + filesep + architecture + filesep + "server"
> 
> home + filesep + "lib" + filesep + architecture + filesep + "client"
> 
> exists before adding it to the library path? And prefer "server" if both
> exist?

Yes, this seems to be the best way to fix this, although AFAICS they don't actually need to be checked since only one will exist: aarch64 uses "client" where ix86/x86_64/armv7hl/ppc64/s390/s390x all use "server".

Patch tested locally with mock (fedora-rawhide-x86_64) and with arm-koji:

http://arm.koji.fedoraproject.org/koji/taskinfo?taskID=2449565
Comment 8 Petr Pisar 2014-06-25 03:02:07 EDT
(In reply to Deepak Bhole from comment #6)
> It is not a question of obsession. If I am an upstream developer who wants
> to link to libjvm, why would I use pkg config if I know that 2 of 3
> (IBM/Oracle vs OpenJDK) JDKs do not support that system?

You should use pkg-config because it brings automated configuration to OpenJDK users. There would be no change with other JDKs. (Unless distributors amend them with home-made pkg-config file which is fairly possible as that brings simplification even for the packagers.) Don't forget that users of current JDKs have to fiddle the compiler flags manually. And don't forget that pkg-config usage can be optional.

I would understand your worries if the change were negative or disruptive. However this change is an improvement. Somebody has to to be the first one.
Comment 9 Petr Pisar 2014-06-25 04:17:32 EDT
(In reply to Yaakov Selkowitz from comment #7)
> Created attachment 911909 [details]
> Patch for rawhide
> 
Thanks. I applied it.
Comment 10 Deepak Bhole 2014-06-25 09:50:01 EDT
Omair is following up on this per comment 3. Whether or not other JDKs do it is of no concern -- I was merely pointing out that it is a potential barrier to adoption for other projects.

Omair, I have reassigned #740762 to you.
Comment 11 Omair Majid 2014-06-25 16:22:14 EDT
(In reply to Petr Pisar from comment #8)
> You should use pkg-config because it brings automated configuration to
> OpenJDK users.

Can you give me an example of what you would like from this pkg-config file? Would just including the various -L/path/to/jvm/ be enough or should it also include -ljvm and -ljava?
Comment 12 Petr Pisar 2014-06-26 04:23:37 EDT
I'm not experienced in using java, so I don't know if there are some libraries which are always needed. If that's so, then they (like -ljvm -ljava) should be output on --libs argument. If there are some extensions which consists of other libraries, then the pkg-config way is to provide a separate pkg-config file for each of them.

Personally, I need the -L path (--libs output) and the java home directory (--variable=home output). I also think the -I path to header files (--cflags output) would be nice as well as --version output.
Comment 13 Omair Majid 2014-06-26 12:43:03 EDT
I just spoke with Mikolaj. His opinion is already described here: https://bugzilla.redhat.com/show_bug.cgi?id=449456#c5

Basically, a pkg-config file is the wrong solution for Fedora. Fedora (and JPackage in general) guidelines allow users to easily switch between JREs. This requires that applications respect $JAVA_HOME at runtime. They should not link to a specific libjvm, but rely on dlopen() instead.
Comment 14 Omair Majid 2014-06-26 12:59:31 EDT
This is the patch used in hadoop that makes it use dlopen() instead:
http://pkgs.fedoraproject.org/cgit/hadoop.git/tree/hadoop-dlopen-libjvm.patch
Comment 15 Petr Pisar 2014-06-27 01:28:19 EDT
dlopen() requires absolute path to the library if the library is not in a regeristered linker search path (/etc/ld.so.conf). The patch repeats exactly the same mistake which each application should avoid---it hardcodes paths. Moreover the quoted patch will work only in i386 and x86_64 and only with JDK 1.7 and 1.8. There is still need for library path discovery mechanism at JDK level.

Note You need to log in before you can comment on or make changes to this bug.