comparison src/share/vm/classfile/classLoader.cpp @ 1980:828eafbd85cc

6348631: remove the use of the HPI library from Hotspot Summary: move functions from hpi library to hotspot, communicate with licensees and open source community, check jdk for dependency, file CCC request Reviewed-by: coleenp, acorn, dsamersoff
author ikrylov
date Wed, 01 Dec 2010 18:26:32 -0500
parents f95d63e2154a
children 06f017f7daa7 75efcee5ac47
comparison
equal deleted inserted replaced
1972:f95d63e2154a 1980:828eafbd85cc
46 #include "runtime/arguments.hpp" 46 #include "runtime/arguments.hpp"
47 #include "runtime/compilationPolicy.hpp" 47 #include "runtime/compilationPolicy.hpp"
48 #include "runtime/fprofiler.hpp" 48 #include "runtime/fprofiler.hpp"
49 #include "runtime/handles.hpp" 49 #include "runtime/handles.hpp"
50 #include "runtime/handles.inline.hpp" 50 #include "runtime/handles.inline.hpp"
51 #include "runtime/hpi.hpp"
52 #include "runtime/init.hpp" 51 #include "runtime/init.hpp"
53 #include "runtime/interfaceSupport.hpp" 52 #include "runtime/interfaceSupport.hpp"
54 #include "runtime/java.hpp" 53 #include "runtime/java.hpp"
55 #include "runtime/javaCalls.hpp" 54 #include "runtime/javaCalls.hpp"
56 #include "runtime/threadCritical.hpp" 55 #include "runtime/threadCritical.hpp"
59 #include "services/threadService.hpp" 58 #include "services/threadService.hpp"
60 #include "utilities/events.hpp" 59 #include "utilities/events.hpp"
61 #include "utilities/hashtable.hpp" 60 #include "utilities/hashtable.hpp"
62 #include "utilities/hashtable.inline.hpp" 61 #include "utilities/hashtable.inline.hpp"
63 #ifdef TARGET_OS_FAMILY_linux 62 #ifdef TARGET_OS_FAMILY_linux
64 # include "hpi_linux.hpp"
65 # include "os_linux.inline.hpp" 63 # include "os_linux.inline.hpp"
66 #endif 64 #endif
67 #ifdef TARGET_OS_FAMILY_solaris 65 #ifdef TARGET_OS_FAMILY_solaris
68 # include "hpi_solaris.hpp"
69 # include "os_solaris.inline.hpp" 66 # include "os_solaris.inline.hpp"
70 #endif 67 #endif
71 #ifdef TARGET_OS_FAMILY_windows 68 #ifdef TARGET_OS_FAMILY_windows
72 # include "hpi_windows.hpp"
73 # include "os_windows.inline.hpp" 69 # include "os_windows.inline.hpp"
74 #endif 70 #endif
75 71
76 72
77 // Entry points in zip.dll for loading zip/jar file entries 73 // Entry points in zip.dll for loading zip/jar file entries
206 } 202 }
207 // check if file exists 203 // check if file exists
208 struct stat st; 204 struct stat st;
209 if (os::stat(path, &st) == 0) { 205 if (os::stat(path, &st) == 0) {
210 // found file, open it 206 // found file, open it
211 int file_handle = hpi::open(path, 0, 0); 207 int file_handle = os::open(path, 0, 0);
212 if (file_handle != -1) { 208 if (file_handle != -1) {
213 // read contents into resource array 209 // read contents into resource array
214 u1* buffer = NEW_RESOURCE_ARRAY(u1, st.st_size); 210 u1* buffer = NEW_RESOURCE_ARRAY(u1, st.st_size);
215 size_t num_read = os::read(file_handle, (char*) buffer, st.st_size); 211 size_t num_read = os::read(file_handle, (char*) buffer, st.st_size);
216 // close file 212 // close file
217 hpi::close(file_handle); 213 os::close(file_handle);
218 // construct ClassFileStream 214 // construct ClassFileStream
219 if (num_read == (size_t)st.st_size) { 215 if (num_read == (size_t)st.st_size) {
220 if (UsePerfData) { 216 if (UsePerfData) {
221 ClassLoader::perf_sys_classfile_bytes_read()->inc(num_read); 217 ClassLoader::perf_sys_classfile_bytes_read()->inc(num_read);
222 } 218 }
605 // First make sure native library is loaded 601 // First make sure native library is loaded
606 os::native_java_library(); 602 os::native_java_library();
607 // Load zip library 603 // Load zip library
608 char path[JVM_MAXPATHLEN]; 604 char path[JVM_MAXPATHLEN];
609 char ebuf[1024]; 605 char ebuf[1024];
610 hpi::dll_build_name(path, sizeof(path), Arguments::get_dll_dir(), "zip"); 606 os::dll_build_name(path, sizeof(path), Arguments::get_dll_dir(), "zip");
611 void* handle = hpi::dll_load(path, ebuf, sizeof ebuf); 607 void* handle = os::dll_load(path, ebuf, sizeof ebuf);
612 if (handle == NULL) { 608 if (handle == NULL) {
613 vm_exit_during_initialization("Unable to load ZIP library", path); 609 vm_exit_during_initialization("Unable to load ZIP library", path);
614 } 610 }
615 // Lookup zip entry points 611 // Lookup zip entry points
616 ZipOpen = CAST_TO_FN_PTR(ZipOpen_t, hpi::dll_lookup(handle, "ZIP_Open")); 612 ZipOpen = CAST_TO_FN_PTR(ZipOpen_t, os::dll_lookup(handle, "ZIP_Open"));
617 ZipClose = CAST_TO_FN_PTR(ZipClose_t, hpi::dll_lookup(handle, "ZIP_Close")); 613 ZipClose = CAST_TO_FN_PTR(ZipClose_t, os::dll_lookup(handle, "ZIP_Close"));
618 FindEntry = CAST_TO_FN_PTR(FindEntry_t, hpi::dll_lookup(handle, "ZIP_FindEntry")); 614 FindEntry = CAST_TO_FN_PTR(FindEntry_t, os::dll_lookup(handle, "ZIP_FindEntry"));
619 ReadEntry = CAST_TO_FN_PTR(ReadEntry_t, hpi::dll_lookup(handle, "ZIP_ReadEntry")); 615 ReadEntry = CAST_TO_FN_PTR(ReadEntry_t, os::dll_lookup(handle, "ZIP_ReadEntry"));
620 ReadMappedEntry = CAST_TO_FN_PTR(ReadMappedEntry_t, hpi::dll_lookup(handle, "ZIP_ReadMappedEntry")); 616 ReadMappedEntry = CAST_TO_FN_PTR(ReadMappedEntry_t, os::dll_lookup(handle, "ZIP_ReadMappedEntry"));
621 GetNextEntry = CAST_TO_FN_PTR(GetNextEntry_t, hpi::dll_lookup(handle, "ZIP_GetNextEntry")); 617 GetNextEntry = CAST_TO_FN_PTR(GetNextEntry_t, os::dll_lookup(handle, "ZIP_GetNextEntry"));
622 618
623 // ZIP_Close is not exported on Windows in JDK5.0 so don't abort if ZIP_Close is NULL 619 // ZIP_Close is not exported on Windows in JDK5.0 so don't abort if ZIP_Close is NULL
624 if (ZipOpen == NULL || FindEntry == NULL || ReadEntry == NULL || GetNextEntry == NULL) { 620 if (ZipOpen == NULL || FindEntry == NULL || ReadEntry == NULL || GetNextEntry == NULL) {
625 vm_exit_during_initialization("Corrupted ZIP library", path); 621 vm_exit_during_initialization("Corrupted ZIP library", path);
626 } 622 }
627 623
628 // Lookup canonicalize entry in libjava.dll 624 // Lookup canonicalize entry in libjava.dll
629 void *javalib_handle = os::native_java_library(); 625 void *javalib_handle = os::native_java_library();
630 CanonicalizeEntry = CAST_TO_FN_PTR(canonicalize_fn_t, hpi::dll_lookup(javalib_handle, "Canonicalize")); 626 CanonicalizeEntry = CAST_TO_FN_PTR(canonicalize_fn_t, os::dll_lookup(javalib_handle, "Canonicalize"));
631 // This lookup only works on 1.3. Do not check for non-null here 627 // This lookup only works on 1.3. Do not check for non-null here
632 } 628 }
633 629
634 // PackageInfo data exists in order to support the java.lang.Package 630 // PackageInfo data exists in order to support the java.lang.Package
635 // class. A Package object provides information about a java package 631 // class. A Package object provides information about a java package
1074 1070
1075 bool ClassLoader::get_canonical_path(char* orig, char* out, int len) { 1071 bool ClassLoader::get_canonical_path(char* orig, char* out, int len) {
1076 assert(orig != NULL && out != NULL && len > 0, "bad arguments"); 1072 assert(orig != NULL && out != NULL && len > 0, "bad arguments");
1077 if (CanonicalizeEntry != NULL) { 1073 if (CanonicalizeEntry != NULL) {
1078 JNIEnv* env = JavaThread::current()->jni_environment(); 1074 JNIEnv* env = JavaThread::current()->jni_environment();
1079 if ((CanonicalizeEntry)(env, hpi::native_path(orig), out, len) < 0) { 1075 if ((CanonicalizeEntry)(env, os::native_path(orig), out, len) < 0) {
1080 return false; 1076 return false;
1081 } 1077 }
1082 } else { 1078 } else {
1083 // On JDK 1.2.2 the Canonicalize does not exist, so just do nothing 1079 // On JDK 1.2.2 the Canonicalize does not exist, so just do nothing
1084 strncpy(out, orig, len); 1080 strncpy(out, orig, len);