JDK-7151203 : Java 7 java.library.path no longer includes shared library directories on Linux.
  • Type: Bug
  • Component: docs
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: linux_redhat_5.0
  • CPU: x86
  • Submitted: 2012-03-05
  • Updated: 2014-11-06
  • Resolved: 2014-11-06
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
> /usr/java/jdk1.7.0_03/bin/javac -version
javac 1.7.0_03
> /usr/java/jdk1.7.0_03/bin/java -version
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) Server VM (build 22.1-b02, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux xxxxxxxx 2.6.18-308.el5 #1 SMP Fri Jan 27 17:17:51 EST 2012 x86_64 x86_64 x86_64 GNU/Linux


EXTRA RELEVANT SYSTEM CONFIGURATION :
> cat /etc/issue
Red Hat Enterprise Linux Server release 5.8 (Tikanga)
Kernel \r on an \m
> echo $LD_LIBRARY_PATH
LD_LIBRARY_PATH: Undefined variable.


A DESCRIPTION OF THE PROBLEM :
The Java 7 java.library.path system property no longer includes the paths to the directories containing the Java shared libraries on Linux.  It did in Java 6.


REGRESSION.  Last worked in version 6u29

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create LibraryPathPrinter.java as indicated below:

public class
LibraryPathPrinter
{
   public static void
   main( String[] args)
   {
      String libPath = System.getProperty( "java.library.path");
      if( libPath != null) {
         System.out.println( libPath);
      }
      System.exit( 0);
   }
}

Compile and run as follows:

/usr/java/jdk1.7.0_03/bin/javac LibraryPathPrinter.java
/usr/java/jdk1.7.0_03/bin/java LibraryPathPrinter
/usr/java/jdk1.7.0_03/jre/bin/java LibraryPathPrinter
/usr/java/jdk1.6.0_29/bin/javac LibraryPathPrinter.java
/usr/java/jdk1.6.0_29/bin/java LibraryPathPrinter
/usr/java/jdk1.6.0_29/jre/bin/java LibraryPathPrinter

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A value of java.library.path containing a similar set of shared library directories as returned by the Java 6 runs of the program.
ACTUAL -
> cat LibraryPathPrinter.java
public class
LibraryPathPrinter
{
   public static void
   main( String[] args)
   {
      String libPath = System.getProperty( "java.library.path");
      if( libPath != null) {
         System.out.println( libPath);
      }
      System.exit( 0);
   }
}
> /usr/java/jdk1.7.0_03/bin/javac LibraryPathPrinter.java
> /usr/java/jdk1.7.0_03/bin/java LibraryPathPrinter
/usr/java/packages/lib/i386:/lib:/usr/lib
> /usr/java/jdk1.7.0_03/jre/bin/java LibraryPathPrinter
/usr/java/packages/lib/i386:/lib:/usr/lib
> /usr/java/jdk1.6.0_29/bin/javac LibraryPathPrinter.java
> /usr/java/jdk1.6.0_29/bin/java LibraryPathPrinter
/usr/java/jdk1.6.0_29/jre/lib/i386/server:/usr/java/jdk1.6.0_29/jre/lib/i386:/usr/java/jdk1.6.0_29/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib
> /usr/java/jdk1.6.0_29/jre/bin/java LibraryPathPrinter
/usr/java/jdk1.6.0_29/jre/lib/i386/server:/usr/java/jdk1.6.0_29/jre/lib/i386:/usr/java/jdk1.6.0_29/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib



REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class
LibraryPathPrinter
{
   public static void
   main( String[] args)
   {
      String libPath = System.getProperty( "java.library.path");
      if( libPath != null) {
         System.out.println( libPath);
      }
      System.exit( 0);
   }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Write a wrapper function, add the expected set of directories to the path and return that new path.  Setting LD_LIBRARY_PATH or explicitly setting -Djava.library.path also work but are not acceptable in our current application.

Comments
It seems this is nothing that will require a code fix, but rather something to be documented. Changing component to docs
21-02-2014

EVALUATION I am reassigning this bug to the HotSpot team for their analysis, the java.library.path is set at src/os/solaris/vm/os_solaris.cpp os::init_system_properties_values()
06-03-2012

EVALUATION This is correct behavior, in JDK7 the LD_LIBRARY_PATH was purged via 6367077, thus the LD_LIBRARY_PATH willl not be set by the VM. If the paths need to be set should be able to set -Djava.library.path when java is invoked. See the blog for more information: https://blogs.oracle.com/darcy/entry/purging_ld_library_path The only bug here is that the documentation or the Release Notes should be clearer and cover this aspect of the LD_LIBRARY_PATH purging. *** (#1 of 1): [ UNSAVED ] ###@###.###
06-03-2012