8166930: minor cleanups 1) remove reference to ZIP_ReadMappedEntry 2) checking of st_mode

Reviewed-by: jiangli, lfoltan
This commit is contained in:
Calvin Cheung 2016-09-30 12:11:02 -07:00
parent d058e0d477
commit ac6b2ca3dc
3 changed files with 6 additions and 18 deletions

View file

@ -81,7 +81,6 @@ typedef void * * (JNICALL *ZipOpen_t)(const char *name, char **pmsg);
typedef void (JNICALL *ZipClose_t)(jzfile *zip); typedef void (JNICALL *ZipClose_t)(jzfile *zip);
typedef jzentry* (JNICALL *FindEntry_t)(jzfile *zip, const char *name, jint *sizeP, jint *nameLen); typedef jzentry* (JNICALL *FindEntry_t)(jzfile *zip, const char *name, jint *sizeP, jint *nameLen);
typedef jboolean (JNICALL *ReadEntry_t)(jzfile *zip, jzentry *entry, unsigned char *buf, char *namebuf); typedef jboolean (JNICALL *ReadEntry_t)(jzfile *zip, jzentry *entry, unsigned char *buf, char *namebuf);
typedef jboolean (JNICALL *ReadMappedEntry_t)(jzfile *zip, jzentry *entry, unsigned char **buf, char *namebuf);
typedef jzentry* (JNICALL *GetNextEntry_t)(jzfile *zip, jint n); typedef jzentry* (JNICALL *GetNextEntry_t)(jzfile *zip, jint n);
typedef jboolean (JNICALL *ZipInflateFully_t)(void *inBuf, jlong inLen, void *outBuf, jlong outLen, char **pmsg); typedef jboolean (JNICALL *ZipInflateFully_t)(void *inBuf, jlong inLen, void *outBuf, jlong outLen, char **pmsg);
typedef jint (JNICALL *Crc32_t)(jint crc, const jbyte *buf, jint len); typedef jint (JNICALL *Crc32_t)(jint crc, const jbyte *buf, jint len);
@ -91,7 +90,6 @@ static ZipOpen_t ZipOpen = NULL;
static ZipClose_t ZipClose = NULL; static ZipClose_t ZipClose = NULL;
static FindEntry_t FindEntry = NULL; static FindEntry_t FindEntry = NULL;
static ReadEntry_t ReadEntry = NULL; static ReadEntry_t ReadEntry = NULL;
static ReadMappedEntry_t ReadMappedEntry = NULL;
static GetNextEntry_t GetNextEntry = NULL; static GetNextEntry_t GetNextEntry = NULL;
static canonicalize_fn_t CanonicalizeEntry = NULL; static canonicalize_fn_t CanonicalizeEntry = NULL;
static ZipInflateFully_t ZipInflateFully = NULL; static ZipInflateFully_t ZipInflateFully = NULL;
@ -353,15 +351,10 @@ u1* ClassPathZipEntry::open_entry(const char* name, jint* filesize, bool nul_ter
filename = NEW_RESOURCE_ARRAY(char, name_len + 1); filename = NEW_RESOURCE_ARRAY(char, name_len + 1);
} }
// file found, get pointer to the entry in mmapped jar file. // read contents into resource array
if (ReadMappedEntry == NULL || int size = (*filesize) + ((nul_terminate) ? 1 : 0);
!(*ReadMappedEntry)(_zip, entry, &buffer, filename)) { buffer = NEW_RESOURCE_ARRAY(u1, size);
// mmapped access not available, perhaps due to compression, if (!(*ReadEntry)(_zip, entry, buffer, filename)) return NULL;
// read contents into resource array
int size = (*filesize) + ((nul_terminate) ? 1 : 0);
buffer = NEW_RESOURCE_ARRAY(u1, size);
if (!(*ReadEntry)(_zip, entry, buffer, filename)) return NULL;
}
// return result // return result
if (nul_terminate) { if (nul_terminate) {
@ -1079,7 +1072,6 @@ void ClassLoader::load_zip_library() {
ZipClose = CAST_TO_FN_PTR(ZipClose_t, os::dll_lookup(handle, "ZIP_Close")); ZipClose = CAST_TO_FN_PTR(ZipClose_t, os::dll_lookup(handle, "ZIP_Close"));
FindEntry = CAST_TO_FN_PTR(FindEntry_t, os::dll_lookup(handle, "ZIP_FindEntry")); FindEntry = CAST_TO_FN_PTR(FindEntry_t, os::dll_lookup(handle, "ZIP_FindEntry"));
ReadEntry = CAST_TO_FN_PTR(ReadEntry_t, os::dll_lookup(handle, "ZIP_ReadEntry")); ReadEntry = CAST_TO_FN_PTR(ReadEntry_t, os::dll_lookup(handle, "ZIP_ReadEntry"));
ReadMappedEntry = CAST_TO_FN_PTR(ReadMappedEntry_t, os::dll_lookup(handle, "ZIP_ReadMappedEntry"));
GetNextEntry = CAST_TO_FN_PTR(GetNextEntry_t, os::dll_lookup(handle, "ZIP_GetNextEntry")); GetNextEntry = CAST_TO_FN_PTR(GetNextEntry_t, os::dll_lookup(handle, "ZIP_GetNextEntry"));
ZipInflateFully = CAST_TO_FN_PTR(ZipInflateFully_t, os::dll_lookup(handle, "ZIP_InflateFully")); ZipInflateFully = CAST_TO_FN_PTR(ZipInflateFully_t, os::dll_lookup(handle, "ZIP_InflateFully"));
Crc32 = CAST_TO_FN_PTR(Crc32_t, os::dll_lookup(handle, "ZIP_CRC32")); Crc32 = CAST_TO_FN_PTR(Crc32_t, os::dll_lookup(handle, "ZIP_CRC32"));

View file

@ -97,11 +97,7 @@ static bool is_regular_file(const char* filename) {
if (ret != 0) { if (ret != 0) {
return false; return false;
} }
#ifdef _WINDOWS return (st.st_mode & S_IFMT) == S_IFREG;
return (st.st_mode & S_IFMT) == _S_IFREG;
#else
return S_ISREG(st.st_mode);
#endif
} }
// Try to find the next number that should be used for file rotation. // Try to find the next number that should be used for file rotation.

View file

@ -263,7 +263,7 @@ void FileMapInfo::allocate_classpath_entry_table() {
} else { } else {
struct stat st; struct stat st;
if (os::stat(name, &st) == 0) { if (os::stat(name, &st) == 0) {
if ((st.st_mode & S_IFDIR) == S_IFDIR) { if ((st.st_mode & S_IFMT) == S_IFDIR) {
if (!os::dir_is_empty(name)) { if (!os::dir_is_empty(name)) {
ClassLoader::exit_with_path_failure( ClassLoader::exit_with_path_failure(
"Cannot have non-empty directory in archived classpaths", name); "Cannot have non-empty directory in archived classpaths", name);