< prev index next >
src/java.base/share/native/libjimage/jimage.cpp
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2015, 2016, 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
* are met:
*
--- 1,7 ----
/*
! * Copyright (c) 2015, 2018, 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
* are met:
*
*** 53,63 ****
* tty->print_cr("JImage failed to open: %d", error);
* ...
* }
* ...
*/
! extern "C" JImageFile* JIMAGE_Open(const char *name, jint* error) {
// TODO - return a meaningful error code
*error = 0;
ImageFileReader* jfile = ImageFileReader::open(name);
return (JImageFile*) jfile;
}
--- 53,64 ----
* tty->print_cr("JImage failed to open: %d", error);
* ...
* }
* ...
*/
! extern "C" JNIEXPORT JImageFile* JNICALL
! JIMAGE_Open(const char *name, jint* error) {
// TODO - return a meaningful error code
*error = 0;
ImageFileReader* jfile = ImageFileReader::open(name);
return (JImageFile*) jfile;
}
*** 69,79 ****
* is also closed.
*
* Ex.
* (*JImageClose)(image);
*/
! extern "C" void JIMAGE_Close(JImageFile* image) {
ImageFileReader::close((ImageFileReader*) image);
}
/*
* JImagePackageToModule - Given an open image file (see JImageOpen) and the name
--- 70,81 ----
* is also closed.
*
* Ex.
* (*JImageClose)(image);
*/
! extern "C" JNIEXPORT void JNICALL
! JIMAGE_Close(JImageFile* image) {
ImageFileReader::close((ImageFileReader*) image);
}
/*
* JImagePackageToModule - Given an open image file (see JImageOpen) and the name
*** 85,95 ****
* Ex.
* const char* package = (*JImagePackageToModule)(image, "java/lang");
* tty->print_cr(package);
* -> java.base
*/
! extern "C" const char* JIMAGE_PackageToModule(JImageFile* image, const char* package_name) {
return ((ImageFileReader*) image)->get_image_module_data()->package_to_module(package_name);
}
/*
* JImageFindResource - Given an open image file (see JImageOpen), a module
--- 87,98 ----
* Ex.
* const char* package = (*JImagePackageToModule)(image, "java/lang");
* tty->print_cr(package);
* -> java.base
*/
! extern "C" JNIEXPORT const char* JNICALL
! JIMAGE_PackageToModule(JImageFile* image, const char* package_name) {
return ((ImageFileReader*) image)->get_image_module_data()->package_to_module(package_name);
}
/*
* JImageFindResource - Given an open image file (see JImageOpen), a module
*** 103,113 ****
* Ex.
* jlong size;
* JImageLocationRef location = (*JImageFindResource)(image,
* "java.base", "9.0", "java/lang/String.class", &size);
*/
! extern "C" JImageLocationRef JIMAGE_FindResource(JImageFile* image,
const char* module_name, const char* version, const char* name,
jlong* size) {
// Concatenate to get full path
char fullpath[IMAGE_MAX_PATH];
size_t moduleNameLen = strlen(module_name);
--- 106,117 ----
* Ex.
* jlong size;
* JImageLocationRef location = (*JImageFindResource)(image,
* "java.base", "9.0", "java/lang/String.class", &size);
*/
! extern "C" JNIEXPORT JImageLocationRef JNICALL
! JIMAGE_FindResource(JImageFile* image,
const char* module_name, const char* version, const char* name,
jlong* size) {
// Concatenate to get full path
char fullpath[IMAGE_MAX_PATH];
size_t moduleNameLen = strlen(module_name);
*** 149,159 ****
* JImageLocationRef location = (*JImageFindResource)(image,
* "java.base", "9.0", "java/lang/String.class", &size);
* char* buffer = new char[size];
* (*JImageGetResource)(image, location, buffer, size);
*/
! extern "C" jlong JIMAGE_GetResource(JImageFile* image, JImageLocationRef location,
char* buffer, jlong size) {
((ImageFileReader*) image)->get_resource((u4) location, (u1*) buffer);
return size;
}
--- 153,164 ----
* JImageLocationRef location = (*JImageFindResource)(image,
* "java.base", "9.0", "java/lang/String.class", &size);
* char* buffer = new char[size];
* (*JImageGetResource)(image, location, buffer, size);
*/
! extern "C" JNIEXPORT jlong JNICALL
! JIMAGE_GetResource(JImageFile* image, JImageLocationRef location,
char* buffer, jlong size) {
((ImageFileReader*) image)->get_resource((u4) location, (u1*) buffer);
return size;
}
*** 177,187 ****
* }
* return true;
* }
* (*JImageResourceIterator)(image, ctw_visitor, loader);
*/
! extern "C" void JIMAGE_ResourceIterator(JImageFile* image,
JImageResourceVisitor_t visitor, void* arg) {
ImageFileReader* imageFile = (ImageFileReader*) image;
u4 nEntries = imageFile->table_length();
const ImageStrings strings = imageFile->get_strings();
for (u4 i = 0; i < nEntries; i++) {
--- 182,193 ----
* }
* return true;
* }
* (*JImageResourceIterator)(image, ctw_visitor, loader);
*/
! extern "C" JNIEXPORT void JNICALL
! JIMAGE_ResourceIterator(JImageFile* image,
JImageResourceVisitor_t visitor, void* arg) {
ImageFileReader* imageFile = (ImageFileReader*) image;
u4 nEntries = imageFile->table_length();
const ImageStrings strings = imageFile->get_strings();
for (u4 i = 0; i < nEntries; i++) {
*** 218,228 ****
* 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()) {
--- 224,235 ----
* Ex.
* JImageLocationRef location = ...
* char path[JIMAGE_MAX_PATH];
* (*JImageResourcePath)(image, location, path, JIMAGE_MAX_PATH);
*/
! extern "C" JNIEXPORT bool JNICALL
! JIMAGE_ResourcePath(JImageFile* image, JImageLocationRef locationRef,
char* path, size_t max) {
ImageFileReader* imageFile = (ImageFileReader*) image;
u4 offset = (u4) locationRef;
if (offset >= imageFile->locations_size()) {
< prev index next >