hotspot/src/share/vm/classfile/jimage.hpp
author rehn
Mon, 23 May 2016 09:57:17 +0200
changeset 38647 e17e25c51396
parent 37490 fd089d3f8cb3
child 42609 601fb6316b0c
permissions -rw-r--r--
8157097: OptionsValidation/TestOptionsWithRanges.java crashes at CompactHashtableWriter::add during StringTable::copy_shared_string Reviewed-by: dholmes, jiangli
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32619
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
     1
/*
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 32619
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
32619
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
     4
 *
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
     7
 * published by the Free Software Foundation.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
     8
 *
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    13
 * accompanied this code).
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    14
 *
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    18
 *
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    21
 * questions.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    22
 *
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    23
 */
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    24
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 32619
diff changeset
    25
#include "prims/jni.h"
32619
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    26
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    27
// Opaque reference to a JImage file.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    28
class JImageFile;
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    29
// Opaque reference to an image file resource location.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    30
typedef jlong JImageLocationRef;
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    31
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    32
// Max path length limit independent of platform.  Windows max path is 1024,
37489
b2812e811d0d 8147426: Missing definition for JIMAGE_NOT_FOUND
jlaskey
parents: 36508
diff changeset
    33
// other platforms use 4096.
32619
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    34
#define JIMAGE_MAX_PATH 4096
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    35
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    36
// JImage Error Codes
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    37
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 32619
diff changeset
    38
// Resource was not found
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 32619
diff changeset
    39
