aboutsummaryrefslogtreecommitdiff
path: root/src/share
diff options
context:
space:
mode:
authorcjplummer <none@none>2012-11-09 09:45:00 -0800
committercjplummer <none@none>2012-11-09 09:45:00 -0800
commitca4f52d1389f9b1911e4f5b439c52561dc385562 (patch)
tree85cb6c07489ef48108e6a65bdfa7dd7917dca012 /src/share
parent819f81c655c207b41ab0cb02788682aa69c3dceb (diff)
parentf5e892179deba3088fc1dc8328bdd4b8af6ba246 (diff)
Merge
Diffstat (limited to 'src/share')
-rw-r--r--src/share/vm/classfile/classLoader.cpp6
-rw-r--r--src/share/vm/prims/jvmtiExport.cpp13
-rw-r--r--src/share/vm/runtime/os.cpp20
-rw-r--r--src/share/vm/runtime/os.hpp3
-rw-r--r--src/share/vm/runtime/thread.cpp11
5 files changed, 34 insertions, 19 deletions
diff --git a/src/share/vm/classfile/classLoader.cpp b/src/share/vm/classfile/classLoader.cpp
index 057b17728..b5e858a33 100644
--- a/src/share/vm/classfile/classLoader.cpp
+++ b/src/share/vm/classfile/classLoader.cpp
@@ -605,8 +605,10 @@ void ClassLoader::load_zip_library() {
// Load zip library
char path[JVM_MAXPATHLEN];
char ebuf[1024];
- os::dll_build_name(path, sizeof(path), Arguments::get_dll_dir(), "zip");
- void* handle = os::dll_load(path, ebuf, sizeof ebuf);
+ void* handle = NULL;
+ if (os::dll_build_name(path, sizeof(path), Arguments::get_dll_dir(), "zip")) {
+ handle = os::dll_load(path, ebuf, sizeof ebuf);
+ }
if (handle == NULL) {
vm_exit_during_initialization("Unable to load ZIP library", path);
}
diff --git a/src/share/vm/prims/jvmtiExport.cpp b/src/share/vm/prims/jvmtiExport.cpp
index 40e8e2115..63cab9c7d 100644
--- a/src/share/vm/prims/jvmtiExport.cpp
+++ b/src/share/vm/prims/jvmtiExport.cpp
@@ -2177,7 +2177,7 @@ extern "C" {
jint JvmtiExport::load_agent_library(AttachOperation* op, outputStream* st) {
char ebuf[1024];
char buffer[JVM_MAXPATHLEN];
- void* library;
+ void* library = NULL;
jint result = JNI_ERR;
// get agent name and options
@@ -2196,13 +2196,16 @@ jint JvmtiExport::load_agent_library(AttachOperation* op, outputStream* st) {
library = os::dll_load(agent, ebuf, sizeof ebuf);
} else {
// Try to load the agent from the standard dll directory
- os::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), agent);
- library = os::dll_load(buffer, ebuf, sizeof ebuf);
+ if (os::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(),
+ agent)) {
+ library = os::dll_load(buffer, ebuf, sizeof ebuf);
+ }
if (library == NULL) {
// not found - try local path
char ns[1] = {0};
- os::dll_build_name(buffer, sizeof(buffer), ns, agent);
- library = os::dll_load(buffer, ebuf, sizeof ebuf);
+ if (os::dll_build_name(buffer, sizeof(buffer), ns, agent)) {
+ library = os::dll_load(buffer, ebuf, sizeof ebuf);
+ }
}
}
diff --git a/src/share/vm/runtime/os.cpp b/src/share/vm/runtime/os.cpp
index 56bd82613..93041c0aa 100644
--- a/src/share/vm/runtime/os.cpp
+++ b/src/share/vm/runtime/os.cpp
@@ -397,12 +397,16 @@ void* os::native_java_library() {
// Try to load verify dll first. In 1.3 java dll depends on it and is not
// always able to find it when the loading executable is outside the JDK.
// In order to keep working with 1.2 we ignore any loading errors.
- dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "verify");
- dll_load(buffer, ebuf, sizeof(ebuf));
+ if (dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(),
+ "verify")) {
+ dll_load(buffer, ebuf, sizeof(ebuf));
+ }
// Load java dll
- dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "java");
- _native_java_library = dll_load(buffer, ebuf, sizeof(ebuf));
+ if (dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(),
+ "java")) {
+ _native_java_library = dll_load(buffer, ebuf, sizeof(ebuf));
+ }
if (_native_java_library == NULL) {
vm_exit_during_initialization("Unable to load native library", ebuf);
}
@@ -410,8 +414,10 @@ void* os::native_java_library() {
#if defined(__OpenBSD__)
// Work-around OpenBSD's lack of $ORIGIN support by pre-loading libnet.so
// ignore errors
- dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "net");
- dll_load(buffer, ebuf, sizeof(ebuf));
+ if (dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(),
+ "net")) {
+ dll_load(buffer, ebuf, sizeof(ebuf));
+ }
#endif
}
static jboolean onLoaded = JNI_FALSE;
@@ -1156,7 +1162,7 @@ char** os::split_path(const char* path, int* n) {
if (inpath == NULL) {
return NULL;
}
- strncpy(inpath, path, strlen(path));
+ strcpy(inpath, path);
int count = 1;
char* p = strchr(inpath, psepchar);
// Get a count of elements to allocate memory
diff --git a/src/share/vm/runtime/os.hpp b/src/share/vm/runtime/os.hpp
index bb5d6ea9e..ad43ddf83 100644
--- a/src/share/vm/runtime/os.hpp
+++ b/src/share/vm/runtime/os.hpp
@@ -479,7 +479,8 @@ class os: AllStatic {
static const char* get_current_directory(char *buf, int buflen);
// Builds a platform-specific full library path given a ld path and lib name
- static void dll_build_name(char* buffer, size_t size,
+ // Returns true if buffer contains full path to existing file, false otherwise
+ static bool dll_build_name(char* buffer, size_t size,
const char* pathname, const char* fname);
// Symbol lookup, find nearest function name; basically it implements
diff --git a/src/share/vm/runtime/thread.cpp b/src/share/vm/runtime/thread.cpp
index a3656dcda..acdf01241 100644
--- a/src/share/vm/runtime/thread.cpp
+++ b/src/share/vm/runtime/thread.cpp
@@ -3753,8 +3753,10 @@ static OnLoadEntry_t lookup_on_load(AgentLibrary* agent, const char *on_load_sym
}
} else {
// Try to load the agent from the standard dll directory
- os::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), name);
- library = os::dll_load(buffer, ebuf, sizeof ebuf);
+ if (os::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(),
+ name)) {
+ library = os::dll_load(buffer, ebuf, sizeof ebuf);
+ }
#ifdef KERNEL
// Download instrument dll
if (library == NULL && strcmp(name, "instrument") == 0) {
@@ -3779,8 +3781,9 @@ static OnLoadEntry_t lookup_on_load(AgentLibrary* agent, const char *on_load_sym
#endif // KERNEL
if (library == NULL) { // Try the local directory
char ns[1] = {0};
- os::dll_build_name(buffer, sizeof(buffer), ns, name);
- library = os::dll_load(buffer, ebuf, sizeof ebuf);
+ if (os::dll_build_name(buffer, sizeof(buffer), ns, name)) {
+ library = os::dll_load(buffer, ebuf, sizeof ebuf);
+ }
if (library == NULL) {
const char *sub_msg = " on the library path, with error: ";
size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1;