Mercurial > hg > truffle
comparison src/share/vm/classfile/classLoader.cpp @ 20730:8210e5f2e21b
8044269: Analysis of archive files.
Summary: Add checksum verification.
Reviewed-by: iklam, dholmes, mschoene
author | jiangli |
---|---|
date | Tue, 12 Aug 2014 17:46:16 -0400 |
parents | 78bbf4d43a14 |
children | eaf39a954227 8cb56c8cb30d |
comparison
equal
deleted
inserted
replaced
20729:609faa407cfd | 20730:8210e5f2e21b |
---|---|
82 typedef void (JNICALL *ZipClose_t)(jzfile *zip); | 82 typedef void (JNICALL *ZipClose_t)(jzfile *zip); |
83 typedef jzentry* (JNICALL *FindEntry_t)(jzfile *zip, const char *name, jint *sizeP, jint *nameLen); | 83 typedef jzentry* (JNICALL *FindEntry_t)(jzfile *zip, const char *name, jint *sizeP, jint *nameLen); |
84 typedef jboolean (JNICALL *ReadEntry_t)(jzfile *zip, jzentry *entry, unsigned char *buf, char *namebuf); | 84 typedef jboolean (JNICALL *ReadEntry_t)(jzfile *zip, jzentry *entry, unsigned char *buf, char *namebuf); |
85 typedef jboolean (JNICALL *ReadMappedEntry_t)(jzfile *zip, jzentry *entry, unsigned char **buf, char *namebuf); | 85 typedef jboolean (JNICALL *ReadMappedEntry_t)(jzfile *zip, jzentry *entry, unsigned char **buf, char *namebuf); |
86 typedef jzentry* (JNICALL *GetNextEntry_t)(jzfile *zip, jint n); | 86 typedef jzentry* (JNICALL *GetNextEntry_t)(jzfile *zip, jint n); |
87 typedef jint (JNICALL *Crc32_t)(jint crc, const jbyte *buf, jint len); | |
87 | 88 |
88 static ZipOpen_t ZipOpen = NULL; | 89 static ZipOpen_t ZipOpen = NULL; |
89 static ZipClose_t ZipClose = NULL; | 90 static ZipClose_t ZipClose = NULL; |
90 static FindEntry_t FindEntry = NULL; | 91 static FindEntry_t FindEntry = NULL; |
91 static ReadEntry_t ReadEntry = NULL; | 92 static ReadEntry_t ReadEntry = NULL; |
92 static ReadMappedEntry_t ReadMappedEntry = NULL; | 93 static ReadMappedEntry_t ReadMappedEntry = NULL; |
93 static GetNextEntry_t GetNextEntry = NULL; | 94 static GetNextEntry_t GetNextEntry = NULL; |
94 static canonicalize_fn_t CanonicalizeEntry = NULL; | 95 static canonicalize_fn_t CanonicalizeEntry = NULL; |
96 static Crc32_t Crc32 = NULL; | |
95 | 97 |
96 // Globals | 98 // Globals |
97 | 99 |
98 PerfCounter* ClassLoader::_perf_accumulated_time = NULL; | 100 PerfCounter* ClassLoader::_perf_accumulated_time = NULL; |
99 PerfCounter* ClassLoader::_perf_classes_inited = NULL; | 101 PerfCounter* ClassLoader::_perf_classes_inited = NULL; |
630 ZipClose = CAST_TO_FN_PTR(ZipClose_t, os::dll_lookup(handle, "ZIP_Close")); | 632 ZipClose = CAST_TO_FN_PTR(ZipClose_t, os::dll_lookup(handle, "ZIP_Close")); |
631 FindEntry = CAST_TO_FN_PTR(FindEntry_t, os::dll_lookup(handle, "ZIP_FindEntry")); | 633 FindEntry = CAST_TO_FN_PTR(FindEntry_t, os::dll_lookup(handle, "ZIP_FindEntry")); |
632 ReadEntry = CAST_TO_FN_PTR(ReadEntry_t, os::dll_lookup(handle, "ZIP_ReadEntry")); | 634 ReadEntry = CAST_TO_FN_PTR(ReadEntry_t, os::dll_lookup(handle, "ZIP_ReadEntry")); |
633 ReadMappedEntry = CAST_TO_FN_PTR(ReadMappedEntry_t, os::dll_lookup(handle, "ZIP_ReadMappedEntry")); | 635 ReadMappedEntry = CAST_TO_FN_PTR(ReadMappedEntry_t, os::dll_lookup(handle, "ZIP_ReadMappedEntry")); |
634 GetNextEntry = CAST_TO_FN_PTR(GetNextEntry_t, os::dll_lookup(handle, "ZIP_GetNextEntry")); | 636 GetNextEntry = CAST_TO_FN_PTR(GetNextEntry_t, os::dll_lookup(handle, "ZIP_GetNextEntry")); |
637 Crc32 = CAST_TO_FN_PTR(Crc32_t, os::dll_lookup(handle, "ZIP_CRC32")); | |
635 | 638 |
636 // ZIP_Close is not exported on Windows in JDK5.0 so don't abort if ZIP_Close is NULL | 639 // ZIP_Close is not exported on Windows in JDK5.0 so don't abort if ZIP_Close is NULL |
637 if (ZipOpen == NULL || FindEntry == NULL || ReadEntry == NULL || GetNextEntry == NULL) { | 640 if (ZipOpen == NULL || FindEntry == NULL || ReadEntry == NULL || |
641 GetNextEntry == NULL || Crc32 == NULL) { | |
638 vm_exit_during_initialization("Corrupted ZIP library", path); | 642 vm_exit_during_initialization("Corrupted ZIP library", path); |
639 } | 643 } |
640 | 644 |
641 // Lookup canonicalize entry in libjava.dll | 645 // Lookup canonicalize entry in libjava.dll |
642 void *javalib_handle = os::native_java_library(); | 646 void *javalib_handle = os::native_java_library(); |
643 CanonicalizeEntry = CAST_TO_FN_PTR(canonicalize_fn_t, os::dll_lookup(javalib_handle, "Canonicalize")); | 647 CanonicalizeEntry = CAST_TO_FN_PTR(canonicalize_fn_t, os::dll_lookup(javalib_handle, "Canonicalize")); |
644 // This lookup only works on 1.3. Do not check for non-null here | 648 // This lookup only works on 1.3. Do not check for non-null here |
649 } | |
650 | |
651 int ClassLoader::crc32(int crc, const char* buf, int len) { | |
652 assert(Crc32 != NULL, "ZIP_CRC32 is not found"); | |
653 return (*Crc32)(crc, (const jbyte*)buf, len); | |
645 } | 654 } |
646 | 655 |
647 // PackageInfo data exists in order to support the java.lang.Package | 656 // PackageInfo data exists in order to support the java.lang.Package |
648 // class. A Package object provides information about a java package | 657 // class. A Package object provides information about a java package |
649 // (version, vendor, etc.) which originates in the manifest of the jar | 658 // (version, vendor, etc.) which originates in the manifest of the jar |