src/java.base/unix/native/libjli/java_md_solinux.c

Print this page


   1 /*
   2  * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #include "java.h"
  27 #include "jvm_md.h"
  28 #include <dirent.h>
  29 #include <dlfcn.h>
  30 #include <fcntl.h>
  31 #include <inttypes.h>
  32 #include <stdio.h>
  33 #include <string.h>
  34 #include <stdlib.h>
  35 #include <sys/stat.h>
  36 #include <unistd.h>
  37 #include <sys/types.h>
  38 #include "manifest_info.h"
  39 #include "version_comp.h"
  40 
  41 
  42 #define JVM_DLL "libjvm.so"
  43 #define JAVA_DLL "libjava.so"
  44 #ifdef AIX
  45 #define LD_LIBRARY_PATH "LIBPATH"
  46 #else
  47 #define LD_LIBRARY_PATH "LD_LIBRARY_PATH"
  48 #endif
  49 
  50 /* help jettison the LD_LIBRARY_PATH settings in the future */
  51 #ifndef SETENV_REQUIRED
  52 #define SETENV_REQUIRED
  53 #endif
  54 
  55 #ifdef __solaris__
  56 #  ifndef LIBARCHNAME
  57 #    error "The macro LIBARCHNAME was not defined on the compile line"
  58 #  endif
  59 #  include <sys/systeminfo.h>


  83  *
  84  * Now, in most cases,the launcher will dlopen the target libjvm.so. All
  85  * required libraries are loaded by the runtime linker, using the
  86  * $RPATH/$ORIGIN baked into the shared libraries at compile time. Therefore,
  87  * in most cases, the launcher will only exec, if the data models are
  88  * mismatched, and will not set any environment variables, regardless of the
  89  * data models.
  90  *
  91  * However, if the environment contains a LD_LIBRARY_PATH, this will cause the
  92  * launcher to inspect the LD_LIBRARY_PATH. The launcher will check
  93  *  a. if the LD_LIBRARY_PATH's first component is the the path to the desired
  94  *     libjvm.so
  95  *  b. if any other libjvm.so is found in any of the paths.
  96  * If case b is true, then the launcher will set the LD_LIBRARY_PATH to the
  97  * desired JRE and reexec, in order to propagate the environment.
  98  *
  99  *  Main
 100  *  (incoming argv)
 101  *  |
 102  * \|/
 103  * SelectVersion
 104  * (selects the JRE version, note: not data model)
 105  *  |
 106  * \|/
 107  * CreateExecutionEnvironment
 108  * (determines desired data model)
 109  *  |
 110  *  |
 111  * \|/
 112  *  Have Desired Model ? --> NO --> Exit(with error)
 113  *  |
 114  *  |
 115  * \|/
 116  * YES
 117  *  |
 118  *  |
 119  * \|/
 120  * CheckJvmType
 121  * (removes -client, -server, etc.)
 122  *  |
 123  *  |
 124  * \|/
 125  * TranslateDashJArgs...
 126  * (Prepare to pass args to vm)


   1 /*
   2  * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #include "java.h"
  27 #include "jvm_md.h"
  28 #include <dirent.h>
  29 #include <dlfcn.h>
  30 #include <fcntl.h>
  31 #include <inttypes.h>
  32 #include <stdio.h>
  33 #include <string.h>
  34 #include <stdlib.h>
  35 #include <sys/stat.h>
  36 #include <unistd.h>
  37 #include <sys/types.h>
  38 #include "manifest_info.h"

  39 
  40 
  41 #define JVM_DLL "libjvm.so"
  42 #define JAVA_DLL "libjava.so"
  43 #ifdef AIX
  44 #define LD_LIBRARY_PATH "LIBPATH"
  45 #else
  46 #define LD_LIBRARY_PATH "LD_LIBRARY_PATH"
  47 #endif
  48 
  49 /* help jettison the LD_LIBRARY_PATH settings in the future */
  50 #ifndef SETENV_REQUIRED
  51 #define SETENV_REQUIRED
  52 #endif
  53 
  54 #ifdef __solaris__
  55 #  ifndef LIBARCHNAME
  56 #    error "The macro LIBARCHNAME was not defined on the compile line"
  57 #  endif
  58 #  include <sys/systeminfo.h>


  82  *
  83  * Now, in most cases,the launcher will dlopen the target libjvm.so. All
  84  * required libraries are loaded by the runtime linker, using the
  85  * $RPATH/$ORIGIN baked into the shared libraries at compile time. Therefore,
  86  * in most cases, the launcher will only exec, if the data models are
  87  * mismatched, and will not set any environment variables, regardless of the
  88  * data models.
  89  *
  90  * However, if the environment contains a LD_LIBRARY_PATH, this will cause the
  91  * launcher to inspect the LD_LIBRARY_PATH. The launcher will check
  92  *  a. if the LD_LIBRARY_PATH's first component is the the path to the desired
  93  *     libjvm.so
  94  *  b. if any other libjvm.so is found in any of the paths.
  95  * If case b is true, then the launcher will set the LD_LIBRARY_PATH to the
  96  * desired JRE and reexec, in order to propagate the environment.
  97  *
  98  *  Main
  99  *  (incoming argv)
 100  *  |
 101  * \|/




 102  * CreateExecutionEnvironment
 103  * (determines desired data model)
 104  *  |
 105  *  |
 106  * \|/
 107  *  Have Desired Model ? --> NO --> Exit(with error)
 108  *  |
 109  *  |
 110  * \|/
 111  * YES
 112  *  |
 113  *  |
 114  * \|/
 115  * CheckJvmType
 116  * (removes -client, -server, etc.)
 117  *  |
 118  *  |
 119  * \|/
 120  * TranslateDashJArgs...
 121  * (Prepare to pass args to vm)