8219142: Remove unused JIMAGE_ResourcePath
authormikael
Wed, 20 Feb 2019 09:43:01 -0800
changeset 53851 cc4f5bf6b26b
parent 53850 f42c58bab973
child 53852 25002c4f0145
child 53853 7ca9e625d6b2
child 53858 e7cf035682e3
8219142: Remove unused JIMAGE_ResourcePath Reviewed-by: dholmes, alanb
src/hotspot/share/classfile/classLoader.cpp
src/java.base/share/native/libjimage/imageFile.cpp
src/java.base/share/native/libjimage/imageFile.hpp
src/java.base/share/native/libjimage/jimage.cpp
src/java.base/share/native/libjimage/jimage.hpp
--- a/src/hotspot/share/classfile/classLoader.cpp	Wed Feb 20 16:29:29 2019 +0100
+++ b/src/hotspot/share/classfile/classLoader.cpp	Wed Feb 20 09:43:01 2019 -0800
@@ -101,7 +101,6 @@
 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 @@
   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) {
--- a/src/java.base/share/native/libjimage/imageFile.cpp	Wed Feb 20 16:29:29 2019 +0100
+++ b/src/java.base/share/native/libjimage/imageFile.cpp	Wed Feb 20 09:43:01 2019 -0800
@@ -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 @@
     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.
--- a/src/java.base/share/native/libjimage/imageFile.hpp	Wed Feb 20 16:29:29 2019 +0100
+++ b/src/java.base/share/native/libjimage/imageFile.hpp	Wed Feb 20 09:43:01 2019 -0800
@@ -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 @@
     // 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;
 
--- a/src/java.base/share/native/libjimage/jimage.cpp	Wed Feb 20 16:29:29 2019 +0100
+++ b/src/java.base/share/native/libjimage/jimage.cpp	Wed Feb 20 09:43:01 2019 -0800
@@ -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_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;
-}
--- a/src/java.base/share/native/libjimage/jimage.hpp	Wed Feb 20 16:29:29 2019 +0100
+++ b/src/java.base/share/native/libjimage/jimage.hpp	Wed Feb 20 09:43:01 2019 -0800
@@ -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 @@
 
 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);