84 *
85 * Ex.
86 * (*JImageClose)(image);
87 */
88
89 extern "C" void JIMAGE_Close(JImageFile* jimage);
90
91 typedef void (*JImageClose_t)(JImageFile* jimage);
92
93
94 /*
95 * JImagePackageToModule - Given an open image file (see JImageOpen) and the name
96 * of a package, return the name of module where the package resides. If the
97 * package does not exist in the image file, the function returns NULL.
98 * The resulting string does/should not have to be released. All strings are
99 * utf-8, zero byte terminated.
100 *
101 * Ex.
102 * const char* package = (*JImagePackageToModule)(image, "java/lang");
103 * tty->print_cr(package);
104 * —> java.base
105 */
106
107 extern "C" const char * JIMAGE_PackageToModule(JImageFile* jimage, const char* package_name);
108
109 typedef const char* (*JImagePackageToModule_t)(JImageFile* jimage, const char* package_name);
110
111
112 /*
113 * JImageFindResource - Given an open image file (see JImageOpen), a module
114 * name, a version string and the name of a class/resource, return location
115 * information describing the resource and its size. If no resource is found, the
116 * function returns JIMAGE_NOT_FOUND and the value of size is undefined.
117 * The version number should be "9.0" and is not used in locating the resource.
118 * The resulting location does/should not have to be released.
119 * All strings are utf-8, zero byte terminated.
120 *
121 * Ex.
122 * jlong size;
123 * JImageLocationRef location = (*JImageFindResource)(image,
124 * "java.base", "9.0", "java/lang/String.class", &size);
125 */
126 extern "C" JImageLocationRef JIMAGE_FindResource(JImageFile* jimage,
127 const char* module_name, const char* version, const char* name,
128 jlong* size);
129
130 typedef JImageLocationRef(*JImageFindResource_t)(JImageFile* jimage,
131 const char* module_name, const char* version, const char* name,
132 jlong* size);
133
134
135 /*
136 * JImageGetResource - Given an open image file (see JImageOpen), a resource’s
137 * location information (see JImageFindResource), a buffer of appropriate
138 * size and the size, retrieve the bytes associated with the
139 * resource. If the size is less than the resource size then the read is truncated.
140 * If the size is greater than the resource size then the remainder of the buffer
141 * is zero filled. The function will return the actual size of the resource.
142 *
143 * Ex.
144 * jlong size;
145 * JImageLocationRef location = (*JImageFindResource)(image,
146 * "java.base", "9.0", "java/lang/String.class", &size);
147 * char* buffer = new char[size];
148 * (*JImageGetResource)(image, location, buffer, size);
149 */
150 extern "C" jlong JIMAGE_GetResource(JImageFile* jimage, JImageLocationRef location,
151 char* buffer, jlong size);
152
153 typedef jlong(*JImageGetResource_t)(JImageFile* jimage, JImageLocationRef location,
154 char* buffer, jlong size);
155
156
157 /*
158 * JImageResourceIterator - Given an open image file (see JImageOpen), a visitor
159 * function and a visitor argument, iterator through each of the image's resources.
160 * The visitor function is called with the image file, the module name, the
161 * package name, the base name, the extension and the visitor argument. The return
162 * value of the visitor function should be true, unless an early iteration exit is
163 * required. All strings are utf-8, zero byte terminated.file.
164 *
165 * Ex.
166 * bool ctw_visitor(JImageFile* jimage, const char* module_name, const char* version,
167 * const char* package, const char* name, const char* extension, void* arg) {
168 * if (strcmp(extension, “class”) == 0) {
169 * char path[JIMAGE_MAX_PATH];
170 * Thread* THREAD = Thread::current();
171 * jio_snprintf(path, JIMAGE_MAX_PATH - 1, "/%s/%s", package, name);
172 * ClassLoader::compile_the_world_in(path, (Handle)arg, THREAD);
173 * return !HAS_PENDING_EXCEPTION;
174 * }
175 * return true;
176 * }
177 * (*JImageResourceIterator)(image, ctw_visitor, loader);
178 */
179
180 typedef bool (*JImageResourceVisitor_t)(JImageFile* jimage,
181 const char* module_name, const char* version, const char* package,
182 const char* name, const char* extension, void* arg);
183
184 extern "C" void JIMAGE_ResourceIterator(JImageFile* jimage,
185 JImageResourceVisitor_t visitor, void *arg);
186
187 typedef void (*JImageResourceIterator_t)(JImageFile* jimage,
188 JImageResourceVisitor_t visitor, void* arg);
|
84 *
85 * Ex.
86 * (*JImageClose)(image);
87 */
88
89 extern "C" void JIMAGE_Close(JImageFile* jimage);
90
91 typedef void (*JImageClose_t)(JImageFile* jimage);
92
93
94 /*
95 * JImagePackageToModule - Given an open image file (see JImageOpen) and the name
96 * of a package, return the name of module where the package resides. If the
97 * package does not exist in the image file, the function returns NULL.
98 * The resulting string does/should not have to be released. All strings are
99 * utf-8, zero byte terminated.
100 *
101 * Ex.
102 * const char* package = (*JImagePackageToModule)(image, "java/lang");
103 * tty->print_cr(package);
104 * -> java.base
105 */
106
107 extern "C" const char * JIMAGE_PackageToModule(JImageFile* jimage, const char* package_name);
108
109 typedef const char* (*JImagePackageToModule_t)(JImageFile* jimage, const char* package_name);
110
111
112 /*
113 * JImageFindResource - Given an open image file (see JImageOpen), a module
114 * name, a version string and the name of a class/resource, return location
115 * information describing the resource and its size. If no resource is found, the
116 * function returns JIMAGE_NOT_FOUND and the value of size is undefined.
117 * The version number should be "9.0" and is not used in locating the resource.
118 * The resulting location does/should not have to be released.
119 * All strings are utf-8, zero byte terminated.
120 *
121 * Ex.
122 * jlong size;
123 * JImageLocationRef location = (*JImageFindResource)(image,
124 * "java.base", "9.0", "java/lang/String.class", &size);
125 */
126 extern "C" JImageLocationRef JIMAGE_FindResource(JImageFile* jimage,
127 const char* module_name, const char* version, const char* name,
128 jlong* size);
129
130 typedef JImageLocationRef(*JImageFindResource_t)(JImageFile* jimage,
131 const char* module_name, const char* version, const char* name,
132 jlong* size);
133
134
135 /*
136 * JImageGetResource - Given an open image file (see JImageOpen), a resource's
137 * location information (see JImageFindResource), a buffer of appropriate
138 * size and the size, retrieve the bytes associated with the
139 * resource. If the size is less than the resource size then the read is truncated.
140 * If the size is greater than the resource size then the remainder of the buffer
141 * is zero filled. The function will return the actual size of the resource.
142 *
143 * Ex.
144 * jlong size;
145 * JImageLocationRef location = (*JImageFindResource)(image,
146 * "java.base", "9.0", "java/lang/String.class", &size);
147 * char* buffer = new char[size];
148 * (*JImageGetResource)(image, location, buffer, size);
149 */
150 extern "C" jlong JIMAGE_GetResource(JImageFile* jimage, JImageLocationRef location,
151 char* buffer, jlong size);
152
153 typedef jlong(*JImageGetResource_t)(JImageFile* jimage, JImageLocationRef location,
154 char* buffer, jlong size);
155
156
157 /*
158 * JImageResourceIterator - Given an open image file (see JImageOpen), a visitor
159 * function and a visitor argument, iterator through each of the image's resources.
160 * The visitor function is called with the image file, the module name, the
161 * package name, the base name, the extension and the visitor argument. The return
162 * value of the visitor function should be true, unless an early iteration exit is
163 * required. All strings are utf-8, zero byte terminated.file.
164 *
165 * Ex.
166 * bool ctw_visitor(JImageFile* jimage, const char* module_name, const char* version,
167 * const char* package, const char* name, const char* extension, void* arg) {
168 * if (strcmp(extension, "class") == 0) {
169 * char path[JIMAGE_MAX_PATH];
170 * Thread* THREAD = Thread::current();
171 * jio_snprintf(path, JIMAGE_MAX_PATH - 1, "/%s/%s", package, name);
172 * ClassLoader::compile_the_world_in(path, (Handle)arg, THREAD);
173 * return !HAS_PENDING_EXCEPTION;
174 * }
175 * return true;
176 * }
177 * (*JImageResourceIterator)(image, ctw_visitor, loader);
178 */
179
180 typedef bool (*JImageResourceVisitor_t)(JImageFile* jimage,
181 const char* module_name, const char* version, const char* package,
182 const char* name, const char* extension, void* arg);
183
184 extern "C" void JIMAGE_ResourceIterator(JImageFile* jimage,
185 JImageResourceVisitor_t visitor, void *arg);
186
187 typedef void (*JImageResourceIterator_t)(JImageFile* jimage,
188 JImageResourceVisitor_t visitor, void* arg);
|