#define JIMAGE_NOT_FOUND (0)
32619
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    40
// The image file is not prefixed with 0xCAFEDADA
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    41
#define JIMAGE_BAD_MAGIC (-1)
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    42
// The image file does not have a compatible (translatable) version
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    43
#define JIMAGE_BAD_VERSION (-2)
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    44
// The image file content is malformed
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    45
#define JIMAGE_CORRUPTED (-3)
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    46
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    47
/*
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    48
 * JImageOpen - Given the supplied full path file name, open an image file. This
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    49
 * function will also initialize tables and retrieve meta-data necessary to
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    50
 * satisfy other functions in the API. If the image file has been previously
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    51
 * open, a new open request will share memory and resources used by the previous
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    52
 * open. A call to JImageOpen should be balanced by a call to JImageClose, to
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    53
 * release memory and resources used. If the image file is not found or cannot
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    54
 * be open, then NULL is returned and error will contain a reason for the
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    55
 * failure; a positive value for a system error number, negative for a jimage
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    56
 * specific error (see JImage Error Codes.)
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    57
 *
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    58
 *  Ex.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    59
 *   jint error;
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 32619
diff changeset
    60
 *   JImageFile* jimage = (*JImageOpen)(JAVA_HOME "lib/modules", &error);
32619
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    61
 *   if (image == NULL) {
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    62
 *     tty->print_cr("JImage failed to open: %d", error);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    63
 *     ...
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    64
 *   }
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    65
 *   ...
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    66
 */
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    67
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    68
extern "C" JImageFile* JIMAGE_Open(const char *name, jint* error);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    69
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    70
typedef JImageFile* (*JImageOpen_t)(const char *name, jint* error);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    71
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    72
/*
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    73
 * JImageClose - Given the supplied open image file (see JImageOpen), release
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    74
 * memory and resources used by the open file and close the file. If the image
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    75
 * file is shared by other uses, release and close is deferred until the last use
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    76
 * is also closed.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    77
 *
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    78
 * Ex.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    79
 *  (*JImageClose)(image);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    80
 */
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    81
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    82
extern "C" void JIMAGE_Close(JImageFile* jimage);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    83
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    84
typedef void (*JImageClose_t)(JImageFile* jimage);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    85
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    86
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    87
/*
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    88
 * JImagePackageToModule - Given an open image file (see JImageOpen) and the name
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    89
 * of a package, return the name of module where the package resides. If the
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    90
 * package does not exist in the image file, the function returns NULL.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    91
 * The resulting string does/should not have to be released. All strings are
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    92
 * utf-8, zero byte terminated.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    93
 *
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    94
 * Ex.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    95
 *  const char* package = (*JImagePackageToModule)(image, "java/lang");
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    96
 *  tty->print_cr(package);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    97
 *  —> java.base
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    98
 */
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    99
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   100
extern "C" const char * JIMAGE_PackageToModule(JImageFile* jimage, const char* package_name);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   101
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   102
typedef const char* (*JImagePackageToModule_t)(JImageFile* jimage, const char* package_name);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   103
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   104
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   105
/*
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   106
 * JImageFindResource - Given an open image file (see JImageOpen), a module
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   107
 * name, a version string and the name of a class/resource, return location
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   108
 * information describing the resource and its size. If no resource is found, the
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   109
 * function returns JIMAGE_NOT_FOUND and the value of size is undefined.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   110
 * The version number should be "9.0" and is not used in locating the resource.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   111
 * The resulting location does/should not have to be released.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   112
 * All strings are utf-8, zero byte terminated.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   113
 *
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   114
 *  Ex.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   115
 *   jlong size;
37489
b2812e811d0d 8147426: Missing definition for JIMAGE_NOT_FOUND
jlaskey
parents: 36508
diff changeset
   116
 *   JImageLocationRef location = (*JImageFindResource)(image,
b2812e811d0d 8147426: Missing definition for JIMAGE_NOT_FOUND
jlaskey
parents: 36508
diff changeset
   117
 *                                "java.base", "9.0", "java/lang/String.class", &size);
32619
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   118
 */
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   119
extern "C" JImageLocationRef JIMAGE_FindResource(JImageFile* jimage,
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   120
        const char* module_name, const char* version, const char* name,
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   121
        jlong* size);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   122
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   123
typedef JImageLocationRef(*JImageFindResource_t)(JImageFile* jimage,
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   124
        const char* module_name, const char* version, const char* name,
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   125
        jlong* size);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   126
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   127
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   128
/*
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   129
 * JImageGetResource - Given an open image file (see JImageOpen), a resource’s
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   130
 * location information (see JImageFindResource), a buffer of appropriate
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   131
 * size and the size, retrieve the bytes associated with the
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   132
 * resource. If the size is less than the resource size then the read is truncated.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   133
 * If the size is greater than the resource size then the remainder of the buffer
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   134
 * is zero filled.  The function will return the actual size of the resource.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   135
 *
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   136
 * Ex.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   137
 *  jlong size;
37489
b2812e811d0d 8147426: Missing definition for JIMAGE_NOT_FOUND
jlaskey
parents: 36508
diff changeset
   138
 *  JImageLocationRef location = (*JImageFindResource)(image,
b2812e811d0d 8147426: Missing definition for JIMAGE_NOT_FOUND
jlaskey
parents: 36508
diff changeset
   139
 *                               "java.base", "9.0", "java/lang/String.class", &size);
32619
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   140
 *  char* buffer = new char[size];
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   141
 *  (*JImageGetResource)(image, location, buffer, size);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   142
 */
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   143
extern "C" jlong JIMAGE_GetResource(JImageFile* jimage, JImageLocationRef location,
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   144
        char* buffer, jlong size);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   145
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   146
typedef jlong(*JImageGetResource_t)(JImageFile* jimage, JImageLocationRef location,
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   147
        char* buffer, jlong size);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   148
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   149
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   150
/*
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   151
 * JImageResourceIterator - Given an open image file (see JImageOpen), a visitor
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   152
 * function and a visitor argument, iterator through each of the image's resources.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   153
 * The visitor function is called with the image file, the module name, the
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   154
 * package name, the base name, the extension and the visitor argument. The return
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   155
 * value of the visitor function should be true, unless an early iteration exit is
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   156
 * required. All strings are utf-8, zero byte terminated.file.
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   157
 *
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   158
 * Ex.
37489
b2812e811d0d 8147426: Missing definition for JIMAGE_NOT_FOUND
jlaskey
parents: 36508
diff changeset
   159
 *   bool ctw_visitor(JImageFile* jimage, const char* module_name, const char* version,
b2812e811d0d 8147426: Missing definition for JIMAGE_NOT_FOUND
jlaskey
parents: 36508
diff changeset
   160
 *                  const char* package, const char* name, const char* extension, void* arg) {
32619
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   161
 *     if (strcmp(extension, “class”) == 0) {
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   162
 *       char path[JIMAGE_MAX_PATH];
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   163
 *       Thread* THREAD = Thread::current();
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   164
 *       jio_snprintf(path, JIMAGE_MAX_PATH - 1, "/%s/%s", package, name);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   165
 *       ClassLoader::compile_the_world_in(path, (Handle)arg, THREAD);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   166
 *       return !HAS_PENDING_EXCEPTION;
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   167
 *     }
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   168
 *     return true;
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   169
 *   }
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   170
 *   (*JImageResourceIterator)(image, ctw_visitor, loader);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   171
 */
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   172
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   173
typedef bool (*JImageResourceVisitor_t)(JImageFile* jimage,
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   174
        const char* module_name, const char* version, const char* package,
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   175
        const char* name, const char* extension, void* arg);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   176
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   177
extern "C" void JIMAGE_ResourceIterator(JImageFile* jimage,
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   178
        JImageResourceVisitor_t visitor, void *arg);
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   179
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   180
typedef void (*JImageResourceIterator_t)(JImageFile* jimage,
47acec81dcca 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   181
        JImageResourceVisitor_t visitor, void* arg);
