8219142: Remove unused JIMAGE_ResourcePath
Reviewed-by: dholmes, alanb
This commit is contained in:
parent
96e4678510
commit
ea42bbcd24
@ -101,7 +101,6 @@ static JImagePackageToModule_t JImagePackageToModule = NULL;
|
||||
static JImageFindResource_t JImageFindResource = NULL;
|
||||
static JImageGetResource_t JImageGetResource = NULL;
|
||||
static JImageResourceIterator_t JImageResourceIterator = NULL;
|
||||
static JImage_ResourcePath_t JImageResourcePath = NULL;
|
||||
|
||||
// Globals
|
||||
|
||||
@ -1094,8 +1093,6 @@ void ClassLoader::load_jimage_library() {
|
||||
guarantee(JImageGetResource != NULL, "function JIMAGE_GetResource not found");
|
||||
JImageResourceIterator = CAST_TO_FN_PTR(JImageResourceIterator_t, os::dll_lookup(handle, "JIMAGE_ResourceIterator"));
|
||||
guarantee(JImageResourceIterator != NULL, "function JIMAGE_ResourceIterator not found");
|
||||
JImageResourcePath = CAST_TO_FN_PTR(JImage_ResourcePath_t, os::dll_lookup(handle, "JIMAGE_ResourcePath"));
|
||||
guarantee(JImageResourcePath != NULL, "function JIMAGE_ResourcePath not found");
|
||||
}
|
||||
|
||||
jboolean ClassLoader::decompress(void *in, u8 inSize, void *out, u8 outSize, char **pmsg) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -481,65 +481,6 @@ u4 ImageFileReader::find_location_index(const char* path, u8 *size) const {
|
||||
return 0; // not found
|
||||
}
|
||||
|
||||
// Assemble the location path from the string fragments indicated in the location attributes.
|
||||
void ImageFileReader::location_path(ImageLocation& location, char* path, size_t max) const {
|
||||
// Manage the image string table.
|
||||
ImageStrings strings(_string_bytes, _header.strings_size(_endian));
|
||||
// Position to first character of the path buffer.
|
||||
char* next = path;
|
||||
// Temp for string length.
|
||||
size_t length;
|
||||
// Get module string.
|
||||
const char* module = location.get_attribute(ImageLocation::ATTRIBUTE_MODULE, strings);
|
||||
// If module string is not empty string.
|
||||
if (*module != '\0') {
|
||||
// Get length of module name.
|
||||
length = strlen(module);
|
||||
// Make sure there is no buffer overflow.
|
||||
assert(next - path + length + 2 < max && "buffer overflow");
|
||||
// Append '/module/'.
|
||||
*next++ = '/';
|
||||
strncpy(next, module, length); next += length;
|
||||
*next++ = '/';
|
||||
}
|
||||
// Get parent (package) string.
|
||||
const char* parent = location.get_attribute(ImageLocation::ATTRIBUTE_PARENT, strings);
|
||||
// If parent string is not empty string.
|
||||
if (*parent != '\0') {
|
||||
// Get length of module string.
|
||||
length = strlen(parent);
|
||||
// Make sure there is no buffer overflow.
|
||||
assert(next - path + length + 1 < max && "buffer overflow");
|
||||
// Append 'patent/' .
|
||||
strncpy(next, parent, length); next += length;
|
||||
*next++ = '/';
|
||||
}
|
||||
// Get base name string.
|
||||
const char* base = location.get_attribute(ImageLocation::ATTRIBUTE_BASE, strings);
|
||||
// Get length of base name.
|
||||
length = strlen(base);
|
||||
// Make sure there is no buffer overflow.
|
||||
assert(next - path + length < max && "buffer overflow");
|
||||
// Append base name.
|
||||
strncpy(next, base, length); next += length;
|
||||
// Get extension string.
|
||||
const char* extension = location.get_attribute(ImageLocation::ATTRIBUTE_EXTENSION, strings);
|
||||
// If extension string is not empty string.
|
||||
if (*extension != '\0') {
|
||||
// Get length of extension string.
|
||||
length = strlen(extension);
|
||||
// Make sure there is no buffer overflow.
|
||||
assert(next - path + length + 1 < max && "buffer overflow");
|
||||
// Append '.extension' .
|
||||
*next++ = '.';
|
||||
strncpy(next, extension, length); next += length;
|
||||
}
|
||||
// Make sure there is no buffer overflow.
|
||||
assert((size_t)(next - path) < max && "buffer overflow");
|
||||
// Terminate string.
|
||||
*next = '\0';
|
||||
}
|
||||
|
||||
// Verify that a found location matches the supplied path (without copying.)
|
||||
bool ImageFileReader::verify_location(ImageLocation& location, const char* path) const {
|
||||
// Manage the image string table.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -564,9 +564,6 @@ public:
|
||||
// ImageFileReader::NOT_FOUND otherwise.
|
||||
u4 find_location_index(const char* path, u8 *size) const;
|
||||
|
||||
// Assemble the location path.
|
||||
void location_path(ImageLocation& location, char* path, size_t max) const;
|
||||
|
||||
// Verify that a found location matches the supplied path.
|
||||
bool verify_location(ImageLocation& location, const char* path) const;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -215,29 +215,3 @@ JIMAGE_ResourceIterator(JImageFile* image,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* JIMAGE_ResourcePath- Given an open image file, a location reference, a buffer
|
||||
* and a maximum buffer size, copy the path of the resource into the buffer.
|
||||
* Returns false if not a valid location reference.
|
||||
*
|
||||
* Ex.
|
||||
* JImageLocationRef location = ...
|
||||
* char path[JIMAGE_MAX_PATH];
|
||||
* (*JImageResourcePath)(image, location, path, JIMAGE_MAX_PATH);
|
||||
*/
|
||||
extern "C" JNIEXPORT bool
|
||||
JIMAGE_ResourcePath(JImageFile* image, JImageLocationRef locationRef,
|
||||
char* path, size_t max) {
|
||||
ImageFileReader* imageFile = (ImageFileReader*) image;
|
||||
|
||||
u4 offset = (u4) locationRef;
|
||||
if (offset >= imageFile->locations_size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ImageLocation location(imageFile->get_location_offset_data(offset));
|
||||
imageFile->location_path(location, path, max);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -191,20 +191,3 @@ JIMAGE_ResourceIterator(JImageFile* jimage,
|
||||
|
||||
typedef void (*JImageResourceIterator_t)(JImageFile* jimage,
|
||||
JImageResourceVisitor_t visitor, void* arg);
|
||||
|
||||
/*
|
||||
* JIMAGE_ResourcePath- Given an open image file, a location reference, a buffer
|
||||
* and a maximum buffer size, copy the path of the resource into the buffer.
|
||||
* Returns false if not a valid location reference.
|
||||
*
|
||||
* Ex.
|
||||
* JImageLocationRef location = ...
|
||||
* char path[JIMAGE_MAX_PATH];
|
||||
* (*JImageResourcePath)(image, location, path, JIMAGE_MAX_PATH);
|
||||
*/
|
||||
extern "C" JNIEXPORT bool
|
||||
JIMAGE_ResourcePath(JImageFile* image, JImageLocationRef locationRef,
|
||||
char* path, size_t max);
|
||||
|
||||
typedef bool (*JImage_ResourcePath_t)(JImageFile* jimage, JImageLocationRef location,
|
||||
char* buffer, jlong size);
|
||||
|
Loading…
Reference in New Issue
Block a user