hotspot/src/share/vm/classfile/jimage.hpp
changeset 37489 b2812e811d0d
parent 36508 5f9eee6b383b
child 37490 fd089d3f8cb3
equal deleted inserted replaced
37488:ab63cdc0e14e 37489:b2812e811d0d
    28 class JImageFile;
    28 class JImageFile;
    29 // Opaque reference to an image file resource location.
    29 // Opaque reference to an image file resource location.
    30 typedef jlong JImageLocationRef;
    30 typedef jlong JImageLocationRef;
    31 
    31 
    32 // Max path length limit independent of platform.  Windows max path is 1024,
    32 // Max path length limit independent of platform.  Windows max path is 1024,
    33 // other platforms use 4096.  The JCK fails several tests when 1024 is used.
    33 // other platforms use 4096.
    34 #define JIMAGE_MAX_PATH 4096
    34 #define JIMAGE_MAX_PATH 4096
    35 
    35 
    36 // JImage Error Codes
    36 // JImage Error Codes
    37 
    37 
    38 // Resource was not found
    38 // Resource was not found
   111  * The resulting location does/should not have to be released.
   111  * The resulting location does/should not have to be released.
   112  * All strings are utf-8, zero byte terminated.
   112  * All strings are utf-8, zero byte terminated.
   113  *
   113  *
   114  *  Ex.
   114  *  Ex.
   115  *   jlong size;
   115  *   jlong size;
   116  *   JImageLocationRef location = (*JImageFindResource)(image, "java.base", "9.0", "java/lang/String.class", &size);
   116  *   JImageLocationRef location = (*JImageFindResource)(image,
       
   117  *                                "java.base", "9.0", "java/lang/String.class", &size);
   117  */
   118  */
   118 extern "C" JImageLocationRef JIMAGE_FindResource(JImageFile* jimage,
   119 extern "C" JImageLocationRef JIMAGE_FindResource(JImageFile* jimage,
   119         const char* module_name, const char* version, const char* name,
   120         const char* module_name, const char* version, const char* name,
   120         jlong* size);
   121         jlong* size);
   121 
   122 
   132  * If the size is greater than the resource size then the remainder of the buffer
   133  * If the size is greater than the resource size then the remainder of the buffer
   133  * is zero filled.  The function will return the actual size of the resource.
   134  * is zero filled.  The function will return the actual size of the resource.
   134  *
   135  *
   135  * Ex.
   136  * Ex.
   136  *  jlong size;
   137  *  jlong size;
   137  *  JImageLocationRef location = (*JImageFindResource)(image, "java.base", "9.0", "java/lang/String.class", &size);
   138  *  JImageLocationRef location = (*JImageFindResource)(image,
       
   139  *                               "java.base", "9.0", "java/lang/String.class", &size);
   138  *  char* buffer = new char[size];
   140  *  char* buffer = new char[size];
   139  *  (*JImageGetResource)(image, location, buffer, size);
   141  *  (*JImageGetResource)(image, location, buffer, size);
   140  */
   142  */
   141 extern "C" jlong JIMAGE_GetResource(JImageFile* jimage, JImageLocationRef location,
   143 extern "C" jlong JIMAGE_GetResource(JImageFile* jimage, JImageLocationRef location,
   142         char* buffer, jlong size);
   144         char* buffer, jlong size);
   152  * package name, the base name, the extension and the visitor argument. The return
   154  * package name, the base name, the extension and the visitor argument. The return
   153  * value of the visitor function should be true, unless an early iteration exit is
   155  * value of the visitor function should be true, unless an early iteration exit is
   154  * required. All strings are utf-8, zero byte terminated.file.
   156  * required. All strings are utf-8, zero byte terminated.file.
   155  *
   157  *
   156  * Ex.
   158  * Ex.
   157  *   bool ctw_visitor(JImageFile* jimage, const char* module_name, const char* version, const char* package, const char* name, const char* extension, void* arg) {
   159  *   bool ctw_visitor(JImageFile* jimage, const char* module_name, const char* version,
       
   160  *                  const char* package, const char* name, const char* extension, void* arg) {
   158  *     if (strcmp(extension, “class”) == 0) {
   161  *     if (strcmp(extension, “class”) == 0) {
   159  *       char path[JIMAGE_MAX_PATH];
   162  *       char path[JIMAGE_MAX_PATH];
   160  *       Thread* THREAD = Thread::current();
   163  *       Thread* THREAD = Thread::current();
   161  *       jio_snprintf(path, JIMAGE_MAX_PATH - 1, "/%s/%s", package, name);
   164  *       jio_snprintf(path, JIMAGE_MAX_PATH - 1, "/%s/%s", package, name);
   162  *       ClassLoader::compile_the_world_in(path, (Handle)arg, THREAD);
   165  *       ClassLoader::compile_the_world_in(path, (Handle)arg, THREAD);