changeset 37612:2c9bb54c90dc

8147634: Need a JImage API that given a JImageLocationRef returns class name Reviewed-by: hseigel
author jlaskey
date Mon, 25 Apr 2016 09:57:55 -0300
parents 46a18ff2e16e
children 2040f359c9b1
files jdk/make/lib/CoreLibraries.gmk jdk/make/mapfiles/libjimage/mapfile-vers jdk/src/java.base/share/native/libjimage/jimage.cpp jdk/src/java.base/share/native/libjimage/jimage.hpp
diffstat 4 files changed, 43 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/make/lib/CoreLibraries.gmk	Mon Apr 25 09:57:55 2016 -0300
+++ b/jdk/make/lib/CoreLibraries.gmk	Mon Apr 25 09:57:55 2016 -0300
@@ -267,7 +267,7 @@
     LDFLAGS_windows := -export:JIMAGE_Open -export:JIMAGE_Close \
         -export:JIMAGE_PackageToModule \
         -export:JIMAGE_FindResource -export:JIMAGE_GetResource \
-        -export:JIMAGE_ResourceIterator, \
+        -export:JIMAGE_ResourceIterator -export:JIMAGE_ResourcePath, \
     LIBS_unix := -ljvm -ldl $(LIBCXX), \
     LIBS_solaris := -lc, \
     LIBS_macosx := -lc++, \
--- a/jdk/make/mapfiles/libjimage/mapfile-vers	Mon Apr 25 09:57:55 2016 -0300
+++ b/jdk/make/mapfiles/libjimage/mapfile-vers	Mon Apr 25 09:57:55 2016 -0300
@@ -34,6 +34,7 @@
         JIMAGE_FindResource;
         JIMAGE_GetResource;
         JIMAGE_ResourceIterator;
+        JIMAGE_ResourcePath;
     local:
         *;
 };
--- a/jdk/src/java.base/share/native/libjimage/jimage.cpp	Mon Apr 25 09:57:55 2016 -0300
+++ b/jdk/src/java.base/share/native/libjimage/jimage.cpp	Mon Apr 25 09:57:55 2016 -0300
@@ -207,7 +207,30 @@
         if (!(*visitor)(image, module, "9", parent, base, extension, arg)) {
             break;
         }
-
     }
 }
 
+/*
+ * 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" 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/jdk/src/java.base/share/native/libjimage/jimage.hpp	Mon Apr 25 09:57:55 2016 -0300
+++ b/jdk/src/java.base/share/native/libjimage/jimage.hpp	Mon Apr 25 09:57:55 2016 -0300
@@ -186,3 +186,20 @@
 
 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" 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);
+