37490
fd089d3f8cb3 8147634: Need a JImage API that given a JImageLocationRef returns class name
jlaskey
parents: 37489
diff changeset
   182
fd089d3f8cb3 8147634: Need a JImage API that given a JImageLocationRef returns class name
jlaskey
parents: 37489
diff changeset
   183
/*
fd089d3f8cb3 8147634: Need a JImage API that given a JImageLocationRef returns class name
jlaskey
parents: 37489
diff changeset
   184
 * JIMAGE_ResourcePath- Given an open image file, a location reference, a buffer
fd089d3f8cb3 8147634: Need a JImage API that given a JImageLocationRef returns class name
jlaskey
parents: 37489
diff changeset
   185
 * and a maximum buffer size, copy the path of the resource into the buffer.
fd089d3f8cb3 8147634: Need a JImage API that given a JImageLocationRef returns class name
jlaskey
parents: 37489
diff changeset
   186
 * Returns false if not a valid location reference.
fd089d3f8cb3 8147634: Need a JImage API that given a JImageLocationRef returns class name
jlaskey
parents: 37489
diff changeset
   187
 *
fd089d3f8cb3 8147634: Need a JImage API that given a JImageLocationRef returns class name
jlaskey
parents: 37489
diff changeset
   188
 * Ex.
fd089d3f8cb3 8147634: Need a JImage API that given a JImageLocationRef returns class name
jlaskey
parents: 37489
diff changeset
   189
 *   JImageLocationRef location = ...
fd089d3f8cb3 8147634: Need a JImage API that given a JImageLocationRef returns class name
jlaskey
parents: 37489
diff changeset
   190
 *   char path[JIMAGE_MAX_PATH];
fd089d3f8cb3 8147634: Need a JImage API that given a JImageLocationRef returns class name
jlaskey
parents: 37489
diff changeset
   191
 *    (*JImageResourcePath)(image, location, path, JIMAGE_MAX_PATH);
fd089d3f8cb3 8147634: Need a JImage API that given a JImageLocationRef returns class name
jlaskey
parents: 37489
diff changeset
   192
 */
fd089d3f8cb3 8147634: Need a JImage API that given a JImageLocationRef returns class name
jlaskey
parents: 37489
diff changeset
   193
extern "C" bool JIMAGE_ResourcePath(JImageFile* image, JImageLocationRef locationRef,
fd089d3f8cb3 8147634: Need a JImage API that given a JImageLocationRef returns class name
jlaskey
parents: 37489
diff changeset
   194
                                    char* path, size_t max);
fd089d3f8cb3 8147634: Need a JImage API that given a JImageLocationRef returns class name
jlaskey
parents: 37489
diff changeset
   195
fd089d3f8cb3 8147634: Need a JImage API that given a JImageLocationRef returns class name
jlaskey
parents: 37489
diff changeset
   196
typedef bool (*JImage_ResourcePath_t)(JImageFile* jimage, JImageLocationRef location,
fd089d3f8cb3 8147634: Need a JImage API that given a JImageLocationRef returns class name
jlaskey
parents: 37489
diff changeset
   197
        char* buffer, jlong size);
fd089d3f8cb3 8147634: Need a JImage API that given a JImageLocationRef returns class name
jlaskey
parents: 37489
diff changeset
   198