Mercurial > hg > graal-compiler
comparison src/share/vm/classfile/classLoader.cpp @ 2044:06f017f7daa7
Merge.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Fri, 07 Jan 2011 18:18:08 +0100 |
parents | 2d26b0046e0d 828eafbd85cc |
children | d25d4ca69222 |
comparison
equal
deleted
inserted
replaced
1942:00bc9eaf0e24 | 2044:06f017f7daa7 |
---|---|
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 #include "incls/_precompiled.incl" | 25 #include "precompiled.hpp" |
26 #include "incls/_classLoader.cpp.incl" | 26 #include "classfile/classFileParser.hpp" |
27 #include "classfile/classFileStream.hpp" | |
28 #include "classfile/classLoader.hpp" | |
29 #include "classfile/javaClasses.hpp" | |
30 #include "classfile/systemDictionary.hpp" | |
31 #include "classfile/vmSymbols.hpp" | |
32 #include "compiler/compileBroker.hpp" | |
33 #include "gc_interface/collectedHeap.inline.hpp" | |
34 #include "interpreter/bytecodeStream.hpp" | |
35 #include "interpreter/oopMapCache.hpp" | |
36 #include "memory/allocation.inline.hpp" | |
37 #include "memory/generation.hpp" | |
38 #include "memory/oopFactory.hpp" | |
39 #include "memory/universe.inline.hpp" | |
40 #include "oops/constantPoolKlass.hpp" | |
41 #include "oops/instanceKlass.hpp" | |
42 #include "oops/instanceRefKlass.hpp" | |
43 #include "oops/oop.inline.hpp" | |
44 #include "oops/symbolOop.hpp" | |
45 #include "prims/jvm_misc.hpp" | |
46 #include "runtime/arguments.hpp" | |
47 #include "runtime/compilationPolicy.hpp" | |
48 #include "runtime/fprofiler.hpp" | |
49 #include "runtime/handles.hpp" | |
50 #include "runtime/handles.inline.hpp" | |
51 #include "runtime/init.hpp" | |
52 #include "runtime/interfaceSupport.hpp" | |
53 #include "runtime/java.hpp" | |
54 #include "runtime/javaCalls.hpp" | |
55 #include "runtime/threadCritical.hpp" | |
56 #include "runtime/timer.hpp" | |
57 #include "services/management.hpp" | |
58 #include "services/threadService.hpp" | |
59 #include "utilities/events.hpp" | |
60 #include "utilities/hashtable.hpp" | |
61 #include "utilities/hashtable.inline.hpp" | |
62 #ifdef TARGET_OS_FAMILY_linux | |
63 # include "os_linux.inline.hpp" | |
64 #endif | |
65 #ifdef TARGET_OS_FAMILY_solaris | |
66 # include "os_solaris.inline.hpp" | |
67 #endif | |
68 #ifdef TARGET_OS_FAMILY_windows | |
69 # include "os_windows.inline.hpp" | |
70 #endif | |
27 | 71 |
28 | 72 |
29 // Entry points in zip.dll for loading zip/jar file entries | 73 // Entry points in zip.dll for loading zip/jar file entries |
30 | 74 |
31 typedef void * * (JNICALL *ZipOpen_t)(const char *name, char **pmsg); | 75 typedef void * * (JNICALL *ZipOpen_t)(const char *name, char **pmsg); |
158 } | 202 } |
159 // check if file exists | 203 // check if file exists |
160 struct stat st; | 204 struct stat st; |
161 if (os::stat(path, &st) == 0) { | 205 if (os::stat(path, &st) == 0) { |
162 // found file, open it | 206 // found file, open it |
163 int file_handle = hpi::open(path, 0, 0); | 207 int file_handle = os::open(path, 0, 0); |
164 if (file_handle != -1) { | 208 if (file_handle != -1) { |
165 // read contents into resource array | 209 // read contents into resource array |
166 u1* buffer = NEW_RESOURCE_ARRAY(u1, st.st_size); | 210 u1* buffer = NEW_RESOURCE_ARRAY(u1, st.st_size); |
167 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); |
168 // close file | 212 // close file |
169 hpi::close(file_handle); | 213 os::close(file_handle); |
170 // construct ClassFileStream | 214 // construct ClassFileStream |
171 if (num_read == (size_t)st.st_size) { | 215 if (num_read == (size_t)st.st_size) { |
172 if (UsePerfData) { | 216 if (UsePerfData) { |
173 ClassLoader::perf_sys_classfile_bytes_read()->inc(num_read); | 217 ClassLoader::perf_sys_classfile_bytes_read()->inc(num_read); |
174 } | 218 } |
557 // First make sure native library is loaded | 601 // First make sure native library is loaded |
558 os::native_java_library(); | 602 os::native_java_library(); |
559 // Load zip library | 603 // Load zip library |
560 char path[JVM_MAXPATHLEN]; | 604 char path[JVM_MAXPATHLEN]; |
561 char ebuf[1024]; | 605 char ebuf[1024]; |
562 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"); |
563 void* handle = hpi::dll_load(path, ebuf, sizeof ebuf); | 607 void* handle = os::dll_load(path, ebuf, sizeof ebuf); |
564 if (handle == NULL) { | 608 if (handle == NULL) { |
565 vm_exit_during_initialization("Unable to load ZIP library", path); | 609 vm_exit_during_initialization("Unable to load ZIP library", path); |
566 } | 610 } |
567 // Lookup zip entry points | 611 // Lookup zip entry points |
568 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")); |
569 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")); |
570 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")); |
571 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")); |
572 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")); |
573 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")); |
574 | 618 |
575 // 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 |
576 if (ZipOpen == NULL || FindEntry == NULL || ReadEntry == NULL || GetNextEntry == NULL) { | 620 if (ZipOpen == NULL || FindEntry == NULL || ReadEntry == NULL || GetNextEntry == NULL) { |
577 vm_exit_during_initialization("Corrupted ZIP library", path); | 621 vm_exit_during_initialization("Corrupted ZIP library", path); |
578 } | 622 } |
579 | 623 |
580 // Lookup canonicalize entry in libjava.dll | 624 // Lookup canonicalize entry in libjava.dll |
581 void *javalib_handle = os::native_java_library(); | 625 void *javalib_handle = os::native_java_library(); |
582 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")); |
583 // 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 |
584 } | 628 } |
585 | 629 |
586 // PackageInfo data exists in order to support the java.lang.Package | 630 // PackageInfo data exists in order to support the java.lang.Package |
587 // class. A Package object provides information about a java package | 631 // class. A Package object provides information about a java package |
1026 | 1070 |
1027 bool ClassLoader::get_canonical_path(char* orig, char* out, int len) { | 1071 bool ClassLoader::get_canonical_path(char* orig, char* out, int len) { |
1028 assert(orig != NULL && out != NULL && len > 0, "bad arguments"); | 1072 assert(orig != NULL && out != NULL && len > 0, "bad arguments"); |
1029 if (CanonicalizeEntry != NULL) { | 1073 if (CanonicalizeEntry != NULL) { |
1030 JNIEnv* env = JavaThread::current()->jni_environment(); | 1074 JNIEnv* env = JavaThread::current()->jni_environment(); |
1031 if ((CanonicalizeEntry)(env, hpi::native_path(orig), out, len) < 0) { | 1075 if ((CanonicalizeEntry)(env, os::native_path(orig), out, len) < 0) { |
1032 return false; | 1076 return false; |
1033 } | 1077 } |
1034 } else { | 1078 } else { |
1035 // 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 |
1036 strncpy(out, orig, len); | 1080 strncpy(out, orig, len); |