diff options
| author | Antonin Descampe <antonin@gmail.com> | 2011-04-13 21:01:39 +0000 |
|---|---|---|
| committer | Antonin Descampe <antonin@gmail.com> | 2011-04-13 21:01:39 +0000 |
| commit | 16f205d886407d087fbaa5d00ff31e371f97cb51 (patch) | |
| tree | c711b3f7a6ade13311cd10a2d2ec6cb0ea1b7a4f /applications/JavaOpenJPEG | |
| parent | 87e4c72ee4be8eb4899cfab25359440a9ecacafa (diff) | |
re-organization of openjpeg directories hierarchy : step 1
Diffstat (limited to 'applications/JavaOpenJPEG')
17 files changed, 9904 insertions, 0 deletions
diff --git a/applications/JavaOpenJPEG/CMakeLists.txt b/applications/JavaOpenJPEG/CMakeLists.txt new file mode 100644 index 00000000..6b1720b3 --- /dev/null +++ b/applications/JavaOpenJPEG/CMakeLists.txt @@ -0,0 +1,40 @@ +#JavaOpenJPEG/CMakeLists.txt + +# First thing define the common source: +SET(common_SRCS + ../codec/convert.c + ../codec/index.c + ) + +# If not getopt was found then add it to the lib: +IF(DONT_HAVE_GETOPT) + SET(common_SRCS + ${common_SRCS} + ../common/getopt.c + ) +ENDIF(DONT_HAVE_GETOPT) + + +# Headers file are located here: +INCLUDE_DIRECTORIES( + ${OPENJPEG_SOURCE_DIR}/libopenjpeg + ${LCMS_INCLUDE_DIR} + ${PNG_INCLUDE_DIR} + ${ZLIB_INCLUDE_DIR} + ${TIFF_INCLUDE_DIR} + ) + +# Loop over all executables: +FOREACH(exe j2k_to_image image_to_j2k) + ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS}) + TARGET_LINK_LIBRARIES(${exe} ${OPJ_PREFIX}openjpeg ${TIFF_LIBRARIES} + ${PNG_LIBRARIES} ${ZLIB_LIBRARY} ${LCMS_LIB}) + # On unix you need to link to the math library: + IF(UNIX) + TARGET_LINK_LIBRARIES(${exe} -lm) + ENDIF(UNIX) + # Install exe + INSTALL_TARGETS(/bin/ ${exe}) +ENDFOREACH(exe) + + diff --git a/applications/JavaOpenJPEG/JavaOpenJPEG.c b/applications/JavaOpenJPEG/JavaOpenJPEG.c new file mode 100644 index 00000000..b1f03028 --- /dev/null +++ b/applications/JavaOpenJPEG/JavaOpenJPEG.c @@ -0,0 +1,1976 @@ +/*
+ * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2007, Professor Benoit Macq
+ * Copyright (c) 2001-2003, David Janssens
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2006-2007, Parvatha Elangovan
+ * Copyright (c) 2007, Patrick Piscaglia (Telemis)
+ * 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. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <jni.h>
+#include <math.h>
+
+#include "openjpeg.h"
+#include "getopt.h"
+#include "convert.h"
+#include "index.h"
+#include "dirent.h"
+#include "org_openJpeg_OpenJPEGJavaEncoder.h"
+
+#ifndef _WIN32
+#define stricmp strcasecmp
+#define strnicmp strncasecmp
+#endif
+
+#include "format_defs.h"
+
+#define CINEMA_24_CS 1302083 /*Codestream length for 24fps*/
+#define CINEMA_48_CS 651041 /*Codestream length for 48fps*/
+#define COMP_24_CS 1041666 /*Maximum size per color component for 2K & 4K @ 24fps*/
+#define COMP_48_CS 520833 /*Maximum size per color component for 2K @ 48fps*/
+
+extern int get_file_format(char *filename);
+extern void error_callback(const char *msg, void *client_data);
+extern warning_callback(const char *msg, void *client_data);
+extern void info_callback(const char *msg, void *client_data);
+
+typedef struct callback_variables {
+ JNIEnv *env;
+ /** 'jclass' object used to call a Java method from the C */
+ jobject *jobj;
+ /** 'jclass' object used to call a Java method from the C */
+ jmethodID message_mid;
+ jmethodID error_mid;
+} callback_variables_t;
+
+typedef struct dircnt{
+ /** Buffer for holding images read from Directory*/
+ char *filename_buf;
+ /** Pointer to the buffer*/
+ char **filename;
+}dircnt_t;
+
+typedef struct img_folder{
+ /** The directory path of the folder containing input images*/
+ char *imgdirpath;
+ /** Output format*/
+ char *out_format;
+ /** Enable option*/
+ char set_imgdir;
+ /** Enable Cod Format for output*/
+ char set_out_format;
+ /** User specified rate stored in case of cinema option*/
+ float *rates;
+}img_fol_t;
+
+void encode_help_display() {
+ fprintf(stdout,"HELP\n----\n\n");
+ fprintf(stdout,"- the -h option displays this help information on screen\n\n");
+
+/* UniPG>> */
+ fprintf(stdout,"List of parameters for the JPEG 2000 "
+#ifdef USE_JPWL
+ "+ JPWL "
+#endif /* USE_JPWL */
+ "encoder:\n");
+/* <<UniPG */
+ fprintf(stdout,"\n");
+ fprintf(stdout,"REMARKS:\n");
+ fprintf(stdout,"---------\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"The markers written to the main_header are : SOC SIZ COD QCD COM.\n");
+ fprintf(stdout,"COD and QCD never appear in the tile_header.\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"- This coder can encode a mega image, a test was made on a 24000x24000 pixels \n");
+ fprintf(stdout,"color image. You need enough disk space memory (twice the original) to encode \n");
+ fprintf(stdout,"the image,i.e. for a 1.5 GB image you need a minimum of 3GB of disk memory)\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"By default:\n");
+ fprintf(stdout,"------------\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout," * Lossless\n");
+ fprintf(stdout," * 1 tile\n");
+ fprintf(stdout," * Size of precinct : 2^15 x 2^15 (means 1 precinct)\n");
+ fprintf(stdout," * Size of code-block : 64 x 64\n");
+ fprintf(stdout," * Number of resolutions: 6\n");
+ fprintf(stdout," * No SOP marker in the codestream\n");
+ fprintf(stdout," * No EPH marker in the codestream\n");
+ fprintf(stdout," * No sub-sampling in x or y direction\n");
+ fprintf(stdout," * No mode switch activated\n");
+ fprintf(stdout," * Progression order: LRCP\n");
+ fprintf(stdout," * No index file\n");
+ fprintf(stdout," * No ROI upshifted\n");
+ fprintf(stdout," * No offset of the origin of the image\n");
+ fprintf(stdout," * No offset of the origin of the tiles\n");
+ fprintf(stdout," * Reversible DWT 5-3\n");
+/* UniPG>> */
+#ifdef USE_JPWL
+ fprintf(stdout," * No JPWL protection\n");
+#endif /* USE_JPWL */
+/* <<UniPG */
+ fprintf(stdout,"\n");
+ fprintf(stdout,"Parameters:\n");
+ fprintf(stdout,"------------\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"Required Parameters (except with -h):\n");
+ fprintf(stdout,"One of the two options -ImgDir or -i must be used\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-ImgDir : Image file Directory path (example ../Images) \n");
+ fprintf(stdout," When using this option -OutFor must be used\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-OutFor \n");
+ fprintf(stdout," REQUIRED only if -ImgDir is used\n");
+ fprintf(stdout," Need to specify only format without filename <BMP> \n");
+ fprintf(stdout," Currently accepts PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA formats\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-i : source file (-i source.pnm also *.pgm, *.ppm, *.bmp, *.tif, *.raw, *.tga) \n");
+ fprintf(stdout," When using this option -o must be used\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-o : destination file (-o dest.j2k or .jp2) \n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"Optional Parameters:\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-h : display the help information \n ");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-cinema2K : Digital Cinema 2K profile compliant codestream for 2K resolution.(-cinema2k 24 or 48) \n");
+ fprintf(stdout," Need to specify the frames per second for a 2K resolution. Only 24 or 48 fps is allowed\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-cinema4K : Digital Cinema 4K profile compliant codestream for 4K resolution \n");
+ fprintf(stdout," Frames per second not required. Default value is 24fps\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-r : different compression ratios for successive layers (-r 20,10,5)\n ");
+ fprintf(stdout," - The rate specified for each quality level is the desired \n");
+ fprintf(stdout," compression factor.\n");
+ fprintf(stdout," Example: -r 20,10,1 means quality 1: compress 20x, \n");
+ fprintf(stdout," quality 2: compress 10x and quality 3: compress lossless\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout," (options -r and -q cannot be used together)\n ");
+ fprintf(stdout,"\n");
+
+ fprintf(stdout,"-q : different psnr for successive layers (-q 30,40,50) \n ");
+
+ fprintf(stdout," (options -r and -q cannot be used together)\n ");
+
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-n : number of resolutions (-n 3) \n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-b : size of code block (-b 32,32) \n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-c : size of precinct (-c 128,128) \n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-t : size of tile (-t 512,512) \n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-p : progression order (-p LRCP) [LRCP, RLCP, RPCL, PCRL, CPRL] \n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-s : subsampling factor (-s 2,2) [-s X,Y] \n");
+ fprintf(stdout," Remark: subsampling bigger than 2 can produce error\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-POC : Progression order change (-POC T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL) \n");
+ fprintf(stdout," Example: T1=0,0,1,5,3,CPRL \n");
+ fprintf(stdout," : Ttilenumber=Resolution num start,Component num start,Layer num end,Resolution num end,Component num end,Progression order\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-SOP : write SOP marker before each packet \n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-EPH : write EPH marker after each header packet \n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-M : mode switch (-M 3) [1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL)\n");
+ fprintf(stdout," 8=VSC 16=ERTERM(SEGTERM) 32=SEGMARK(SEGSYM)] \n");
+ fprintf(stdout," Indicate multiple modes by adding their values. \n");
+ fprintf(stdout," ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-x : create an index file *.Idx (-x index_name.Idx) \n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-ROI : c=%%d,U=%%d : quantization indices upshifted \n");
+ fprintf(stdout," for component c=%%d [%%d = 0,1,2]\n");
+ fprintf(stdout," with a value of U=%%d [0 <= %%d <= 37] (i.e. -ROI c=0,U=25) \n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-d : offset of the origin of the image (-d 150,300) \n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-T : offset of the origin of the tiles (-T 100,75) \n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"-I : use the irreversible DWT 9-7 (-I) \n");
+ fprintf(stdout,"\n");
+/* UniPG>> */
+#ifdef USE_JPWL
+ fprintf(stdout,"-W : adoption of JPWL (Part 11) capabilities (-W params)\n");
+ fprintf(stdout," The parameters can be written and repeated in any order:\n");
+ fprintf(stdout," [h<tilepart><=type>,s<tilepart><=method>,a=<addr>,...\n");
+ fprintf(stdout," ...,z=<size>,g=<range>,p<tilepart:pack><=type>]\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout," h selects the header error protection (EPB): 'type' can be\n");
+ fprintf(stdout," [0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]\n");
+ fprintf(stdout," if 'tilepart' is absent, it is for main and tile headers\n");
+ fprintf(stdout," if 'tilepart' is present, it applies from that tile\n");
+ fprintf(stdout," onwards, up to the next h<> spec, or to the last tilepart\n");
+ fprintf(stdout," in the codestream (max. %d specs)\n", JPWL_MAX_NO_TILESPECS);
+ fprintf(stdout,"\n");
+ fprintf(stdout," p selects the packet error protection (EEP/UEP with EPBs)\n");
+ fprintf(stdout," to be applied to raw data: 'type' can be\n");
+ fprintf(stdout," [0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]\n");
+ fprintf(stdout," if 'tilepart:pack' is absent, it is from tile 0, packet 0\n");
+ fprintf(stdout," if 'tilepart:pack' is present, it applies from that tile\n");
+ fprintf(stdout," and that packet onwards, up to the next packet spec\n");
+ fprintf(stdout," or to the last packet in the last tilepart in the stream\n");
+ fprintf(stdout," (max. %d specs)\n", JPWL_MAX_NO_PACKSPECS);
+ fprintf(stdout,"\n");
+ fprintf(stdout," s enables sensitivity data insertion (ESD): 'method' can be\n");
+ fprintf(stdout," [-1=NO ESD 0=RELATIVE ERROR 1=MSE 2=MSE REDUCTION 3=PSNR\n");
+ fprintf(stdout," 4=PSNR INCREMENT 5=MAXERR 6=TSE 7=RESERVED]\n");
+ fprintf(stdout," if 'tilepart' is absent, it is for main header only\n");
+ fprintf(stdout," if 'tilepart' is present, it applies from that tile\n");
+ fprintf(stdout," onwards, up to the next s<> spec, or to the last tilepart\n");
+ fprintf(stdout," in the codestream (max. %d specs)\n", JPWL_MAX_NO_TILESPECS);
+ fprintf(stdout,"\n");
+ fprintf(stdout," g determines the addressing mode: <range> can be\n");
+ fprintf(stdout," [0=PACKET 1=BYTE RANGE 2=PACKET RANGE]\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout," a determines the size of data addressing: <addr> can be\n");
+ fprintf(stdout," 2/4 bytes (small/large codestreams). If not set, auto-mode\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout," z determines the size of sensitivity values: <size> can be\n");
+ fprintf(stdout," 1/2 bytes, for the transformed pseudo-floating point value\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout," ex.:\n");
+ fprintf(stdout," h,h0=64,h3=16,h5=32,p0=78,p0:24=56,p1,p3:0=0,p3:20=32,s=0,\n");
+ fprintf(stdout," s0=6,s3=-1,a=0,g=1,z=1\n");
+ fprintf(stdout," means\n");
+ fprintf(stdout," predefined EPB in MH, rs(64,32) from TPH 0 to TPH 2,\n");
+ fprintf(stdout," CRC-16 in TPH 3 and TPH 4, CRC-32 in remaining TPHs,\n");
+ fprintf(stdout," UEP rs(78,32) for packets 0 to 23 of tile 0,\n");
+ fprintf(stdout," UEP rs(56,32) for packs. 24 to the last of tilepart 0,\n");
+ fprintf(stdout," UEP rs default for packets of tilepart 1,\n");
+ fprintf(stdout," no UEP for packets 0 to 19 of tilepart 3,\n");
+ fprintf(stdout," UEP CRC-32 for packs. 20 of tilepart 3 to last tilepart,\n");
+ fprintf(stdout," relative sensitivity ESD for MH,\n");
+ fprintf(stdout," TSE ESD from TPH 0 to TPH 2, byte range with automatic\n");
+ fprintf(stdout," size of addresses and 1 byte for each sensitivity value\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout," ex.:\n");
+ fprintf(stdout," h,s,p\n");
+ fprintf(stdout," means\n");
+ fprintf(stdout," default protection to headers (MH and TPHs) as well as\n");
+ fprintf(stdout," data packets, one ESD in MH\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout," N.B.: use the following recommendations when specifying\n");
+ fprintf(stdout," the JPWL parameters list\n");
+ fprintf(stdout," - when you use UEP, always pair the 'p' option with 'h'\n");
+ fprintf(stdout," \n");
+#endif /* USE_JPWL */
+/* <<UniPG */
+ fprintf(stdout,"IMPORTANT:\n");
+ fprintf(stdout,"-----------\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"The index file has the structure below:\n");
+ fprintf(stdout,"---------------------------------------\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"Image_height Image_width\n");
+ fprintf(stdout,"progression order\n");
+ fprintf(stdout,"Tiles_size_X Tiles_size_Y\n");
+ fprintf(stdout,"Tiles_nb_X Tiles_nb_Y\n");
+ fprintf(stdout,"Components_nb\n");
+ fprintf(stdout,"Layers_nb\n");
+ fprintf(stdout,"decomposition_levels\n");
+ fprintf(stdout,"[Precincts_size_X_res_Nr Precincts_size_Y_res_Nr]...\n");
+ fprintf(stdout," [Precincts_size_X_res_0 Precincts_size_Y_res_0]\n");
+ fprintf(stdout,"Main_header_start_position\n");
+ fprintf(stdout,"Main_header_end_position\n");
+ fprintf(stdout,"Codestream_size\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout,"INFO ON TILES\n");
+ fprintf(stdout,"tileno start_pos end_hd end_tile nbparts disto nbpix disto/nbpix\n");
+ fprintf(stdout,"Tile_0 start_pos end_Theader end_pos NumParts TotalDisto NumPix MaxMSE\n");
+ fprintf(stdout,"Tile_1 '' '' '' '' '' '' ''\n");
+ fprintf(stdout,"...\n");
+ fprintf(stdout,"Tile_Nt '' '' '' '' '' '' ''\n");
+ fprintf(stdout,"...\n");
+ fprintf(stdout,"TILE 0 DETAILS\n");
+ fprintf(stdout,"part_nb tileno num_packs start_pos end_tph_pos end_pos\n");
+ fprintf(stdout,"...\n");
+ fprintf(stdout,"Progression_string\n");
+ fprintf(stdout,"pack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos disto\n");
+ fprintf(stdout,"Tpacket_0 Tile layer res. comp. prec. start_pos end_pos disto\n");
+ fprintf(stdout,"...\n");
+ fprintf(stdout,"Tpacket_Np '' '' '' '' '' '' '' ''\n");
+
+ fprintf(stdout,"MaxDisto\n");
+
+ fprintf(stdout,"TotalDisto\n\n");
+}
+
+
+OPJ_PROG_ORDER give_progression(char progression[4]) {
+ if(strncmp(progression, "LRCP", 4) == 0) {
+ return LRCP;
+ }
+ if(strncmp(progression, "RLCP", 4) == 0) {
+ return RLCP;
+ }
+ if(strncmp(progression, "RPCL", 4) == 0) {
+ return RPCL;
+ }
+ if(strncmp(progression, "PCRL", 4) == 0) {
+ return PCRL;
+ }
+ if(strncmp(progression, "CPRL", 4) == 0) {
+ return CPRL;
+ }
+
+ return PROG_UNKNOWN;
+}
+
+
+/// <summary>
+/// Get logarithm of an integer and round downwards.
+/// </summary>
+int int_floorlog2(int a) {
+ int l;
+ for (l=0; a>1; l++) {
+ a>>=1;
+ }
+ return l;
+}
+
+static int initialise_4K_poc(opj_poc_t *POC, int numres){
+ POC[0].tile = 1;
+ POC[0].resno0 = 0;
+ POC[0].compno0 = 0;
+ POC[0].layno1 = 1;
+ POC[0].resno1 = numres-1;
+ POC[0].compno1 = 3;
+ POC[0].prg1 = CPRL;
+ POC[1].tile = 1;
+ POC[1].resno0 = numres-1;
+ POC[1].compno0 = 0;
+ POC[1].layno1 = 1;
+ POC[1].resno1 = numres;
+ POC[1].compno1 = 3;
+ POC[1].prg1 = CPRL;
+ return 2;
+}
+
+void cinema_parameters(opj_cparameters_t *parameters){
+ parameters->tile_size_on = false;
+ parameters->cp_tdx=1;
+ parameters->cp_tdy=1;
+
+ /*Tile part*/
+ parameters->tp_flag = 'C';
+ parameters->tp_on = 1;
+
+ /*Tile and Image shall be at (0,0)*/
+ parameters->cp_tx0 = 0;
+ parameters->cp_ty0 = 0;
+ parameters->image_offset_x0 = 0;
+ parameters->image_offset_y0 = 0;
+
+ /*Codeblock size= 32*32*/
+ parameters->cblockw_init = 32;
+ parameters->cblockh_init = 32;
+ parameters->csty |= 0x01;
+
+ /*The progression order shall be CPRL*/
+ parameters->prog_order = CPRL;
+
+ /* No ROI */
+ parameters->roi_compno = -1;
+
+ parameters->subsampling_dx = 1; parameters->subsampling_dy = 1;
+
+ /* 9-7 transform */
+ parameters->irreversible = 1;
+
+}
+
+void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_fol_t *img_fol){
+ int i;
+ float temp_rate;
+ opj_poc_t *POC = NULL;
+
+ switch (parameters->cp_cinema){
+ case CINEMA2K_24:
+ case CINEMA2K_48:
+ if(parameters->numresolution > 6){
+ parameters->numresolution = 6;
+ }
+ if (!((image->comps[0].w == 2048) | (image->comps[0].h == 1080))){
+ fprintf(stdout,"Image coordinates %d x %d is not 2K compliant.\nJPEG Digital Cinema Profile-3"
+ "(2K profile) compliance requires that at least one of coordinates match 2048 x 1080\n",
+ image->comps[0].w,image->comps[0].h);
+ parameters->cp_rsiz = STD_RSIZ;
+ }
+ break;
+
+ case CINEMA4K_24:
+ if(parameters->numresolution < 1){
+ parameters->numresolution = 1;
+ }else if(parameters->numresolution > 7){
+ parameters->numresolution = 7;
+ }
+ if (!((image->comps[0].w == 4096) | (image->comps[0].h == 2160))){
+ fprintf(stdout,"Image coordinates %d x %d is not 4K compliant.\nJPEG Digital Cinema Profile-4"
+ "(4K profile) compliance requires that at least one of coordinates match 4096 x 2160\n",
+ image->comps[0].w,image->comps[0].h);
+ parameters->cp_rsiz = STD_RSIZ;
+ }
+ parameters->numpocs = initialise_4K_poc(parameters->POC,parameters->numresolution);
+ break;
+ }
+
+ switch (parameters->cp_cinema){
+ case CINEMA2K_24:
+ case CINEMA4K_24:
+ for(i=0 ; i<parameters->tcp_numlayers ; i++){
+ temp_rate = 0 ;
+ if (img_fol->rates[i]== 0){
+ parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
+ (CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
+ }else{
+ temp_rate =((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
+ (img_fol->rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
+ if (temp_rate > CINEMA_24_CS ){
+ parameters->tcp_rates[i]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
+ (CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
+ }else{
+ parameters->tcp_rates[i]= img_fol->rates[i];
+ }
+ }
+ }
+ parameters->max_comp_size = COMP_24_CS;
+ break;
+
+ case CINEMA2K_48:
+ for(i=0 ; i<parameters->tcp_numlayers ; i++){
+ temp_rate = 0 ;
+ if (img_fol->rates[i]== 0){
+ parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
+ (CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
+ }else{
+ temp_rate =((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
+ (img_fol->rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
+ if (temp_rate > CINEMA_48_CS ){
+ parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
+ (CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
+ }else{
+ parameters->tcp_rates[i]= img_fol->rates[i];
+ }
+ }
+ }
+ parameters->max_comp_size = COMP_48_CS;
+ break;
+ }
+ parameters->cp_disto_alloc = 1;
+}
+
+
+/* ------------------------------------------------------------------------------------ */
+int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
+ img_fol_t *img_fol, char *indexfilename) {
+ int i, j,totlen;
+ option_t long_option[]={
+ {"cinema2K",REQ_ARG, NULL ,'w'},
+ {"cinema4K",NO_ARG, NULL ,'y'},
+ {"ImgDir",REQ_ARG, NULL ,'z'},
+ {"TP",REQ_ARG, NULL ,'v'},
+ {"SOP",NO_ARG, NULL ,'S'},
+ {"EPH",NO_ARG, NULL ,'E'},
+ {"OutFor",REQ_ARG, NULL ,'O'},
+ {"POC",REQ_ARG, NULL ,'P'},
+ {"ROI",REQ_ARG, NULL ,'R'},
+ };
+
+ /* parse the command line */
+/* UniPG>> */
+ const char optlist[] = "i:o:hr:q:n:b:c:t:p:s:SEM:x:R:d:T:If:P:C:F:"
+#ifdef USE_JPWL
+ "W:"
+#endif /* USE_JPWL */
+ ;
+
+ /*printf("C: parse_cmdline_encoder:");
+ for (i=0; i<argc; i++) {
+ printf("[%s]",argv[i]);
+ }
+ printf("\n");*/
+
+ totlen=sizeof(long_option);
+ img_fol->set_out_format=0;
+ reset_options_reading();
+
+ while (1) {
+ int c = getopt_long(argc, argv, optlist,long_option,totlen);
+ if (c == -1)
+ break;
+ switch (c) {
+
+ /* ----------------------------------------------------- */
+
+ case 'o': /* output file */
+ {
+ char *outfile = optarg;
+ parameters->cod_format = get_file_format(outfile);
+ switch(parameters->cod_format) {
+ case J2K_CFMT:
+ case JP2_CFMT:
+ break;
+ default:
+ fprintf(stderr, "Unknown output format image %s [only *.j2k, *.j2c or *.jp2]!! \n", outfile);
+ return 1;
+ }
+ strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
+ }
+ break;
+
+ /* ----------------------------------------------------- */
+ case 'O': /* output format */
+ {
+ char outformat[50];
+ char *of = optarg;
+ sprintf(outformat,".%s",of);
+ img_fol->set_out_format = 1;
+ parameters->cod_format = get_file_format(outformat);
+ switch(parameters->cod_format) {
+ case J2K_CFMT:
+ case JP2_CFMT:
+ img_fol->out_format = optarg;
+ break;
+ default:
+ fprintf(stderr, "Unknown output format image [only j2k, j2c, jp2]!! \n");
+ return 1;
+ }
+ }
+ break;
+
+
+ /* ----------------------------------------------------- */
+
+
+ case 'r': /* rates rates/distorsion */
+ {
+ char *s = optarg;
+ while (sscanf(s, "%f", ¶meters->tcp_rates[parameters->tcp_numlayers]) == 1) {
+ parameters->tcp_numlayers++;
+ while (*s && *s != ',') {
+ s++;
+ }
+ if (!*s)
+ break;
+ s++;
+ }
+ parameters->cp_disto_alloc = 1;
+ }
+ break;
+
+ /* ----------------------------------------------------- */
+
+ case 'q': /* add fixed_quality */
+ {
+ char *s = optarg;
+ while (sscanf(s, "%f", ¶meters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
+ parameters->tcp_numlayers++;
+ while (*s && *s != ',') {
+ s++;
+ }
+ if (!*s)
+ break;
+ s++;
+ }
+ parameters->cp_fixed_quality = 1;
+ }
+ break;
+
+ /* dda */
+ /* ----------------------------------------------------- */
+
+ case 'f': /* mod fixed_quality (before : -q) */
+ {
+ int *row = NULL, *col = NULL;
+ int numlayers = 0, numresolution = 0, matrix_width = 0;
+
+ char *s = optarg;
+ sscanf(s, "%d", &numlayers);
+ s++;
+ if (numlayers > 9)
+ s++;
+
+ parameters->tcp_numlayers = numlayers;
+ numresolution = parameters->numresolution;
+ matrix_width = numresolution * 3;
+ parameters->cp_matrice = (int *) malloc(numlayers * matrix_width * sizeof(int));
+ s = s + 2;
+
+ for (i = 0; i < numlayers; i++) {
+ row = ¶meters->cp_matrice[i * matrix_width];
+ col = row;
+ parameters->tcp_rates[i] = 1;
+ sscanf(s, "%d,", &col[0]);
+ s += 2;
+ if (col[0] > 9)
+ s++;
+ col[1] = 0;
+ col[2] = 0;
+ for (j = 1; j < numresolution; j++) {
+ col += 3;
+ sscanf(s, "%d,%d,%d", &col[0], &col[1], &col[2]);
+ s += 6;
+ if (col[0] > 9)
+ s++;
+ if (col[1] > 9)
+ s++;
+ if (col[2] > 9)
+ s++;
+ }
+ if (i < numlayers - 1)
+ s++;
+ }
+ parameters->cp_fixed_alloc = 1;
+ }
+ break;
+
+ /* ----------------------------------------------------- */
+
+ case 't': /* tiles */
+ {
+ sscanf(optarg, "%d,%d", ¶meters->cp_tdx, ¶meters->cp_tdy);
+ parameters->tile_size_on = true;
+ }
+ break;
+
+ /* ----------------------------------------------------- */
+
+ case 'n': /* resolution */
+ {
+ sscanf(optarg, "%d", ¶meters->numresolution);
+ }
+ break;
+
+ /* ----------------------------------------------------- */
+ case 'c': /* precinct dimension */
+ {
+ char sep;
+ int res_spec = 0;
+
+ char *s = optarg;
+ do {
+ sep = 0;
+ sscanf(s, "[%d,%d]%c", ¶meters->prcw_init[res_spec],
+ ¶meters->prch_init[res_spec], &sep);
+ parameters->csty |= 0x01;
+ res_spec++;
+ s = strpbrk(s, "]") + 2;
+ }
+ while (sep == ',');
+ parameters->res_spec = res_spec;
+ }
+ break;
+
+ /* ----------------------------------------------------- */
+
+ case 'b': /* code-block dimension */
+ {
+ int cblockw_init = 0, cblockh_init = 0;
+ sscanf(optarg, "%d,%d", &cblockw_init, &cblockh_init);
+ if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
+ || cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
+ fprintf(stderr,
+ "!! Size of code_block error (option -b) !!\n\nRestriction :\n"
+ " * width*height<=4096\n * 4<=width,height<= 1024\n\n");
+ return 1;
+ }
+ parameters->cblockw_init = cblockw_init;
+ parameters->cblockh_init = cblockh_init;
+ }
+ break;
+
+ /* ----------------------------------------------------- */
+
+ case 'x': /* creation of index file */
+ {
+ char *index = optarg;
+ strncpy(indexfilename, index, OPJ_PATH_LEN);
+ }
+ break;
+
+ /* ----------------------------------------------------- */
+
+ case 'p': /* progression order */
+ {
+ char progression[4];
+
+ strncpy(progression, optarg, 4);
+ parameters->prog_order = give_progression(progression);
+ if (parameters->prog_order == -1) {
+ fprintf(stderr, "Unrecognized progression order "
+ "[LRCP, RLCP, RPCL, PCRL, CPRL] !!\n");
+ return 1;
+ }
+ }
+ break;
+
+ /* ----------------------------------------------------- */
+
+ case 's': /* subsampling factor */
+ {
+ if (sscanf(optarg, "%d,%d", ¶meters->subsampling_dx,
+ ¶meters->subsampling_dy) != 2) {
+ fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
+ return 1;
+ }
+ }
+ break;
+
+ /* ----------------------------------------------------- */
+
+ case 'd': /* coordonnate of the reference grid */
+ {
+ if (sscanf(optarg, "%d,%d", ¶meters->image_offset_x0,
+ ¶meters->image_offset_y0) != 2) {
+ fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
+ "error !! [-d x0,y0]\n");
+ return 1;
+ }
+ }
+ break;
+
+ /* ----------------------------------------------------- */
+
+ case 'h': /* display an help description */
+ encode_help_display();
+ return 1;
+
+ /* ----------------------------------------------------- */
+
+ case 'P': /* POC */
+ {
+ int numpocs = 0; /* number of progression order change (POC) default 0 */
+ opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
+
+ char *s = optarg;
+ POC = parameters->POC;
+
+ while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
+ &POC[numpocs].resno0, &POC[numpocs].compno0,
+ &POC[numpocs].layno1, &POC[numpocs].resno1,
+ &POC[numpocs].compno1, &POC[numpocs].progorder) == 7) {
+ POC[numpocs].prg1 = give_progression(POC[numpocs].progorder);
+ numpocs++;
+ while (*s && *s != '/') {
+ s++;
+ }
+ if (!*s) {
+ break;
+ }
+ s++;
+ }
+ parameters->numpocs = numpocs;
+ }
+ break;
+
+ /* ------------------------------------------------------ */
+
+ case 'S': /* SOP marker */
+ {
+ parameters->csty |= 0x02;
+ }
+ break;
+
+ /* ------------------------------------------------------ */
+
+ case 'E': /* EPH marker */
+ {
+ parameters->csty |= 0x04;
+ }
+ break;
+
+ /* ------------------------------------------------------ */
+
+ case 'M': /* Mode switch pas tous au point !! */
+ {
+ int value = 0;
+ if (sscanf(optarg, "%d", &value) == 1) {
+ for (i = 0; i <= 5; i++) {
+ int cache = value & (1 << i);
+ if (cache)
+ parameters->mode |= (1 << i);
+ }
+ }
+ }
+ break;
+
+ /* ------------------------------------------------------ */
+
+ case 'R': /* ROI */
+ {
+ if (sscanf(optarg, "c=%d,U=%d", ¶meters->roi_compno,
+ ¶meters->roi_shift) != 2) {
+ fprintf(stderr, "ROI error !! [-ROI c='compno',U='shift']\n");
+ return 1;
+ }
+ }
+ break;
+
+ /* ------------------------------------------------------ */
+
+ case 'T': /* Tile offset */
+ {
+ if (sscanf(optarg, "%d,%d", ¶meters->cp_tx0, ¶meters->cp_ty0) != 2) {
+ fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
+ return 1;
+ }
+ }
+ break;
+
+ /* ------------------------------------------------------ */
+
+ case 'C': /* add a comment */
+ {
+ parameters->cp_comment = (char*)malloc(strlen(optarg) + 1);
+ if(parameters->cp_comment) {
+ strcpy(parameters->cp_comment, optarg);
+ }
+ }
+ break;
+
+
+ /* ------------------------------------------------------ */
+
+ case 'I': /* reversible or not */
+ {
+ parameters->irreversible = 1;
+ }
+ break;
+
+ /* ------------------------------------------------------ */
+
+ case 'v': /* Tile part generation*/
+ {
+ parameters->tp_flag = optarg[0];
+ parameters->tp_on = 1;
+ }
+ break;
+
+ /* ------------------------------------------------------ */
+
+ case 'z': /* Image Directory path */
+ {
+ img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
+ strcpy(img_fol->imgdirpath,optarg);
+ img_fol->set_imgdir=1;
+ }
+ break;
+
+ /* ------------------------------------------------------ */
+
+ case 'w': /* Digital Cinema 2K profile compliance*/
+ {
+ int fps=0;
+ sscanf(optarg,"%d",&fps);
+ if(fps == 24){
+ parameters->cp_cinema = CINEMA2K_24;
+ }else if(fps == 48 ){
+ parameters->cp_cinema = CINEMA2K_48;
+ }else {
+ fprintf(stderr,"Incorrect value!! must be 24 or 48\n");
+ return 1;
+ }
+ fprintf(stdout,"CINEMA 2K compliant codestream\n");
+ parameters->cp_rsiz = CINEMA2K;
+
+ }
+ break;
+
+ /* ------------------------------------------------------ */
+
+ case 'y': /* Digital Cinema 4K profile compliance*/
+ {
+ parameters->cp_cinema = CINEMA4K_24;
+ fprintf(stdout,"CINEMA 4K compliant codestream\n");
+ parameters->cp_rsiz = CINEMA4K;
+ }
+ break;
+
+ /* ------------------------------------------------------ */
+
+/* UniPG>> */
+#ifdef USE_JPWL
+ /* ------------------------------------------------------ */
+
+ case 'W': /* JPWL capabilities switched on */
+ {
+ char *token = NULL;
+ int hprot, pprot, sens, addr, size, range;
+
+ /* we need to enable indexing */
+ if (!indexfilename) {
+ strncpy(indexfilename, JPWL_PRIVATEINDEX_NAME, OPJ_PATH_LEN);
+ }
+
+ /* search for different protection methods */
+
+ /* break the option in comma points and parse the result */
+ token = strtok(optarg, ",");
+ while(token != NULL) {
+
+ /* search header error protection method */
+ if (*token == 'h') {
+
+ static int tile = 0, tilespec = 0, lasttileno = 0;
+
+ hprot = 1; /* predefined method */
+
+ if(sscanf(token, "h=%d", &hprot) == 1) {
+ /* Main header, specified */
+ if (!((hprot == 0) || (hprot == 1) || (hprot == 16) || (hprot == 32) ||
+ ((hprot >= 37) && (hprot <= 128)))) {
+ fprintf(stderr, "ERROR -> invalid main header protection method h = %d\n", hprot);
+ return 1;
+ }
+ parameters->jpwl_hprot_MH = hprot;
+
+ } else if(sscanf(token, "h%d=%d", &tile, &hprot) == 2) {
+ /* Tile part header, specified */
+ if (!((hprot == 0) || (hprot == 1) || (hprot == 16) || (hprot == 32) ||
+ ((hprot >= 37) && (hprot <= 128)))) {
+ fprintf(stderr, "ERROR -> invalid tile part header protection method h = %d\n", hprot);
+ return 1;
+ }
+ if (tile < 0) {
+ fprintf(stderr, "ERROR -> invalid tile part number on protection method t = %d\n", tile);
+ return 1;
+ }
+ if (tilespec < JPWL_MAX_NO_TILESPECS) {
+ parameters->jpwl_hprot_TPH_tileno[tilespec] = lasttileno = tile;
+ parameters->jpwl_hprot_TPH[tilespec++] = hprot;
+ }
+
+ } else if(sscanf(token, "h%d", &tile) == 1) {
+ /* Tile part header, unspecified */
+ if (tile < 0) {
+ fprintf(stderr, "ERROR -> invalid tile part number on protection method t = %d\n", tile);
+ return 1;
+ }
+ if (tilespec < JPWL_MAX_NO_TILESPECS) {
+ parameters->jpwl_hprot_TPH_tileno[tilespec] = lasttileno = tile;
+ parameters->jpwl_hprot_TPH[tilespec++] = hprot;
+ }
+
+
+ } else if (!strcmp(token, "h")) {
+ /* Main header, unspecified */
+ parameters->jpwl_hprot_MH = hprot;
+
+ } else {
+ fprintf(stderr, "ERROR -> invalid protection method selection = %s\n", token);
+ return 1;
+ };
+
+ }
+
+ /* search packet error protection method */
+ if (*token == 'p') {
+
+ static int pack = 0, tile = 0, packspec = 0, lastpackno = 0;
+
+ pprot = 1; /* predefined method */
+
+ if (sscanf(token, "p=%d", &pprot) == 1) {
+ /* Method for all tiles and all packets */
+ if (!((pprot == 0) || (pprot == 1) || (pprot == 16) || (pprot == 32) ||
+ ((pprot >= 37) && (pprot <= 128)))) {
+ fprintf(stderr, "ERROR -> invalid default packet protection method p = %d\n", pprot);
+ return 1;
+ }
+ parameters->jpwl_pprot_tileno[0] = 0;
+ parameters->jpwl_pprot_packno[0] = 0;
+ parameters->jpwl_pprot[0] = pprot;
+
+ } else if (sscanf(token, "p%d=%d", &tile, &pprot) == 2) {
+ /* method specified from that tile on */
+ if (!((pprot == 0) || (pprot == 1) || (pprot == 16) || (pprot == 32) ||
+ ((pprot >= 37) && (pprot <= 128)))) {
+ fprintf(stderr, "ERROR -> invalid packet protection method p = %d\n", pprot);
+ return 1;
+ }
+ if (tile < 0) {
+ fprintf(stderr, "ERROR -> invalid tile part number on protection method p = %d\n", tile);
+ return 1;
+ }
+ if (packspec < JPWL_MAX_NO_PACKSPECS) {
+ parameters->jpwl_pprot_tileno[packspec] = tile;
+ parameters->jpwl_pprot_packno[packspec] = 0;
+ parameters->jpwl_pprot[packspec++] = pprot;
+ }
+
+ } else if (sscanf(token, "p%d:%d=%d", &tile, &pack, &pprot) == 3) {
+ /* method fully specified from that tile and that packet on */
+ if (!((pprot == 0) || (pprot == 1) || (pprot == 16) || (pprot == 32) ||
+ ((pprot >= 37) && (pprot <= 128)))) {
+ fprintf(stderr, "ERROR -> invalid packet protection method p = %d\n", pprot);
+ return 1;
+ }
+ if (tile < 0) {
+ fprintf(stderr, "ERROR -> invalid tile part number on protection method p = %d\n", tile);
+ return 1;
+ }
+ if (pack < 0) {
+ fprintf(stderr, "ERROR -> invalid packet number on protection method p = %d\n", pack);
+ return 1;
+ }
+ if (packspec < JPWL_MAX_NO_PACKSPECS) {
+ parameters->jpwl_pprot_tileno[packspec] = tile;
+ parameters->jpwl_pprot_packno[packspec] = pack;
+ parameters->jpwl_pprot[packspec++] = pprot;
+ }
+
+ } else if (sscanf(token, "p%d:%d", &tile, &pack) == 2) {
+ /* default method from that tile and that packet on */
+ if (!((pprot == 0) || (pprot == 1) || (pprot == 16) || (pprot == 32) ||
+ ((pprot >= 37) && (pprot <= 128)))) {
+ fprintf(stderr, "ERROR -> invalid packet protection method p = %d\n", pprot);
+ return 1;
+ }
+ if (tile < 0) {
+ fprintf(stderr, "ERROR -> invalid tile part number on protection method p = %d\n", tile);
+ return 1;
+ }
+ if (pack < 0) {
+ fprintf(stderr, "ERROR -> invalid packet number on protection method p = %d\n", pack);
+ return 1;
+ }
+ if (packspec < JPWL_MAX_NO_PACKSPECS) {
+ parameters->jpwl_pprot_tileno[packspec] = tile;
+ parameters->jpwl_pprot_packno[packspec] = pack;
+ parameters->jpwl_pprot[packspec++] = pprot;
+ }
+
+ } else if (sscanf(token, "p%d", &tile) == 1) {
+ /* default from a tile on */
+ if (tile < 0) {
+ fprintf(stderr, "ERROR -> invalid tile part number on protection method p = %d\n", tile);
+ return 1;
+ }
+ if (packspec < JPWL_MAX_NO_PACKSPECS) {
+ parameters->jpwl_pprot_tileno[packspec] = tile;
+ parameters->jpwl_pprot_packno[packspec] = 0;
+ parameters->jpwl_pprot[packspec++] = pprot;
+ }
+
+
+ } else if (!strcmp(token, "p")) {
+ /* all default */
+ parameters->jpwl_pprot_tileno[0] = 0;
+ parameters->jpwl_pprot_packno[0] = 0;
+ parameters->jpwl_pprot[0] = pprot;
+
+ } else {
+ fprintf(stderr, "ERROR -> invalid protection method selection = %s\n", token);
+ return 1;
+ };
+
+ }
+
+ /* search sensitivity method */
+ if (*token == 's') {
+
+ static int tile = 0, tilespec = 0, lasttileno = 0;
+
+ sens = 0; /* predefined: relative error */
+
+ if(sscanf(token, "s=%d", &sens) == 1) {
+ /* Main header, specified */
+ if ((sens < -1) || (sens > 7)) {
+ fprintf(stderr, "ERROR -> invalid main header sensitivity method s = %d\n", sens);
+ return 1;
+ }
+ parameters->jpwl_sens_MH = sens;
+
+ } else if(sscanf(token, "s%d=%d", &tile, &sens) == 2) {
+ /* Tile part header, specified */
+ if ((sens < -1) || (sens > 7)) {
+ fprintf(stderr, "ERROR -> invalid tile part header sensitivity method s = %d\n", sens);
+ return 1;
+ }
+ if (tile < 0) {
+ fprintf(stderr, "ERROR -> invalid tile part number on sensitivity method t = %d\n", tile);
+ return 1;
+ }
+ if (tilespec < JPWL_MAX_NO_TILESPECS) {
+ parameters->jpwl_sens_TPH_tileno[tilespec] = lasttileno = tile;
+ parameters->jpwl_sens_TPH[tilespec++] = sens;
+ }
+
+ } else if(sscanf(token, "s%d", &tile) == 1) {
+ /* Tile part header, unspecified */
+ if (tile < 0) {
+ fprintf(stderr, "ERROR -> invalid tile part number on sensitivity method t = %d\n", tile);
+ return 1;
+ }
+ if (tilespec < JPWL_MAX_NO_TILESPECS) {
+ parameters->jpwl_sens_TPH_tileno[tilespec] = lasttileno = tile;
+ parameters->jpwl_sens_TPH[tilespec++] = hprot;
+ }
+
+ } else if (!strcmp(token, "s")) {
+ /* Main header, unspecified */
+ parameters->jpwl_sens_MH = sens;
+
+ } else {
+ fprintf(stderr, "ERROR -> invalid sensitivity method selection = %s\n", token);
+ return 1;
+ };
+
+ parameters->jpwl_sens_size = 2; /* 2 bytes for default size */
+ }
+
+ /* search addressing size */
+ if (*token == 'a') {
+
+ static int tile = 0, tilespec = 0, lasttileno = 0;
+
+ addr = 0; /* predefined: auto */
+
+ if(sscanf(token, "a=%d", &addr) == 1) {
+ /* Specified */
+ if ((addr != 0) && (addr != 2) && (addr != 4)) {
+ fprintf(stderr, "ERROR -> invalid addressing size a = %d\n", addr);
+ return 1;
+ }
+ parameters->jpwl_sens_addr = addr;
+
+ } else if (!strcmp(token, "a")) {
+ /* default */
+ parameters->jpwl_sens_addr = addr; /* auto for default size */
+
+ } else {
+ fprintf(stderr, "ERROR -> invalid addressing selection = %s\n", token);
+ return 1;
+ };
+
+ }
+
+ /* search sensitivity size */
+ if (*token == 'z') {
+
+ static int tile = 0, tilespec = 0, lasttileno = 0;
+
+ size = 1; /* predefined: 1 byte */
+
+ if(sscanf(token, "z=%d", &size) == 1) {
+ /* Specified */
+ if ((size != 0) && (size != 1) && (size != 2)) {
+ fprintf(stderr, "ERROR -> invalid sensitivity size z = %d\n", size);
+ return 1;
+ }
+ parameters->jpwl_sens_size = size;
+
+ } else if (!strcmp(token, "a")) {
+ /* default */
+ parameters->jpwl_sens_size = size; /* 1 for default size */
+
+ } else {
+ fprintf(stderr, "ERROR -> invalid size selection = %s\n", token);
+ return 1;
+ };
+
+ }
+
+ /* search range method */
+ if (*token == 'g') {
+
+ static int tile = 0, tilespec = 0, lasttileno = 0;
+
+ range = 0; /* predefined: 0 (packet) */
+
+ if(sscanf(token, "g=%d", &range) == 1) {
+ /* Specified */
+ if ((range < 0) || (range > 3)) {
+ fprintf(stderr, "ERROR -> invalid sensitivity range method g = %d\n", range);
+ return 1;
+ }
+ parameters->jpwl_sens_range = range;
+
+ } else if (!strcmp(token, "g")) {
+ /* default */
+ parameters->jpwl_sens_range = range;
+
+ } else {
+ fprintf(stderr, "ERROR -> invalid range selection = %s\n", token);
+ return 1;
+ };
+
+ }
+
+ /* next token or bust */
+ token = strtok(NULL, ",");
+ };
+
+
+ /* some info */
+ fprintf(stdout, "Info: JPWL capabilities enabled\n");
+ parameters->jpwl_epc_on = true;
+
+ }
+ break;
+#endif /* USE_JPWL */
+/* <<UniPG */
+
+ /* ------------------------------------------------------ */
+
+ default:
+ fprintf(stderr, "ERROR -> Command line not valid\n");
+ return 1;
+ }
+ }
+
+ /* check for possible errors */
+ if (parameters->cp_cinema){
+ if(parameters->tcp_numlayers > 1){
+ parameters->cp_rsiz = STD_RSIZ;
+ fprintf(stdout,"Warning: DC profiles do not allow more than one quality layer. The codestream created will not be compliant with the DC profile\n");
+ }
+ }
+
+ if ((parameters->cp_disto_alloc || parameters->cp_fixed_alloc || parameters->cp_fixed_quality)
+ && (!(parameters->cp_disto_alloc ^ parameters->cp_fixed_alloc ^ parameters->cp_fixed_quality))) {
+ fprintf(stderr, "Error: options -r -q and -f cannot be used together !!\n");
+ return 1;
+ } /* mod fixed_quality */
+
+ /* if no rate entered, lossless by default */
+ if (parameters->tcp_numlayers == 0) {
+ parameters->tcp_rates[0] = 0; /* MOD antonin : losslessbug */
+ parameters->tcp_numlayers++;
+ parameters->cp_disto_alloc = 1;
+ }
+
+ if((parameters->cp_tx0 > parameters->image_offset_x0) || (parameters->cp_ty0 > parameters->image_offset_y0)) {
+ fprintf(stderr,
+ "Error: Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) \n",
+ parameters->cp_tx0, parameters->image_offset_x0, parameters->cp_ty0, parameters->image_offset_y0);
+ return 1;
+ }
+
+ for (i = 0; i < parameters->numpocs; i++) {
+ if (parameters->POC[i].prg == -1) {
+ fprintf(stderr,
+ "Unrecognized progression order in option -P (POC n %d) [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n",
+ i + 1);
+ }
+ }
+
+ return 0;
+}
+
+
+/** Create the same index as j2k_create_index does, but in an int[] instead of in a file ==> easy to pass it back to Java, to transfer it etc.
+ @param buffer_size, increased by the length of the compressed index, in number of bytes
+ @return a pointer to a char[]
+ Syntax of the index:
+ one char for the version number (1): one byte because no problem with little endian, big endian etc.
+ one int for each of the following informations:
+ Image Width
+ Image Height
+ progression order
+ Tile width
+ Tile height
+ Nb tiles in X
+ Nb tiles in Y
+ Nb of components
+ Nb of layers
+ Nb of resolutions
+
+ for each resolution:
+ Precinct width
+ Precinct height
+
+ End main header position
+ codestream size
+
+ For each tile:
+ tile number
+ tile start pos in codestream
+ tile header end position
+ tile end position in codestream
+
+ For each LRCP, RLCP etc.:
+ packet number
+ tile number
+ layer number
+ resolution number
+ component number
+ precinct number
+ start position in the codestream
+ end position of this packet
+ */
+char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int* buffer_size) {
+ int tileno, compno, layno, resno, precno, pack_nb, x, y;
+ char* buffer = NULL;
+ int buffer_pos = 0;
+ int prec_max = 0;
+
+ prec_max = 0;
+ for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
+ for (resno = 0; resno < cstr_info->numdecompos[0] + 1; resno++) {
+ prec_max = max(prec_max,cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno]);
+ }
+ }
+
+ // Compute the size of the index buffer, in number of bytes*/
+ *buffer_size =
+ 1 /* version */
+ + (10 /* image_w until decomposition */
+ + (cstr_info->numdecompos[0]+1) * 2 /* pdx size for each tile */
+ + 2 /* main_head_end + codestream_size */
+ + cstr_info->tw * cstr_info->th * 4 /* tile info, without distorsion info */
+ + cstr_info->tw*cstr_info->th * cstr_info->numlayers * (cstr_info->numdecompos[0] + 1) * cstr_info->numcomps * prec_max *8
+ ) * sizeof(int);
+ //printf("C: index buffer size = %d bytes\n", *buffer_size);
+ buffer = (char*) malloc(*buffer_size);
+
+ if (!buffer) {
+ //opj_event_msg(j2k->cinfo, EVT_ERROR, "failed to allocate index buffer for writing %d int\n", *buffer_size);
+ fprintf(stderr, "failed to allocate index buffer for writing %d int\n", *buffer_size);
+ return 0;
+ }
+
+ buffer[0] = 1; // Version stored on a byte
+ buffer++;
+ // Remaining informations are stored on a int.
+ ((int*)buffer)[buffer_pos++] = cstr_info->image_w;
+ ((int*)buffer)[buffer_pos++] = cstr_info->image_h;
+ ((int*)buffer)[buffer_pos++] = cstr_info->prog;
+ ((int*)buffer)[buffer_pos++] = cstr_info->tile_x;
+ ((int*)buffer)[buffer_pos++] = cstr_info->tile_y;
+ ((int*)buffer)[buffer_pos++] = cstr_info->tw;
+ ((int*)buffer)[buffer_pos++] = cstr_info->th;
+ ((int*)buffer)[buffer_pos++] = cstr_info->numcomps;
+ ((int*)buffer)[buffer_pos++] = cstr_info->numlayers;
+ ((int*)buffer)[buffer_pos++] = cstr_info->numdecompos[0];
+
+ for (resno = cstr_info->numdecompos[0]; resno >= 0; resno--) {
+ /* based on tile 0 */
+ ((int*)buffer)[buffer_pos++] = (1 << cstr_info->tile[0].pdx[resno]);
+ ((int*)buffer)[buffer_pos++] = (1 << cstr_info->tile[0].pdx[resno]);
+ }
+ ((int*)buffer)[buffer_pos++] = cstr_info->main_head_end;
+ ((int*)buffer)[buffer_pos++] = cstr_info->codestream_size;
+
+ for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
+ ((int*)buffer)[buffer_pos++] = cstr_info->tile[tileno].tileno;
+ ((int*)buffer)[buffer_pos++] = cstr_info->tile[tileno].start_pos;
+ ((int*)buffer)[buffer_pos++] = cstr_info->tile[tileno].end_header;
+ ((int*)buffer)[buffer_pos++] = cstr_info->tile[tileno].end_pos;
+ }
+
+ for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
+ int start_pos, end_pos;
+ int max_numdecompos = 0;
+ pack_nb = 0;
+
+ for (compno = 0; compno < cstr_info->numcomps; compno++) {
+ if (max_numdecompos < cstr_info->numdecompos[compno])
+ max_numdecompos = cstr_info->numdecompos[compno];
+ }
+
+ if (cstr_info->prog == LRCP) { /* LRCP */
+
+ for (layno = 0; layno < cstr_info->numlayers; layno++) {
+ for (resno = 0; resno < max_numdecompos + 1; resno++) {
+ for (compno = 0; compno < cstr_info->numcomps; compno++) {
+ int prec_max;
+ if (resno > cstr_info->numdecompos[compno])
+ break;
+ prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
+ for (precno = 0; precno < prec_max; precno++) {
+ start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
+ end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
+ ((int*)buffer)[buffer_pos++] = pack_nb;
+ ((int*)buffer)[buffer_pos++] = tileno;
+ ((int*)buffer)[buffer_pos++] = layno;
+ ((int*)buffer)[buffer_pos++] = resno;
+ ((int*)buffer)[buffer_pos++] = compno;
+ ((int*)buffer)[buffer_pos++] = precno;
+ ((int*)buffer)[buffer_pos++] = start_pos;
+ ((int*)buffer)[buffer_pos++] = end_pos;
+ pack_nb++;
+ }
+ }
+ }
+ }
+ } /* LRCP */
+ else if (cstr_info->prog == RLCP) { /* RLCP */
+
+ for (resno = 0; resno < max_numdecompos + 1; resno++) {
+ for (layno = 0; layno < cstr_info->numlayers; layno++) {
+ for (compno = 0; compno < cstr_info->numcomps; compno++) {
+ int prec_max;
+ if (resno > cstr_info->numdecompos[compno])
+ break;
+ prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
+ for (precno = 0; precno < prec_max; precno++) {
+ start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
+ end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
+ ((int*)buffer)[buffer_pos++] = pack_nb;
+ ((int*)buffer)[buffer_pos++] = tileno;
+ ((int*)buffer)[buffer_pos++] = resno;
+ ((int*)buffer)[buffer_pos++] = layno;
+ ((int*)buffer)[buffer_pos++] = compno;
+ ((int*)buffer)[buffer_pos++] = precno;
+ ((int*)buffer)[buffer_pos++] = start_pos;
+ ((int*)buffer)[buffer_pos++] = end_pos;
+ pack_nb++;
+ }
+ }
+ }
+ }
+ } /* RLCP */
+ else if (cstr_info->prog == RPCL) { /* RPCL */
+
+ for (resno = 0; resno < max_numdecompos + 1; resno++) {
+ /* I suppose components have same XRsiz, YRsiz */
+ int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
+ int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
+ int x1 = x0 + cstr_info->tile_x;
+ int y1 = y0 + cstr_info->tile_y;
+ for (compno = 0; compno < cstr_info->numcomps; compno++) {
+ int prec_max;
+ if (resno > cstr_info->numdecompos[compno])
+ break;
+ prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
+ for (precno = 0; precno < prec_max; precno++) {
+ int pcnx = cstr_info->tile[tileno].pw[resno];
+ int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
+ int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
+ int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
+ int precno_y = (int) floor( (float)precno/(float)pcnx );
+ for(y = y0; y < y1; y++) {
+ if (precno_y*pcy == y ) {
+ for (x = x0; x < x1; x++) {
+ if (precno_x*pcx == x ) {
+ for (layno = 0; layno < cstr_info->numlayers; layno++) {
+ start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
+ end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
+ ((int*)buffer)[buffer_pos++] = pack_nb;
+ ((int*)buffer)[buffer_pos++] = tileno;
+ ((int*)buffer)[buffer_pos++] = resno;
+ ((int*)buffer)[buffer_pos++] = precno;
+ ((int*)buffer)[buffer_pos++] = compno;
+ ((int*)buffer)[buffer_pos++] = layno;
+ ((int*)buffer)[buffer_pos++] = start_pos;
+ ((int*)buffer)[buffer_pos++] = end_pos;
+ pack_nb++;
+ }
+ }
+ }/* x = x0..x1 */
+ }
+ } /* y = y0..y1 */
+ } /* precno */
+ } /* compno */
+ } /* resno */
+ } /* RPCL */
+ else if (cstr_info->prog == PCRL) { /* PCRL */
+ /* I suppose components have same XRsiz, YRsiz */
+ int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
+ int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
+ int x1 = x0 + cstr_info->tile_x;
+ int y1 = y0 + cstr_info->tile_y;
+
+ for (compno = 0; compno < cstr_info->numcomps; compno++) {
+ for (resno = 0; resno < max_numdecompos + 1; resno++) {
+ int prec_max;
+ if (resno > cstr_info->numdecompos[compno])
+ break;
+ prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
+ for (precno = 0; precno < prec_max; precno++) {
+ int pcnx = cstr_info->tile[tileno].pw[resno];
+ int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
+ int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
+ int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
+ int precno_y = (int) floor( (float)precno/(float)pcnx );
+ for(y = y0; y < y1; y++) {
+ if (precno_y*pcy == y ) {
+ for (x = x0; x < x1; x++) {
+ if (precno_x*pcx == x ) {
+ for (layno = 0; layno < cstr_info->numlayers; layno++) {
+ start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
+ end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
+ ((int*)buffer)[buffer_pos++] = pack_nb;
+ ((int*)buffer)[buffer_pos++] = tileno;
+ ((int*)buffer)[buffer_pos++] = precno;
+ ((int*)buffer)[buffer_pos++] = compno;
+ ((int*)buffer)[buffer_pos++] = resno;
+ ((int*)buffer)[buffer_pos++] = layno;
+ ((int*)buffer)[buffer_pos++] = start_pos;
+ ((int*)buffer)[buffer_pos++] = end_pos;
+ pack_nb++;
+ }
+ }
+ }/* x = x0..x1 */
+ }
+ } /* y = y0..y1 */
+ } /* precno */
+ } /* resno */
+ } /* compno */
+ } /* PCRL */
+ else { /* CPRL */
+
+ for (compno = 0; compno < cstr_info->numcomps; compno++) {
+ /* I suppose components have same XRsiz, YRsiz */
+ int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
+ int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
+ int x1 = x0 + cstr_info->tile_x;
+ int y1 = y0 + cstr_info->tile_y;
+
+ for (resno = 0; resno < max_numdecompos + 1; resno++) {
+ int prec_max;
+ if (resno > cstr_info->numdecompos[compno])
+ break;
+ prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
+ for (precno = 0; precno < prec_max; precno++) {
+ int pcnx = cstr_info->tile[tileno].pw[resno];
+ int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
+ int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
+ int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
+ int precno_y = (int) floor( (float)precno/(float)pcnx );
+ for(y = y0; y < y1; y++) {
+ if (precno_y*pcy == y ) {
+ for (x = x0; x < x1; x++) {
+ if (precno_x*pcx == x ) {
+ for (layno = 0; layno < cstr_info->numlayers; layno++) {
+ start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
+ end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
+ ((int*)buffer)[buffer_pos++] = pack_nb;
+ ((int*)buffer)[buffer_pos++] = tileno;
+ ((int*)buffer)[buffer_pos++] = compno;
+ ((int*)buffer)[buffer_pos++] = precno;
+ ((int*)buffer)[buffer_pos++] = resno;
+ ((int*)buffer)[buffer_pos++] = layno;
+ ((int*)buffer)[buffer_pos++] = start_pos;
+ ((int*)buffer)[buffer_pos++] = end_pos;
+ pack_nb++;
+ }
+ }
+ }/* x = x0..x1 */
+ }
+ } /* y = y0..y1 */
+ } /* precno */
+ } /* resno */
+ } /* compno */
+ } /* CPRL */
+ } /* tileno */
+
+ if (buffer_pos > *buffer_size) {
+ //opj_event_msg(j2k->cinfo, EVT_ERROR, "index creation: buffer_pos (%d) > buffer_size (%d)!\n", buffer_pos, *buffer_size);
+ fprintf(stderr, "index creation: buffer_pos (%d) > buffer_size (%d)!\n", buffer_pos, *buffer_size);
+ return 0;
+ }
+
+ return --buffer;
+}
+
+
+
+
+/* --------------------------------------------------------------------------
+ ------------ Get the image byte[] from the Java object -------------------*/
+
+opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj, jclass cls) {
+ int i,max,shift,w,h,depth;
+ opj_image_t * img = NULL;
+ int compno, numcomps;
+ opj_image_t * image = NULL;
+ opj_image_comp_t *comp;
+ opj_image_cmptparm_t cmptparm[3]; /* maximum of 3 components */
+ OPJ_COLOR_SPACE color_space;
+ jfieldID fid;
+ jint ji;
+ jbyteArray jba;
+ jshortArray jsa;
+ jintArray jia;
+ int len;
+ jbyte *jbBody;
+ jshort *jsBody;
+ jint *jiBody;
+ boolean isCopy;
+
+ // Image width, height and depth
+ fid = (*env)->GetFieldID(env, cls,"width", "I");
+ ji = (*env)->GetIntField(env, obj, fid);
+ w = ji;
+
+ fid = (*env)->GetFieldID(env, cls,"height", "I");
+ ji = (*env)->GetIntField(env, obj, fid);
+ h = ji;
+
+ fid = (*env)->GetFieldID(env, cls,"depth", "I");
+ ji = (*env)->GetIntField(env, obj, fid);
+ depth = ji;
+
+ // Read the image
+ if (depth <=16) {
+ numcomps = 1;
+ color_space = CLRSPC_GRAY;
+ } else {
+ numcomps = 3;
+ color_space = CLRSPC_SRGB;
+ }
+ memset(&cmptparm[0], 0, numcomps * sizeof(opj_image_cmptparm_t));
+
+ if (numcomps == 1) {
+ cmptparm[0].x0 = parameters->image_offset_x0;
+ cmptparm[0].y0 = parameters->image_offset_y0;
+ cmptparm[0].w = !cmptparm[0].x0 ? (w - 1) * parameters->subsampling_dx + 1 : cmptparm[0].x0 + (w - 1) * parameters->subsampling_dx + 1;
+ cmptparm[0].h = !cmptparm[0].y0 ? (h - 1) * parameters->subsampling_dy + 1 : cmptparm[0].y0 + (h - 1) * parameters->subsampling_dy + 1;
+ // Java types are always signed but we use them as unsigned types (shift of the negative part of
+ // the pixels of the images in Telemis before entering the encoder).
+ cmptparm[0].sgnd = 0;
+ if (depth<=16)
+ cmptparm[0].prec=depth;
+ else
+ cmptparm[0].prec = 8;
+ cmptparm[0].bpp = cmptparm[0].prec;
+ cmptparm[0].dx = parameters->subsampling_dx;
+ cmptparm[0].dy = parameters->subsampling_dy;
+ /*printf("C: component 0 initialised: x0=%d, y0=%d, w=%d, h=%d, sgnd=%d, bpp=%d, dx=%d, dy=%d, color_space=%d\n", cmptparm[0].x0, cmptparm[0].y0, cmptparm[0].w,
+ cmptparm[0].h, cmptparm[0].sgnd, cmptparm[0].bpp, cmptparm[0].dx, cmptparm[0].dy, color_space);*/
+ } else {
+ for(i = 0; i < numcomps; i++) {
+ cmptparm[i].prec = 8;
+ cmptparm[i].bpp = 8;
+ cmptparm[i].sgnd = 0;
+ cmptparm[i].dx = parameters->subsampling_dx;
+ cmptparm[i].dy = parameters->subsampling_dy;
+ cmptparm[i].w = w;
+ cmptparm[i].h = h;
+ }
+ }
+
+ /* create the image */
+ image = opj_image_create(numcomps, &cmptparm[0], color_space);
+
+ if (!image)
+ return NULL;
+
+ if (depth <=16) {
+ image->numcomps=1;
+ } else {
+ image->numcomps = 3;
+ }
+
+ /* set image offset and reference grid */
+ image->x0 = cmptparm[0].x0;
+ image->y0 = cmptparm[0].x0;
+ image->x1 = cmptparm[0].w;
+ image->y1 = cmptparm[0].h;
+
+ /* set image data */
+ for (compno=0; compno<numcomps; compno++) {
+ comp = &image->comps[compno];
+ max = -100000;
+ if (depth == 8) {
+ fid = (*env)->GetFieldID(env, cls,"image8", "[B"); // byteArray []
+ jba = (*env)->GetObjectField(env, obj, fid);
+ len = (*env)->GetArrayLength(env, jba);
+
+ jbBody = (*env)->GetPrimitiveArrayCritical(env, jba, &isCopy);
+ //printf("C: before transfering 8 bpp image\n");
+ if (comp->sgnd) {
+ for(i=0; i< len;i++) {
+ comp->data[i] = (char) jbBody[i];
+ if (comp->data[i] > max) max = comp->data[i];
+ }
+ } else {
+ for(i=0; i< len;i++) {
+ comp->data[i] = (unsigned char) jbBody[i];
+ if (comp->data[i] > max) max = comp->data[i];
+ }
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, jba, jbBody, 0);
+ } else if(depth == 16) {
+ fid = (*env)->GetFieldID(env, cls,"image16", "[S"); // shortArray []
+ jsa = (*env)->GetObjectField(env, obj, fid);
+ len = (*env)->GetArrayLength(env, jsa);
+
+ jsBody = (*env)->GetPrimitiveArrayCritical(env, jsa, &isCopy);
+ //printf("C: before transfering 16 bpp image\n");
+ if (comp->sgnd) { // Special behaviour to deal with signed elements ??
+ comp->data[i] = (short) jsBody[i];
+ for(i=0; i< len;i++) {
+ if (comp->data[i] > max) max = comp->data[i];
+ }
+ } else {
+ for(i=0; i< len;i++) {
+ comp->data[i] = (unsigned short) jsBody[i];
+ if (comp->data[i] > max) max = comp->data[i];
+ }
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, jsa, jsBody, 0);
+ } else if (depth == 24) {
+ fid = (*env)->GetFieldID(env, cls,"image24", "[I"); // intArray []
+ jia = (*env)->GetObjectField(env, obj, fid);
+ len = (*env)->GetArrayLength(env, jia);
+ shift = compno*8;
+
+ jiBody = (*env)->GetPrimitiveArrayCritical(env, jia, &isCopy);
+ //printf("C: before transfering 24 bpp image (component %d, signed = %d)\n", compno, comp->sgnd);
+ if (comp->sgnd) { // Special behaviour to deal with signed elements ?? XXXXX
+ for(i=0; i< len;i++) {
+ comp->data[i] = ( ((int) jiBody[i]) & (0xFF << shift) ) >> shift;
+ if (comp->data[i] > max) max = comp->data[i];
+ }
+ } else {
+ for(i=0; i< len;i++) {
+ comp->data[i] = ( ((unsigned int) jiBody[i]) & (0xFF << shift) ) >> shift;
+ if (comp->data[i] > max) max = comp->data[i];
+ }
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, jia, jiBody, 0);
+ }
+ comp->bpp = int_floorlog2(max)+1;
+ comp->prec = comp->bpp;
+ //printf("C: component %d: max %d, real bpp = %d\n", compno, max, comp->bpp);
+ }
+ return image;
+}
+
+
+/* --------------------------------------------------------------------------
+ -------------------- MAIN METHOD, CALLED BY JAVA -----------------------*/
+JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImageToJ2K(JNIEnv *env, jobject obj, jobjectArray javaParameters) {
+ int argc; /* To simulate the command line parameters (taken from the javaParameters variable) and be able to re-use the */
+ char **argv; /* 'parse_cmdline_decoder' method taken from the j2k_to_image project */
+ bool bSuccess;
+ opj_cparameters_t parameters; /* compression parameters */
+ img_fol_t img_fol;
+ opj_event_mgr_t event_mgr; /* event manager */
+ opj_image_t *image = NULL;
+ int i,j,num_images;
+ int imageno;
+ opj_codestream_info_t cstr_info; /* Codestream information structure */
+ char indexfilename[OPJ_PATH_LEN]; /* index file name */
+
+ int* compressed_index = NULL;
+ int compressed_index_size=-1;
+ // ==> Access variables to the Java member variables
+ jsize arraySize;
+ jclass cls;
+ jobject object;
+ jboolean isCopy;
+ jfieldID fid;
+ jbyteArray jba;
+ jbyte *jbBody;
+ callback_variables_t msgErrorCallback_vars;
+ // <== access variable to the Java member variables.
+
+ // For the encoding and storage into the file
+ opj_cinfo_t* cinfo;
+ int codestream_length;
+ opj_cio_t *cio = NULL;
+ FILE *f = NULL;
+
+ // JNI reference to the calling class
+ cls = (*env)->GetObjectClass(env, obj);
+
+ // Pointers to be able to call a Java method for all the info and error messages
+ msgErrorCallback_vars.env = env;
+ msgErrorCallback_vars.jobj = &obj;
+ msgErrorCallback_vars.message_mid = (*env)->GetMethodID(env, cls, "logMessage", "(Ljava/lang/String;)V");
+ msgErrorCallback_vars.error_mid = (*env)->GetMethodID(env, cls, "logError", "(Ljava/lang/String;)V");
+
+ arraySize = (*env)->GetArrayLength(env, javaParameters);
+ argc = (int) arraySize +1;
+ argv = malloc(argc*sizeof(char*));
+ argv[0] = "ProgramName.exe"; // The program name: useless
+ j=0;
+ for (i=1; i<argc; i++) {
+ object = (*env)->GetObjectArrayElement(env, javaParameters, i-1);
+ argv[i] = (*env)->GetStringUTFChars(env, object, &isCopy);
+ }
+
+ /*printf("C: ");
+ for (i=0; i<argc; i++) {
+ printf("[%s]",argv[i]);
+ }
+ printf("\n");*/
+
+ /*
+ configure the event callbacks
+ */
+ memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
+ event_mgr.error_handler = error_callback;
+ event_mgr.warning_handler = warning_callback;
+ event_mgr.info_handler = info_callback;
+
+ /* set encoding parameters to default values */
+ opj_set_default_encoder_parameters(¶meters);
+ parameters.cod_format = J2K_CFMT;
+ //parameters.index_on = 1;
+
+ /* Initialize indexfilename and img_fol */
+ *indexfilename = 0;
+ memset(&img_fol,0,sizeof(img_fol_t));
+
+ /* parse input and get user encoding parameters */
+ if (parse_cmdline_encoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
+ // Release the Java arguments array
+ for (i=1; i<argc; i++)
+ (*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
+ return -1;
+ }
+
+ // Release the Java arguments array
+ for (i=1; i<argc; i++)
+ (*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
+
+ if (parameters.cp_cinema){
+ cinema_parameters(¶meters);
+ }
+
+
+ /* Create comment for codestream */
+ if(parameters.cp_comment == NULL) {
+ const char comment[] = "Created by JavaOpenJPEG version ";
+ const size_t clen = strlen(comment);
+ const char *version = opj_version();
+/* UniPG>> */
+#ifdef USE_JPWL
+ parameters.cp_comment = (char*)malloc(clen+strlen(version)+11);
+ sprintf(parameters.cp_comment,"%s%s with JPWL", comment, version);
+#else
+ parameters.cp_comment = (char*)malloc(clen+strlen(version)+1);
+ sprintf(parameters.cp_comment,"%s%s", comment, version);
+#endif
+/* <<UniPG */
+
+ }
+
+ /* Read directory if necessary */
+ num_images=1;
+
+ /*Encoding image one by one*/
+ for(imageno=0;imageno<num_images;imageno++)
+ {
+ image = NULL;
+ fprintf(stderr,"\n");
+
+ image = loadImage(¶meters, env, obj, cls);
+ //printf("C: after load image: image = %d\n", image);
+ if (!image) {
+ fprintf(stderr, "Unable to load image\n");
+ return -1;
+ }
+
+ /* Decide if MCT should be used */
+ parameters.tcp_mct = image->numcomps == 3 ? 1 : 0;
+
+ if(parameters.cp_cinema){
+ cinema_setup_encoder(¶meters,image,&img_fol);
+ }
+
+ /* encode the destination image */
+ /* ---------------------------- */
+ /* get a J2K compressor handle */
+ if (parameters.cod_format == J2K_CFMT) { /* J2K format output */
+ cinfo = opj_create_compress(CODEC_J2K);
+ } else { /* JP2 format output */
+ cinfo = opj_create_compress(CODEC_JP2);
+ }
+ /* catch events using our callbacks and give a local context */
+ opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, &msgErrorCallback_vars);
+
+ /* setup the encoder parameters using the current image and user parameters */
+ opj_setup_encoder(cinfo, ¶meters, image);
+
+ /* open a byte stream for writing */
+ /* allocate memory for all tiles */
+ cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
+
+ /* encode the image */
+ bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info);
+ printf("C: after opj_encode_with_info\n");
+ if (!bSuccess) {
+ opj_cio_close(cio);
+ fprintf(stderr, "failed to encode image\n");
+ return -1;
+ }
+ codestream_length = cio_tell(cio);
+
+ /* write the index on disk, if needed (-x 'filename') */
+ if (*indexfilename) {
+ bSuccess = write_index_file(&cstr_info, indexfilename);
+ if (bSuccess) {
+ fprintf(stderr, "Failed to output index file into [%s]\n", indexfilename);
+ }
+ }
+
+ compressed_index = create_index_into_byte_array(&cstr_info, &compressed_index_size);
+ /* Allocates the Java compressedIndex byte[] and sends this index into the Java object */
+ fid = (*env)->GetFieldID(env, cls,"compressedIndex", "[B");
+ jba = (*env)->NewByteArray(env, compressed_index_size+1);
+ jbBody = (*env)->GetPrimitiveArrayCritical(env, jba, 0);
+ memcpy(jbBody, compressed_index, compressed_index_size);
+ (*env)->ReleasePrimitiveArrayCritical(env, jba, jbBody, 0);
+ (*env)->SetObjectField(env, obj, fid, jba);
+ free(compressed_index);
+
+ /* write the generated codestream to disk ? */
+ if (parameters.outfile[0]!='\0') {
+ f = fopen(parameters.outfile, "wb");
+ if (!f) {
+ fprintf(stderr, "failed to open [%s] for writing\n", parameters.outfile);
+ return -1;
+ }
+ fwrite(cio->buffer, 1, codestream_length, f);
+ fclose(f);
+ fprintf(stdout,"Generated outfile [%s]\n",parameters.outfile);
+ }
+
+ /* Write the generated codestream to the Java pre-allocated compressedStream byte[] */
+ fid = (*env)->GetFieldID(env, cls,"compressedStream", "[B");
+ jba = (*env)->GetObjectField(env, obj, fid);
+ jbBody = (*env)->GetPrimitiveArrayCritical(env, jba, 0);
+ memcpy(jbBody, cio->buffer, codestream_length);
+ (*env)->ReleasePrimitiveArrayCritical(env, jba, jbBody, 0);
+
+ /* close and free the byte stream */
+ opj_cio_close(cio);
+
+ /* free remaining compression structures */
+ opj_destroy_compress(cinfo);
+ opj_destroy_cstr_info(&cstr_info);
+
+ /* free image data */
+ opj_image_destroy(image);
+ }
+
+ /* free user parameters structure */
+ if(parameters.cp_comment) free(parameters.cp_comment);
+ if(parameters.cp_matrice) free(parameters.cp_matrice);
+
+ return codestream_length;
+}
diff --git a/applications/JavaOpenJPEG/JavaOpenJPEGDecoder.c b/applications/JavaOpenJPEG/JavaOpenJPEGDecoder.c new file mode 100644 index 00000000..decc1373 --- /dev/null +++ b/applications/JavaOpenJPEG/JavaOpenJPEGDecoder.c @@ -0,0 +1,883 @@ +/*
+ * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2007, Professor Benoit Macq
+ * Copyright (c) 2001-2003, David Janssens
+ * Copyright (c) 2002-2003, Yannick Verschueren
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2006-2007, Parvatha Elangovan
+ * Copyright (c) 2007, Patrick Piscaglia (Telemis)
+ * 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. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <jni.h>
+#include <math.h>
+
+#include "openjpeg.h"
+#include "getopt.h"
+#include "convert.h"
+#include "dirent.h"
+#include "org_openJpeg_OpenJPEGJavaDecoder.h"
+
+#ifndef _WIN32
+#define stricmp strcasecmp
+#define strnicmp strncasecmp
+#endif
+
+#include "format_defs.h"
+
+typedef struct callback_variables {
+ JNIEnv *env;
+ /** 'jclass' object used to call a Java method from the C */
+ jobject *jobj;
+ /** 'jclass' object used to call a Java method from the C */
+ jmethodID message_mid;
+ jmethodID error_mid;
+} callback_variables_t;
+
+typedef struct dircnt{
+ /** Buffer for holding images read from Directory*/
+ char *filename_buf;
+ /** Pointer to the buffer*/
+ char **filename;
+}dircnt_t;
+
+
+typedef struct img_folder{
+ /** The directory path of the folder containing input images*/
+ char *imgdirpath;
+ /** Output format*/
+ char *out_format;
+ /** Enable option*/
+ char set_imgdir;
+ /** Enable Cod Format for output*/
+ char set_out_format;
+
+}img_fol_t;
+
+
+void decode_help_display() {
+ fprintf(stdout,"HELP\n----\n\n");
+ fprintf(stdout,"- the -h option displays this help information on screen\n\n");
+
+/* UniPG>> */
+ fprintf(stdout,"List of parameters for the JPEG 2000 "
+#ifdef USE_JPWL
+ "+ JPWL "
+#endif /* USE_JPWL */
+ "decoder:\n");
+/* <<UniPG */
+ fprintf(stdout,"\n");
+ fprintf(stdout,"\n");
+ fprintf(stdout," -ImgDir \n");
+ fprintf(stdout," Image file Directory path \n");
+ fprintf(stdout," -OutFor \n");
+ fprintf(stdout," REQUIRED only if -ImgDir is used\n");
+ fprintf(stdout," Need to specify only format without filename <BMP> \n");
+ fprintf(stdout," Currently accepts PGM, PPM, PNM, PGX, BMP format\n");
+ fprintf(stdout," -i <compressed file>\n");
+ fprintf(stdout," REQUIRED only if an Input image directory not specified\n");
+ fprintf(stdout," Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
+ fprintf(stdout," is identified based on its suffix.\n");
+ fprintf(stdout," -o <decompressed file>\n");
+ fprintf(stdout," REQUIRED\n");
+ fprintf(stdout," Currently accepts PGM-files, PPM-files, PNM-files, PGX-files and\n");
+ fprintf(stdout," BMP-files. Binary data is written to the file (not ascii). If a PGX\n");
+ fprintf(stdout," filename is given, there will be as many output files as there are\n");
+ fprintf(stdout," components: an indice starting from 0 will then be appended to the\n");
+ fprintf(stdout," output filename, just before the \"pgx\" extension. If a PGM filename\n");
+ fprintf(stdout," is given and there are more than one component, only the first component\n");
+ fprintf(stdout," will be written to the file.\n");
+ fprintf(stdout," -r <reduce factor>\n");
+ fprintf(stdout," Set the number of highest resolution levels to be discarded. The\n");
+ fprintf(stdout," image resolution is effectively divided by 2 to the power of the\n");
+ fprintf(stdout," number of discarded levels. The reduce factor is limited by the\n");
+ fprintf(stdout," smallest total number of decomposition levels among tiles.\n");
+ fprintf(stdout," -l <number of quality layers to decode>\n");
+ fprintf(stdout," Set the maximum number of quality layers to decode. If there are\n");
+ fprintf(stdout," less quality layers than the specified number, all the quality layers\n");
+ fprintf(stdout," are decoded.\n");
+/* UniPG>> */
+#ifdef USE_JPWL
+ fprintf(stdout," -W <options>\n");
+ fprintf(stdout," Activates the JPWL correction capability, if the codestream complies.\n");
+ fprintf(stdout," Options can be a comma separated list of <param=val> tokens:\n");
+ fprintf(stdout," c, c=numcomps\n");
+ fprintf(stdout," numcomps is the number of expected components in the codestream\n");
+ fprintf(stdout," (search of first EPB rely upon this, default is %d)\n", JPWL_EXPECTED_COMPONENTS);
+#endif /* USE_JPWL */
+/* <<UniPG */
+ fprintf(stdout,"\n");
+}
+
+/* -------------------------------------------------------------------------- */
+
+int get_num_images(char *imgdirpath){
+ DIR *dir;
+ struct dirent* content;
+ int num_images = 0;
+
+ /*Reading the input images from given input directory*/
+
+ dir= opendir(imgdirpath);
+ if(!dir){
+ fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
+ return 0;
+ }
+
+ while((content=readdir(dir))!=NULL){
+ if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
+ continue;
+ num_images++;
+ }
+ return num_images;
+}
+
+int load_images(dircnt_t *dirptr, char *imgdirpath){
+ DIR *dir;
+ struct dirent* content;
+ int i = 0;
+
+ /*Reading the input images from given input directory*/
+
+ dir= opendir(imgdirpath);
+ if(!dir){
+ fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
+ return 1;
+ }else {
+ fprintf(stderr,"Folder opened successfully\n");
+ }
+
+ while((content=readdir(dir))!=NULL){
+ if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
+ continue;
+
+ strcpy(dirptr->filename[i],content->d_name);
+ i++;
+ }
+ return 0;
+}
+
+int get_file_format(char *filename) {
+ unsigned int i;
+ static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "j2k", "jp2", "jpt", "j2c" };
+ static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT };
+ char * ext = strrchr(filename, '.');
+ if (ext == NULL)
+ return -1;
+ ext++;
+ if(ext) {
+ for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
+ if(strnicmp(ext, extension[i], 3) == 0) {
+ return format[i];
+ }
+ }
+ }
+
+ return -1;
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol) {
+ /* parse the command line */
+ int totlen;
+ option_t long_option[]={
+ {"ImgDir",REQ_ARG, NULL ,'y'},
+ {"OutFor",REQ_ARG, NULL ,'O'},
+ };
+
+/* UniPG>> */
+ const char optlist[] = "i:o:r:l:hx:"
+
+#ifdef USE_JPWL
+ "W:"
+#endif /* USE_JPWL */
+ ;
+ /*for (i=0; i<argc; i++) {
+ printf("[%s]",argv[i]);
+ }
+ printf("\n");*/
+
+/* <<UniPG */
+ totlen=sizeof(long_option);
+ img_fol->set_out_format = 0;
+ reset_options_reading();
+
+ while (1) {
+ int c = getopt_long(argc, argv,optlist,long_option,totlen);
+ if (c == -1)
+ break;
+ switch (c) {
+ case 'i': /* input file */
+ {
+ char *infile = optarg;
+ parameters->decod_format = get_file_format(infile);
+ switch(parameters->decod_format) {
+ case J2K_CFMT:
+ case JP2_CFMT:
+ case JPT_CFMT:
+ break;
+ default:
+ fprintf(stderr,
+ "!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
+ infile);
+ return 1;
+ }
+ strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
+ }
+ break;
+
+ /* ----------------------------------------------------- */
+
+ case 'o': /* output file */
+ {
+ char *outfile = optarg;
+ parameters->cod_format = get_file_format(outfile);
+ switch(parameters->cod_format) {
+ case PGX_DFMT:
+ case PXM_DFMT:
+ case BMP_DFMT:
+ case TIF_DFMT:
+ case RAW_DFMT:
+ case TGA_DFMT:
+ break;
+ default:
+ fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outfile);
+ return 1;
+ }
+ strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
+ }
+ break;
+
+ /* ----------------------------------------------------- */
+
+ case 'O': /* output format */
+ {
+ char outformat[50];
+ char *of = optarg;
+ sprintf(outformat,".%s",of);
+ img_fol->set_out_format = 1;
+ parameters->cod_format = get_file_format(outformat);
+ switch(parameters->cod_format) {
+ case PGX_DFMT:
+ img_fol->out_format = "pgx";
+ break;
+ case PXM_DFMT:
+ img_fol->out_format = "ppm";
+ break;
+ case BMP_DFMT:
+ img_fol->out_format = "bmp";
+ break;
+ case TIF_DFMT:
+ img_fol->out_format = "tif";
+ break;
+ case RAW_DFMT:
+ img_fol->out_format = "raw";
+ break;
+ case TGA_DFMT:
+ img_fol->out_format = "raw";
+ break;
+ default:
+ fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outformat);
+ return 1;
+ break;
+ }
+ }
+ break;
+
+ /* ----------------------------------------------------- */
+
+
+ case 'r': /* reduce option */
+ {
+ sscanf(optarg, "%d", ¶meters->cp_reduce);
+ }
+ break;
+
+ /* ----------------------------------------------------- */
+
+
+ case 'l': /* layering option */
+ {
+ sscanf(optarg, "%d", ¶meters->cp_layer);
+ }
+ break;
+
+ /* ----------------------------------------------------- */
+
+ case 'h': /* display an help description */
+ decode_help_display();
+ return 1;
+
+ /* ------------------------------------------------------ */
+
+ case 'y': /* Image Directory path */
+ {
+ img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
+ strcpy(img_fol->imgdirpath,optarg);
+ img_fol->set_imgdir=1;
+ }
+ break;
+ /* ----------------------------------------------------- */
+/* UniPG>> */
+#ifdef USE_JPWL
+
+ case 'W': /* activate JPWL correction */
+ {
+ char *token = NULL;
+
+ token = strtok(optarg, ",");
+ while(token != NULL) {
+
+ /* search expected number of components */
+ if (*token == 'c') {
+
+ static int compno;
+
+ compno = JPWL_EXPECTED_COMPONENTS; /* predefined no. of components */
+
+ if(sscanf(token, "c=%d", &compno) == 1) {
+ /* Specified */
+ if ((compno < 1) || (compno > 256)) {
+ fprintf(stderr, "ERROR -> invalid number of components c = %d\n", compno);
+ return 1;
+ }
+ parameters->jpwl_exp_comps = compno;
+
+ } else if (!strcmp(token, "c")) {
+ /* default */
+ parameters->jpwl_exp_comps = compno; /* auto for default size */
+
+ } else {
+ fprintf(stderr, "ERROR -> invalid components specified = %s\n", token);
+ return 1;
+ };
+ }
+
+ /* search maximum number of tiles */
+ if (*token == 't') {
+
+ static int tileno;
+
+ tileno = JPWL_MAXIMUM_TILES; /* maximum no. of tiles */
+
+ if(sscanf(token, "t=%d", &tileno) == 1) {
+ /* Specified */
+ if ((tileno < 1) || (tileno > JPWL_MAXIMUM_TILES)) {
+ fprintf(stderr, "ERROR -> invalid number of tiles t = %d\n", tileno);
+ return 1;
+ }
+ parameters->jpwl_max_tiles = tileno;
+
+ } else if (!strcmp(token, "t")) {
+ /* default */
+ parameters->jpwl_max_tiles = tileno; /* auto for default size */
+
+ } else {
+ fprintf(stderr, "ERROR -> invalid tiles specified = %s\n", token);
+ return 1;
+ };
+ }
+
+ /* next token or bust */
+ token = strtok(NULL, ",");
+ };
+ parameters->jpwl_correct = true;
+ fprintf(stdout, "JPWL correction capability activated\n");
+ fprintf(stdout, "- expecting %d components\n", parameters->jpwl_exp_comps);
+ }
+ break;
+#endif /* USE_JPWL */
+/* <<UniPG */
+
+ /* ----------------------------------------------------- */
+
+ default:
+ fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
+ break;
+ }
+ }
+
+ /* No check for possible errors before the -i and -o options are of course not mandatory*/
+
+ return 0;
+}
+
+/* -------------------------------------------------------------------------- */
+
+/**
+error callback returning the message to Java andexpecting a callback_variables_t client object
+*/
+void error_callback(const char *msg, void *client_data) {
+ callback_variables_t* vars = (callback_variables_t*) client_data;
+ JNIEnv *env = vars->env;
+ jstring jbuffer;
+
+ jbuffer = (*env)->NewStringUTF(env, msg);
+ (*env)->ExceptionClear(env);
+ (*env)->CallVoidMethod(env, *(vars->jobj), vars->error_mid, jbuffer);
+
+ if ((*env)->ExceptionOccurred(env)) {
+ fprintf(stderr,"C: Exception during call back method\n");
+ (*env)->ExceptionDescribe(env);
+ (*env)->ExceptionClear(env);
+ }
+ (*env)->DeleteLocalRef(env, jbuffer);
+}
+/**
+warning callback returning the message to Java andexpecting a callback_variables_t client object
+*/
+void warning_callback(const char *msg, void *client_data) {
+ callback_variables_t* vars = (callback_variables_t*) client_data;
+ JNIEnv *env = vars->env;
+ jstring jbuffer;
+
+ jbuffer = (*env)->NewStringUTF(env, msg);
+ (*env)->ExceptionClear(env);
+ (*env)->CallVoidMethod(env, *(vars->jobj), vars->message_mid, jbuffer);
+
+ if ((*env)->ExceptionOccurred(env)) {
+ fprintf(stderr,"C: Exception during call back method\n");
+ (*env)->ExceptionDescribe(env);
+ (*env)->ExceptionClear(env);
+ }
+ (*env)->DeleteLocalRef(env, jbuffer);
+}
+/**
+information callback returning the message to Java andexpecting a callback_variables_t client object
+*/
+void info_callback(const char *msg, void *client_data) {
+ callback_variables_t* vars = (callback_variables_t*) client_data;
+ JNIEnv *env = vars->env;
+ jstring jbuffer;
+
+ jbuffer = (*env)->NewStringUTF(env, msg);
+ (*env)->ExceptionClear(env);
+ (*env)->CallVoidMethod(env, *(vars->jobj), vars->message_mid, jbuffer);
+
+ if ((*env)->ExceptionOccurred(env)) {
+ fprintf(stderr,"C: Exception during call back method\n");
+ (*env)->ExceptionDescribe(env);
+ (*env)->ExceptionClear(env);
+ }
+ (*env)->DeleteLocalRef(env, jbuffer);
+}
+
+
+/* --------------------------------------------------------------------------
+ -------------------- MAIN METHOD, CALLED BY JAVA -----------------------*/
+JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2KtoImage(JNIEnv *env, jobject obj, jobjectArray javaParameters) {
+ int argc; /* To simulate the command line parameters (taken from the javaParameters variable) and be able to re-use the */
+ char **argv; /* 'parse_cmdline_decoder' method taken from the j2k_to_image project */
+ opj_dparameters_t parameters; /* decompression parameters */
+ img_fol_t img_fol;
+ opj_event_mgr_t event_mgr; /* event manager */
+ opj_image_t *image = NULL;
+ FILE *fsrc = NULL;
+ unsigned char *src = NULL;
+ int file_length;
+ int num_images;
+ int i,j,imageno;
+ opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
+ opj_cio_t *cio = NULL;
+ int w,h;
+ long min_value, max_value;
+ short tempS; unsigned char tempUC, tempUC1, tempUC2;
+ // ==> Access variables to the Java member variables
+ jsize arraySize;
+ jclass cls;
+ jobject object;
+ jboolean isCopy;
+ jfieldID fid;
+ jbyteArray jba;
+ jshortArray jsa;
+ jintArray jia;
+ jbyte *jbBody, *ptrBBody;
+ jshort *jsBody, *ptrSBody;
+ jint *jiBody, *ptrIBody;
+ callback_variables_t msgErrorCallback_vars;
+ // <=== access variable to Java member variables */
+ int *ptr, *ptr1, *ptr2; // <== To transfer the decoded image to Java
+
+ /* configure the event callbacks */
+ memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
+ event_mgr.error_handler = error_callback;
+ event_mgr.warning_handler = warning_callback;
+ event_mgr.info_handler = info_callback;
+
+ // JNI reference to the calling class
+ cls = (*env)->GetObjectClass(env, obj);
+
+ // Pointers to be able to call a Java method for all the info and error messages
+ msgErrorCallback_vars.env = env;
+ msgErrorCallback_vars.jobj = &obj;
+ msgErrorCallback_vars.message_mid = (*env)->GetMethodID(env, cls, "logMessage", "(Ljava/lang/String;)V");
+ msgErrorCallback_vars.error_mid = (*env)->GetMethodID(env, cls, "logError", "(Ljava/lang/String;)V");
+
+ // Get the String[] containing the parameters, and converts it into a char** to simulate command line arguments.
+ arraySize = (*env)->GetArrayLength(env, javaParameters);
+ argc = (int) arraySize +1;
+ argv = malloc(argc*sizeof(char*));
+ argv[0] = "ProgramName.exe"; // The program name: useless
+ j=0;
+ for (i=1; i<argc; i++) {
+ object = (*env)->GetObjectArrayElement(env, javaParameters, i-1);
+ argv[i] = (*env)->GetStringUTFChars(env, object, &isCopy);
+ }
+
+ /*printf("C: decoder params = ");
+ for (i=0; i<argc; i++) {
+ printf("[%s]",argv[i]);
+ }
+ printf("\n");*/
+
+ /* set decoding parameters to default values */
+ opj_set_default_decoder_parameters(¶meters);
+ parameters.decod_format = J2K_CFMT;
+
+ /* parse input and get user encoding parameters */
+ if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol) == 1) {
+ // Release the Java arguments array
+ for (i=1; i<argc; i++)
+ (*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
+ return -1;
+ }
+ // Release the Java arguments array
+ for (i=1; i<argc; i++)
+ (*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
+
+ num_images=1;
+
+ // Get additional information from the Java object variables
+ fid = (*env)->GetFieldID(env, cls,"skippedResolutions", "I");
+ parameters.cp_reduce = (short) (*env)->GetIntField(env, obj, fid);
+
+ /*Decoding image one by one*/
+ for(imageno = 0; imageno < num_images ; imageno++)
+ {
+ image = NULL;
+ fprintf(stderr,"\n");
+
+ /* read the input file and put it in memory into the 'src' object, if the -i option is given in JavaParameters.
+ Implemented for debug purpose. */
+ /* -------------------------------------------------------------- */
+ if (parameters.infile && parameters.infile[0]!='\0') {
+ //printf("C: opening [%s]\n", parameters.infile);
+ fsrc = fopen(parameters.infile, "rb");
+ if (!fsrc) {
+ fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
+ return 1;
+ }
+ fseek(fsrc, 0, SEEK_END);
+ file_length = ftell(fsrc);
+ fseek(fsrc, 0, SEEK_SET);
+ src = (unsigned char *) malloc(file_length);
+ fread(src, 1, file_length, fsrc);
+ fclose(fsrc);
+ //printf("C: %d bytes read from file\n",file_length);
+ } else {
+ // Preparing the transfer of the codestream from Java to C
+ //printf("C: before transfering codestream\n");
+ fid = (*env)->GetFieldID(env, cls,"compressedStream", "[B");
+ jba = (*env)->GetObjectField(env, obj, fid);
+ file_length = (*env)->GetArrayLength(env, jba);
+ jbBody = (*env)->GetByteArrayElements(env, jba, &isCopy);
+ src = (unsigned char*)jbBody;
+ }
+
+ /* decode the code-stream */
+ /* ---------------------- */
+
+ switch(parameters.decod_format) {
+ case J2K_CFMT:
+ {
+ /* JPEG-2000 codestream */
+
+ /* get a decoder handle */
+ dinfo = opj_create_decompress(CODEC_J2K);
+
+ /* catch events using our callbacks and give a local context */
+ opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, &msgErrorCallback_vars);
+
+ /* setup the decoder decoding parameters using user parameters */
+ opj_setup_decoder(dinfo, ¶meters);
+
+ /* open a byte stream */
+ cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
+
+ /* decode the stream and fill the image structure */
+ image = opj_decode(dinfo, cio);
+ if(!image) {
+ fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
+ opj_destroy_decompress(dinfo);
+ opj_cio_close(cio);
+ return 1;
+ }
+
+ /* close the byte stream */
+ opj_cio_close(cio);
+ }
+ break;
+
+ case JP2_CFMT:
+ {
+ /* JPEG 2000 compressed image data */
+
+ /* get a decoder handle */
+ dinfo = opj_create_decompress(CODEC_JP2);
+
+ /* catch events using our callbacks and give a local context */
+ opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, &msgErrorCallback_vars);
+
+ /* setup the decoder decoding parameters using the current image and user parameters */
+ opj_setup_decoder(dinfo, ¶meters);
+
+ /* open a byte stream */
+ cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
+
+ /* decode the stream and fill the image structure */
+ image = opj_decode(dinfo, cio);
+ if(!image) {
+ fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
+ opj_destroy_decompress(dinfo);
+ opj_cio_close(cio);
+ return 1;
+ }
+
+ /* close the byte stream */
+ opj_cio_close(cio);
+
+ }
+ break;
+
+ case JPT_CFMT:
+ {
+ /* JPEG 2000, JPIP */
+
+ /* get a decoder handle */
+ dinfo = opj_create_decompress(CODEC_JPT);
+
+ /* catch events using our callbacks and give a local context */
+ opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, &msgErrorCallback_vars);
+
+ /* setup the decoder decoding parameters using user parameters */
+ opj_setup_decoder(dinfo, ¶meters);
+
+ /* open a byte stream */
+ cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
+
+ /* decode the stream and fill the image structure */
+ image = opj_decode(dinfo, cio);
+ if(!image) {
+ fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
+ opj_destroy_decompress(dinfo);
+ opj_cio_close(cio);
+ return 1;
+ }
+
+ /* close the byte stream */
+ opj_cio_close(cio);
+ }
+ break;
+
+ default:
+ fprintf(stderr, "skipping file..\n");
+ continue;
+ }
+
+ /* free the memory containing the code-stream */
+ if (parameters.infile && parameters.infile[0]!='\0') {
+ free(src);
+ } else {
+ (*env)->ReleaseByteArrayElements(env, jba, jbBody, 0);
+ }
+ src = NULL;
+
+ /* create output image.
+ If the -o parameter is given in the JavaParameters, write the decoded version into a file.
+ Implemented for debug purpose. */
+ /* ---------------------------------- */
+ switch (parameters.cod_format) {
+ case PXM_DFMT: /* PNM PGM PPM */
+ if (imagetopnm(image, parameters.outfile)) {
+ fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
+ }
+ else {
+ fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
+ }
+ break;
+
+ case PGX_DFMT: /* PGX */
+ if(imagetopgx(image, parameters.outfile)){
+ fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
+ }
+ else {
+ fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
+ }
+ break;
+
+ case BMP_DFMT: /* BMP */
+ if(imagetobmp(image, parameters.outfile)){
+ fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
+ }
+ else {
+ fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
+ }
+ break;
+
+ }
+
+ // ========= Return the image to the Java structure ===============
+#ifdef CHECK_THRESHOLDS
+ printf("C: checking thresholds\n");
+#endif
+ // First compute the real with and height, in function of the resolutions decoded.
+ //wr = (image->comps[0].w + (1 << image->comps[0].factor) -1) >> image->comps[0].factor;
+ //hr = (image->comps[0].h + (1 << image->comps[0].factor) -1) >> image->comps[0].factor;
+ w = image->comps[0].w;
+ h = image->comps[0].h;
+
+ if (image->numcomps==3) { // 3 components color image
+ ptr = image->comps[0].data;
+ ptr1 = image->comps[1].data;
+ ptr2 = image->comps[2].data;
+#ifdef CHECK_THRESHOLDS
+ if (image->comps[0].sgnd) {
+ min_value = -128;
+ max_value = 127;
+ } else {
+ min_value = 0;
+ max_value = 255;
+ }
+#endif
+ // Get the pointer to the Java structure where the data must be copied
+ fid = (*env)->GetFieldID(env, cls,"image24", "[I");
+ jia = (*env)->GetObjectField(env, obj, fid);
+ jiBody = (*env)->GetIntArrayElements(env, jia, 0);
+ ptrIBody = jiBody;
+ printf("C: transfering image24: %d int to Java pointer=%d\n",image->numcomps*w*h, ptrIBody);
+
+ for (i=0; i<w*h; i++) {
+ tempUC = (unsigned char)(ptr[i]);
+ tempUC1 = (unsigned char)(ptr1[i]);
+ tempUC2 = (unsigned char)(ptr2[i]);
+#ifdef CHECK_THRESHOLDS
+ if (tempUC < min_value)
+ tempUC=min_value;
+ else if (tempUC > max_value)
+ tempUC=max_value;
+ if (tempUC1 < min_value)
+ tempUC1=min_value;
+ else if (tempUC1 > max_value)
+ tempUC1=max_value;
+ if (tempUC2 < min_value)
+ tempUC2=min_value;
+ else if (tempUC2 > max_value)
+ tempUC2=max_value;
+#endif
+ *(ptrIBody++) = (int) ( (tempUC2<<16) + (tempUC1<<8) + tempUC );
+ }
+ (*env)->ReleaseIntArrayElements(env, jia, jiBody, 0);
+
+ } else { // 1 component 8 or 16 bpp image
+ ptr = image->comps[0].data;
+ printf("C: before transfering a %d bpp image to java (length = %d)\n",image->comps[0].prec ,w*h);
+ if (image->comps[0].prec<=8) {
+ fid = (*env)->GetFieldID(env, cls,"image8", "[B");
+ jba = (*env)->GetObjectField(env, obj, fid);
+ jbBody = (*env)->GetByteArrayElements(env, jba, 0);
+ ptrBBody = jbBody;
+#ifdef CHECK_THRESHOLDS
+ if (image->comps[0].sgnd) {
+ min_value = -128;
+ max_value = 127;
+ } else {
+ min_value = 0;
+ max_value = 255;
+ }
+#endif
+ //printf("C: transfering %d shorts to Java image8 pointer = %d\n", wr*hr,ptrSBody);
+ for (i=0; i<w*h; i++) {
+ tempUC = (unsigned char) (ptr[i]);
+#ifdef CHECK_THRESHOLDS
+ if (tempUC<min_value)
+ tempUC = min_value;
+ else if (tempUC > max_value)
+ tempUC = max_value;
+#endif
+ *(ptrBBody++) = tempUC;
+ }
+ (*env)->ReleaseByteArrayElements(env, jba, jbBody, 0);
+ printf("C: image8 transfered to Java\n");
+ } else {
+ fid = (*env)->GetFieldID(env, cls,"image16", "[S");
+ jsa = (*env)->GetObjectField(env, obj, fid);
+ jsBody = (*env)->GetShortArrayElements(env, jsa, 0);
+ ptrSBody = jsBody;
+#ifdef CHECK_THRESHOLDS
+ if (image->comps[0].sgnd) {
+ min_value = -32768;
+ max_value = 32767;
+ } else {
+ min_value = 0;
+ max_value = 65535;
+ }
+ printf("C: minValue = %d, maxValue = %d\n", min_value, max_value);
+#endif
+ printf("C: transfering %d shorts to Java image16 pointer = %d\n", w*h,ptrSBody);
+ for (i=0; i<w*h; i++) {
+ tempS = (short) (ptr[i]);
+#ifdef CHECK_THRESHOLDS
+ if (tempS<min_value) {
+ printf("C: value %d truncated to %d\n", tempS, min_value);
+ tempS = min_value;
+ } else if (tempS > max_value) {
+ printf("C: value %d truncated to %d\n", tempS, max_value);
+ tempS = max_value;
+ }
+#endif
+ *(ptrSBody++) = tempS;
+ }
+ (*env)->ReleaseShortArrayElements(env, jsa, jsBody, 0);
+ printf("C: image16 completely filled\n");
+ }
+ }
+
+
+ /* free remaining structures */
+ if(dinfo) {
+ opj_destroy_decompress(dinfo);
+ }
+ /* free image data structure */
+ opj_image_destroy(image);
+
+ }
+ return 1; /* OK */
+}
+//end main
+
diff --git a/applications/JavaOpenJPEG/Makefile b/applications/JavaOpenJPEG/Makefile new file mode 100644 index 00000000..9ac3e407 --- /dev/null +++ b/applications/JavaOpenJPEG/Makefile @@ -0,0 +1,14 @@ +# Makefile for the main OpenJPEG codecs: j2k_to_image and image_to_j2k + +CFLAGS = -O3 -lstdc++ # -g -p -pg + +all: j2k_to_image image_to_j2k + +j2k_to_image: j2k_to_image.c ../libopenjpeg.a + gcc $(CFLAGS) ../common/getopt.c convert.c j2k_to_image.c -o j2k_to_image -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff + +image_to_j2k: image_to_j2k.c ../libopenjpeg.a + gcc $(CFLAGS) ../common/getopt.c convert.c image_to_j2k.c -o image_to_j2k -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff + +clean: + rm -f j2k_to_image image_to_j2k diff --git a/applications/JavaOpenJPEG/java-jni/include/jawt.h b/applications/JavaOpenJPEG/java-jni/include/jawt.h new file mode 100644 index 00000000..30a49adf --- /dev/null +++ b/applications/JavaOpenJPEG/java-jni/include/jawt.h @@ -0,0 +1,278 @@ +/*
+ * @(#)jawt.h 1.10 03/12/19
+ *
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+#ifndef _JAVASOFT_JAWT_H_
+#define _JAVASOFT_JAWT_H_
+
+#include "jni.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * AWT native interface (new in JDK 1.3)
+ *
+ * The AWT native interface allows a native C or C++ application a means
+ * by which to access native structures in AWT. This is to facilitate moving
+ * legacy C and C++ applications to Java and to target the needs of the
+ * community who, at present, wish to do their own native rendering to canvases
+ * for performance reasons. Standard extensions such as Java3D also require a
+ * means to access the underlying native data structures of AWT.
+ *
+ * There may be future extensions to this API depending on demand.
+ *
+ * A VM does not have to implement this API in order to pass the JCK.
+ * It is recommended, however, that this API is implemented on VMs that support
+ * standard extensions, such as Java3D.
+ *
+ * Since this is a native API, any program which uses it cannot be considered
+ * 100% pure java.
+ */
+
+/*
+ * AWT Native Drawing Surface (JAWT_DrawingSurface).
+ *
+ * For each platform, there is a native drawing surface structure. This
+ * platform-specific structure can be found in jawt_md.h. It is recommended
+ * that additional platforms follow the same model. It is also recommended
+ * that VMs on Win32 and Solaris support the existing structures in jawt_md.h.
+ *
+ *******************
+ * EXAMPLE OF USAGE:
+ *******************
+ *
+ * In Win32, a programmer wishes to access the HWND of a canvas to perform
+ * native rendering into it. The programmer has declared the paint() method
+ * for their canvas subclass to be native:
+ *
+ *
+ * MyCanvas.java:
+ *
+ * import java.awt.*;
+ *
+ * public class MyCanvas extends Canvas {
+ *
+ * static {
+ * System.loadLibrary("mylib");
+ * }
+ *
+ * public native void paint(Graphics g);
+ * }
+ *
+ *
+ * myfile.c:
+ *
+ * #include "jawt_md.h"
+ * #include <assert.h>
+ *
+ * JNIEXPORT void JNICALL
+ * Java_MyCanvas_paint(JNIEnv* env, jobject canvas, jobject graphics)
+ * {
+ * JAWT awt;
+ * JAWT_DrawingSurface* ds;
+ * JAWT_DrawingSurfaceInfo* dsi;
+ * JAWT_Win32DrawingSurfaceInfo* dsi_win;
+ * jboolean result;
+ * jint lock;
+ *
+ * // Get the AWT
+ * awt.version = JAWT_VERSION_1_3;
+ * result = JAWT_GetAWT(env, &awt);
+ * assert(result != JNI_FALSE);
+ *
+ * // Get the drawing surface
+ * ds = awt.GetDrawingSurface(env, canvas);
+ * assert(ds != NULL);
+ *
+ * // Lock the drawing surface
+ * lock = ds->Lock(ds);
+ * assert((lock & JAWT_LOCK_ERROR) == 0);
+ *
+ * // Get the drawing surface info
+ * dsi = ds->GetDrawingSurfaceInfo(ds);
+ *
+ * // Get the platform-specific drawing info
+ * dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
+ *
+ * //////////////////////////////
+ * // !!! DO PAINTING HERE !!! //
+ * //////////////////////////////
+ *
+ * // Free the drawing surface info
+ * ds->FreeDrawingSurfaceInfo(dsi);
+ *
+ * // Unlock the drawing surface
+ * ds->Unlock(ds);
+ *
+ * // Free the drawing surface
+ * awt.FreeDrawingSurface(ds);
+ * }
+ *
+ */
+
+/*
+ * JAWT_Rectangle
+ * Structure for a native rectangle.
+ */
+typedef struct jawt_Rectangle {
+ jint x;
+ jint y;
+ jint width;
+ jint height;
+} JAWT_Rectangle;
+
+struct jawt_DrawingSurface;
+
+/*
+ * JAWT_DrawingSurfaceInfo
+ * Structure for containing the underlying drawing information of a component.
+ */
+typedef struct jawt_DrawingSurfaceInfo {
+ /*
+ * Pointer to the platform-specific information. This can be safely
+ * cast to a JAWT_Win32DrawingSurfaceInfo on Windows or a
+ * JAWT_X11DrawingSurfaceInfo on Solaris. See jawt_md.h for details.
+ */
+ void* platformInfo;
+ /* Cached pointer to the underlying drawing surface */
+ struct jawt_DrawingSurface* ds;
+ /* Bounding rectangle of the drawing surface */
+ JAWT_Rectangle bounds;
+ /* Number of rectangles in the clip */
+ jint clipSize;
+ /* Clip rectangle array */
+ JAWT_Rectangle* clip;
+} JAWT_DrawingSurfaceInfo;
+
+#define JAWT_LOCK_ERROR 0x00000001
+#define JAWT_LOCK_CLIP_CHANGED 0x00000002
+#define JAWT_LOCK_BOUNDS_CHANGED 0x00000004
+#define JAWT_LOCK_SURFACE_CHANGED 0x00000008
+
+/*
+ * JAWT_DrawingSurface
+ * Structure for containing the underlying drawing information of a component.
+ * All operations on a JAWT_DrawingSurface MUST be performed from the same
+ * thread as the call to GetDrawingSurface.
+ */
+typedef struct jawt_DrawingSurface {
+ /*
+ * Cached reference to the Java environment of the calling thread.
+ * If Lock(), Unlock(), GetDrawingSurfaceInfo() or
+ * FreeDrawingSurfaceInfo() are called from a different thread,
+ * this data member should be set before calling those functions.
+ */
+ JNIEnv* env;
+ /* Cached reference to the target object */
+ jobject target;
+ /*
+ * Lock the surface of the target component for native rendering.
+ * When finished drawing, the surface must be unlocked with
+ * Unlock(). This function returns a bitmask with one or more of the
+ * following values:
+ *
+ * JAWT_LOCK_ERROR - When an error has occurred and the surface could not
+ * be locked.
+ *
+ * JAWT_LOCK_CLIP_CHANGED - When the clip region has changed.
+ *
+ * JAWT_LOCK_BOUNDS_CHANGED - When the bounds of the surface have changed.
+ *
+ * JAWT_LOCK_SURFACE_CHANGED - When the surface itself has changed
+ */
+ jint (JNICALL *Lock)
+ (struct jawt_DrawingSurface* ds);
+ /*
+ * Get the drawing surface info.
+ * The value returned may be cached, but the values may change if
+ * additional calls to Lock() or Unlock() are made.
+ * Lock() must be called before this can return a valid value.
+ * Returns NULL if an error has occurred.
+ * When finished with the returned value, FreeDrawingSurfaceInfo must be
+ * called.
+ */
+ JAWT_DrawingSurfaceInfo* (JNICALL *GetDrawingSurfaceInfo)
+ (struct jawt_DrawingSurface* ds);
+ /*
+ * Free the drawing surface info.
+ */
+ void (JNICALL *FreeDrawingSurfaceInfo)
+ (JAWT_DrawingSurfaceInfo* dsi);
+ /*
+ * Unlock the drawing surface of the target component for native rendering.
+ */
+ void (JNICALL *Unlock)
+ (struct jawt_DrawingSurface* ds);
+} JAWT_DrawingSurface;
+
+/*
+ * JAWT
+ * Structure for containing native AWT functions.
+ */
+typedef struct jawt {
+ /*
+ * Version of this structure. This must always be set before
+ * calling JAWT_GetAWT()
+ */
+ jint version;
+ /*
+ * Return a drawing surface from a target jobject. This value
+ * may be cached.
+ * Returns NULL if an error has occurred.
+ * Target must be a java.awt.Component (should be a Canvas
+ * or Window for native rendering).
+ * FreeDrawingSurface() must be called when finished with the
+ * returned JAWT_DrawingSurface.
+ */
+ JAWT_DrawingSurface* (JNICALL *GetDrawingSurface)
+ (JNIEnv* env, jobject target);
+ /*
+ * Free the drawing surface allocated in GetDrawingSurface.
+ */
+ void (JNICALL *FreeDrawingSurface)
+ (JAWT_DrawingSurface* ds);
+ /*
+ * Since 1.4
+ * Locks the entire AWT for synchronization purposes
+ */
+ void (JNICALL *Lock)(JNIEnv* env);
+ /*
+ * Since 1.4
+ * Unlocks the entire AWT for synchronization purposes
+ */
+ void (JNICALL *Unlock)(JNIEnv* env);
+ /*
+ * Since 1.4
+ * Returns a reference to a java.awt.Component from a native
+ * platform handle. On Windows, this corresponds to an HWND;
+ * on Solaris and Linux, this is a Drawable. For other platforms,
+ * see the appropriate machine-dependent header file for a description.
+ * The reference returned by this function is a local
+ * reference that is only valid in this environment.
+ * This function returns a NULL reference if no component could be
+ * found with matching platform information.
+ */
+ jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo);
+
+} JAWT;
+
+/*
+ * Get the AWT native structure. This function returns JNI_FALSE if
+ * an error occurs.
+ */
+_JNI_IMPORT_OR_EXPORT_
+jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt);
+
+#define JAWT_VERSION_1_3 0x00010003
+#define JAWT_VERSION_1_4 0x00010004
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !_JAVASOFT_JAWT_H_ */
diff --git a/applications/JavaOpenJPEG/java-jni/include/jdwpTransport.h b/applications/JavaOpenJPEG/java-jni/include/jdwpTransport.h new file mode 100644 index 00000000..1d780092 --- /dev/null +++ b/applications/JavaOpenJPEG/java-jni/include/jdwpTransport.h @@ -0,0 +1,237 @@ +/*
+ * @(#)jdwpTransport.h 1.7 03/12/19
+ *
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+/*
+ * Java Debug Wire Protocol Transport Service Provider Interface.
+ */
+
+#ifndef JDWPTRANSPORT_H
+#define JDWPTRANSPORT_H
+
+#include "jni.h"
+
+enum {
+ JDWPTRANSPORT_VERSION_1_0 = 0x00010000
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct jdwpTransportNativeInterface_;
+
+struct _jdwpTransportEnv;
+
+#ifdef __cplusplus
+typedef _jdwpTransportEnv jdwpTransportEnv;
+#else
+typedef const struct jdwpTransportNativeInterface_ *jdwpTransportEnv;
+#endif /* __cplusplus */
+
+/*
+ * Errors. Universal errors with JVMTI/JVMDI equivalents keep the
+ * values the same.
+ */
+typedef enum {
+ JDWPTRANSPORT_ERROR_NONE = 0,
+ JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT = 103,
+ JDWPTRANSPORT_ERROR_OUT_OF_MEMORY = 110,
+ JDWPTRANSPORT_ERROR_INTERNAL = 113,
+ JDWPTRANSPORT_ERROR_ILLEGAL_STATE = 201,
+ JDWPTRANSPORT_ERROR_IO_ERROR = 202,
+ JDWPTRANSPORT_ERROR_TIMEOUT = 203,
+ JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE = 204
+} jdwpTransportError;
+
+
+/*
+ * Structure to define capabilities
+ */
+typedef struct {
+ unsigned int can_timeout_attach :1;
+ unsigned int can_timeout_accept :1;
+ unsigned int can_timeout_handshake :1;
+ unsigned int reserved3 :1;
+ unsigned int reserved4 :1;
+ unsigned int reserved5 :1;
+ unsigned int reserved6 :1;
+ unsigned int reserved7 :1;
+ unsigned int reserved8 :1;
+ unsigned int reserved9 :1;
+ unsigned int reserved10 :1;
+ unsigned int reserved11 :1;
+ unsigned int reserved12 :1;
+ unsigned int reserved13 :1;
+ unsigned int reserved14 :1;
+ unsigned int reserved15 :1;
+} JDWPTransportCapabilities;
+
+
+/*
+ * Structures to define packet layout.
+ *
+ * See: http://java.sun.com/j2se/1.5/docs/guide/jpda/jdwp-spec.html
+ */
+
+enum {
+ JDWPTRANSPORT_FLAGS_NONE = 0x0,
+ JDWPTRANSPORT_FLAGS_REPLY = 0x80
+};
+
+typedef struct {
+ jint len;
+ jint id;
+ jbyte flags;
+ jbyte cmdSet;
+ jbyte cmd;
+ jbyte *data;
+} jdwpCmdPacket;
+
+typedef struct {
+ jint len;
+ jint id;
+ jbyte flags;
+ jshort errorCode;
+ jbyte *data;
+} jdwpReplyPacket;
+
+typedef struct {
+ union {
+ jdwpCmdPacket cmd;
+ jdwpReplyPacket reply;
+ } type;
+} jdwpPacket;
+
+/*
+ * JDWP functions called by the transport.
+ */
+typedef struct jdwpTransportCallback {
+ void *(*alloc)(jint numBytes); /* Call this for all allocations */
+ void (*free)(void *buffer); /* Call this for all deallocations */
+} jdwpTransportCallback;
+
+typedef jint (JNICALL *jdwpTransport_OnLoad_t)(JavaVM *jvm,
+ jdwpTransportCallback *callback,
+ jint version,
+ jdwpTransportEnv** env);
+
+
+
+/* Function Interface */
+
+struct jdwpTransportNativeInterface_ {
+ /* 1 : RESERVED */
+ void *reserved1;
+
+ /* 2 : Get Capabilities */
+ jdwpTransportError (JNICALL *GetCapabilities)(jdwpTransportEnv* env,
+ JDWPTransportCapabilities *capabilities_ptr);
+
+ /* 3 : Attach */
+ jdwpTransportError (JNICALL *Attach)(jdwpTransportEnv* env,
+ const char* address,
+ jlong attach_timeout,
+ jlong handshake_timeout);
+
+ /* 4: StartListening */
+ jdwpTransportError (JNICALL *StartListening)(jdwpTransportEnv* env,
+ const char* address,
+ char** actual_address);
+
+ /* 5: StopListening */
+ jdwpTransportError (JNICALL *StopListening)(jdwpTransportEnv* env);
+
+ /* 6: Accept */
+ jdwpTransportError (JNICALL *Accept)(jdwpTransportEnv* env,
+ jlong accept_timeout,
+ jlong handshake_timeout);
+
+ /* 7: IsOpen */
+ jboolean (JNICALL *IsOpen)(jdwpTransportEnv* env);
+
+ /* 8: Close */
+ jdwpTransportError (JNICALL *Close)(jdwpTransportEnv* env);
+
+ /* 9: ReadPacket */
+ jdwpTransportError (JNICALL *ReadPacket)(jdwpTransportEnv* env,
+ jdwpPacket *pkt);
+
+ /* 10: Write Packet */
+ jdwpTransportError (JNICALL *WritePacket)(jdwpTransportEnv* env,
+ const jdwpPacket* pkt);
+
+ /* 11: GetLastError */
+ jdwpTransportError (JNICALL *GetLastError)(jdwpTransportEnv* env,
+ char** error);
+
+};
+
+
+/*
+ * Use inlined functions so that C++ code can use syntax such as
+ * env->Attach("mymachine:5000", 10*1000, 0);
+ *
+ * rather than using C's :-
+ *
+ * (*env)->Attach(env, "mymachine:5000", 10*1000, 0);
+ */
+struct _jdwpTransportEnv {
+ const struct jdwpTransportNativeInterface_ *functions;
+#ifdef __cplusplus
+
+ jdwpTransportError GetCapabilities(JDWPTransportCapabilities *capabilities_ptr) {
+ return functions->GetCapabilities(this, capabilities_ptr);
+ }
+
+ jdwpTransportError Attach(const char* address, jlong attach_timeout,
+ jlong handshake_timeout) {
+ return functions->Attach(this, address, attach_timeout, handshake_timeout);
+ }
+
+ jdwpTransportError StartListening(const char* address,
+ char** actual_address) {
+ return functions->StartListening(this, address, actual_address);
+ }
+
+ jdwpTransportError StopListening(void) {
+ return functions->StopListening(this);
+ }
+
+ jdwpTransportError Accept(jlong accept_timeout, jlong handshake_timeout) {
+ return functions->Accept(this, accept_timeout, handshake_timeout);
+ }
+
+ jboolean IsOpen(void) {
+ return functions->IsOpen(this);
+ }
+
+ jdwpTransportError Close(void) {
+ return functions->Close(this);
+ }
+
+ jdwpTransportError ReadPacket(jdwpPacket *pkt) {
+ return functions->ReadPacket(this, pkt);
+ }
+
+ jdwpTransportError WritePacket(const jdwpPacket* pkt) {
+ return functions->WritePacket(this, pkt);
+ }
+
+ jdwpTransportError GetLastError(char** error) {
+ return functions->GetLastError(this, error);
+ }
+
+
+#endif /* __cplusplus */
+};
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif /* __cplusplus */
+
+#endif /* JDWPTRANSPORT_H */
+
diff --git a/applications/JavaOpenJPEG/java-jni/include/jni.h b/applications/JavaOpenJPEG/java-jni/include/jni.h new file mode 100644 index 00000000..cb3baef5 --- /dev/null +++ b/applications/JavaOpenJPEG/java-jni/include/jni.h @@ -0,0 +1,1951 @@ +/*
+ * @(#)jni.h 1.56 03/12/19
+ *
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+/*
+ * We used part of Netscape's Java Runtime Interface (JRI) as the starting
+ * point of our design and implementation.
+ */
+
+/******************************************************************************
+ * Java Runtime Interface
+ * Copyright (c) 1996 Netscape Communications Corporation. All rights reserved.
+ *****************************************************************************/
+
+#ifndef _JAVASOFT_JNI_H_
+#define _JAVASOFT_JNI_H_
+
+#include <stdio.h>
+#include <stdarg.h>
+
+/* jni_md.h contains the machine-dependent typedefs for jbyte, jint
+ and jlong */
+
+#include "jni_md.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * JNI Types
+ */
+
+#ifndef JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H
+
+typedef unsigned char jboolean;
+typedef unsigned short jchar;
+typedef short jshort;
+typedef float jfloat;
+typedef double jdouble;
+
+typedef jint jsize;
+
+#ifdef __cplusplus
+
+class _jobject {};
+class _jclass : public _jobject {};
+class _jthrowable : public _jobject {};
+class _jstring : public _jobject {};
+class _jarray : public _jobject {};
+class _jbooleanArray : public _jarray {};
+class _jbyteArray : public _jarray {};
+class _jcharArray : public _jarray {};
+class _jshortArray : public _jarray {};
+class _jintArray : public _jarray {};
+class _jlongArray : public _jarray {};
+class _jfloatArray : public _jarray {};
+class _jdoubleArray : public _jarray {};
+class _jobjectArray : public _jarray {};
+
+typedef _jobject *jobject;
+typedef _jclass *jclass;
+typedef _jthrowable *jthrowable;
+typedef _jstring *jstring;
+typedef _jarray *jarray;
+typedef _jbooleanArray *jbooleanArray;
+typedef _jbyteArray *jbyteArray;
+typedef _jcharArray *jcharArray;
+typedef _jshortArray *jshortArray;
+typedef _jintArray *jintArray;
+typedef _jlongArray *jlongArray;
+typedef _jfloatArray *jfloatArray;
+typedef _jdoubleArray *jdoubleArray;
+typedef _jobjectArray *jobjectArray;
+
+#else
+
+struct _jobject;
+
+typedef struct _jobject *jobject;
+typedef jobject jclass;
+typedef jobject jthrowable;
+typedef jobject jstring;
+typedef jobject jarray;
+typedef jarray jbooleanArray;
+typedef jarray jbyteArray;
+typedef jarray jcharArray;
+typedef jarray jshortArray;
+typedef jarray jintArray;
+typedef jarray jlongArray;
+typedef jarray jfloatArray;
+typedef jarray jdoubleArray;
+typedef jarray jobjectArray;
+
+#endif
+
+typedef jobject jweak;
+
+typedef union jvalue {
+ jboolean z;
+ jbyte b;
+ jchar c;
+ jshort s;
+ jint i;
+ jlong j;
+ jfloat f;
+ jdouble d;
+ jobject l;
+} jvalue;
+
+struct _jfieldID;
+typedef struct _jfieldID *jfieldID;
+
+struct _jmethodID;
+typedef struct _jmethodID *jmethodID;
+
+#endif /* JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H */
+
+/*
+ * jboolean constants
+ */
+
+#define JNI_FALSE 0
+#define JNI_TRUE 1
+
+/*
+ * possible return values for JNI functions.
+ */
+
+#define JNI_OK 0 /* success */
+#define JNI_ERR (-1) /* unknown error */
+#define JNI_EDETACHED (-2) /* thread detached from the VM */
+#define JNI_EVERSION (-3) /* JNI version error */
+#define JNI_ENOMEM (-4) /* not enough memory */
+#define JNI_EEXIST (-5) /* VM already created */
+#define JNI_EINVAL (-6) /* invalid arguments */
+
+/*
+ * used in ReleaseScalarArrayElements
+ */
+
+#define JNI_COMMIT 1
+#define JNI_ABORT 2
+
+/*
+ * used in RegisterNatives to describe native method name, signature,
+ * and function pointer.
+ */
+
+typedef struct {
+ char *name;
+ char *signature;
+ void *fnPtr;
+} JNINativeMethod;
+
+/*
+ * JNI Native Method Interface.
+ */
+
+struct JNINativeInterface_;
+
+struct JNIEnv_;
+
+#ifdef __cplusplus
+typedef JNIEnv_ JNIEnv;
+#else
+typedef const struct JNINativeInterface_ *JNIEnv;
+#endif
+
+/*
+ * JNI Invocation Interface.
+ */
+
+struct JNIInvokeInterface_;
+
+struct JavaVM_;
+
+#ifdef __cplusplus
+typedef JavaVM_ JavaVM;
+#else
+typedef const struct JNIInvokeInterface_ *JavaVM;
+#endif
+
+struct JNINativeInterface_ {
+ void *reserved0;
+ void *reserved1;
+ void *reserved2;
+
+ void *reserved3;
+ jint (JNICALL *GetVersion)(JNIEnv *env);
+
+ jclass (JNICALL *DefineClass)
+ (JNIEnv *env, const char *name, jobject loader, const jbyte *buf,
+ jsize len);
+ jclass (JNICALL *FindClass)
+ (JNIEnv *env, const char *name);
+
+ jmethodID (JNICALL *FromReflectedMethod)
+ (JNIEnv *env, jobject method);
+ jfieldID (JNICALL *FromReflectedField)
+ (JNIEnv *env, jobject field);
+
+ jobject (JNICALL *ToReflectedMethod)
+ (JNIEnv *env, jclass cls, jmethodID methodID, jboolean isStatic);
+
+ jclass (JNICALL *GetSuperclass)
+ (JNIEnv *env, jclass sub);
+ jboolean (JNICALL *IsAssignableFrom)
+ (JNIEnv *env, jclass sub, jclass sup);
+
+ jobject (JNICALL *ToReflectedField)
+ (JNIEnv *env, jclass cls, jfieldID fieldID, jboolean isStatic);
+
+ jint (JNICALL *Throw)
+ (JNIEnv *env, jthrowable obj);
+ jint (JNICALL *ThrowNew)
+ (JNIEnv *env, jclass clazz, const char *msg);
+ jthrowable (JNICALL *ExceptionOccurred)
+ (JNIEnv *env);
+ void (JNICALL *ExceptionDescribe)
+ (JNIEnv *env);
+ void (JNICALL *ExceptionClear)
+ (JNIEnv *env);
+ void (JNICALL *FatalError)
+ (JNIEnv *env, const char *msg);
+
+ jint (JNICALL *PushLocalFrame)
+ (JNIEnv *env, jint capacity);
+ jobject (JNICALL *PopLocalFrame)
+ (JNIEnv *env, jobject result);
+
+ jobject (JNICALL *NewGlobalRef)
+ (JNIEnv *env, jobject lobj);
+ void (JNICALL *DeleteGlobalRef)
+ (JNIEnv *env, jobject gref);
+ void (JNICALL *DeleteLocalRef)
+ (JNIEnv *env, jobject obj);
+ jboolean (JNICALL *IsSameObject)
+ (JNIEnv *env, jobject obj1, jobject obj2);
+ jobject (JNICALL *NewLocalRef)
+ (JNIEnv *env, jobject ref);
+ jint (JNICALL *EnsureLocalCapacity)
+ (JNIEnv *env, jint capacity);
+
+ jobject (JNICALL *AllocObject)
+ (JNIEnv *env, jclass clazz);
+ jobject (JNICALL *NewObject)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+ jobject (JNICALL *NewObjectV)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+ jobject (JNICALL *NewObjectA)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+
+ jclass (JNICALL *GetObjectClass)
+ (JNIEnv *env, jobject obj);
+ jboolean (JNICALL *IsInstanceOf)
+ (JNIEnv *env, jobject obj, jclass clazz);
+
+ jmethodID (JNICALL *GetMethodID)
+ (JNIEnv *env, jclass clazz, const char *name, const char *sig);
+
+ jobject (JNICALL *CallObjectMethod)
+ (JNIEnv *env, jobject obj, jmethodID methodID, ...);
+ jobject (JNICALL *CallObjectMethodV)
+ (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+ jobject (JNICALL *CallObjectMethodA)
+ (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args);
+
+ jboolean (JNICALL *CallBooleanMethod)
+ (JNIEnv *env, jobject obj, jmethodID methodID, ...);
+ jboolean (JNICALL *CallBooleanMethodV)
+ (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+ jboolean (JNICALL *CallBooleanMethodA)
+ (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args);
+
+ jbyte (JNICALL *CallByteMethod)
+ (JNIEnv *env, jobject obj, jmethodID methodID, ...);
+ jbyte (JNICALL *CallByteMethodV)
+ (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+ jbyte (JNICALL *CallByteMethodA)
+ (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
+
+ jchar (JNICALL *CallCharMethod)
+ (JNIEnv *env, jobject obj, jmethodID methodID, ...);
+ jchar (JNICALL *CallCharMethodV)
+ (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+ jchar (JNICALL *CallCharMethodA)
+ (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
+
+ jshort (JNICALL *CallShortMethod)
+ (JNIEnv *env, jobject obj, jmethodID methodID, ...);
+ jshort (JNICALL *CallShortMethodV)
+ (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+ jshort (JNICALL *CallShortMethodA)
+ (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
+
+ jint (JNICALL *CallIntMethod)
+ (JNIEnv *env, jobject obj, jmethodID methodID, ...);
+ jint (JNICALL *CallIntMethodV)
+ (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+ jint (JNICALL *CallIntMethodA)
+ (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
+
+ jlong (JNICALL *CallLongMethod)
+ (JNIEnv *env, jobject obj, jmethodID methodID, ...);
+ jlong (JNICALL *CallLongMethodV)
+ (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+ jlong (JNICALL *CallLongMethodA)
+ (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
+
+ jfloat (JNICALL *CallFloatMethod)
+ (JNIEnv *env, jobject obj, jmethodID methodID, ...);
+ jfloat (JNICALL *CallFloatMethodV)
+ (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+ jfloat (JNICALL *CallFloatMethodA)
+ (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
+
+ jdouble (JNICALL *CallDoubleMethod)
+ (JNIEnv *env, jobject obj, jmethodID methodID, ...);
+ jdouble (JNICALL *CallDoubleMethodV)
+ (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+ jdouble (JNICALL *CallDoubleMethodA)
+ (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
+
+ void (JNICALL *CallVoidMethod)
+ (JNIEnv *env, jobject obj, jmethodID methodID, ...);
+ void (JNICALL *CallVoidMethodV)
+ (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+ void (JNICALL *CallVoidMethodA)
+ (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args);
+
+ jobject (JNICALL *CallNonvirtualObjectMethod)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+ jobject (JNICALL *CallNonvirtualObjectMethodV)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ va_list args);
+ jobject (JNICALL *CallNonvirtualObjectMethodA)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ const jvalue * args);
+
+ jboolean (JNICALL *CallNonvirtualBooleanMethod)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+ jboolean (JNICALL *CallNonvirtualBooleanMethodV)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ va_list args);
+ jboolean (JNICALL *CallNonvirtualBooleanMethodA)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ const jvalue * args);
+
+ jbyte (JNICALL *CallNonvirtualByteMethod)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+ jbyte (JNICALL *CallNonvirtualByteMethodV)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ va_list args);
+ jbyte (JNICALL *CallNonvirtualByteMethodA)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ const jvalue *args);
+
+ jchar (JNICALL *CallNonvirtualCharMethod)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+ jchar (JNICALL *CallNonvirtualCharMethodV)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ va_list args);
+ jchar (JNICALL *CallNonvirtualCharMethodA)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ const jvalue *args);
+
+ jshort (JNICALL *CallNonvirtualShortMethod)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+ jshort (JNICALL *CallNonvirtualShortMethodV)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ va_list args);
+ jshort (JNICALL *CallNonvirtualShortMethodA)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ const jvalue *args);
+
+ jint (JNICALL *CallNonvirtualIntMethod)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+ jint (JNICALL *CallNonvirtualIntMethodV)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ va_list args);
+ jint (JNICALL *CallNonvirtualIntMethodA)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ const jvalue *args);
+
+ jlong (JNICALL *CallNonvirtualLongMethod)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+ jlong (JNICALL *CallNonvirtualLongMethodV)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ va_list args);
+ jlong (JNICALL *CallNonvirtualLongMethodA)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ const jvalue *args);
+
+ jfloat (JNICALL *CallNonvirtualFloatMethod)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+ jfloat (JNICALL *CallNonvirtualFloatMethodV)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ va_list args);
+ jfloat (JNICALL *CallNonvirtualFloatMethodA)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ const jvalue *args);
+
+ jdouble (JNICALL *CallNonvirtualDoubleMethod)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+ jdouble (JNICALL *CallNonvirtualDoubleMethodV)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ va_list args);
+ jdouble (JNICALL *CallNonvirtualDoubleMethodA)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ const jvalue *args);
+
+ void (JNICALL *CallNonvirtualVoidMethod)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+ void (JNICALL *CallNonvirtualVoidMethodV)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ va_list args);
+ void (JNICALL *CallNonvirtualVoidMethodA)
+ (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
+ const jvalue * args);
+
+ jfieldID (JNICALL *GetFieldID)
+ (JNIEnv *env, jclass clazz, const char *name, const char *sig);
+
+ jobject (JNICALL *GetObjectField)
+ (JNIEnv *env, jobject obj, jfieldID fieldID);
+ jboolean (JNICALL *GetBooleanField)
+ (JNIEnv *env, jobject obj, jfieldID fieldID);
+ jbyte (JNICALL *GetByteField)
+ (JNIEnv *env, jobject obj, jfieldID fieldID);
+ jchar (JNICALL *GetCharField)
+ (JNIEnv *env, jobject obj, jfieldID fieldID);
+ jshort (JNICALL *GetShortField)
+ (JNIEnv *env, jobject obj, jfieldID fieldID);
+ jint (JNICALL *GetIntField)
+ (JNIEnv *env, jobject obj, jfieldID fieldID);
+ jlong (JNICALL *GetLongField)
+ (JNIEnv *env, jobject obj, jfieldID fieldID);
+ jfloat (JNICALL *GetFloatField)
+ (JNIEnv *env, jobject obj, jfieldID fieldID);
+ jdouble (JNICALL *GetDoubleField)
+ (JNIEnv *env, jobject obj, jfieldID fieldID);
+
+ void (JNICALL *SetObjectField)
+ (JNIEnv *env, jobject obj, jfieldID fieldID, jobject val);
+ void (JNICALL *SetBooleanField)
+ (JNIEnv *env, jobject obj, jfieldID fieldID, jboolean val);
+ void (JNICALL *SetByteField)
+ (JNIEnv *env, jobject obj, jfieldID fieldID, jbyte val);
+ void (JNICALL *SetCharField)
+ (JNIEnv *env, jobject obj, jfieldID fieldID, jchar val);
+ void (JNICALL *SetShortField)
+ (JNIEnv *env, jobject obj, jfieldID fieldID, jshort val);
+ void (JNICALL *SetIntField)
+ (JNIEnv *env, jobject obj, jfieldID fieldID, jint val);
+ void (JNICALL *SetLongField)
+ (JNIEnv *env, jobject obj, jfieldID fieldID, jlong val);
+ void (JNICALL *SetFloatField)
+ (JNIEnv *env, jobject obj, jfieldID fieldID, jfloat val);
+ void (JNICALL *SetDoubleField)
+ (JNIEnv *env, jobject obj, jfieldID fieldID, jdouble val);
+
+ jmethodID (JNICALL *GetStaticMethodID)
+ (JNIEnv *env, jclass clazz, const char *name, const char *sig);
+
+ jobject (JNICALL *CallStaticObjectMethod)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+ jobject (JNICALL *CallStaticObjectMethodV)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+ jobject (JNICALL *CallStaticObjectMethodA)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+
+ jboolean (JNICALL *CallStaticBooleanMethod)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+ jboolean (JNICALL *CallStaticBooleanMethodV)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+ jboolean (JNICALL *CallStaticBooleanMethodA)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+
+ jbyte (JNICALL *CallStaticByteMethod)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+ jbyte (JNICALL *CallStaticByteMethodV)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+ jbyte (JNICALL *CallStaticByteMethodA)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+
+ jchar (JNICALL *CallStaticCharMethod)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+ jchar (JNICALL *CallStaticCharMethodV)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+ jchar (JNICALL *CallStaticCharMethodA)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+
+ jshort (JNICALL *CallStaticShortMethod)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+ jshort (JNICALL *CallStaticShortMethodV)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+ jshort (JNICALL *CallStaticShortMethodA)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+
+ jint (JNICALL *CallStaticIntMethod)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+ jint (JNICALL *CallStaticIntMethodV)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+ jint (JNICALL *CallStaticIntMethodA)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+
+ jlong (JNICALL *CallStaticLongMethod)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+ jlong (JNICALL *CallStaticLongMethodV)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+ jlong (JNICALL *CallStaticLongMethodA)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+
+ jfloat (JNICALL *CallStaticFloatMethod)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+ jfloat (JNICALL *CallStaticFloatMethodV)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+ jfloat (JNICALL *CallStaticFloatMethodA)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+
+ jdouble (JNICALL *CallStaticDoubleMethod)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+ jdouble (JNICALL *CallStaticDoubleMethodV)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+ jdouble (JNICALL *CallStaticDoubleMethodA)
+ (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+
+ void (JNICALL *CallStaticVoidMethod)
+ (JNIEnv *env, jclass cls, jmethodID methodID, ...);
+ void (JNICALL *CallStaticVoidMethodV)
+ (JNIEnv *env, jclass cls, jmethodID methodID, va_list args);
+ void (JNICALL *CallStaticVoidMethodA)
+ (JNIEnv *env, jclass cls, jmethodID methodID, const jvalue * args);
+
+ jfieldID (JNICALL *GetStaticFieldID)
+ (JNIEnv *env, jclass clazz, const char *name, const char *sig);
+ jobject (JNICALL *GetStaticObjectField)
+ (JNIEnv *env, jclass clazz, jfieldID fieldID);
+ jboolean (JNICALL *GetStaticBooleanField)
+ (JNIEnv *env, jclass clazz, jfieldID fieldID);
+ jbyte (JNICALL *GetStaticByteField)
+ (JNIEnv *env, jclass clazz, jfieldID fieldID);
+ jchar (JNICALL *GetStaticCharField)
+ (JNIEnv *env, jclass clazz, jfieldID fieldID);
+ jshort (JNICALL *GetStaticShortField)
+ (JNIEnv *env, jclass clazz, jfieldID fieldID);
+ jint (JNICALL *GetStaticIntField)
+ (JNIEnv *env, jclass clazz, jfieldID fieldID);
+ jlong (JNICALL *GetStaticLongField)
+ (JNIEnv *env, jclass clazz, jfieldID fieldID);
+ jfloat (JNICALL *GetStaticFloatField)
+ (JNIEnv *env, jclass clazz, jfieldID fieldID);
+ jdouble (JNICALL *GetStaticDoubleField)
+ (JNIEnv *env, jclass clazz, jfieldID fieldID);
+
+ void (JNICALL *SetStaticObjectField)
+ (JNIEnv *env, jclass clazz, jfieldID fieldID, jobject value);
+ void (JNICALL *SetStaticBooleanField)
+ (JNIEnv *env, jclass clazz, jfieldID fieldID, jboolean value);
+ void (JNICALL *SetStaticByteField)
+ (JNIEnv *env, jclass clazz, jfieldID fieldID, jbyte value);
+ void (JNICALL *SetStaticCharField)
+ (JNIEnv *env, jclass clazz, jfieldID fieldID, jchar value);
+ void (JNICALL *SetStaticShortField)
+ (JNIEnv *env, jclass clazz, jfieldID fieldID, jshort value);
+ void (JNICALL *SetStaticIntField)
+ (JNIEnv *env, jclass clazz, jfieldID fieldID, jint value);
+ void (JNICALL *SetStaticLongField)
+ (JNIEnv *env, jclass clazz, jfieldID fieldID, jlong value);
+ void (JNICALL *SetStaticFloatField)
+ (JNIEnv *env, jclass clazz, jfieldID fieldID, jfloat value);
+ void (JNICALL *SetStaticDoubleField)
+ (JNIEnv *env, jclass clazz, jfieldID fieldID, jdouble value);
+
+ jstring (JNICALL *NewString)
+ (JNIEnv *env, const jchar *unicode, jsize len);
+ jsize (JNICALL *GetStringLength)
+ (JNIEnv *env, jstring str);
+ const jchar *(JNICALL *GetStringChars)
+ (JNIEnv *env, jstring str, jboolean *isCopy);
+ void (JNICALL *ReleaseStringChars)
+ (JNIEnv *env, jstring str, const jchar *chars);
+
+ jstring (JNICALL *NewStringUTF)
+ (JNIEnv *env, const char *utf);
+ jsize (JNICALL *GetStringUTFLength)
+ (JNIEnv *env, jstring str);
+ const char* (JNICALL *GetStringUTFChars)
+ (JNIEnv *env, jstring str, jboolean *isCopy);
+ void (JNICALL *ReleaseStringUTFChars)
+ (JNIEnv *env, jstring str, const char* chars);
+
+
+ jsize (JNICALL *GetArrayLength)
+ (JNIEnv *env, jarray array);
+
+ jobjectArray (JNICALL *NewObjectArray)
+ (JNIEnv *env, jsize len, jclass clazz, jobject init);
+ jobject (JNICALL *GetObjectArrayElement)
+ (JNIEnv *env, jobjectArray array, jsize index);
+ void (JNICALL *SetObjectArrayElement)
+ (JNIEnv *env, jobjectArray array, jsize index, jobject val);
+
+ jbooleanArray (JNICALL *NewBooleanArray)
+ (JNIEnv *env, jsize len);
+ jbyteArray (JNICALL *NewByteArray)
+ (JNIEnv *env, jsize len);
+ jcharArray (JNICALL *NewCharArray)
+ (JNIEnv *env, jsize len);
+ jshortArray (JNICALL *NewShortArray)
+ (JNIEnv *env, jsize len);
+ jintArray (JNICALL *NewIntArray)
+ (JNIEnv *env, jsize len);
+ jlongArray (JNICALL *NewLongArray)
+ (JNIEnv *env, jsize len);
+ jfloatArray (JNICALL *NewFloatArray)
+ (JNIEnv *env, jsize len);
+ jdoubleArray (JNICALL *NewDoubleArray)
+ (JNIEnv *env, jsize len);
+
+ jboolean * (JNICALL *GetBooleanArrayElements)
+ (JNIEnv *env, jbooleanArray array, jboolean *isCopy);
+ jbyte * (JNICALL *GetByteArrayElements)
+ (JNIEnv *env, jbyteArray array, jboolean *isCopy);
+ jchar * (JNICALL *GetCharArrayElements)
+ (JNIEnv *env, jcharArray array, jboolean *isCopy);
+ jshort * (JNICALL *GetShortArrayElements)
+ (JNIEnv *env, jshortArray array, jboolean *isCopy);
+ jint * (JNICALL *GetIntArrayElements)
+ (JNIEnv *env, jintArray array, jboolean *isCopy);
+ jlong * (JNICALL *GetLongArrayElements)
+ (JNIEnv *env, jlongArray array, jboolean *isCopy);
+ jfloat * (JNICALL *GetFloatArrayElements)
+ (JNIEnv *env, jfloatArray array, jboolean *isCopy);
+ jdouble * (JNICALL *GetDoubleArrayElements)
+ (JNIEnv *env, jdoubleArray array, jboolean *isCopy);
+
+ void (JNICALL *ReleaseBooleanArrayElements)
+ (JNIEnv *env, jbooleanArray array, jboolean *elems, jint mode);
+ void (JNICALL *ReleaseByteArrayElements)
+ (JNIEnv *env, jbyteArray array, jbyte *elems, jint mode);
+ void (JNICALL *ReleaseCharArrayElements)
+ (JNIEnv *env, jcharArray array, jchar *elems, jint mode);
+ void (JNICALL *ReleaseShortArrayElements)
+ (JNIEnv *env, jshortArray array, jshort *elems, jint mode);
+ void (JNICALL *ReleaseIntArrayElements)
+ (JNIEnv *env, jintArray array, jint *elems, jint mode);
+ void (JNICALL *ReleaseLongArrayElements)
+ (JNIEnv *env, jlongArray array, jlong *elems, jint mode);
+ void (JNICALL *ReleaseFloatArrayElements)
+ (JNIEnv *env, jfloatArray array, jfloat *elems, jint mode);
+ void (JNICALL *ReleaseDoubleArrayElements)
+ (JNIEnv *env, jdoubleArray array, jdouble *elems, jint mode);
+
+ void (JNICALL *GetBooleanArrayRegion)
+ (JNIEnv *env, jbooleanArray array, jsize start, jsize l, jboolean *buf);
+ void (JNICALL *GetByteArrayRegion)
+ (JNIEnv *env, jbyteArray array, jsize start, jsize len, jbyte *buf);
+ void (JNICALL *GetCharArrayRegion)
+ (JNIEnv *env, jcharArray array, jsize start, jsize len, jchar *buf);
+ void (JNICALL *GetShortArrayRegion)
+ (JNIEnv *env, jshortArray array, jsize start, jsize len, jshort *buf);
+ void (JNICALL *GetIntArrayRegion)
+ (JNIEnv *env, jintArray array, jsize start, jsize len, jint *buf);
+ void (JNICALL *GetLongArrayRegion)
+ (JNIEnv *env, jlongArray array, jsize start, jsize len, jlong *buf);
+ void (JNICALL *GetFloatArrayRegion)
+ (JNIEnv *env, jfloatArray array, jsize start, jsize len, jfloat *buf);
+ void (JNICALL *GetDoubleArrayRegion)
+ (JNIEnv *env, jdoubleArray array, jsize start, jsize len, jdouble *buf);
+
+ void (JNICALL *SetBooleanArrayRegion)
+ (JNIEnv *env, jbooleanArray array, jsize start, jsize l, const jboolean *buf);
+ void (JNICALL *SetByteArrayRegion)
+ (JNIEnv *env, jbyteArray array, jsize start, jsize len, const jbyte *buf);
+ void (JNICALL *SetCharArrayRegion)
+ (JNIEnv *env, jcharArray array, jsize start, jsize len, const jchar *buf);
+ void (JNICALL *SetShortArrayRegion)
+ (JNIEnv *env, jshortArray array, jsize start, jsize len, const jshort *buf);
+ void (JNICALL *SetIntArrayRegion)
+ (JNIEnv *env, jintArray array, jsize start, jsize len, const jint *buf);
+ void (JNICALL *SetLongArrayRegion)
+ (JNIEnv *env, jlongArray array, jsize start, jsize len, const jlong *buf);
+ void (JNICALL *SetFloatArrayRegion)
+ (JNIEnv *env, jfloatArray array, jsize start, jsize len, const jfloat *buf);
+ void (JNICALL *SetDoubleArrayRegion)
+ (JNIEnv *env, jdoubleArray array, jsize start, jsize len, const jdouble *buf);
+
+ jint (JNICALL *RegisterNatives)
+ (JNIEnv *env, jclass clazz, const JNINativeMethod *methods,
+ jint nMethods);
+ jint (JNICALL *UnregisterNatives)
+ (JNIEnv *env, jclass clazz);
+
+ jint (JNICALL *MonitorEnter)
+ (JNIEnv *env, jobject obj);
+ jint (JNICALL *MonitorExit)
+ (JNIEnv *env, jobject obj);
+
+ jint (JNICALL *GetJavaVM)
+ (JNIEnv *env, JavaVM **vm);
+
+ void (JNICALL *GetStringRegion)
+ (JNIEnv *env, jstring str, jsize start, jsize len, jchar *buf);
+ void (JNICALL *GetStringUTFRegion)
+ (JNIEnv *env, jstring str, jsize start, jsize len, char *buf);
+
+ void * (JNICALL *GetPrimitiveArrayCritical)
+ (JNIEnv *env, jarray array, jboolean *isCopy);
+ void (JNICALL *ReleasePrimitiveArrayCritical)
+ (JNIEnv *env, jarray array, void *carray, jint mode);
+
+ const jchar * (JNICALL *GetStringCritical)
+ (JNIEnv *env, jstring string, jboolean *isCopy);
+ void (JNICALL *ReleaseStringCritical)
+ (JNIEnv *env, jstring string, const jchar *cstring);
+
+ jweak (JNICALL *NewWeakGlobalRef)
+ (JNIEnv *env, jobject obj);
+ void (JNICALL *DeleteWeakGlobalRef)
+ (JNIEnv *env, jweak ref);
+
+ jboolean (JNICALL *ExceptionCheck)
+ (JNIEnv *env);
+
+ jobject (JNICALL *NewDirectByteBuffer)
+ (JNIEnv* env, void* address, jlong capacity);
+ void* (JNICALL *GetDirectBufferAddress)
+ (JNIEnv* env, jobject buf);
+ jlong (JNICALL *GetDirectBufferCapacity)
+ (JNIEnv* env, jobject buf);
+};
+
+/*
+ * We use inlined functions for C++ so that programmers can write:
+ *
+ * env->FindClass("java/lang/String")
+ *
+ * in C++ rather than:
+ *
+ * (*env)->FindClass(env, "java/lang/String")
+ *
+ * in C.
+ */
+
+struct JNIEnv_ {
+ const struct JNINativeInterface_ *functions;
+#ifdef __cplusplus
+
+ jint GetVersion() {
+ return functions->GetVersion(this);
+ }
+ jclass DefineClass(const char *name, jobject loader, const jbyte *buf,
+ jsize len) {
+ return functions->DefineClass(this, name, loader, buf, len);
+ }
+ jclass FindClass(const char *name) {
+ return functions->FindClass(this, name);
+ }
+ jmethodID FromReflectedMethod(jobject method) {
+ return functions->FromReflectedMethod(this,method);
+ }
+ jfieldID FromReflectedField(jobject field) {
+ return functions->FromReflectedField(this,field);
+ }
+
+ jobject ToReflectedMethod(jclass cls, jmethodID methodID, jboolean isStatic) {
+ return functions->ToReflectedMethod(this, cls, methodID, isStatic);
+ }
+
+ jclass GetSuperclass(jclass sub) {
+ return functions->GetSuperclass(this, sub);
+ }
+ jboolean IsAssignableFrom(jclass sub, jclass sup) {
+ return functions->IsAssignableFrom(this, sub, sup);
+ }
+
+ jobject ToReflectedField(jclass cls, jfieldID fieldID, jboolean isStatic) {
+ return functions->ToReflectedField(this,cls,fieldID,isStatic);
+ }
+
+ jint Throw(jthrowable obj) {
+ return functions->Throw(this, obj);
+ }
+ jint ThrowNew(jclass clazz, const char *msg) {
+ return functions->ThrowNew(this, clazz, msg);
+ }
+ jthrowable ExceptionOccurred() {
+ return functions->ExceptionOccurred(this);
+ }
+ void ExceptionDescribe() {
+ functions->ExceptionDescribe(this);
+ }
+ void ExceptionClear() {
+ functions->ExceptionClear(this);
+ }
+ void FatalError(const char *msg) {
+ functions->FatalError(this, msg);
+ }
+
+ jint PushLocalFrame(jint capacity) {
+ return functions->PushLocalFrame(this,capacity);
+ }
+ jobject PopLocalFrame(jobject result) {
+ return functions->PopLocalFrame(this,result);
+ }
+
+ jobject NewGlobalRef(jobject lobj) {
+ return functions->NewGlobalRef(this,lobj);
+ }
+ void DeleteGlobalRef(jobject gref) {
+ functions->DeleteGlobalRef(this,gref);
+ }
+ void DeleteLocalRef(jobject obj) {
+ functions->DeleteLocalRef(this, obj);
+ }
+
+ jboolean IsSameObject(jobject obj1, jobject obj2) {
+ return functions->IsSameObject(this,obj1,obj2);
+ }
+
+ jobject NewLocalRef(jobject ref) {
+ return functions->NewLocalRef(this,ref);
+ }
+ jint EnsureLocalCapacity(jint capacity) {
+ return functions->EnsureLocalCapacity(this,capacity);
+ }
+
+ jobject AllocObject(jclass clazz) {
+ return functions->AllocObject(this,clazz);
+ }
+ jobject NewObject(jclass clazz, jmethodID methodID, ...) {
+ va_list args;
+ jobject result;
+ va_start(args, methodID);
+ result = functions->NewObjectV(this,clazz,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jobject NewObjectV(jclass clazz, jmethodID methodID,
+ va_list args) {
+ return functions->NewObjectV(this,clazz,methodID,args);
+ }
+ jobject NewObjectA(jclass clazz, jmethodID methodID,
+ const jvalue *args) {
+ return functions->NewObjectA(this,clazz,methodID,args);
+ }
+
+ jclass GetObjectClass(jobject obj) {
+ return functions->GetObjectClass(this,obj);
+ }
+ jboolean IsInstanceOf(jobject obj, jclass clazz) {
+ return functions->IsInstanceOf(this,obj,clazz);
+ }
+
+ jmethodID GetMethodID(jclass clazz, const char *name,
+ const char *sig) {
+ return functions->GetMethodID(this,clazz,name,sig);
+ }
+
+ jobject CallObjectMethod(jobject obj, jmethodID methodID, ...) {
+ va_list args;
+ jobject result;
+ va_start(args,methodID);
+ result = functions->CallObjectMethodV(this,obj,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jobject CallObjectMethodV(jobject obj, jmethodID methodID,
+ va_list args) {
+ return functions->CallObjectMethodV(this,obj,methodID,args);
+ }
+ jobject CallObjectMethodA(jobject obj, jmethodID methodID,
+ const jvalue * args) {
+ return functions->CallObjectMethodA(this,obj,methodID,args);
+ }
+
+ jboolean CallBooleanMethod(jobject obj,
+ jmethodID methodID, ...) {
+ va_list args;
+ jboolean result;
+ va_start(args,methodID);
+ result = functions->CallBooleanMethodV(this,obj,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jboolean CallBooleanMethodV(jobject obj, jmethodID methodID,
+ va_list args) {
+ return functions->CallBooleanMethodV(this,obj,methodID,args);
+ }
+ jboolean CallBooleanMethodA(jobject obj, jmethodID methodID,
+ const jvalue * args) {
+ return functions->CallBooleanMethodA(this,obj,methodID, args);
+ }
+
+ jbyte CallByteMethod(jobject obj, jmethodID methodID, ...) {
+ va_list args;
+ jbyte result;
+ va_start(args,methodID);
+ result = functions->CallByteMethodV(this,obj,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jbyte CallByteMethodV(jobject obj, jmethodID methodID,
+ va_list args) {
+ return functions->CallByteMethodV(this,obj,methodID,args);
+ }
+ jbyte CallByteMethodA(jobject obj, jmethodID methodID,
+ const jvalue * args) {
+ return functions->CallByteMethodA(this,obj,methodID,args);
+ }
+
+ jchar CallCharMethod(jobject obj, jmethodID methodID, ...) {
+ va_list args;
+ jchar result;
+ va_start(args,methodID);
+ result = functions->CallCharMethodV(this,obj,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jchar CallCharMethodV(jobject obj, jmethodID methodID,
+ va_list args) {
+ return functions->CallCharMethodV(this,obj,methodID,args);
+ }
+ jchar CallCharMethodA(jobject obj, jmethodID methodID,
+ const jvalue * args) {
+ return functions->CallCharMethodA(this,obj,methodID,args);
+ }
+
+ jshort CallShortMethod(jobject obj, jmethodID methodID, ...) {
+ va_list args;
+ jshort result;
+ va_start(args,methodID);
+ result = functions->CallShortMethodV(this,obj,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jshort CallShortMethodV(jobject obj, jmethodID methodID,
+ va_list args) {
+ return functions->CallShortMethodV(this,obj,methodID,args);
+ }
+ jshort CallShortMethodA(jobject obj, jmethodID methodID,
+ const jvalue * args) {
+ return functions->CallShortMethodA(this,obj,methodID,args);
+ }
+
+ jint CallIntMethod(jobject obj, jmethodID methodID, ...) {
+ va_list args;
+ jint result;
+ va_start(args,methodID);
+ result = functions->CallIntMethodV(this,obj,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jint CallIntMethodV(jobject obj, jmethodID methodID,
+ va_list args) {
+ return functions->CallIntMethodV(this,obj,methodID,args);
+ }
+ jint CallIntMethodA(jobject obj, jmethodID methodID,
+ const jvalue * args) {
+ return functions->CallIntMethodA(this,obj,methodID,args);
+ }
+
+ jlong CallLongMethod(jobject obj, jmethodID methodID, ...) {
+ va_list args;
+ jlong result;
+ va_start(args,methodID);
+ result = functions->CallLongMethodV(this,obj,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jlong CallLongMethodV(jobject obj, jmethodID methodID,
+ va_list args) {
+ return functions->CallLongMethodV(this,obj,methodID,args);
+ }
+ jlong CallLongMethodA(jobject obj, jmethodID methodID,
+ const jvalue * args) {
+ return functions->CallLongMethodA(this,obj,methodID,args);
+ }
+
+ jfloat CallFloatMethod(jobject obj, jmethodID methodID, ...) {
+ va_list args;
+ jfloat result;
+ va_start(args,methodID);
+ result = functions->CallFloatMethodV(this,obj,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jfloat CallFloatMethodV(jobject obj, jmethodID methodID,
+ va_list args) {
+ return functions->CallFloatMethodV(this,obj,methodID,args);
+ }
+ jfloat CallFloatMethodA(jobject obj, jmethodID methodID,
+ const jvalue * args) {
+ return functions->CallFloatMethodA(this,obj,methodID,args);
+ }
+
+ jdouble CallDoubleMethod(jobject obj, jmethodID methodID, ...) {
+ va_list args;
+ jdouble result;
+ va_start(args,methodID);
+ result = functions->CallDoubleMethodV(this,obj,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jdouble CallDoubleMethodV(jobject obj, jmethodID methodID,
+ va_list args) {
+ return functions->CallDoubleMethodV(this,obj,methodID,args);
+ }
+ jdouble CallDoubleMethodA(jobject obj, jmethodID methodID,
+ const jvalue * args) {
+ return functions->CallDoubleMethodA(this,obj,methodID,args);
+ }
+
+ void CallVoidMethod(jobject obj, jmethodID methodID, ...) {
+ va_list args;
+ va_start(args,methodID);
+ functions->CallVoidMethodV(this,obj,methodID,args);
+ va_end(args);
+ }
+ void CallVoidMethodV(jobject obj, jmethodID methodID,
+ va_list args) {
+ functions->CallVoidMethodV(this,obj,methodID,args);
+ }
+ void CallVoidMethodA(jobject obj, jmethodID methodID,
+ const jvalue * args) {
+ functions->CallVoidMethodA(this,obj,methodID,args);
+ }
+
+ jobject CallNonvirtualObjectMethod(jobject obj, jclass clazz,
+ jmethodID methodID, ...) {
+ va_list args;
+ jobject result;
+ va_start(args,methodID);
+ result = functions->CallNonvirtualObjectMethodV(this,obj,clazz,
+ methodID,args);
+ va_end(args);
+ return result;
+ }
+ jobject CallNonvirtualObjectMethodV(jobject obj, jclass clazz,
+ jmethodID methodID, va_list args) {
+ return functions->CallNonvirtualObjectMethodV(this,obj,clazz,
+ methodID,args);
+ }
+ jobject CallNonvirtualObjectMethodA(jobject obj, jclass clazz,
+ jmethodID methodID, const jvalue * args) {
+ return functions->CallNonvirtualObjectMethodA(this,obj,clazz,
+ methodID,args);
+ }
+
+ jboolean CallNonvirtualBooleanMethod(jobject obj, jclass clazz,
+ jmethodID methodID, ...) {
+ va_list args;
+ jboolean result;
+ va_start(args,methodID);
+ result = functions->CallNonvirtualBooleanMethodV(this,obj,clazz,
+ methodID,args);
+ va_end(args);
+ return result;
+ }
+ jboolean CallNonvirtualBooleanMethodV(jobject obj, jclass clazz,
+ jmethodID methodID, va_list args) {
+ return functions->CallNonvirtualBooleanMethodV(this,obj,clazz,
+ methodID,args);
+ }
+ jboolean CallNonvirtualBooleanMethodA(jobject obj, jclass clazz,
+ jmethodID methodID, const jvalue * args) {
+ return functions->CallNonvirtualBooleanMethodA(this,obj,clazz,
+ methodID, args);
+ }
+
+ jbyte CallNonvirtualByteMethod(jobject obj, jclass clazz,
+ jmethodID methodID, ...) {
+ va_list args;
+ jbyte result;
+ va_start(args,methodID);
+ result = functions->CallNonvirtualByteMethodV(this,obj,clazz,
+ methodID,args);
+ va_end(args);
+ return result;
+ }
+ jbyte CallNonvirtualByteMethodV(jobject obj, jclass clazz,
+ jmethodID methodID, va_list args) {
+ return functions->CallNonvirtualByteMethodV(this,obj,clazz,
+ methodID,args);
+ }
+ jbyte CallNonvirtualByteMethodA(jobject obj, jclass clazz,
+ jmethodID methodID, const jvalue * args) {
+ return functions->CallNonvirtualByteMethodA(this,obj,clazz,
+ methodID,args);
+ }
+
+ jchar CallNonvirtualCharMethod(jobject obj, jclass clazz,
+ jmethodID methodID, ...) {
+ va_list args;
+ jchar result;
+ va_start(args,methodID);
+ result = functions->CallNonvirtualCharMethodV(this,obj,clazz,
+ methodID,args);
+ va_end(args);
+ return result;
+ }
+ jchar CallNonvirtualCharMethodV(jobject obj, jclass clazz,
+ jmethodID methodID, va_list args) {
+ return functions->CallNonvirtualCharMethodV(this,obj,clazz,
+ methodID,args);
+ }
+ jchar CallNonvirtualCharMethodA(jobject obj, jclass clazz,
+ jmethodID methodID, const jvalue * args) {
+ return functions->CallNonvirtualCharMethodA(this,obj,clazz,
+ methodID,args);
+ }
+
+ jshort CallNonvirtualShortMethod(jobject obj, jclass clazz,
+ jmethodID methodID, ...) {
+ va_list args;
+ jshort result;
+ va_start(args,methodID);
+ result = functions->CallNonvirtualShortMethodV(this,obj,clazz,
+ methodID,args);
+ va_end(args);
+ return result;
+ }
+ jshort CallNonvirtualShortMethodV(jobject obj, jclass clazz,
+ jmethodID methodID, va_list args) {
+ return functions->CallNonvirtualShortMethodV(this,obj,clazz,
+ methodID,args);
+ }
+ jshort CallNonvirtualShortMethodA(jobject obj, jclass clazz,
+ jmethodID methodID, const jvalue * args) {
+ return functions->CallNonvirtualShortMethodA(this,obj,clazz,
+ methodID,args);
+ }
+
+ jint CallNonvirtualIntMethod(jobject obj, jclass clazz,
+ jmethodID methodID, ...) {
+ va_list args;
+ jint result;
+ va_start(args,methodID);
+ result = functions->CallNonvirtualIntMethodV(this,obj,clazz,
+ methodID,args);
+ va_end(args);
+ return result;
+ }
+ jint CallNonvirtualIntMethodV(jobject obj, jclass clazz,
+ jmethodID methodID, va_list args) {
+ return functions->CallNonvirtualIntMethodV(this,obj,clazz,
+ methodID,args);
+ }
+ jint CallNonvirtualIntMethodA(jobject obj, jclass clazz,
+ jmethodID methodID, const jvalue * args) {
+ return functions->CallNonvirtualIntMethodA(this,obj,clazz,
+ methodID,args);
+ }
+
+ jlong CallNonvirtualLongMethod(jobject obj, jclass clazz,
+ jmethodID methodID, ...) {
+ va_list args;
+ jlong result;
+ va_start(args,methodID);
+ result = functions->CallNonvirtualLongMethodV(this,obj,clazz,
+ methodID,args);
+ va_end(args);
+ return result;
+ }
+ jlong CallNonvirtualLongMethodV(jobject obj, jclass clazz,
+ jmethodID methodID, va_list args) {
+ return functions->CallNonvirtualLongMethodV(this,obj,clazz,
+ methodID,args);
+ }
+ jlong CallNonvirtualLongMethodA(jobject obj, jclass clazz,
+ jmethodID methodID, const jvalue * args) {
+ return functions->CallNonvirtualLongMethodA(this,obj,clazz,
+ methodID,args);
+ }
+
+ jfloat CallNonvirtualFloatMethod(jobject obj, jclass clazz,
+ jmethodID methodID, ...) {
+ va_list args;
+ jfloat result;
+ va_start(args,methodID);
+ result = functions->CallNonvirtualFloatMethodV(this,obj,clazz,
+ methodID,args);
+ va_end(args);
+ return result;
+ }
+ jfloat CallNonvirtualFloatMethodV(jobject obj, jclass clazz,
+ jmethodID methodID,
+ va_list args) {
+ return functions->CallNonvirtualFloatMethodV(this,obj,clazz,
+ methodID,args);
+ }
+ jfloat CallNonvirtualFloatMethodA(jobject obj, jclass clazz,
+ jmethodID methodID,
+ const jvalue * args) {
+ return functions->CallNonvirtualFloatMethodA(this,obj,clazz,
+ methodID,args);
+ }
+
+ jdouble CallNonvirtualDoubleMethod(jobject obj, jclass clazz,
+ jmethodID methodID, ...) {
+ va_list args;
+ jdouble result;
+ va_start(args,methodID);
+ result = functions->CallNonvirtualDoubleMethodV(this,obj,clazz,
+ methodID,args);
+ va_end(args);
+ return result;
+ }
+ jdouble CallNonvirtualDoubleMethodV(jobject obj, jclass clazz,
+ jmethodID methodID,
+ va_list args) {
+ return functions->CallNonvirtualDoubleMethodV(this,obj,clazz,
+ methodID,args);
+ }
+ jdouble CallNonvirtualDoubleMethodA(jobject obj, jclass clazz,
+ jmethodID methodID,
+ const jvalue * args) {
+ return functions->CallNonvirtualDoubleMethodA(this,obj,clazz,
+ methodID,args);
+ }
+
+ void CallNonvirtualVoidMethod(jobject obj, jclass clazz,
+ jmethodID methodID, ...) {
+ va_list args;
+ va_start(args,methodID);
+ functions->CallNonvirtualVoidMethodV(this,obj,clazz,methodID,args);
+ va_end(args);
+ }
+ void CallNonvirtualVoidMethodV(jobject obj, jclass clazz,
+ jmethodID methodID,
+ va_list args) {
+ functions->CallNonvirtualVoidMethodV(this,obj,clazz,methodID,args);
+ }
+ void CallNonvirtualVoidMethodA(jobject obj, jclass clazz,
+ jmethodID methodID,
+ const jvalue * args) {
+ functions->CallNonvirtualVoidMethodA(this,obj,clazz,methodID,args);
+ }
+
+ jfieldID GetFieldID(jclass clazz, const char *name,
+ const char *sig) {
+ return functions->GetFieldID(this,clazz,name,sig);
+ }
+
+ jobject GetObjectField(jobject obj, jfieldID fieldID) {
+ return functions->GetObjectField(this,obj,fieldID);
+ }
+ jboolean GetBooleanField(jobject obj, jfieldID fieldID) {
+ return functions->GetBooleanField(this,obj,fieldID);
+ }
+ jbyte GetByteField(jobject obj, jfieldID fieldID) {
+ return functions->GetByteField(this,obj,fieldID);
+ }
+ jchar GetCharField(jobject obj, jfieldID fieldID) {
+ return functions->GetCharField(this,obj,fieldID);
+ }
+ jshort GetShortField(jobject obj, jfieldID fieldID) {
+ return functions->GetShortField(this,obj,fieldID);
+ }
+ jint GetIntField(jobject obj, jfieldID fieldID) {
+ return functions->GetIntField(this,obj,fieldID);
+ }
+ jlong GetLongField(jobject obj, jfieldID fieldID) {
+ return functions->GetLongField(this,obj,fieldID);
+ }
+ jfloat GetFloatField(jobject obj, jfieldID fieldID) {
+ return functions->GetFloatField(this,obj,fieldID);
+ }
+ jdouble GetDoubleField(jobject obj, jfieldID fieldID) {
+ return functions->GetDoubleField(this,obj,fieldID);
+ }
+
+ void SetObjectField(jobject obj, jfieldID fieldID, jobject val) {
+ functions->SetObjectField(this,obj,fieldID,val);
+ }
+ void SetBooleanField(jobject obj, jfieldID fieldID,
+ jboolean val) {
+ functions->SetBooleanField(this,obj,fieldID,val);
+ }
+ void SetByteField(jobject obj, jfieldID fieldID,
+ jbyte val) {
+ functions->SetByteField(this,obj,fieldID,val);
+ }
+ void SetCharField(jobject obj, jfieldID fieldID,
+ jchar val) {
+ functions->SetCharField(this,obj,fieldID,val);
+ }
+ void SetShortField(jobject obj, jfieldID fieldID,
+ jshort val) {
+ functions->SetShortField(this,obj,fieldID,val);
+ }
+ void SetIntField(jobject obj, jfieldID fieldID,
+ jint val) {
+ functions->SetIntField(this,obj,fieldID,val);
+ }
+ void SetLongField(jobject obj, jfieldID fieldID,
+ jlong val) {
+ functions->SetLongField(this,obj,fieldID,val);
+ }
+ void SetFloatField(jobject obj, jfieldID fieldID,
+ jfloat val) {
+ functions->SetFloatField(this,obj,fieldID,val);
+ }
+ void SetDoubleField(jobject obj, jfieldID fieldID,
+ jdouble val) {
+ functions->SetDoubleField(this,obj,fieldID,val);
+ }
+
+ jmethodID GetStaticMethodID(jclass clazz, const char *name,
+ const char *sig) {
+ return functions->GetStaticMethodID(this,clazz,name,sig);
+ }
+
+ jobject CallStaticObjectMethod(jclass clazz, jmethodID methodID,
+ ...) {
+ va_list args;
+ jobject result;
+ va_start(args,methodID);
+ result = functions->CallStaticObjectMethodV(this,clazz,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jobject CallStaticObjectMethodV(jclass clazz, jmethodID methodID,
+ va_list args) {
+ return functions->CallStaticObjectMethodV(this,clazz,methodID,args);
+ }
+ jobject CallStaticObjectMethodA(jclass clazz, jmethodID methodID,
+ const jvalue *args) {
+ return functions->CallStaticObjectMethodA(this,clazz,methodID,args);
+ }
+
+ jboolean CallStaticBooleanMethod(jclass clazz,
+ jmethodID methodID, ...) {
+ va_list args;
+ jboolean result;
+ va_start(args,methodID);
+ result = functions->CallStaticBooleanMethodV(this,clazz,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jboolean CallStaticBooleanMethodV(jclass clazz,
+ jmethodID methodID, va_list args) {
+ return functions->CallStaticBooleanMethodV(this,clazz,methodID,args);
+ }
+ jboolean CallStaticBooleanMethodA(jclass clazz,
+ jmethodID methodID, const jvalue *args) {
+ return functions->CallStaticBooleanMethodA(this,clazz,methodID,args);
+ }
+
+ jbyte CallStaticByteMethod(jclass clazz,
+ jmethodID methodID, ...) {
+ va_list args;
+ jbyte result;
+ va_start(args,methodID);
+ result = functions->CallStaticByteMethodV(this,clazz,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jbyte CallStaticByteMethodV(jclass clazz,
+ jmethodID methodID, va_list args) {
+ return functions->CallStaticByteMethodV(this,clazz,methodID,args);
+ }
+ jbyte CallStaticByteMethodA(jclass clazz,
+ jmethodID methodID, const jvalue *args) {
+ return functions->CallStaticByteMethodA(this,clazz,methodID,args);
+ }
+
+ jchar CallStaticCharMethod(jclass clazz,
+ jmethodID methodID, ...) {
+ va_list args;
+ jchar result;
+ va_start(args,methodID);
+ result = functions->CallStaticCharMethodV(this,clazz,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jchar CallStaticCharMethodV(jclass clazz,
+ jmethodID methodID, va_list args) {
+ return functions->CallStaticCharMethodV(this,clazz,methodID,args);
+ }
+ jchar CallStaticCharMethodA(jclass clazz,
+ jmethodID methodID, const jvalue *args) {
+ return functions->CallStaticCharMethodA(this,clazz,methodID,args);
+ }
+
+ jshort CallStaticShortMethod(jclass clazz,
+ jmethodID methodID, ...) {
+ va_list args;
+ jshort result;
+ va_start(args,methodID);
+ result = functions->CallStaticShortMethodV(this,clazz,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jshort CallStaticShortMethodV(jclass clazz,
+ jmethodID methodID, va_list args) {
+ return functions->CallStaticShortMethodV(this,clazz,methodID,args);
+ }
+ jshort CallStaticShortMethodA(jclass clazz,
+ jmethodID methodID, const jvalue *args) {
+ return functions->CallStaticShortMethodA(this,clazz,methodID,args);
+ }
+
+ jint CallStaticIntMethod(jclass clazz,
+ jmethodID methodID, ...) {
+ va_list args;
+ jint result;
+ va_start(args,methodID);
+ result = functions->CallStaticIntMethodV(this,clazz,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jint CallStaticIntMethodV(jclass clazz,
+ jmethodID methodID, va_list args) {
+ return functions->CallStaticIntMethodV(this,clazz,methodID,args);
+ }
+ jint CallStaticIntMethodA(jclass clazz,
+ jmethodID methodID, const jvalue *args) {
+ return functions->CallStaticIntMethodA(this,clazz,methodID,args);
+ }
+
+ jlong CallStaticLongMethod(jclass clazz,
+ jmethodID methodID, ...) {
+ va_list args;
+ jlong result;
+ va_start(args,methodID);
+ result = functions->CallStaticLongMethodV(this,clazz,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jlong CallStaticLongMethodV(jclass clazz,
+ jmethodID methodID, va_list args) {
+ return functions->CallStaticLongMethodV(this,clazz,methodID,args);
+ }
+ jlong CallStaticLongMethodA(jclass clazz,
+ jmethodID methodID, const jvalue *args) {
+ return functions->CallStaticLongMethodA(this,clazz,methodID,args);
+ }
+
+ jfloat CallStaticFloatMethod(jclass clazz,
+ jmethodID methodID, ...) {
+ va_list args;
+ jfloat result;
+ va_start(args,methodID);
+ result = functions->CallStaticFloatMethodV(this,clazz,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jfloat CallStaticFloatMethodV(jclass clazz,
+ jmethodID methodID, va_list args) {
+ return functions->CallStaticFloatMethodV(this,clazz,methodID,args);
+ }
+ jfloat CallStaticFloatMethodA(jclass clazz,
+ jmethodID methodID, const jvalue *args) {
+ return functions->CallStaticFloatMethodA(this,clazz,methodID,args);
+ }
+
+ jdouble CallStaticDoubleMethod(jclass clazz,
+ jmethodID methodID, ...) {
+ va_list args;
+ jdouble result;
+ va_start(args,methodID);
+ result = functions->CallStaticDoubleMethodV(this,clazz,methodID,args);
+ va_end(args);
+ return result;
+ }
+ jdouble CallStaticDoubleMethodV(jclass clazz,
+ jmethodID methodID, va_list args) {
+ return functions->CallStaticDoubleMethodV(this,clazz,methodID,args);
+ }
+ jdouble CallStaticDoubleMethodA(jclass clazz,
+ jmethodID methodID, const jvalue *args) {
+ return functions->CallStaticDoubleMethodA(this,clazz,methodID,args);
+ }
+
+ void CallStaticVoidMethod(jclass cls, jmethodID methodID, ...) {
+ va_list args;
+ va_start(args,methodID);
+ functions->CallStaticVoidMethodV(this,cls,methodID,args);
+ va_end(args);
+ }
+ void CallStaticVoidMethodV(jclass cls, jmethodID methodID,
+ va_list args) {
+ functions->CallStaticVoidMethodV(this,cls,methodID,args);
+ }
+ void CallStaticVoidMethodA(jclass cls, jmethodID methodID,
+ const jvalue * args) {
+ functions->CallStaticVoidMethodA(this,cls,methodID,args);
+ }
+
+ jfieldID GetStaticFieldID(jclass clazz, const char *name,
+ const char *sig) {
+ return functions->GetStaticFieldID(this,clazz,name,sig);
+ }
+ jobject GetStaticObjectField(jclass clazz, jfieldID fieldID) {
+ return functions->GetStaticObjectField(this,clazz,fieldID);
+ }
+ jboolean GetStaticBooleanField(jclass clazz, jfieldID fieldID) {
+ return functions->GetStaticBooleanField(this,clazz,fieldID);
+ }
+ jbyte GetStaticByteField(jclass clazz, jfieldID fieldID) {
+ return functions->GetStaticByteField(this,clazz,fieldID);
+ }
+ jchar GetStaticCharField(jclass clazz, jfieldID fieldID) {
+ return functions->GetStaticCharField(this,clazz,fieldID);
+ }
+ jshort GetStaticShortField(jclass clazz, jfieldID fieldID) {
+ return functions->GetStaticShortField(this,clazz,fieldID);
+ }
+ jint GetStaticIntField(jclass clazz, jfieldID fieldID) {
+ return functions->GetStaticIntField(this,clazz,fieldID);
+ }
+ jlong GetStaticLongField(jclass clazz, jfieldID fieldID) {
+ return functions->GetStaticLongField(this,clazz,fieldID);
+ }
+ jfloat GetStaticFloatField(jclass clazz, jfieldID fieldID) {
+ return functions->GetStaticFloatField(this,clazz,fieldID);
+ }
+ jdouble GetStaticDoubleField(jclass clazz, jfieldID fieldID) {
+ return functions->GetStaticDoubleField(this,clazz,fieldID);
+ }
+
+ void SetStaticObjectField(jclass clazz, jfieldID fieldID,
+ jobject value) {
+ functions->SetStaticObjectField(this,clazz,fieldID,value);
+ }
+ void SetStaticBooleanField(jclass clazz, jfieldID fieldID,
+ jboolean value) {
+ functions->SetStaticBooleanField(this,clazz,fieldID,value);
+ }
+ void SetStaticByteField(jclass clazz, jfieldID fieldID,
+ jbyte value) {
+ functions->SetStaticByteField(this,clazz,fieldID,value);
+ }
+ void SetStaticCharField(jclass clazz, jfieldID fieldID,
+ jchar value) {
+ functions->SetStaticCharField(this,clazz,fieldID,value);
+ }
+ void SetStaticShortField(jclass clazz, jfieldID fieldID,
+ jshort value) {
+ functions->SetStaticShortField(this,clazz,fieldID,value);
+ }
+ void SetStaticIntField(jclass clazz, jfieldID fieldID,
+ jint value) {
+ functions->SetStaticIntField(this,clazz,fieldID,value);
+ }
+ void SetStaticLongField(jclass clazz, jfieldID fieldID,
+ jlong value) {
+ functions->SetStaticLongField(this,clazz,fieldID,value);
+ }
+ void SetStaticFloatField(jclass clazz, jfieldID fieldID,
+ jfloat value) {
+ functions->SetStaticFloatField(this,clazz,fieldID,value);
+ }
+ void SetStaticDoubleField(jclass clazz, jfieldID fieldID,
+ jdouble value) {
+ functions->SetStaticDoubleField(this,clazz,fieldID,value);
+ }
+
+ jstring NewString(const jchar *unicode, jsize len) {
+ return functions->NewString(this,unicode,len);
+ }
+ jsize GetStringLength(jstring str) {
+ return functions->GetStringLength(this,str);
+ }
+ const jchar *GetStringChars(jstring str, jboolean *isCopy) {
+ return functions->GetStringChars(this,str,isCopy);
+ }
+ void ReleaseStringChars(jstring str, const jchar *chars) {
+ functions->ReleaseStringChars(this,str,chars);
+ }
+
+ jstring NewStringUTF(const char *utf) {
+ return functions->NewStringUTF(this,utf);
+ }
+ jsize GetStringUTFLength(jstring str) {
+ return functions->GetStringUTFLength(this,str);
+ }
+ const char* GetStringUTFChars(jstring str, jboolean *isCopy) {
+ return functions->GetStringUTFChars(this,str,isCopy);
+ }
+ void ReleaseStringUTFChars(jstring str, const char* chars) {
+ functions->ReleaseStringUTFChars(this,str,chars);
+ }
+
+ jsize GetArrayLength(jarray array) {
+ return functions->GetArrayLength(this,array);
+ }
+
+ jobjectArray NewObjectArray(jsize len, jclass clazz,
+ jobject init) {
+ return functions->NewObjectArray(this,len,clazz,init);
+ }
+ jobject GetObjectArrayElement(jobjectArray array, jsize index) {
+ return functions->GetObjectArrayElement(this,array,index);
+ }
+ void SetObjectArrayElement(jobjectArray array, jsize index,
+ jobject val) {
+ functions->SetObjectArrayElement(this,array,index,val);
+ }
+
+ jbooleanArray NewBooleanArray(jsize len) {
+ return functions->NewBooleanArray(this,len);
+ }
+ jbyteArray NewByteArray(jsize len) {
+ return functions->NewByteArray(this,len);
+ }
+ jcharArray NewCharArray(jsize len) {
+ return functions->NewCharArray(this,len);
+ }
+ jshortArray NewShortArray(jsize len) {
+ return functions->NewShortArray(this,len);
+ }
+ jintArray NewIntArray(jsize len) {
+ return functions->NewIntArray(this,len);
+ }
+ jlongArray NewLongArray(jsize len) {
+ return functions->NewLongArray(this,len);
+ }
+ jfloatArray NewFloatArray(jsize len) {
+ return functions->NewFloatArray(this,len);
+ }
+ jdoubleArray NewDoubleArray(jsize len) {
+ return functions->NewDoubleArray(this,len);
+ }
+
+ jboolean * GetBooleanArrayElements(jbooleanArray array, jboolean *isCopy) {
+ return functions->GetBooleanArrayElements(this,array,isCopy);
+ }
+ jbyte * GetByteArrayElements(jbyteArray array, jboolean *isCopy) {
+ return functions->GetByteArrayElements(this,array,isCopy);
+ }
+ jchar * GetCharArrayElements(jcharArray array, jboolean *isCopy) {
+ return functions->GetCharArrayElements(this,array,isCopy);
+ }
+ jshort * GetShortArrayElements(jshortArray array, jboolean *isCopy) {
+ return functions->GetShortArrayElements(this,array,isCopy);
+ }
+ jint * GetIntArrayElements(jintArray array, jboolean *isCopy) {
+ return functions->GetIntArrayElements(this,array,isCopy);
+ }
+ jlong * GetLongArrayElements(jlongArray array, jboolean *isCopy) {
+ return functions->GetLongArrayElements(this,array,isCopy);
+ }
+ jfloat * GetFloatArrayElements(jfloatArray array, jboolean *isCopy) {
+ return functions->GetFloatArrayElements(this,array,isCopy);
+ }
+ jdouble * GetDoubleArrayElements(jdoubleArray array, jboolean *isCopy) {
+ return functions->GetDoubleArrayElements(this,array,isCopy);
+ }
+
+ void ReleaseBooleanArrayElements(jbooleanArray array,
+ jboolean *elems,
+ jint mode) {
+ functions->ReleaseBooleanArrayElements(this,array,elems,mode);
+ }
+ void ReleaseByteArrayElements(jbyteArray array,
+ jbyte *elems,
+ jint mode) {
+ functions->ReleaseByteArrayElements(this,array,elems,mode);
+ }
+ void ReleaseCharArrayElements(jcharArray array,
+ jchar *elems,
+ jint mode) {
+ functions->ReleaseCharArrayElements(this,array,elems,mode);
+ }
+ void ReleaseShortArrayElements(jshortArray array,
+ jshort *elems,
+ jint mode) {
+ functions->ReleaseShortArrayElements(this,array,elems,mode);
+ }
+ void ReleaseIntArrayElements(jintArray array,
+ jint *elems,
+ jint mode) {
+ functions->ReleaseIntArrayElements(this,array,elems,mode);
+ }
+ void ReleaseLongArrayElements(jlongArray array,
+ jlong *elems,
+ jint mode) {
+ functions->ReleaseLongArrayElements(this,array,elems,mode);
+ }
+ void ReleaseFloatArrayElements(jfloatArray array,
+ jfloat *elems,
+ jint mode) {
+ functions->ReleaseFloatArrayElements(this,array,elems,mode);
+ }
+ void ReleaseDoubleArrayElements(jdoubleArray array,
+ jdouble *elems,
+ jint mode) {
+ functions->ReleaseDoubleArrayElements(this,array,elems,mode);
+ }
+
+ void GetBooleanArrayRegion(jbooleanArray array,
+ jsize start, jsize len, jboolean *buf) {
+ functions->GetBooleanArrayRegion(this,array,start,len,buf);
+ }
+ void GetByteArrayRegion(jbyteArray array,
+ jsize start, jsize len, jbyte *buf) {
+ functions->GetByteArrayRegion(this,array,start,len,buf);
+ }
+ void GetCharArrayRegion(jcharArray array,
+ jsize start, jsize len, jchar *buf) {
+ functions->GetCharArrayRegion(this,array,start,len,buf);
+ }
+ void GetShortArrayRegion(jshortArray array,
+ jsize start, jsize len, jshort *buf) {
+ functions->GetShortArrayRegion(this,array,start,len,buf);
+ }
+ void GetIntArrayRegion(jintArray array,
+ jsize start, jsize len, jint *buf) {
+ functions->GetIntArrayRegion(this,array,start,len,buf);
+ }
+ void GetLongArrayRegion(jlongArray array,
+ jsize start, jsize len, jlong *buf) {
+ functions->GetLongArrayRegion(this,array,start,len,buf);
+ }
+ void GetFloatArrayRegion(jfloatArray array,
+ jsize start, jsize len, jfloat *buf) {
+ functions->GetFloatArrayRegion(this,array,start,len,buf);
+ }
+ void GetDoubleArrayRegion(jdoubleArray array,
+ jsize start, jsize len, jdouble *buf) {
+ functions->GetDoubleArrayRegion(this,array,start,len,buf);
+ }
+
+ void SetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len,
+ const jboolean *buf) {
+ functions->SetBooleanArrayRegion(this,array,start,len,buf);
+ }
+ void SetByteArrayRegion(jbyteArray array, jsize start, jsize len,
+ const jbyte *buf) {
+ functions->SetByteArrayRegion(this,array,start,len,buf);
+ }
+ void SetCharArrayRegion(jcharArray array, jsize start, jsize len,
+ const jchar *buf) {
+ functions->SetCharArrayRegion(this,array,start,len,buf);
+ }
+ void SetShortArrayRegion(jshortArray array, jsize start, jsize len,
+ const jshort *buf) {
+ functions->SetShortArrayRegion(this,array,start,len,buf);
+ }
+ void SetIntArrayRegion(jintArray array, jsize start, jsize len,
+ const jint *buf) {
+ functions->SetIntArrayRegion(this,array,start,len,buf);
+ }
+ void SetLongArrayRegion(jlongArray array, jsize start, jsize len,
+ const jlong *buf) {
+ functions->SetLongArrayRegion(this,array,start,len,buf);
+ }
+ void SetFloatArrayRegion(jfloatArray array, jsize start, jsize len,
+ const jfloat *buf) {
+ functions->SetFloatArrayRegion(this,array,start,len,buf);
+ }
+ void SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len,
+ const jdouble *buf) {
+ functions->SetDoubleArrayRegion(this,array,start,len,buf);
+ }
+
+ jint RegisterNatives(jclass clazz, const JNINativeMethod *methods,
+ jint nMethods) {
+ return functions->RegisterNatives(this,clazz,methods,nMethods);
+ }
+ jint UnregisterNatives(jclass clazz) {
+ return functions->UnregisterNatives(this,clazz);
+ }
+
+ jint MonitorEnter(jobject obj) {
+ return functions->MonitorEnter(this,obj);
+ }
+ jint MonitorExit(jobject obj) {
+ return functions->MonitorExit(this,obj);
+ }
+
+ jint GetJavaVM(JavaVM **vm) {
+ return functions->GetJavaVM(this,vm);
+ }
+
+ void GetStringRegion(jstring str, jsize start, jsize len, jchar *buf) {
+ functions->GetStringRegion(this,str,start,len,buf);
+ }
+ void GetStringUTFRegion(jstring str, jsize start, jsize len, char *buf) {
+ functions->GetStringUTFRegion(this,str,start,len,buf);
+ }
+
+ void * GetPrimitiveArrayCritical(jarray array, jboolean *isCopy) {
+ return functions->GetPrimitiveArrayCritical(this,array,isCopy);
+ }
+ void ReleasePrimitiveArrayCritical(jarray array, void *carray, jint mode) {
+ functions->ReleasePrimitiveArrayCritical(this,array,carray,mode);
+ }
+
+ const jchar * GetStringCritical(jstring string, jboolean *isCopy) {
+ return functions->GetStringCritical(this,string,isCopy);
+ }
+ void ReleaseStringCritical(jstring string, const jchar *cstring) {
+ functions->ReleaseStringCritical(this,string,cstring);
+ }
+
+ jweak NewWeakGlobalRef(jobject obj) {
+ return functions->NewWeakGlobalRef(this,obj);
+ }
+ void DeleteWeakGlobalRef(jweak ref) {
+ functions->DeleteWeakGlobalRef(this,ref);
+ }
+
+ jboolean ExceptionCheck() {
+ return functions->ExceptionCheck(this);
+ }
+
+ jobject NewDirectByteBuffer(void* address, jlong capacity) {
+ return functions->NewDirectByteBuffer(this, address, capacity);
+ }
+ void* GetDirectBufferAddress(jobject buf) {
+ return functions->GetDirectBufferAddress(this, buf);
+ }
+ jlong GetDirectBufferCapacity(jobject buf) {
+ return functions->GetDirectBufferCapacity(this, buf);
+ }
+
+#endif /* __cplusplus */
+};
+
+typedef struct JavaVMOption {
+ char *optionString;
+ void *extraInfo;
+} JavaVMOption;
+
+typedef struct JavaVMInitArgs {
+ jint version;
+
+ jint nOptions;
+ JavaVMOption *options;
+ jboolean ignoreUnrecognized;
+} JavaVMInitArgs;
+
+typedef struct JavaVMAttachArgs {
+ jint version;
+
+ char *name;
+ jobject group;
+} JavaVMAttachArgs;
+
+/* These structures will be VM-specific. */
+
+typedef struct JDK1_1InitArgs {
+ jint version;
+
+ char **properties;
+ jint checkSource;
+ jint nativeStackSize;
+ jint javaStackSize;
+ jint minHeapSize;
+ jint maxHeapSize;
+ jint verifyMode;
+ char *classpath;
+
+ jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args);
+ void (JNICALL *exit)(jint code);
+ void (JNICALL *abort)(void);
+
+ jint enableClassGC;
+ jint enableVerboseGC;
+ jint disableAsyncGC;
+ jint verbose;
+ jboolean debugging;
+ jint debugPort;
+} JDK1_1InitArgs;
+
+typedef struct JDK1_1AttachArgs {
+ void * __padding; /* C compilers don't allow empty structures. */
+} JDK1_1AttachArgs;
+
+#define JDK1_2
+#define JDK1_4
+
+/* End VM-specific. */
+
+struct JNIInvokeInterface_ {
+ void *reserved0;
+ void *reserved1;
+ void *reserved2;
+
+ jint (JNICALL *DestroyJavaVM)(JavaVM *vm);
+
+ jint (JNICALL *AttachCurrentThread)(JavaVM *vm, void **penv, void *args);
+
+ jint (JNICALL *DetachCurrentThread)(JavaVM *vm);
+
+ jint (JNICALL *GetEnv)(JavaVM *vm, void **penv, jint version);
+
+ jint (JNICALL *AttachCurrentThreadAsDaemon)(JavaVM *vm, void **penv, void *args);
+};
+
+struct JavaVM_ {
+ const struct JNIInvokeInterface_ *functions;
+#ifdef __cplusplus
+
+ jint DestroyJavaVM() {
+ return functions->DestroyJavaVM(this);
+ }
+ jint AttachCurrentThread(void **penv, void *args) {
+ return functions->AttachCurrentThread(this, penv, args);
+ }
+ jint DetachCurrentThread() {
+ return functions->DetachCurrentThread(this);
+ }
+
+ jint GetEnv(void **penv, jint version) {
+ return functions->GetEnv(this, penv, version);
+ }
+ jint AttachCurrentThreadAsDaemon(void **penv, void *args) {
+ return functions->AttachCurrentThreadAsDaemon(this, penv, args);
+ }
+#endif
+};
+
+#ifdef _JNI_IMPLEMENTATION_
+#define _JNI_IMPORT_OR_EXPORT_ JNIEXPORT
+#else
+#define _JNI_IMPORT_OR_EXPORT_ JNIIMPORT
+#endif
+_JNI_IMPORT_OR_EXPORT_ jint JNICALL
+JNI_GetDefaultJavaVMInitArgs(void *args);
+
+_JNI_IMPORT_OR_EXPORT_ jint JNICALL
+JNI_CreateJavaVM(JavaVM **pvm, void **penv, void *args);
+
+_JNI_IMPORT_OR_EXPORT_ jint JNICALL
+JNI_GetCreatedJavaVMs(JavaVM **, jsize, jsize *);
+
+/* Defined by native libraries. */
+JNIEXPORT jint JNICALL
+JNI_OnLoad(JavaVM *vm, void *reserved);
+
+JNIEXPORT void JNICALL
+JNI_OnUnload(JavaVM *vm, void *reserved);
+
+#define JNI_VERSION_1_1 0x00010001
+#define JNI_VERSION_1_2 0x00010002
+#define JNI_VERSION_1_4 0x00010004
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif /* __cplusplus */
+
+#endif /* !_JAVASOFT_JNI_H_ */
diff --git a/applications/JavaOpenJPEG/java-jni/include/jvmdi.h b/applications/JavaOpenJPEG/java-jni/include/jvmdi.h new file mode 100644 index 00000000..d39c4a95 --- /dev/null +++ b/applications/JavaOpenJPEG/java-jni/include/jvmdi.h @@ -0,0 +1,1012 @@ +/*
+ * @(#)jvmdi.h 1.48 03/12/19
+ *
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+/*
+ * Java Virtual Machine Debug Interface
+ *
+ * Defines debugging functionality that a VM should provide.
+ *
+ * Should not overlap functionality in jni.h
+ */
+
+#ifndef _JAVASOFT_JVMDI_H_
+#define _JAVASOFT_JVMDI_H_
+
+#include "jni.h"
+
+#define JVMDI_VERSION_1 0x20010000
+#define JVMDI_VERSION_1_1 0x20010001
+#define JVMDI_VERSION_1_2 0x20010002
+#define JVMDI_VERSION_1_3 0x20010003
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef jobject jthread;
+
+typedef jobject jthreadGroup;
+
+struct _jframeID;
+typedef struct _jframeID *jframeID;
+
+ /* specifies program location "pc" - often byte code index */
+typedef jlong jlocation;
+
+ /* The jmethodID for methods that have been replaced */
+ /* via RedefineClasses - used when the implementation */
+ /* does not wish to retain replaced jmethodIDs */
+#define OBSOLETE_METHOD_ID ((jmethodID)(NULL))
+
+ /*
+ * Errors
+ */
+
+typedef jint jvmdiError;
+
+ /* no error */
+#define JVMDI_ERROR_NONE ((jvmdiError)0)
+
+ /*
+ * Errors on thread operations
+ */
+
+ /* invalid thread */
+#define JVMDI_ERROR_INVALID_THREAD ((jvmdiError)10)
+ /* invalid thread group */
+#define JVMDI_ERROR_INVALID_THREAD_GROUP ((jvmdiError)11)
+ /* invalid thread priority */
+#define JVMDI_ERROR_INVALID_PRIORITY ((jvmdiError)12)
+ /* thread not suspended */
+#define JVMDI_ERROR_THREAD_NOT_SUSPENDED ((jvmdiError)13)
+ /* thread already suspended */
+#define JVMDI_ERROR_THREAD_SUSPENDED ((jvmdiError)14)
+
+ /*
+ * Errors on object and class operations
+ */
+
+ /* invalid object (implementation not required to gracefully catch) */
+#define JVMDI_ERROR_INVALID_OBJECT ((jvmdiError)20)
+ /* invalid class (implementation not required to gracefully catch) */
+#define JVMDI_ERROR_INVALID_CLASS ((jvmdiError)21)
+ /* class not prepared */
+#define JVMDI_ERROR_CLASS_NOT_PREPARED ((jvmdiError)22)
+ /* invalid methodID (implementation not required to gracefully catch) */
+#define JVMDI_ERROR_INVALID_METHODID ((jvmdiError)23)
+ /* invalid location */
+#define JVMDI_ERROR_INVALID_LOCATION ((jvmdiError)24)
+ /* invalid fieldID (implementation not required to gracefully catch) */
+#define JVMDI_ERROR_INVALID_FIELDID ((jvmdiError)25)
+
+ /*
+ * Errors on frame operations
+ */
+
+ /* invalid frameID (implementation not required to gracefully catch) */
+#define JVMDI_ERROR_INVALID_FRAMEID ((jvmdiError)30)
+ /* there are no more frames on the stack */
+#define JVMDI_ERROR_NO_MORE_FRAMES ((jvmdiError)31)
+ /* operation cannot be performed on this frame */
+#define JVMDI_ERROR_OPAQUE_FRAME ((jvmdiError)32)
+ /* operation can only be performed on current frame */
+#define JVMDI_ERROR_NOT_CURRENT_FRAME ((jvmdiError)33)
+ /* type mismatch (implementation not required to gracefully catch) */
+#define JVMDI_ERROR_TYPE_MISMATCH ((jvmdiError)34)
+ /* invalid slot */
+#define JVMDI_ERROR_INVALID_SLOT ((jvmdiError)35)
+
+ /*
+ * Errors on set/clear/find operations
+ */
+
+ /* item already present */
+#define JVMDI_ERROR_DUPLICATE ((jvmdiError)40)
+ /* item not found */
+#define JVMDI_ERROR_NOT_FOUND ((jvmdiError)41)
+
+ /*
+ * Errors on monitor operations
+ */
+
+ /* invalid monitor */
+#define JVMDI_ERROR_INVALID_MONITOR ((jvmdiError)50)
+ /* wait, notify, notify all tried without entering monitor */
+#define JVMDI_ERROR_NOT_MONITOR_OWNER ((jvmdiError)51)
+ /* waiting thread interrupted */
+#define JVMDI_ERROR_INTERRUPT ((jvmdiError)52)
+
+ /*
+ * Class redefinition / operand stack errors
+ */
+
+ /* The equivalent of ClassFormatError */
+#define JVMDI_ERROR_INVALID_CLASS_FORMAT ((jvmdiError)60)
+ /* The equivalent of ClassCircularityError */
+#define JVMDI_ERROR_CIRCULAR_CLASS_DEFINITION ((jvmdiError)61)
+ /* The class bytes fail verification */
+#define JVMDI_ERROR_FAILS_VERIFICATION ((jvmdiError)62)
+ /* The new class version adds new methods */
+ /* and can_add_method is false */
+#define JVMDI_ERROR_ADD_METHOD_NOT_IMPLEMENTED ((jvmdiError)63)
+ /* The new class version changes fields */
+ /* and can_unrestrictedly_redefine_classes is false */
+#define JVMDI_ERROR_SCHEMA_CHANGE_NOT_IMPLEMENTED ((jvmdiError)64)
+ /* bci/operand stack/local var combination is not verifiably */
+ /* type safe */
+#define JVMDI_ERROR_INVALID_TYPESTATE ((jvmdiError)65)
+ /* A direct superclass is different for the new class */
+ /* version, or the set of directly implemented */
+ /* interfaces is different */
+ /* and can_unrestrictedly_redefine_classes is false */
+#define JVMDI_ERROR_HIERARCHY_CHANGE_NOT_IMPLEMENTED ((jvmdiError)66)
+ /* The new class version does not declare a method */
+ /* declared in the old class version */
+ /* and can_unrestrictedly_redefine_classes is false */
+#define JVMDI_ERROR_DELETE_METHOD_NOT_IMPLEMENTED ((jvmdiError)67)
+ /* A class file has a version number not supported */
+ /* by this VM. */
+#define JVMDI_ERROR_UNSUPPORTED_VERSION ((jvmdiError)68)
+ /* The class name defined in the new class file is */
+ /* different from the name in the old class object */
+#define JVMDI_ERROR_NAMES_DONT_MATCH ((jvmdiError)69)
+ /* The new class version has different modifiers and */
+ /* can_unrestrictedly_redefine_classes is false */
+#define JVMDI_ERROR_CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED ((jvmdiError)70)
+ /* A method in the new class version has different modifiers */
+ /* than its counterpart in the old class version */
+ /* and can_unrestrictedly_redefine_classes is false */
+#define JVMDI_ERROR_METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED ((jvmdiError)71)
+
+ /*
+ * Miscellaneous errors
+ */
+
+ /* Not yet implemented */
+#define JVMDI_ERROR_NOT_IMPLEMENTED ((jvmdiError)99)
+ /* null pointer */
+#define JVMDI_ERROR_NULL_POINTER ((jvmdiError)100)
+ /* information is absent */
+#define JVMDI_ERROR_ABSENT_INFORMATION ((jvmdiError)101)
+ /* invalid event type */
+#define JVMDI_ERROR_INVALID_EVENT_TYPE ((jvmdiError)102)
+ /* invalid argument */
+#define JVMDI_ERROR_ILLEGAL_ARGUMENT ((jvmdiError)103)
+
+ /*
+ * Universal errors. These errors may be returned by
+ * any JVMDI function, not just the ones for which they are listed
+ * below.
+ */
+
+ /* no more memory available for allocation */
+#define JVMDI_ERROR_OUT_OF_MEMORY ((jvmdiError)110)
+ /* debugging has not been enabled in this VM */
+#define JVMDI_ERROR_ACCESS_DENIED ((jvmdiError)111)
+ /* VM is dead (implementation not required to gracefully catch) */
+#define JVMDI_ERROR_VM_DEAD ((jvmdiError)112)
+ /* internal error */
+#define JVMDI_ERROR_INTERNAL ((jvmdiError)113)
+ /* Thread calling JVMDI function not attached to VM */
+#define JVMDI_ERROR_UNATTACHED_THREAD ((jvmdiError)115)
+
+
+ /*
+ * Threads
+ */
+
+ /* Thread status is unknown */
+#define JVMDI_THREAD_STATUS_UNKNOWN ((jint)-1)
+ /* Thread is waiting to die */
+#define JVMDI_THREAD_STATUS_ZOMBIE ((jint)0)
+ /* Thread is runnable */
+#define JVMDI_THREAD_STATUS_RUNNING ((jint)1)
+ /* Thread is sleeping - Thread.sleep() or JVM_Sleep() was called */
+#define JVMDI_THREAD_STATUS_SLEEPING ((jint)2)
+ /* Thread is waiting on a java monitor */
+#define JVMDI_THREAD_STATUS_MONITOR ((jint)3)
+ /* Thread is waiting - Thread.wait() or JVM_MonitorWait() was called */
+#define JVMDI_THREAD_STATUS_WAIT ((jint)4)
+
+ /* Thread is suspended - Thread.suspend(), JVM_Suspend() or
+ * JVMDI_Suspend was called */
+#define JVMDI_SUSPEND_STATUS_SUSPENDED ((jint)0x1)
+ /* Thread is at a breakpoint */
+#define JVMDI_SUSPEND_STATUS_BREAK ((jint)0x2)
+
+
+ /* Thread priority constants */
+#define JVMDI_THREAD_MIN_PRIORITY ((jint)1)
+#define JVMDI_THREAD_NORM_PRIORITY ((jint)5)
+#define JVMDI_THREAD_MAX_PRIORITY ((jint)10)
+
+typedef struct {
+ char *name;
+ jint priority;
+ jboolean is_daemon;
+ jthreadGroup thread_group;
+ jobject context_class_loader;
+} JVMDI_thread_info;
+
+typedef struct {
+ jthreadGroup parent;
+ char *name;
+ jint max_priority;
+ jboolean is_daemon;
+} JVMDI_thread_group_info;
+
+#define JVMDI_DISABLE ((jint) 0)
+#define JVMDI_ENABLE ((jint) 1)
+
+/*
+ * Initial function for debug threads created through JVMDI
+ */
+typedef void (*JVMDI_StartFunction)(void *);
+
+/*
+ * Type for debug monitors created through JVMDI
+ */
+typedef void *JVMDI_RawMonitor;
+
+#define JVMDI_MONITOR_WAIT_FOREVER ((jlong)(-1))
+
+/*
+ * Monitor information
+ */
+typedef struct {
+ jthread owner;
+ jint entry_count;
+ jint waiter_count;
+ jthread *waiters;
+} JVMDI_monitor_info;
+
+typedef struct {
+ jint owned_monitor_count;
+ jobject *owned_monitors;
+} JVMDI_owned_monitor_info;
+
+ /*
+ * Events
+ */
+
+ /* kind = JVMDI_EVENT_SINGLE_STEP */
+ typedef struct {
+ jthread thread;
+ jclass clazz;
+ jmethodID method;
+ jlocation location;
+ } JVMDI_single_step_event_data;
+
+ /* kind = JVMDI_EVENT_BREAKPOINT */
+ typedef struct {
+ jthread thread;
+ jclass clazz;
+ jmethodID method;
+ jlocation location;
+ } JVMDI_breakpoint_event_data;
+
+ /* kind = JVMDI_EVENT_FIELD_ACCESS */
+ typedef struct {
+ jthread thread;
+ jclass clazz;
+ jmethodID method;
+ jlocation location;
+ jclass field_clazz;
+ jobject object;
+ jfieldID field;
+ } JVMDI_field_access_event_data;
+
+ /* kind = JVMDI_EVENT_FIELD_MODIFICATION */
+ typedef struct {
+ jthread thread;
+ jclass clazz;
+ jmethodID method;
+ jlocation location;
+ jclass field_clazz;
+ jobject object;
+ jfieldID field;
+ char signature_type;
+ jvalue new_value;
+ } JVMDI_field_modification_event_data;
+
+ /* kind = JVMDI_EVENT_FRAME_POP */
+ /* kind = JVMDI_EVENT_METHOD_ENTRY */
+ /* kind = JVMDI_EVENT_METHOD_EXIT */
+ typedef struct {
+ jthread thread;
+ jclass clazz;
+ jmethodID method;
+ jframeID frame;
+ } JVMDI_frame_event_data;
+
+ /* kind = JVMDI_EVENT_EXCEPTION */
+ typedef struct {
+ jthread thread;
+ jclass clazz;
+ jmethodID method;
+ jlocation location;
+ jobject exception;
+ jclass catch_clazz;
+ jmethodID catch_method;
+ jlocation catch_location;
+ } JVMDI_exception_event_data;
+
+ /* kind = JVMDI_EVENT_EXCEPTION_CATCH */
+ typedef struct {
+ jthread thread;
+ jclass clazz;
+ jmethodID method;
+ jlocation location;
+ jobject exception;
+ } JVMDI_exception_catch_event_data;
+
+ /* kind = JVMDI_EVENT_USER_DEFINED */
+ typedef struct {
+ jobject object;
+ jint key;
+ } JVMDI_user_event_data;
+
+ /* kind = JVMDI_EVENT_THREAD_END or */
+ /* JVMDI_EVENT_THREAD_START */
+ typedef struct {
+ jthread thread;
+ } JVMDI_thread_change_event_data;
+
+ /* kind = JVMDI_EVENT_CLASS_LOAD, */
+ /* JVMDI_EVENT_CLASS_UNLOAD, or */
+ /* JVMDI_EVENT_CLASS_PREPARE */
+ typedef struct {
+ jthread thread;
+ jclass clazz;
+ } JVMDI_class_event_data;
+
+/* This stucture passes information about the event.
+ * location is the index of the last instruction executed.
+ */
+typedef struct {
+ jint kind; /* the discriminant */
+
+ union {
+ /* kind = JVMDI_EVENT_SINGLE_STEP */
+ JVMDI_single_step_event_data single_step;
+
+ /* kind = JVMDI_EVENT_BREAKPOINT */
+ JVMDI_breakpoint_event_data breakpoint;
+
+ /* kind = JVMDI_EVENT_FRAME_POP */
+ /* kind = JVMDI_EVENT_METHOD_ENTRY */
+ /* kind = JVMDI_EVENT_METHOD_EXIT */
+ JVMDI_frame_event_data frame;
+
+ /* kind = JVMDI_EVENT_FIELD_ACCESS */
+ JVMDI_field_access_event_data field_access;
+
+ /* kind = JVMDI_EVENT_FIELD_MODIFICATION */
+ JVMDI_field_modification_event_data field_modification;
+
+ /* kind = JVMDI_EVENT_EXCEPTION */
+ JVMDI_exception_event_data exception;
+
+ /* kind = JVMDI_EVENT_EXCEPTION_CATCH */
+ JVMDI_exception_catch_event_data exception_catch;
+
+ /* kind = JVMDI_EVENT_USER_DEFINED */
+ JVMDI_user_event_data user;
+
+ /* kind = JVMDI_EVENT_THREAD_END or */
+ /* JVMDI_EVENT_THREAD_START */
+ JVMDI_thread_change_event_data thread_change;
+
+ /* kind = JVMDI_EVENT_CLASS_LOAD, */
+ /* JVMDI_EVENT_CLASS_UNLOAD, or */
+ /* JVMDI_EVENT_CLASS_PREPARE */
+ JVMDI_class_event_data class_event;
+
+ /* kind = JVMDI_EVENT_VM_DEATH, JVMDI_EVENT_VM_INIT */
+ /* no additional fields */
+ } u;
+} JVMDI_Event;
+
+ /*** event kinds ***/
+#define JVMDI_EVENT_SINGLE_STEP ((jint)1)
+#define JVMDI_EVENT_BREAKPOINT ((jint)2)
+#define JVMDI_EVENT_FRAME_POP ((jint)3)
+#define JVMDI_EVENT_EXCEPTION ((jint)4)
+#define JVMDI_EVENT_USER_DEFINED ((jint)5)
+#define JVMDI_EVENT_THREAD_START ((jint)6)
+#define JVMDI_EVENT_THREAD_END ((jint)7)
+#define JVMDI_EVENT_CLASS_PREPARE ((jint)8)
+#define JVMDI_EVENT_CLASS_UNLOAD ((jint)9)
+#define JVMDI_EVENT_CLASS_LOAD ((jint)10)
+#define JVMDI_EVENT_FIELD_ACCESS ((jint)20)
+#define JVMDI_EVENT_FIELD_MODIFICATION ((jint)21)
+#define JVMDI_EVENT_EXCEPTION_CATCH ((jint)30)
+#define JVMDI_EVENT_METHOD_ENTRY ((jint)40)
+#define JVMDI_EVENT_METHOD_EXIT ((jint)41)
+#define JVMDI_EVENT_VM_INIT ((jint)90)
+#define JVMDI_EVENT_VM_DEATH ((jint)99)
+
+#define JVMDI_MAX_EVENT_TYPE_VAL ((jint)99)
+
+
+
+/* event handler hook */
+typedef void (*JVMDI_EventHook)(JNIEnv *env, JVMDI_Event *event);
+
+typedef jvmdiError (*JVMDI_AllocHook) (jlong size, jbyte** memPtr);
+typedef jvmdiError (*JVMDI_DeallocHook) (jbyte* buffer);
+
+/*
+ * Class states used in JVMDI_GetClassStatus
+ */
+#define JVMDI_CLASS_STATUS_VERIFIED ((jint)0x01)
+#define JVMDI_CLASS_STATUS_PREPARED ((jint)0x02)
+#define JVMDI_CLASS_STATUS_INITIALIZED ((jint)0x04)
+ /* Error prevents initialization */
+#define JVMDI_CLASS_STATUS_ERROR ((jint)0x08)
+
+/* structure for returning line number information
+ */
+typedef struct {
+ jlocation start_location;
+ jint line_number;
+} JVMDI_line_number_entry;
+
+
+/* structure for returning local variable information
+ */
+typedef struct {
+ jlocation start_location; /* variable valid start_location */
+ jint length; /* upto start_location+length */
+ char *name; /* name in UTF8 */
+ char *signature; /* type signature in UTF8 */
+ jint slot; /* variable slot, see JVMDI_GetLocal*() */
+} JVMDI_local_variable_entry;
+
+/* structure for returning exception handler information
+ */
+typedef struct {
+ jlocation start_location;
+ jlocation end_location;
+ jlocation handler_location;
+ jclass exception; /* if null, all exceptions */
+} JVMDI_exception_handler_entry;
+
+#define JVMDI_OPERAND_TYPE_REFERENCE ((jint)1)
+#define JVMDI_OPERAND_TYPE_INT ((jint)2)
+#define JVMDI_OPERAND_TYPE_FLOAT ((jint)3)
+#define JVMDI_OPERAND_TYPE_LONG0 ((jint)4) /* least sig. 32 bits */
+#define JVMDI_OPERAND_TYPE_LONG1 ((jint)5) /* most sig. 32 bits */
+#define JVMDI_OPERAND_TYPE_DOUBLE0 ((jint)6) /* least sig. 32 bits */
+#define JVMDI_OPERAND_TYPE_DOUBLE1 ((jint)7) /* most sig. 32 bits */
+#define JVMDI_OPERAND_TYPE_RETURN_ADDRESS ((jint)8)
+
+typedef struct {
+ jint word; /* 32 bit operand stack quantities */
+ jint type; /* type encoding of the operand word */
+ /* one of JVMDI_OPERAND_TYPE_* */
+} JVMDI_operand_stack_element;
+
+typedef struct {
+ jint instance_field_count; /* number of instance fields referencing obj */
+ struct JVMDI_instance_field {
+ jobject instance; /* instance referencing obj */
+ jfieldID field; /* field holding reference */
+ } *instance_fields; /* instanceField_count of them */
+
+ jint static_field_count; /* number of static fields referencing obj */
+ struct JVMDI_static_field {
+ jclass clazz; /* class referencing obj */
+ jfieldID static_field; /* field holding reference */
+ } *static_fields; /* static_field_count of them */
+
+ jint array_element_count; /* number of array elements referencing obj */
+ struct JVMDI_array_element {
+ jobjectArray array; /* array referencing obj */
+ jint index; /* index holding reference */
+ } *array_elements; /* array_element_count of them */
+
+ jint frame_slot_count; /* number of frame slots referencing obj */
+ struct JVMDI_frame_slot {
+ jthread thread; /* thread of the frame */
+ jframeID frame; /* frame referencing obj */
+ jint slot; /* slot holding reference */
+ } *frame_slots; /* frame_slot_count of them */
+} JVMDI_object_reference_info;
+
+/* structure for defining a class
+*/
+typedef struct {
+ jclass clazz; /* Class object for this class */
+ jint class_byte_count; /* number of bytes defining class (below) */
+ jbyte *class_bytes; /* bytes defining class (in JVM spec */
+ /* Class File Format) */
+} JVMDI_class_definition;
+
+ /* For backwards compatibility */
+#define can_change_schema can_unrestrictedly_redefine_classes
+
+typedef struct {
+ unsigned int can_watch_field_modification : 1;
+ unsigned int can_watch_field_access : 1;
+ unsigned int can_get_bytecodes : 1;
+ unsigned int can_get_synthetic_attribute : 1;
+ unsigned int can_get_owned_monitor_info : 1;
+ unsigned int can_get_current_contended_monitor : 1;
+ unsigned int can_get_monitor_info : 1;
+ unsigned int can_get_heap_info : 1;
+ unsigned int can_get_operand_stack : 1;
+ unsigned int can_set_operand_stack : 1;
+ unsigned int can_pop_frame : 1;
+ unsigned int can_get_class_definition : 1;
+ unsigned int can_redefine_classes : 1;
+ unsigned int can_add_method : 1;
+ unsigned int can_unrestrictedly_redefine_classes : 1;
+ unsigned int can_suspend_resume_thread_lists : 1;
+} JVMDI_capabilities;
+
+typedef struct JVMDI_Interface_1_ {
+ jvmdiError (JNICALL *SetEventHook)
+ (JVMDI_EventHook hook);
+ jvmdiError (JNICALL *SetEventNotificationMode)
+ (jint mode, jint eventType, jthread thread, ...);
+
+ jvmdiError (JNICALL *GetThreadStatus)
+ (jthread thread,
+ jint *threadStatusPtr, jint *suspendStatusPtr);
+ jvmdiError (JNICALL *GetAllThreads)
+ (jint *threadsCountPtr, jthread **threadsPtr);
+ jvmdiError (JNICALL *SuspendThread)
+ (jthread thread);
+ jvmdiError (JNICALL *ResumeThread)
+ (jthread thread);
+ jvmdiError (JNICALL *StopThread)
+ (jthread thread, jobject exception);
+ jvmdiError (JNICALL *InterruptThread)
+ (jthread thread);
+ jvmdiError (JNICALL *GetThreadInfo)
+ (jthread thread, JVMDI_thread_info *infoPtr);
+ jvmdiError (JNICALL *GetOwnedMonitorInfo)
+ (jthread thread, JVMDI_owned_monitor_info *infoPtr);
+ jvmdiError (JNICALL *GetCurrentContendedMonitor)
+ (jthread thread, jobject *monitor);
+ jvmdiError (JNICALL *RunDebugThread)
+ (jthread thread, JVMDI_StartFunction proc, void *arg,
+ int priority);
+
+ jvmdiError (JNICALL *GetTopThreadGroups)
+ (jint *groupCountPtr, jthreadGroup **groupsPtr);
+ jvmdiError (JNICALL *GetThreadGroupInfo)
+ (jthreadGroup group, JVMDI_thread_group_info *infoPtr);
+ jvmdiError (JNICALL *GetThreadGroupChildren)
+ (jthreadGroup group,
+ jint *threadCountPtr, jthread **threadsPtr,
+ jint *groupCountPtr, jthreadGroup **groupsPtr);
+
+ jvmdiError (JNICALL *GetFrameCount)
+ (jthread thread, jint *countPtr);
+ jvmdiError (JNICALL *GetCurrentFrame)
+ (jthread thread, jframeID *framePtr);
+ jvmdiError (JNICALL *GetCallerFrame)
+ (jframeID called, jframeID *framePtr);
+ jvmdiError (JNICALL *GetFrameLocation)
+ (jframeID frame, jclass *classPtr, jmethodID *methodPtr,
+ jlocation *locationPtr);
+ jvmdiError (JNICALL *NotifyFramePop)
+ (jframeID frame);
+ jvmdiError (JNICALL *GetLocalObject)
+ (jframeID frame, jint slot, jobject *valuePtr);
+ jvmdiError (JNICALL *GetLocalInt)
+ (jframeID frame, jint slot, jint *valuePtr);
+ jvmdiError (JNICALL *GetLocalLong)
+ (jframeID frame, jint slot, jlong *valuePtr);
+ jvmdiError (JNICALL *GetLocalFloat)
+ (jframeID frame, jint slot, jfloat *valuePtr);
+ jvmdiError (JNICALL *GetLocalDouble)
+ (jframeID frame, jint slot, jdouble *valuePtr);
+ jvmdiError (JNICALL *SetLocalObject)
+ (jframeID frame, jint slot, jobject value);
+ jvmdiError (JNICALL *SetLocalInt)
+ (jframeID frame, jint slot, jint value);
+ jvmdiError (JNICALL *SetLocalLong)
+ (jframeID frame, jint slot, jlong value);
+ jvmdiError (JNICALL *SetLocalFloat)
+ (jframeID frame, jint slot, jfloat value);
+ jvmdiError (JNICALL *SetLocalDouble)
+ (jframeID frame, jint slot, jdouble value);
+
+ jvmdiError (JNICALL *CreateRawMonitor)
+ (char *name, JVMDI_RawMonitor *monitorPtr);
+ jvmdiError (JNICALL *DestroyRawMonitor)
+ (JVMDI_RawMonitor monitor);
+ jvmdiError (JNICALL *RawMonitorEnter)
+ (JVMDI_RawMonitor monitor);
+ jvmdiError (JNICALL *RawMonitorExit)
+ (JVMDI_RawMonitor monitor);
+ jvmdiError (JNICALL *RawMonitorWait)
+ (JVMDI_RawMonitor monitor, jlong millis);
+ jvmdiError (JNICALL *RawMonitorNotify)
+ (JVMDI_RawMonitor monitor);
+ jvmdiError (JNICALL *RawMonitorNotifyAll)
+ (JVMDI_RawMonitor monitor);
+
+ jvmdiError (JNICALL *SetBreakpoint)
+ (jclass clazz, jmethodID method, jlocation location);
+ jvmdiError (JNICALL *ClearBreakpoint)
+ (jclass clazz, jmethodID method, jlocation location);
+ jvmdiError (JNICALL *ClearAllBreakpoints)
+ ();
+
+ jvmdiError (JNICALL *SetFieldAccessWatch)
+ (jclass clazz, jfieldID field);
+ jvmdiError (JNICALL *ClearFieldAccessWatch)
+ (jclass clazz, jfieldID field);
+ jvmdiError (JNICALL *SetFieldModificationWatch)
+ (jclass clazz, jfieldID field);
+ jvmdiError (JNICALL *ClearFieldModificationWatch)
+ (jclass clazz, jfieldID field);
+
+ jvmdiError (JNICALL *SetAllocationHooks)
+ (JVMDI_AllocHook ahook, JVMDI_DeallocHook dhook);
+ jvmdiError (JNICALL *Allocate)
+ (jlong size, jbyte** memPtr);
+ jvmdiError (JNICALL *Deallocate)
+ (jbyte* mem);
+
+ jvmdiError (JNICALL *GetClassSignature)
+ (jclass clazz, char **sigPtr);
+ jvmdiError (JNICALL *GetClassStatus)
+ (jclass clazz, jint *statusPtr);
+ jvmdiError (JNICALL *GetSourceFileName)
+ (jclass clazz, char **sourceNamePtr);
+ jvmdiError (JNICALL *GetClassModifiers)
+ (jclass clazz, jint *modifiersPtr);
+ jvmdiError (JNICALL *GetClassMethods)
+ (jclass clazz, jint *methodCountPtr, jmethodID **methodsPtr);
+ jvmdiError (JNICALL *GetClassFields)
+ (jclass clazz, jint *fieldCountPtr, jfieldID **fieldsPtr);
+ jvmdiError (JNICALL *GetImplementedInterfaces)
+ (jclass clazz, jint *interfaceCountPtr, jclass **interfacesPtr);
+ jvmdiError (JNICALL *IsInterface)
+ (jclass clazz, jboolean *isInterfacePtr);
+ jvmdiError (JNICALL *IsArrayClass)
+ (jclass clazz, jboolean *isArrayClassPtr);
+ jvmdiError (JNICALL *GetClassLoader)
+ (jclass clazz, jobject *classloaderPtr);
+
+ jvmdiError (JNICALL *GetObjectHashCode)
+ (jobject object, jint *hashCodePtr);
+ jvmdiError (JNICALL *GetMonitorInfo)
+ (jobject object, JVMDI_monitor_info *infoPtr);
+
+ jvmdiError (JNICALL *GetFieldName)
+ (jclass clazz, jfieldID field, char **namePtr, char **signaturePtr);
+ jvmdiError (JNICALL *GetFieldDeclaringClass)
+ (jclass clazz, jfieldID field, jclass *declaringClassPtr);
+ jvmdiError (JNICALL *GetFieldModifiers)
+ (jclass clazz, jfieldID field, jint *modifiersPtr);
+ jvmdiError (JNICALL *IsFieldSynthetic)
+ (jclass clazz, jfieldID field, jboolean *isSyntheticPtr);
+
+ jvmdiError (JNICALL *GetMethodName)
+ (jclass clazz, jmethodID method,
+ char **namePtr, char **signaturePtr);
+ jvmdiError (JNICALL *GetMethodDeclaringClass)
+ (jclass clazz, jmethodID method, jclass *declaringClassPtr);
+ jvmdiError (JNICALL *GetMethodModifiers)
+ (jclass clazz, jmethodID method, jint *modifiersPtr);
+ jvmdiError (JNICALL *GetMaxStack)
+ (jclass clazz, jmethodID method, jint *maxPtr);
+ jvmdiError (JNICALL *GetMaxLocals)
+ (jclass clazz, jmethodID method, jint *maxPtr);
+ jvmdiError (JNICALL *GetArgumentsSize)
+ (jclass clazz, jmethodID method, jint *sizePtr);
+ jvmdiError (JNICALL *GetLineNumberTable)
+ (jclass clazz, jmethodID method,
+ jint *entryCountPtr, JVMDI_line_number_entry **tablePtr);
+ jvmdiError (JNICALL *GetMethodLocation)
+ (jclass clazz, jmethodID method,
+ jlocation *startLocationPtr, jlocation *endLocationPtr);
+ jvmdiError (JNICALL *GetLocalVariableTable)
+ (jclass clazz, jmethodID method,
+ jint *entryCountPtr, JVMDI_local_variable_entry **tablePtr);
+ jvmdiError (JNICALL *GetExceptionHandlerTable)
+ (jclass clazz, jmethodID method,
+ jint *entryCountPtr, JVMDI_exception_handler_entry **tablePtr);
+ jvmdiError (JNICALL *GetThrownExceptions)
+ (jclass clazz, jmethodID method,
+ jint *exceptionCountPtr, jclass **exceptionsPtr);
+ jvmdiError (JNICALL *GetBytecodes)
+ (jclass clazz, jmethodID method,
+ jint *bytecodeCountPtr, jbyte **bytecodesPtr);
+ jvmdiError (JNICALL *IsMethodNative)
+ (jclass clazz, jmethodID method, jboolean *isNativePtr);
+ jvmdiError (JNICALL *IsMethodSynthetic)
+ (jclass clazz, jmethodID method, jboolean *isSyntheticPtr);
+
+ jvmdiError (JNICALL *GetLoadedClasses)
+ (jint *classCountPtr, jclass **classesPtr);
+ jvmdiError (JNICALL *GetClassLoaderClasses)
+ (jobject initiatingLoader, jint *classesCountPtr,
+ jclass **classesPtr);
+
+ jvmdiError (JNICALL *PopFrame)
+ (jthread thread);
+ jvmdiError (JNICALL *SetFrameLocation)
+ (jframeID frame, jlocation location);
+ jvmdiError (JNICALL *GetOperandStack)
+ (jframeID frame, jint *operandStackSizePtr,
+ JVMDI_operand_stack_element **operandStackPtr);
+ jvmdiError (JNICALL *SetOperandStack)
+ (jframeID frame, jint operandStackSize,
+ JVMDI_operand_stack_element *operandStack);
+ jvmdiError (JNICALL *AllInstances)
+ (jclass clazz, jint *instanceCountPtr, jobject **instancesPtr);
+ jvmdiError (JNICALL *References)
+ (jobject obj, JVMDI_object_reference_info *refs);
+ jvmdiError (JNICALL *GetClassDefinition)
+ (jclass clazz, JVMDI_class_definition *classDefPtr);
+ jvmdiError (JNICALL *RedefineClasses)
+ (jint classCount, JVMDI_class_definition *classDefs);
+
+ jvmdiError (JNICALL *GetVersionNumber)
+ (jint *versionPtr);
+ jvmdiError (JNICALL *GetCapabilities)
+ (JVMDI_capabilities *capabilitiesPtr);
+
+ jvmdiError (JNICALL *GetSourceDebugExtension)
+ (jclass clazz, char **sourceDebugExtension);
+ jvmdiError (JNICALL *IsMethodObsolete)
+ (jclass clazz, jmethodID method, jboolean *isObsoletePtr);
+
+ jvmdiError (JNICALL *SuspendThreadList)
+ (jint reqCount, jthread *reqList, jvmdiError *results);
+ jvmdiError (JNICALL *ResumeThreadList)
+ (jint reqCount, jthread *reqList, jvmdiError *results);
+} JVMDI_Interface_1;
+
+#ifndef NO_JVMDI_MACROS
+
+#define JVMDI_ERROR_DUPLICATE_BREAKPOINT JVMDI_ERROR_DUPLICATE
+#define JVMDI_ERROR_NO_SUCH_BREAKPOINT JVMDI_ERROR_NOT_FOUND
+#define JVMDI_ERROR_DUPLICATE_FRAME_POP JVMDI_ERROR_DUPLICATE
+
+
+static JVMDI_Interface_1 *jvmdi_interface = NULL;
+static JavaVM *j_vm;
+
+#ifdef __cplusplus
+#define SetJVMDIfromJNIEnv(a_env) ( (jvmdi_interface == NULL)? \
+ ((a_env)->GetJavaVM(&j_vm), \
+ (j_vm)->GetEnv((void **)&jvmdi_interface, \
+ JVMDI_VERSION_1)):0)
+#else
+#define SetJVMDIfromJNIEnv(a_env) ( (jvmdi_interface == NULL)? \
+ ((*a_env)->GetJavaVM(a_env, &j_vm), \
+ (*j_vm)->GetEnv(j_vm, (void **)&jvmdi_interface, \
+ JVMDI_VERSION_1)):0)
+#endif
+
+#define JVMDI_SetEventHook(a_env, a1) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->SetEventHook(a1) )
+#define JVMDI_GetThreadStatus(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetThreadStatus(a1, a2, a3) )
+#define JVMDI_GetAllThreads(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetAllThreads(a1, a2) )
+#define JVMDI_SuspendThread(a_env, a1) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->SuspendThread(a1) )
+#define JVMDI_ResumeThread(a_env, a1) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->ResumeThread(a1) )
+#define JVMDI_StopThread(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->StopThread(a1, a2) )
+#define JVMDI_InterruptThread(a_env, a1) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->InterruptThread(a1) )
+#define JVMDI_SetSingleStep(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->SetEventNotificationMode( \
+ (a2) ? JVMDI_ENABLE : JVMDI_DISABLE, \
+ JVMDI_EVENT_SINGLE_STEP, a1) )
+#define JVMDI_GetThreadInfo(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetThreadInfo(a1, a2) )
+#define JVMDI_RunDebugThread(a_env, a1, a2, a3, a4) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->RunDebugThread(a1, a2, a3, a4) )
+#define JVMDI_GetTopThreadGroups(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetTopThreadGroups(a1, a2) )
+#define JVMDI_GetThreadGroupInfo(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetThreadGroupInfo(a1, a2) )
+#define JVMDI_GetThreadGroupChildren(a_env, a1, a2, a3, a4, a5) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetThreadGroupChildren(a1, a2, a3, a4, a5) )
+#define JVMDI_GetCurrentFrame(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetCurrentFrame(a1, a2) )
+#define JVMDI_GetCallerFrame(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetCallerFrame(a1, a2) )
+#define JVMDI_GetFrameLocation(a_env, a1, a2, a3, a4) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetFrameLocation(a1, a2, a3, a4) )
+#define JVMDI_NotifyFramePop(a_env, a1) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->NotifyFramePop(a1) )
+#define JVMDI_GetLocalObject(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetLocalObject(a1, a2, a3) )
+#define JVMDI_GetLocalInt(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetLocalInt(a1, a2, a3) )
+#define JVMDI_GetLocalLong(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetLocalLong(a1, a2, a3) )
+#define JVMDI_GetLocalFloat(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetLocalFloat(a1, a2, a3) )
+#define JVMDI_GetLocalDouble(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetLocalDouble(a1, a2, a3) )
+#define JVMDI_SetLocalObject(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->SetLocalObject(a1, a2, a3) )
+#define JVMDI_SetLocalInt(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->SetLocalInt(a1, a2, a3) )
+#define JVMDI_SetLocalLong(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->SetLocalLong(a1, a2, a3) )
+#define JVMDI_SetLocalFloat(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->SetLocalFloat(a1, a2, a3) )
+#define JVMDI_SetLocalDouble(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->SetLocalDouble(a1, a2, a3) )
+#define JVMDI_CreateRawMonitor(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->CreateRawMonitor(a1, a2) )
+#define JVMDI_DestroyRawMonitor(a_env, a1) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->DestroyRawMonitor(a1) )
+#define JVMDI_RawMonitorEnter(a_env, a1) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->RawMonitorEnter(a1) )
+#define JVMDI_RawMonitorExit(a_env, a1) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->RawMonitorExit(a1) )
+#define JVMDI_RawMonitorWait(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->RawMonitorWait(a1, a2) )
+#define JVMDI_RawMonitorNotify(a_env, a1) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->RawMonitorNotify(a1) )
+#define JVMDI_RawMonitorNotifyAll(a_env, a1) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->RawMonitorNotifyAll(a1) )
+#define JVMDI_SetBreakpoint(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->SetBreakpoint(a1, a2, a3) )
+#define JVMDI_ClearBreakpoint(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->ClearBreakpoint(a1, a2, a3) )
+#define JVMDI_ClearAllBreakpoints(a_env) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->ClearAllBreakpoints() )
+#define JVMDI_SetAllocationHooks(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->SetAllocationHooks(a1, a2) )
+#define JVMDI_Allocate(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->Allocate(a1, a2) )
+#define JVMDI_Deallocate(a_env, a1) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->Deallocate(a1) )
+#define JVMDI_GetClassSignature(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetClassSignature(a1, a2) )
+#define JVMDI_GetClassStatus(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetClassStatus(a1, a2) )
+#define JVMDI_GetSourceFileName(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetSourceFileName(a1, a2) )
+#define JVMDI_GetClassModifiers(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetClassModifiers(a1, a2) )
+#define JVMDI_GetClassMethods(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetClassMethods(a1, a2, a3) )
+#define JVMDI_GetClassFields(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetClassFields(a1, a2, a3) )
+#define JVMDI_GetImplementedInterfaces(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetImplementedInterfaces(a1, a2, a3) )
+#define JVMDI_IsInterface(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->IsInterface(a1, a2) )
+#define JVMDI_IsArrayClass(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->IsArrayClass(a1, a2) )
+#define JVMDI_ClassLoader(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetClassLoader(a1, a2) )
+#define JVMDI_GetFieldName(a_env, a1, a2, a3, a4) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetFieldName(a1, a2, a3, a4) )
+#define JVMDI_GetFieldDeclaringClass(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetFieldDeclaringClass(a1, a2, a3) )
+#define JVMDI_GetFieldModifiers(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetFieldModifiers(a1, a2, a3) )
+#define JVMDI_GetMethodName(a_env, a1, a2, a3, a4) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetMethodName(a1, a2, a3, a4) )
+#define JVMDI_GetMethodDeclaringClass(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetMethodDeclaringClass(a1, a2, a3) )
+#define JVMDI_GetMethodModifiers(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetMethodModifiers(a1, a2, a3) )
+#define JVMDI_GetMaxStack(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetMaxStack(a1, a2, a3) )
+#define JVMDI_GetMaxLocals(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetMaxLocals(a1, a2, a3) )
+#define JVMDI_GetArgumentsSize(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetArgumentsSize(a1, a2, a3) )
+#define JVMDI_GetLineNumberTable(a_env, a1, a2, a3, a4) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetLineNumberTable(a1, a2, a3, a4) )
+#define JVMDI_GetMethodLocation(a_env, a1, a2, a3, a4) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetMethodLocation(a1, a2, a3, a4) )
+#define JVMDI_GetLocalVariableTable(a_env, a1, a2, a3, a4) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetLocalVariableTable(a1, a2, a3, a4) )
+#define JVMDI_GetExceptionHandlerTable(a_env, a1, a2, a3, a4) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetExceptionHandlerTable(a1, a2, a3, a4) )
+#define JVMDI_GetThrownExceptions(a_env, a1, a2, a3, a4) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetThrownExceptions(a1, a2, a3, a4) )
+#define JVMDI_GetBytecodes(a_env, a1, a2, a3, a4) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetBytecodes(a1, a2, a3, a4) )
+#define JVMDI_IsMethodNative(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->IsMethodNative(a1, a2, a3) )
+#define JVMDI_GetLoadedClasses(a_env, a1, a2) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetLoadedClasses(a1, a2) )
+#define JVMDI_GetClassLoaderClasses(a_env, a1, a2, a3) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetClassLoaderClasses(a1, a2, a3) )
+#define JVMDI_GetVersionNumber(a_env, a1) ( \
+ SetJVMDIfromJNIEnv(a_env), \
+ jvmdi_interface->GetVersionNumber(a1) )
+
+#endif /* !NO_JVMDI_MACROS */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif /* __cplusplus */
+
+#endif /* !_JAVASOFT_JVMDI_H_ */
+
+
diff --git a/applications/JavaOpenJPEG/java-jni/include/jvmpi.h b/applications/JavaOpenJPEG/java-jni/include/jvmpi.h new file mode 100644 index 00000000..557b231b --- /dev/null +++ b/applications/JavaOpenJPEG/java-jni/include/jvmpi.h @@ -0,0 +1,642 @@ +/*
+ * @(#)jvmpi.h 1.28 03/12/19
+ *
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+#ifndef _JAVASOFT_JVMPI_H_
+#define _JAVASOFT_JVMPI_H_
+
+#include "jni.h"
+
+#define JVMPI_VERSION_1 ((jint)0x10000001) /* implied 0 for minor version */
+#define JVMPI_VERSION_1_1 ((jint)0x10000002)
+#define JVMPI_VERSION_1_2 ((jint)0x10000003)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ typedef void (*jvmpi_void_function_of_void)(void *);
+#ifdef __cplusplus
+}
+#endif
+
+/****************************************************************
+ * Profiler interface data structures.
+ ****************************************************************/
+/* identifier types. */
+struct _jobjectID;
+typedef struct _jobjectID * jobjectID; /* type of object ids */
+
+/* raw monitors */
+struct _JVMPI_RawMonitor;
+typedef struct _JVMPI_RawMonitor * JVMPI_RawMonitor;
+
+/* call frame */
+typedef struct {
+ jint lineno; /* line number in the source file */
+ jmethodID method_id; /* method executed in this frame */
+} JVMPI_CallFrame;
+
+/* call trace */
+typedef struct {
+ JNIEnv *env_id; /* Env where trace was recorded */
+ jint num_frames; /* number of frames in this trace */
+ JVMPI_CallFrame *frames; /* frames */
+} JVMPI_CallTrace;
+
+/* method */
+typedef struct {
+ char *method_name; /* name of method */
+ char *method_signature; /* signature of method */
+ jint start_lineno; /* -1 if native, abstract .. */
+ jint end_lineno; /* -1 if native, abstract .. */
+ jmethodID method_id; /* id assigned to this method */
+} JVMPI_Method;
+
+/* Field */
+typedef struct {
+ char *field_name; /* name of field */
+ char *field_signature; /* signature of field */
+} JVMPI_Field;
+
+/* line number info for a compiled method */
+typedef struct {
+ jint offset; /* offset from beginning of method */
+ jint lineno; /* lineno from beginning of src file */
+} JVMPI_Lineno;
+
+/* event */
+typedef struct {
+ jint event_type; /* event_type */
+ JNIEnv *env_id; /* env where this event occured */
+
+ union {
+ struct {
+ const char *class_name; /* class name */
+ char *source_name; /* name of source file */
+ jint num_interfaces; /* number of interfaces implemented */
+ jint num_methods; /* number of methods in the class */
+ JVMPI_Method *methods; /* methods */
+ jint num_static_fields; /* number of static fields */
+ JVMPI_Field *statics; /* static fields */
+ jint num_instance_fields; /* number of instance fields */
+ JVMPI_Field *instances; /* instance fields */
+ jobjectID class_id; /* id of the class object */
+ } class_load;
+
+ struct {
+ jobjectID class_id; /* id of the class object */
+ } class_unload;
+
+ struct {
+ unsigned char *class_data; /* content of class file */
+ jint class_data_len; /* class file length */
+ unsigned char *new_class_data; /* instrumented class file */
+ jint new_class_data_len; /* new class file length */
+ void * (*malloc_f)(unsigned int); /* memory allocation function */
+ } class_load_hook;
+
+ struct {
+ jint arena_id;
+ jobjectID class_id; /* id of object class */
+ jint is_array; /* JVMPI_NORMAL_OBJECT, ... */
+ jint size; /* size in number of bytes */
+ jobjectID obj_id; /* id assigned to this object */
+ } obj_alloc;
+
+ struct {
+ jobjectID obj_id; /* id of the object */
+ } obj_free;
+
+ struct {
+ jint arena_id; /* cur arena id */
+ jobjectID obj_id; /* cur object id */
+ jint new_arena_id; /* new arena id */
+ jobjectID new_obj_id; /* new object id */
+ } obj_move;
+
+ struct {
+ jint arena_id; /* id of arena */
+ const char *arena_name; /* name of arena */
+ } new_arena;
+
+ struct {
+ jint arena_id; /* id of arena */
+ } delete_arena;
+
+ struct {
+ char *thread_name; /* name of thread */
+ char *group_name; /* name of group */
+ char *parent_name; /* name of parent */
+ jobjectID thread_id; /* id of the thread object */
+ JNIEnv *thread_env_id;
+ } thread_start;
+
+ struct {
+ int dump_level; /* level of the heap dump info */
+ char *begin; /* where all the root records begin,
+ please see the heap dump buffer
+ format described below */
+ char *end; /* where the object records end. */
+ jint num_traces; /* number of thread traces,
+ 0 if dump level = JVMPI_DUMP_LEVEL_0 */
+ JVMPI_CallTrace *traces; /* thread traces collected during
+ heap dump */
+ } heap_dump;
+
+ struct {
+ jobjectID obj_id; /* object id */
+ jobject ref_id; /* id assigned to the globalref */
+ } jni_globalref_alloc;
+
+ struct {
+ jobject ref_id; /* id of the global ref */
+ } jni_globalref_free;
+
+ struct {
+ jmethodID method_id; /* method */
+ } method;
+
+ struct {
+ jmethodID method_id; /* id of method */
+ jobjectID obj_id; /* id of target object */
+ } method_entry2;
+
+ struct {
+ jmethodID method_id; /* id of compiled method */
+ void *code_addr; /* code start addr. in memory */
+ jint code_size; /* code size */
+ jint lineno_table_size; /* size of lineno table */
+ JVMPI_Lineno *lineno_table; /* lineno info */
+ } compiled_method_load;
+
+ struct {
+ jmethodID method_id; /* id of unloaded compiled method */
+ } compiled_method_unload;
+
+ struct {
+ jmethodID method_id; /* id of the method the instruction belongs to */
+ jint offset; /* instruction offset in the method's bytecode */
+ union {
+ struct {
+ jboolean is_true; /* whether true or false branch is taken */
+ } if_info;
+ struct {
+ jint key; /* top stack value used as an index */
+ jint low; /* min value of the index */
+ jint hi; /* max value of the index */
+ } tableswitch_info;
+ struct {
+ jint chosen_pair_index; /* actually chosen pair index (0-based)
+ * if chosen_pair_index == pairs_total then
+ * the 'default' branch is taken
+ */
+ jint pairs_total; /* total number of lookupswitch pairs */
+ } lookupswitch_info;
+ } u;
+ } instruction;
+
+ struct {
+ char *begin; /* beginning of dump buffer,
+ see below for format */
+ char *end; /* end of dump buffer */
+ jint num_traces; /* number of traces */
+ JVMPI_CallTrace *traces; /* traces of all threads */
+ jint *threads_status; /* status of all threads */
+ } monitor_dump;
+
+ struct {
+ const char *name; /* name of raw monitor */
+ JVMPI_RawMonitor id; /* id */
+ } raw_monitor;
+
+ struct {
+ jobjectID object; /* Java object */
+ } monitor;
+
+ struct {
+ jobjectID object; /* Java object */
+ jlong timeout; /* timeout period */
+ } monitor_wait;
+
+ struct {
+ jlong used_objects;
+ jlong used_object_space;
+ jlong total_object_space;
+ } gc_info;
+
+ struct {
+ jint data_len;
+ char *data;
+ } object_dump;
+ } u;
+} JVMPI_Event;
+
+/* interface functions */
+typedef struct {
+ jint version; /* JVMPI version */
+
+ /* ------interface implemented by the profiler------ */
+
+ /**
+ * Function called by the JVM to notify an event.
+ */
+ void (*NotifyEvent)(JVMPI_Event *event);
+
+ /* ------interface implemented by the JVM------ */
+
+ /**
+ * Function called by the profiler to enable/disable/send notification
+ * for a particular event type.
+ *
+ * event_type - event_type
+ * arg - event specific arg
+ *
+ * return JVMPI_NOT_AVAILABLE, JVMPI_SUCCESS or JVMPI_FAIL
+ */
+ jint (*EnableEvent)(jint event_type, void *arg);
+ jint (*DisableEvent)(jint event_type, void *arg);
+ jint (*RequestEvent)(jint event_type, void *arg);
+
+ /**
+ * Function called by the profiler to get a stack
+ * trace from the JVM.
+ *
+ * trace - trace data structure to be filled
+ * depth - maximum depth of the trace.
+ */
+ void (*GetCallTrace)(JVMPI_CallTrace *trace, jint depth);
+
+ /**
+ * Function called by profiler when it wants to exit/stop.
+ */
+ void (*ProfilerExit)(jint);
+
+ /**
+ * Utility functions provided by the JVM.
+ */
+ JVMPI_RawMonitor (*RawMonitorCreate)(char *lock_name);
+ void (*RawMonitorEnter)(JVMPI_RawMonitor lock_id);
+ void (*RawMonitorExit)(JVMPI_RawMonitor lock_id);
+ void (*RawMonitorWait)(JVMPI_RawMonitor lock_id, jlong ms);
+ void (*RawMonitorNotifyAll)(JVMPI_RawMonitor lock_id);
+ void (*RawMonitorDestroy)(JVMPI_RawMonitor lock_id);
+
+ /**
+ * Function called by the profiler to get the current thread's CPU time.
+ *
+ * return time in nanoseconds;
+ */
+ jlong (*GetCurrentThreadCpuTime)(void);
+
+ void (*SuspendThread)(JNIEnv *env);
+ void (*ResumeThread)(JNIEnv *env);
+ jint (*GetThreadStatus)(JNIEnv *env);
+ jboolean (*ThreadHasRun)(JNIEnv *env);
+
+ /* This function can be called safely only after JVMPI_EVENT_VM_INIT_DONE
+ notification by the JVM. */
+ jint (*CreateSystemThread)(char *name, jint priority, void (*f)(void *));
+
+ /* thread local storage access functions to avoid locking in time
+ critical functions */
+ void (*SetThreadLocalStorage)(JNIEnv *env_id, void *ptr);
+ void * (*GetThreadLocalStorage)(JNIEnv *env_id);
+
+ /* control GC */
+ void (*DisableGC)(void);
+ void (*EnableGC)(void);
+ void (*RunGC)(void);
+
+ jobjectID (*GetThreadObject)(JNIEnv *env);
+ jobjectID (*GetMethodClass)(jmethodID mid);
+
+ /* JNI <-> jobject conversions */
+ jobject (*jobjectID2jobject)(jobjectID jid);
+ jobjectID (*jobject2jobjectID)(jobject jobj);
+
+ void (*SuspendThreadList)
+ (jint reqCount, JNIEnv **reqList, jint *results);
+ void (*ResumeThreadList)
+ (jint reqCount, JNIEnv **reqList, jint *results);
+} JVMPI_Interface;
+
+/* type of argument passed to RequestEvent for heap dumps */
+typedef struct {
+ jint heap_dump_level;
+} JVMPI_HeapDumpArg;
+
+/**********************************************************************
+ * Constants and formats used in JVM Profiler Interface.
+ **********************************************************************/
+/*
+ * Event type constants.
+ */
+#define JVMPI_EVENT_METHOD_ENTRY ((jint)1)
+#define JVMPI_EVENT_METHOD_ENTRY2 ((jint)2)
+#define JVMPI_EVENT_METHOD_EXIT ((jint)3)
+
+#define JVMPI_EVENT_OBJECT_ALLOC ((jint)4)
+#define JVMPI_EVENT_OBJECT_FREE ((jint)5)
+#define JVMPI_EVENT_OBJECT_MOVE ((jint)6)
+
+#define JVMPI_EVENT_COMPILED_METHOD_LOAD ((jint)7)
+#define JVMPI_EVENT_COMPILED_METHOD_UNLOAD ((jint)8)
+
+#define JVMPI_EVENT_INSTRUCTION_START ((jint)9)
+
+#define JVMPI_EVENT_THREAD_START ((jint)33)
+#define JVMPI_EVENT_THREAD_END ((jint)34)
+
+#define JVMPI_EVENT_CLASS_LOAD_HOOK ((jint)35)
+
+#define JVMPI_EVENT_HEAP_DUMP ((jint)37)
+#define JVMPI_EVENT_JNI_GLOBALREF_ALLOC ((jint)38)
+#define JVMPI_EVENT_JNI_GLOBALREF_FREE ((jint)39)
+#define JVMPI_EVENT_JNI_WEAK_GLOBALREF_ALLOC ((jint)40)
+#define JVMPI_EVENT_JNI_WEAK_GLOBALREF_FREE ((jint)41)
+#define JVMPI_EVENT_CLASS_LOAD ((jint)42)
+#define JVMPI_EVENT_CLASS_UNLOAD ((jint)43)
+#define JVMPI_EVENT_DATA_DUMP_REQUEST ((jint)44)
+#define JVMPI_EVENT_DATA_RESET_REQUEST ((jint)45)
+
+#define JVMPI_EVENT_JVM_INIT_DONE ((jint)46)
+#define JVMPI_EVENT_JVM_SHUT_DOWN ((jint)47)
+
+#define JVMPI_EVENT_ARENA_NEW ((jint)48)
+#define JVMPI_EVENT_ARENA_DELETE ((jint)49)
+
+#define JVMPI_EVENT_OBJECT_DUMP ((jint)50)
+
+#define JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTER ((jint)51)
+#define JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTERED ((jint)52)
+#define JVMPI_EVENT_RAW_MONITOR_CONTENDED_EXIT ((jint)53)
+#define JVMPI_EVENT_MONITOR_CONTENDED_ENTER ((jint)54)
+#define JVMPI_EVENT_MONITOR_CONTENDED_ENTERED ((jint)55)
+#define JVMPI_EVENT_MONITOR_CONTENDED_EXIT ((jint)56)
+#define JVMPI_EVENT_MONITOR_WAIT ((jint)57)
+#define JVMPI_EVENT_MONITOR_WAITED ((jint)58)
+#define JVMPI_EVENT_MONITOR_DUMP ((jint)59)
+
+#define JVMPI_EVENT_GC_START ((jint)60)
+#define JVMPI_EVENT_GC_FINISH ((jint)61)
+
+#define JVMPI_MAX_EVENT_TYPE_VAL ((jint)61)
+
+/* old definitions, to be removed */
+#define JVMPI_EVENT_LOAD_COMPILED_METHOD ((jint)7)
+#define JVMPI_EVENT_UNLOAD_COMPILED_METHOD ((jint)8)
+#define JVMPI_EVENT_NEW_ARENA ((jint)48)
+#define JVMPI_EVENT_DELETE_ARENA ((jint)49)
+#define JVMPI_EVENT_DUMP_DATA_REQUEST ((jint)44)
+#define JVMPI_EVENT_RESET_DATA_REQUEST ((jint)45)
+#define JVMPI_EVENT_OBJ_ALLOC ((jint)4)
+#define JVMPI_EVENT_OBJ_FREE ((jint)5)
+#define JVMPI_EVENT_OBJ_MOVE ((jint)6)
+
+#define JVMPI_REQUESTED_EVENT ((jint)0x10000000)
+
+
+
+/*
+ * enabling/disabling event notification.
+ */
+/* results */
+#define JVMPI_SUCCESS ((jint)0)
+#define JVMPI_NOT_AVAILABLE ((jint)1)
+#define JVMPI_FAIL ((jint)-1)
+
+/*
+ * Thread status
+ */
+enum {
+ JVMPI_THREAD_RUNNABLE = 1,
+ JVMPI_THREAD_MONITOR_WAIT,
+ JVMPI_THREAD_CONDVAR_WAIT
+};
+
+#define JVMPI_THREAD_SUSPENDED 0x8000
+#define JVMPI_THREAD_INTERRUPTED 0x4000
+
+/*
+ * Thread priority
+ */
+#define JVMPI_MINIMUM_PRIORITY 1
+#define JVMPI_MAXIMUM_PRIORITY 10
+#define JVMPI_NORMAL_PRIORITY 5
+
+/*
+ * Object type constants.
+ */
+#define JVMPI_NORMAL_OBJECT ((jint)0)
+#define JVMPI_CLASS ((jint)2)
+#define JVMPI_BOOLEAN ((jint)4)
+#define JVMPI_CHAR ((jint)5)
+#define JVMPI_FLOAT ((jint)6)
+#define JVMPI_DOUBLE ((jint)7)
+#define JVMPI_BYTE ((jint)8)
+#define JVMPI_SHORT ((jint)9)
+#define JVMPI_INT ((jint)10)
+#define JVMPI_LONG ((jint)11)
+
+/*
+ * Monitor dump constants.
+ */
+
+#define JVMPI_MONITOR_JAVA 0x01
+#define JVMPI_MONITOR_RAW 0x02
+
+/*
+ * Heap dump constants.
+ */
+#define JVMPI_GC_ROOT_UNKNOWN 0xff
+#define JVMPI_GC_ROOT_JNI_GLOBAL 0x01
+#define JVMPI_GC_ROOT_JNI_LOCAL 0x02
+#define JVMPI_GC_ROOT_JAVA_FRAME 0x03
+#define JVMPI_GC_ROOT_NATIVE_STACK 0x04
+#define JVMPI_GC_ROOT_STICKY_CLASS 0x05
+#define JVMPI_GC_ROOT_THREAD_BLOCK 0x06
+#define JVMPI_GC_ROOT_MONITOR_USED 0x07
+#define JVMPI_GC_ROOT_THREAD_OBJ 0x08
+
+#define JVMPI_GC_CLASS_DUMP 0x20
+#define JVMPI_GC_INSTANCE_DUMP 0x21
+#define JVMPI_GC_OBJ_ARRAY_DUMP 0x22
+#define JVMPI_GC_PRIM_ARRAY_DUMP 0x23
+
+/*
+ * Dump levels
+ */
+#define JVMPI_DUMP_LEVEL_0 ((jint)0)
+#define JVMPI_DUMP_LEVEL_1 ((jint)1)
+#define JVMPI_DUMP_LEVEL_2 ((jint)2)
+
+/* Types used in dumps -
+ *
+ * u1: 1 byte
+ * u2: 2 bytes
+ * u4: 4 bytes
+ * u8: 8 bytes
+ *
+ * ty: u1 where:
+ * JVMPI_CLASS: object
+ * JVMPI_BOOLEAN: boolean
+ * JVMPI_CHAR: char
+ * JVMPI_FLOAT: float
+ * JVMPI_DOUBLE: double
+ * JVMPI_BYTE: byte
+ * JVMPI_SHORT: short
+ * JVMPI_INT: int
+ * JVMPI_LONG: long
+ *
+ * vl: values, exact type depends on the type of the value:
+ * JVMPI_BOOLEAN & JVMPI_BYTE: u1
+ * JVMPI_SHORT & JVMPI_CHAR: u2
+ * JVMPI_INT & JVMPI_FLOAT: u4
+ * JVMPI_LONG & JVMPI_DOUBLE: u8
+ * JVMPI_CLASS: jobjectID
+ */
+
+/* Format of the monitor dump buffer:
+ *
+ * u1 monitor type
+ *
+ * JVMPI_MONITOR_JAVA Java monitor
+ *
+ * jobjectID object
+ * JNIEnv * owner thread
+ * u4 entry count
+ * u4 # of threads waiting to enter
+ * [JNIEnv *]* threads waiting to enter
+ * u4 # of threads waiting to be notified
+ * [JNIEnv *]* threads waiting to be notified
+ *
+ * JVMPI_MONITOR_RAW raw monitor
+ *
+ * char * name
+ * JVMPI_RawMonitor raw monitor
+ * JNIEnv * owner thread
+ * u4 entry count
+ * u4 # of threads waiting to enter
+ * [JNIEnv *]* threads waiting to enter
+ * u4 # of threads waiting to be notified
+ * [JNIEnv *]* threads waiting to be notified
+ */
+
+/* Format of the heap dump buffer depends on the dump level
+ * specified in the JVMPI_HeapDumpArg passed to RequestEvent as arg.
+ * The default is JVMPI_DUMP_LEVEL_2.
+ *
+ * JVMPI_DUMP_LEVEL_0:
+ *
+ * u1 object type (JVMPI_CLASS ...)
+ * jobjectID object
+ *
+ * JVMPI_DUMP_LEVEL_1 and JVMPI_DUMP_LEVEL_2 use the following format:
+ * In the case of JVMPI_DUMP_LEVEL_1 the values of primitive fields in object
+ * instance dumps , the values of primitive statics in class dumps and the
+ * values of primitive arrays are excluded. JVMPI_DUMP_LEVEL_2 includes the
+ * primitive values.
+ *
+ * u1 record type
+ *
+ * JVMPI_GC_ROOT_UNKNOWN unknown root
+ *
+ * jobjectID object
+ *
+ * JVMPI_GC_ROOT_JNI_GLOBAL JNI global ref root
+ *
+ * jobjectID object
+ * jobject JNI global reference
+ *
+ * JVMPI_GC_ROOT_JNI_LOCAL JNI local ref
+ *
+ * jobjectID object
+ * JNIEnv * thread
+ * u4 frame # in stack trace (-1 for empty)
+ *
+ * JVMPI_GC_ROOT_JAVA_FRAME Java stack frame
+ *
+ * jobjectID object
+ * JNIEnv * thread
+ * u4 frame # in stack trace (-1 for empty)
+ *
+ * JVMPI_GC_ROOT_NATIVE_STACK Native stack
+ *
+ * jobjectID object
+ * JNIEnv * thread
+ *
+ * JVMPI_GC_ROOT_STICKY_CLASS System class
+ *
+ * jobjectID class object
+ *
+ * JVMPI_GC_ROOT_THREAD_BLOCK Reference from thread block
+ *
+ * jobjectID thread object
+ * JNIEnv * thread
+ *
+ * JVMPI_GC_ROOT_MONITOR_USED Busy monitor
+ *
+ * jobjectID object
+ *
+ * JVMPI_GC_CLASS_DUMP dump of a class object
+ *
+ * jobjectID class
+ * jobjectID super
+ * jobjectID class loader
+ * jobjectID signers
+ * jobjectID protection domain
+ * jobjectID class name
+ * void * reserved
+ *
+ * u4 instance size (in bytes)
+ *
+ * [jobjectID]* interfaces
+ *
+ * u2 size of constant pool
+ * [u2, constant pool index,
+ * ty, type,
+ * vl]* value
+ *
+ * [vl]* static field values
+ *
+ * JVMPI_GC_INSTANCE_DUMP dump of a normal object
+ *
+ * jobjectID object
+ * jobjectID class
+ * u4 number of bytes that follow
+ * [vl]* instance field values (class, followed
+ * by super, super's super ...)
+ *
+ * JVMPI_GC_OBJ_ARRAY_DUMP dump of an object array
+ *
+ * jobjectID array object
+ * u4 number of elements
+ * jobjectID element class
+ * [jobjectID]* elements
+ *
+ * JVMPI_GC_PRIM_ARRAY_DUMP dump of a primitive array
+ *
+ * jobjectID array object
+ * u4 number of elements
+ * ty element type
+ * [vl]* elements
+ *
+ */
+
+/* Format of the dump received in JVMPI_EVENT_OBJECT_DUMP:
+ * All the records have JVMPI_DUMP_LEVEL_2 information.
+ *
+ * u1 record type
+ *
+ * followed by a:
+ *
+ * JVMPI_GC_CLASS_DUMP,
+ * JVMPI_GC_INSTANCE_DUMP,
+ * JVMPI_GC_OBJ_ARRAY_DUMP, or
+ * JVMPI_GC_PRIM_ARRAY_DUMP record.
+ */
+
+#endif /* !_JAVASOFT_JVMPI_H_ */
diff --git a/applications/JavaOpenJPEG/java-jni/include/jvmti.h b/applications/JavaOpenJPEG/java-jni/include/jvmti.h new file mode 100644 index 00000000..de24e3e9 --- /dev/null +++ b/applications/JavaOpenJPEG/java-jni/include/jvmti.h @@ -0,0 +1,2181 @@ +#ifdef USE_PRAGMA_IDENT_HDR
+#pragma ident "@(#)jvmtiLib.xsl 1.32 04/06/01 20:19:53 JVM"
+#endif
+/*
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+ /* AUTOMATICALLY GENERATED FILE - DO NOT EDIT */
+
+
+ /* Include file for the Java(tm) Virtual Machine Tool Interface */
+
+#ifndef _JAVA_JVMTI_H_
+#define _JAVA_JVMTI_H_
+
+#include "jni.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ JVMTI_VERSION_1 = 0x30010000,
+ JVMTI_VERSION_1_0 = 0x30010000,
+
+ JVMTI_VERSION = 0x30000000 + (1 * 0x10000) + (0 * 0x100) + 33 /* version: 1.0.33 */
+};
+
+JNIEXPORT jint JNICALL
+Agent_OnLoad(JavaVM *vm, char *options, void *reserved);
+
+JNIEXPORT void JNICALL
+Agent_OnUnload(JavaVM *vm);
+
+ /* Forward declaration of the environment */
+
+struct _jvmtiEnv;
+
+struct jvmtiInterface_1_;
+
+#ifdef __cplusplus
+typedef _jvmtiEnv jvmtiEnv;
+#else
+typedef const struct jvmtiInterface_1_ *jvmtiEnv;
+#endif /* __cplusplus */
+
+/* Derived Base Types */
+
+typedef jobject jthread;
+typedef jobject jthreadGroup;
+typedef jlong jlocation;
+struct _jrawMonitorID;
+typedef struct _jrawMonitorID *jrawMonitorID;
+typedef struct JNINativeInterface_ jniNativeInterface;
+
+ /* Constants */
+
+
+ /* Thread State Flags */
+
+enum {
+ JVMTI_THREAD_STATE_ALIVE = 0x0001,
+ JVMTI_THREAD_STATE_TERMINATED = 0x0002,
+ JVMTI_THREAD_STATE_RUNNABLE = 0x0004,
+ JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER = 0x0400,
+ JVMTI_THREAD_STATE_WAITING = 0x0080,
+ JVMTI_THREAD_STATE_WAITING_INDEFINITELY = 0x0010,
+ JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT = 0x0020,
+ JVMTI_THREAD_STATE_SLEEPING = 0x0040,
+ JVMTI_THREAD_STATE_IN_OBJECT_WAIT = 0x0100,
+ JVMTI_THREAD_STATE_PARKED = 0x0200,
+ JVMTI_THREAD_STATE_SUSPENDED = 0x100000,
+ JVMTI_THREAD_STATE_INTERRUPTED = 0x200000,
+ JVMTI_THREAD_STATE_IN_NATIVE = 0x400000,
+ JVMTI_THREAD_STATE_VENDOR_1 = 0x10000000,
+ JVMTI_THREAD_STATE_VENDOR_2 = 0x20000000,
+ JVMTI_THREAD_STATE_VENDOR_3 = 0x40000000
+};
+
+ /* java.lang.Thread.State Conversion Masks */
+
+enum {
+ JVMTI_JAVA_LANG_THREAD_STATE_MASK = JVMTI_THREAD_STATE_TERMINATED | JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_RUNNABLE | JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER | JVMTI_THREAD_STATE_WAITING | JVMTI_THREAD_STATE_WAITING_INDEFINITELY | JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT,
+ JVMTI_JAVA_LANG_THREAD_STATE_NEW = 0,
+ JVMTI_JAVA_LANG_THREAD_STATE_TERMINATED = JVMTI_THREAD_STATE_TERMINATED,
+ JVMTI_JAVA_LANG_THREAD_STATE_RUNNABLE = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_RUNNABLE,
+ JVMTI_JAVA_LANG_THREAD_STATE_BLOCKED = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER,
+ JVMTI_JAVA_LANG_THREAD_STATE_WAITING = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_WAITING | JVMTI_THREAD_STATE_WAITING_INDEFINITELY,
+ JVMTI_JAVA_LANG_THREAD_STATE_TIMED_WAITING = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_WAITING | JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT
+};
+
+ /* Thread Priority Constants */
+
+enum {
+ JVMTI_THREAD_MIN_PRIORITY = 1,
+ JVMTI_THREAD_NORM_PRIORITY = 5,
+ JVMTI_THREAD_MAX_PRIORITY = 10
+};
+
+ /* Heap Object Filter Enumeration */
+
+typedef enum {
+ JVMTI_HEAP_OBJECT_TAGGED = 1,
+ JVMTI_HEAP_OBJECT_UNTAGGED = 2,
+ JVMTI_HEAP_OBJECT_EITHER = 3
+} jvmtiHeapObjectFilter;
+
+ /* Heap Root Kind Enumeration */
+
+typedef enum {
+ JVMTI_HEAP_ROOT_JNI_GLOBAL = 1,
+ JVMTI_HEAP_ROOT_SYSTEM_CLASS = 2,
+ JVMTI_HEAP_ROOT_MONITOR = 3,
+ JVMTI_HEAP_ROOT_STACK_LOCAL = 4,
+ JVMTI_HEAP_ROOT_JNI_LOCAL = 5,
+ JVMTI_HEAP_ROOT_THREAD = 6,
+ JVMTI_HEAP_ROOT_OTHER = 7
+} jvmtiHeapRootKind;
+
+ /* Object Reference Enumeration */
+
+typedef enum {
+ JVMTI_REFERENCE_CLASS = 1,
+ JVMTI_REFERENCE_FIELD = 2,
+ JVMTI_REFERENCE_ARRAY_ELEMENT = 3,
+ JVMTI_REFERENCE_CLASS_LOADER = 4,
+ JVMTI_REFERENCE_SIGNERS = 5,
+ JVMTI_REFERENCE_PROTECTION_DOMAIN = 6,
+ JVMTI_REFERENCE_INTERFACE = 7,
+ JVMTI_REFERENCE_STATIC_FIELD = 8,
+ JVMTI_REFERENCE_CONSTANT_POOL = 9
+} jvmtiObjectReferenceKind;
+
+ /* Iteration Control Enumeration */
+
+typedef enum {
+ JVMTI_ITERATION_CONTINUE = 1,
+ JVMTI_ITERATION_IGNORE = 2,
+ JVMTI_ITERATION_ABORT = 0
+} jvmtiIterationControl;
+
+ /* Class Status Flags */
+
+enum {
+ JVMTI_CLASS_STATUS_VERIFIED = 1,
+ JVMTI_CLASS_STATUS_PREPARED = 2,
+ JVMTI_CLASS_STATUS_INITIALIZED = 4,
+ JVMTI_CLASS_STATUS_ERROR = 8,
+ JVMTI_CLASS_STATUS_ARRAY = 16,
+ JVMTI_CLASS_STATUS_PRIMITIVE = 32
+};
+
+ /* Event Enable/Disable */
+
+typedef enum {
+ JVMTI_ENABLE = 1,
+ JVMTI_DISABLE = 0
+} jvmtiEventMode;
+
+ /* Extension Function/Event Parameter Types */
+
+typedef enum {
+ JVMTI_TYPE_JBYTE = 101,
+ JVMTI_TYPE_JCHAR = 102,
+ JVMTI_TYPE_JSHORT = 103,
+ JVMTI_TYPE_JINT = 104,
+ JVMTI_TYPE_JLONG = 105,
+ JVMTI_TYPE_JFLOAT = 106,
+ JVMTI_TYPE_JDOUBLE = 107,
+ JVMTI_TYPE_JBOOLEAN = 108,
+ JVMTI_TYPE_JOBJECT = 109,
+ JVMTI_TYPE_JTHREAD = 110,
+ JVMTI_TYPE_JCLASS = 111,
+ JVMTI_TYPE_JVALUE = 112,
+ JVMTI_TYPE_JFIELDID = 113,
+ JVMTI_TYPE_JMETHODID = 114,
+ JVMTI_TYPE_CCHAR = 115,
+ JVMTI_TYPE_CVOID = 116,
+ JVMTI_TYPE_JNIENV = 117
+} jvmtiParamTypes;
+
+ /* Extension Function/Event Parameter Kinds */
+
+typedef enum {
+ JVMTI_KIND_IN = 91,
+ JVMTI_KIND_IN_PTR = 92,
+ JVMTI_KIND_IN_BUF = 93,
+ JVMTI_KIND_ALLOC_BUF = 94,
+ JVMTI_KIND_ALLOC_ALLOC_BUF = 95,
+ JVMTI_KIND_OUT = 96,
+ JVMTI_KIND_OUT_BUF = 97
+} jvmtiParamKind;
+
+ /* Timer Kinds */
+
+typedef enum {
+ JVMTI_TIMER_USER_CPU = 30,
+ JVMTI_TIMER_TOTAL_CPU = 31,
+ JVMTI_TIMER_ELAPSED = 32
+} jvmtiTimerKind;
+
+ /* Phases of execution */
+
+typedef enum {
+ JVMTI_PHASE_ONLOAD = 1,
+ JVMTI_PHASE_PRIMORDIAL = 2,
+ JVMTI_PHASE_START = 6,
+ JVMTI_PHASE_LIVE = 4,
+ JVMTI_PHASE_DEAD = 8
+} jvmtiPhase;
+
+ /* Version Interface Types */
+
+enum {
+ JVMTI_VERSION_INTERFACE_JNI = 0x00000000,
+ JVMTI_VERSION_INTERFACE_JVMTI = 0x30000000
+};
+
+ /* Version Masks */
+
+enum {
+ JVMTI_VERSION_MASK_INTERFACE_TYPE = 0x70000000,
+ JVMTI_VERSION_MASK_MAJOR = 0x0FFF0000,
+ JVMTI_VERSION_MASK_MINOR = 0x0000FF00,
+ JVMTI_VERSION_MASK_MICRO = 0x000000FF
+};
+
+ /* Version Shifts */
+
+enum {
+ JVMTI_VERSION_SHIFT_MAJOR = 16,
+ JVMTI_VERSION_SHIFT_MINOR = 8,
+ JVMTI_VERSION_SHIFT_MICRO = 0
+};
+
+ /* Verbose Flag Enumeration */
+
+typedef enum {
+ JVMTI_VERBOSE_OTHER = 0,
+ JVMTI_VERBOSE_GC = 1,
+ JVMTI_VERBOSE_CLASS = 2,
+ JVMTI_VERBOSE_JNI = 4
+} jvmtiVerboseFlag;
+
+ /* JLocation Format Enumeration */
+
+typedef enum {
+ JVMTI_JLOCATION_JVMBCI = 1,
+ JVMTI_JLOCATION_MACHINEPC = 2,
+ JVMTI_JLOCATION_OTHER = 0
+} jvmtiJlocationFormat;
+
+ /* Errors */
+
+typedef enum {
+ JVMTI_ERROR_NONE = 0,
+ JVMTI_ERROR_INVALID_THREAD = 10,
+ JVMTI_ERROR_INVALID_THREAD_GROUP = 11,
+ JVMTI_ERROR_INVALID_PRIORITY = 12,
+ JVMTI_ERROR_THREAD_NOT_SUSPENDED = 13,
+ JVMTI_ERROR_THREAD_SUSPENDED = 14,
+ JVMTI_ERROR_THREAD_NOT_ALIVE = 15,
+ JVMTI_ERROR_INVALID_OBJECT = 20,
+ JVMTI_ERROR_INVALID_CLASS = 21,
+ JVMTI_ERROR_CLASS_NOT_PREPARED = 22,
+ JVMTI_ERROR_INVALID_METHODID = 23,
+ JVMTI_ERROR_INVALID_LOCATION = 24,
+ JVMTI_ERROR_INVALID_FIELDID = 25,
+ JVMTI_ERROR_NO_MORE_FRAMES = 31,
+ JVMTI_ERROR_OPAQUE_FRAME = 32,
+ JVMTI_ERROR_TYPE_MISMATCH = 34,
+ JVMTI_ERROR_INVALID_SLOT = 35,
+ JVMTI_ERROR_DUPLICATE = 40,
+ JVMTI_ERROR_NOT_FOUND = 41,
+ JVMTI_ERROR_INVALID_MONITOR = 50,
+ JVMTI_ERROR_NOT_MONITOR_OWNER = 51,
+ JVMTI_ERROR_INTERRUPT = 52,
+ JVMTI_ERROR_INVALID_CLASS_FORMAT = 60,
+ JVMTI_ERROR_CIRCULAR_CLASS_DEFINITION = 61,
+ JVMTI_ERROR_FAILS_VERIFICATION = 62,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_ADDED = 63,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED = 64,
+ JVMTI_ERROR_INVALID_TYPESTATE = 65,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED = 66,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_DELETED = 67,
+ JVMTI_ERROR_UNSUPPORTED_VERSION = 68,
+ JVMTI_ERROR_NAMES_DONT_MATCH = 69,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED = 70,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED = 71,
+ JVMTI_ERROR_UNMODIFIABLE_CLASS = 79,
+ JVMTI_ERROR_NOT_AVAILABLE = 98,
+ JVMTI_ERROR_MUST_POSSESS_CAPABILITY = 99,
+ JVMTI_ERROR_NULL_POINTER = 100,
+ JVMTI_ERROR_ABSENT_INFORMATION = 101,
+ JVMTI_ERROR_INVALID_EVENT_TYPE = 102,
+ JVMTI_ERROR_ILLEGAL_ARGUMENT = 103,
+ JVMTI_ERROR_NATIVE_METHOD = 104,
+ JVMTI_ERROR_OUT_OF_MEMORY = 110,
+ JVMTI_ERROR_ACCESS_DENIED = 111,
+ JVMTI_ERROR_WRONG_PHASE = 112,
+ JVMTI_ERROR_INTERNAL = 113,
+ JVMTI_ERROR_UNATTACHED_THREAD = 115,
+ JVMTI_ERROR_INVALID_ENVIRONMENT = 116,
+ JVMTI_ERROR_MAX = 116
+} jvmtiError;
+
+ /* Event IDs */
+
+typedef enum {
+ JVMTI_MIN_EVENT_TYPE_VAL = 50,
+ JVMTI_EVENT_VM_INIT = 50,
+ JVMTI_EVENT_VM_DEATH = 51,
+ JVMTI_EVENT_THREAD_START = 52,
+ JVMTI_EVENT_THREAD_END = 53,
+ JVMTI_EVENT_CLASS_FILE_LOAD_HOOK = 54,
+ JVMTI_EVENT_CLASS_LOAD = 55,
+ JVMTI_EVENT_CLASS_PREPARE = 56,
+ JVMTI_EVENT_VM_START = 57,
+ JVMTI_EVENT_EXCEPTION = 58,
+ JVMTI_EVENT_EXCEPTION_CATCH = 59,
+ JVMTI_EVENT_SINGLE_STEP = 60,
+ JVMTI_EVENT_FRAME_POP = 61,
+ JVMTI_EVENT_BREAKPOINT = 62,
+ JVMTI_EVENT_FIELD_ACCESS = 63,
+ JVMTI_EVENT_FIELD_MODIFICATION = 64,
+ JVMTI_EVENT_METHOD_ENTRY = 65,
+ JVMTI_EVENT_METHOD_EXIT = 66,
+ JVMTI_EVENT_NATIVE_METHOD_BIND = 67,
+ JVMTI_EVENT_COMPILED_METHOD_LOAD = 68,
+ JVMTI_EVENT_COMPILED_METHOD_UNLOAD = 69,
+ JVMTI_EVENT_DYNAMIC_CODE_GENERATED = 70,
+ JVMTI_EVENT_DATA_DUMP_REQUEST = 71,
+ JVMTI_EVENT_MONITOR_WAIT = 73,
+ JVMTI_EVENT_MONITOR_WAITED = 74,
+ JVMTI_EVENT_MONITOR_CONTENDED_ENTER = 75,
+ JVMTI_EVENT_MONITOR_CONTENDED_ENTERED = 76,
+ JVMTI_EVENT_GARBAGE_COLLECTION_START = 81,
+ JVMTI_EVENT_GARBAGE_COLLECTION_FINISH = 82,
+ JVMTI_EVENT_OBJECT_FREE = 83,
+ JVMTI_EVENT_VM_OBJECT_ALLOC = 84,
+ JVMTI_MAX_EVENT_TYPE_VAL = 84
+} jvmtiEvent;
+
+
+ /* Function Types */
+
+typedef void (JNICALL *jvmtiStartFunction)
+ (jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg);
+
+typedef jvmtiIterationControl (JNICALL *jvmtiHeapObjectCallback)
+ (jlong class_tag, jlong size, jlong* tag_ptr, void* user_data);
+
+typedef jvmtiIterationControl (JNICALL *jvmtiHeapRootCallback)
+ (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong* tag_ptr, void* user_data);
+
+typedef jvmtiIterationControl (JNICALL *jvmtiStackReferenceCallback)
+ (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong* tag_ptr, jlong thread_tag, jint depth, jmethodID method, jint slot, void* user_data);
+
+typedef jvmtiIterationControl (JNICALL *jvmtiObjectReferenceCallback)
+ (jvmtiObjectReferenceKind reference_kind, jlong class_tag, jlong size, jlong* tag_ptr, jlong referrer_tag, jint referrer_index, void* user_data);
+
+typedef jvmtiError (JNICALL *jvmtiExtensionFunction)
+ (jvmtiEnv* jvmti_env, ...);
+
+typedef void (JNICALL *jvmtiExtensionEvent)
+ (jvmtiEnv* jvmti_env, ...);
+
+
+ /* Structure Types */
+
+typedef struct {
+ char* name;
+ jint priority;
+ jboolean is_daemon;
+ jthreadGroup thread_group;
+ jobject context_class_loader;
+} jvmtiThreadInfo;
+
+typedef struct {
+ jthreadGroup parent;
+ char* name;
+ jint max_priority;
+ jboolean is_daemon;
+} jvmtiThreadGroupInfo;
+
+typedef struct {
+ jmethodID method;
+ jlocation location;
+} jvmtiFrameInfo;
+
+typedef struct {
+ jthread thread;
+ jint state;
+ jvmtiFrameInfo* frame_buffer;
+ jint frame_count;
+} jvmtiStackInfo;
+
+typedef struct {
+ jclass klass;
+ jint class_byte_count;
+ const unsigned char* class_bytes;
+} jvmtiClassDefinition;
+
+typedef struct {
+ jthread owner;
+ jint entry_count;
+ jint waiter_count;
+ jthread* waiters;
+ jint notify_waiter_count;
+ jthread* notify_waiters;
+} jvmtiMonitorUsage;
+
+typedef struct {
+ jlocation start_location;
+ jint line_number;
+} jvmtiLineNumberEntry;
+
+typedef struct {
+ jlocation start_location;
+ jint length;
+ char* name;
+ char* signature;
+ char* generic_signature;
+ jint slot;
+} jvmtiLocalVariableEntry;
+
+typedef struct {
+ char* name;
+ jvmtiParamKind kind;
+ jvmtiParamTypes base_type;
+ jboolean null_ok;
+} jvmtiParamInfo;
+
+typedef struct {
+ jvmtiExtensionFunction func;
+ char* id;
+ char* short_description;
+ jint param_count;
+ jvmtiParamInfo* params;
+ jint error_count;
+ jvmtiError* errors;
+} jvmtiExtensionFunctionInfo;
+
+typedef struct {
+ jint extension_event_index;
+ char* id;
+ char* short_description;
+ jint param_count;
+ jvmtiParamInfo* params;
+} jvmtiExtensionEventInfo;
+
+typedef struct {
+ jlong max_value;
+ jboolean may_skip_forward;
+ jboolean may_skip_backward;
+ jvmtiTimerKind kind;
+ jlong reserved1;
+ jlong reserved2;
+} jvmtiTimerInfo;
+
+typedef struct {
+ const void* start_address;
+ jlocation location;
+} jvmtiAddrLocationMap;
+
+typedef struct {
+ unsigned int can_tag_objects : 1;
+ unsigned int can_generate_field_modification_events : 1;
+ unsigned int can_generate_field_access_events : 1;
+ unsigned int can_get_bytecodes : 1;
+ unsigned int can_get_synthetic_attribute : 1;
+ unsigned int can_get_owned_monitor_info : 1;
+ unsigned int can_get_current_contended_monitor : 1;
+ unsigned int can_get_monitor_info : 1;
+ unsigned int can_pop_frame : 1;
+ unsigned int can_redefine_classes : 1;
+ unsigned int can_signal_thread : 1;
+ unsigned int can_get_source_file_name : 1;
+ unsigned int can_get_line_numbers : 1;
+ unsigned int can_get_source_debug_extension : 1;
+ unsigned int can_access_local_variables : 1;
+ unsigned int can_maintain_original_method_order : 1;
+ unsigned int can_generate_single_step_events : 1;
+ unsigned int can_generate_exception_events : 1;
+ unsigned int can_generate_frame_pop_events : 1;
+ unsigned int can_generate_breakpoint_events : 1;
+ unsigned int can_suspend : 1;
+ unsigned int can_redefine_any_class : 1;
+ unsigned int can_get_current_thread_cpu_time : 1;
+ unsigned int can_get_thread_cpu_time : 1;
+ unsigned int can_generate_method_entry_events : 1;
+ unsigned int can_generate_method_exit_events : 1;
+ unsigned int can_generate_all_class_hook_events : 1;
+ unsigned int can_generate_compiled_method_load_events : 1;
+ unsigned int can_generate_monitor_events : 1;
+ unsigned int can_generate_vm_object_alloc_events : 1;
+ unsigned int can_generate_native_method_bind_events : 1;
+ unsigned int can_generate_garbage_collection_events : 1;
+ unsigned int can_generate_object_free_events : 1;
+ unsigned int : 15;
+ unsigned int : 16;
+ unsigned int : 16;
+ unsigned int : 16;
+ unsigned int : 16;
+ unsigned int : 16;
+} jvmtiCapabilities;
+
+
+ /* Event Definitions */
+
+typedef void (JNICALL *jvmtiEventReserved)(void);
+
+
+typedef void (JNICALL *jvmtiEventBreakpoint)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread,
+ jmethodID method,
+ jlocation location);
+
+typedef void (JNICALL *jvmtiEventClassFileLoadHook)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jclass class_being_redefined,
+ jobject loader,
+ const char* name,
+ jobject protection_domain,
+ jint class_data_len,
+ const unsigned char* class_data,
+ jint* new_class_data_len,
+ unsigned char** new_class_data);
+
+typedef void (JNICALL *jvmtiEventClassLoad)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread,
+ jclass klass);
+
+typedef void (JNICALL *jvmtiEventClassPrepare)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread,
+ jclass klass);
+
+typedef void (JNICALL *jvmtiEventCompiledMethodLoad)
+ (jvmtiEnv *jvmti_env,
+ jmethodID method,
+ jint code_size,
+ const void* code_addr,
+ jint map_length,
+ const jvmtiAddrLocationMap* map,
+ const void* compile_info);
+
+typedef void (JNICALL *jvmtiEventCompiledMethodUnload)
+ (jvmtiEnv *jvmti_env,
+ jmethodID method,
+ const void* code_addr);
+
+typedef void (JNICALL *jvmtiEventDataDumpRequest)
+ (jvmtiEnv *jvmti_env);
+
+typedef void (JNICALL *jvmtiEventDynamicCodeGenerated)
+ (jvmtiEnv *jvmti_env,
+ const char* name,
+ const void* address,
+ jint length);
+
+typedef void (JNICALL *jvmtiEventException)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread,
+ jmethodID method,
+ jlocation location,
+ jobject exception,
+ jmethodID catch_method,
+ jlocation catch_location);
+
+typedef void (JNICALL *jvmtiEventExceptionCatch)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread,
+ jmethodID method,
+ jlocation location,
+ jobject exception);
+
+typedef void (JNICALL *jvmtiEventFieldAccess)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread,
+ jmethodID method,
+ jlocation location,
+ jclass field_klass,
+ jobject object,
+ jfieldID field);
+
+typedef void (JNICALL *jvmtiEventFieldModification)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread,
+ jmethodID method,
+ jlocation location,
+ jclass field_klass,
+ jobject object,
+ jfieldID field,
+ char signature_type,
+ jvalue new_value);
+
+typedef void (JNICALL *jvmtiEventFramePop)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread,
+ jmethodID method,
+ jboolean was_popped_by_exception);
+
+typedef void (JNICALL *jvmtiEventGarbageCollectionFinish)
+ (jvmtiEnv *jvmti_env);
+
+typedef void (JNICALL *jvmtiEventGarbageCollectionStart)
+ (jvmtiEnv *jvmti_env);
+
+typedef void (JNICALL *jvmtiEventMethodEntry)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread,
+ jmethodID method);
+
+typedef void (JNICALL *jvmtiEventMethodExit)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread,
+ jmethodID method,
+ jboolean was_popped_by_exception,
+ jvalue return_value);
+
+typedef void (JNICALL *jvmtiEventMonitorContendedEnter)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread,
+ jobject object);
+
+typedef void (JNICALL *jvmtiEventMonitorContendedEntered)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread,
+ jobject object);
+
+typedef void (JNICALL *jvmtiEventMonitorWait)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread,
+ jobject object,
+ jlong timeout);
+
+typedef void (JNICALL *jvmtiEventMonitorWaited)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread,
+ jobject object,
+ jboolean timed_out);
+
+typedef void (JNICALL *jvmtiEventNativeMethodBind)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread,
+ jmethodID method,
+ void* address,
+ void** new_address_ptr);
+
+typedef void (JNICALL *jvmtiEventObjectFree)
+ (jvmtiEnv *jvmti_env,
+ jlong tag);
+
+typedef void (JNICALL *jvmtiEventSingleStep)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread,
+ jmethodID method,
+ jlocation location);
+
+typedef void (JNICALL *jvmtiEventThreadEnd)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread);
+
+typedef void (JNICALL *jvmtiEventThreadStart)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread);
+
+typedef void (JNICALL *jvmtiEventVMDeath)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env);
+
+typedef void (JNICALL *jvmtiEventVMInit)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread);
+
+typedef void (JNICALL *jvmtiEventVMObjectAlloc)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env,
+ jthread thread,
+ jobject object,
+ jclass object_klass,
+ jlong size);
+
+typedef void (JNICALL *jvmtiEventVMStart)
+ (jvmtiEnv *jvmti_env,
+ JNIEnv* jni_env);
+
+ /* Event Callback Structure */
+
+typedef struct {
+ /* 50 : VM Initialization Event */
+ jvmtiEventVMInit VMInit;
+ /* 51 : VM Death Event */
+ jvmtiEventVMDeath VMDeath;
+ /* 52 : Thread Start */
+ jvmtiEventThreadStart ThreadStart;
+ /* 53 : Thread End */
+ jvmtiEventThreadEnd ThreadEnd;
+ /* 54 : Class File Load Hook */
+ jvmtiEventClassFileLoadHook ClassFileLoadHook;
+ /* 55 : Class Load */
+ jvmtiEventClassLoad ClassLoad;
+ /* 56 : Class Prepare */
+ jvmtiEventClassPrepare ClassPrepare;
+ /* 57 : VM Start Event */
+ jvmtiEventVMStart VMStart;
+ /* 58 : Exception */
+ jvmtiEventException Exception;
+ /* 59 : Exception Catch */
+ jvmtiEventExceptionCatch ExceptionCatch;
+ /* 60 : Single Step */
+ jvmtiEventSingleStep SingleStep;
+ /* 61 : Frame Pop */
+ jvmtiEventFramePop FramePop;
+ /* 62 : Breakpoint */
+ jvmtiEventBreakpoint Breakpoint;
+ /* 63 : Field Access */
+ jvmtiEventFieldAccess FieldAccess;
+ /* 64 : Field Modification */
+ jvmtiEventFieldModification FieldModification;
+ /* 65 : Method Entry */
+ jvmtiEventMethodEntry MethodEntry;
+ /* 66 : Method Exit */
+ jvmtiEventMethodExit MethodExit;
+ /* 67 : Native Method Bind */
+ jvmtiEventNativeMethodBind NativeMethodBind;
+ /* 68 : Compiled Method Load */
+ jvmtiEventCompiledMethodLoad CompiledMethodLoad;
+ /* 69 : Compiled Method Unload */
+ jvmtiEventCompiledMethodUnload CompiledMethodUnload;
+ /* 70 : Dynamic Code Generated */
+ jvmtiEventDynamicCodeGenerated DynamicCodeGenerated;
+ /* 71 : Data Dump Request */
+ jvmtiEventDataDumpRequest DataDumpRequest;
+ /* 72 */
+ jvmtiEventReserved reserved72;
+ /* 73 : Monitor Wait */
+ jvmtiEventMonitorWait MonitorWait;
+ /* 74 : Monitor Waited */
+ jvmtiEventMonitorWaited MonitorWaited;
+ /* 75 : Monitor Contended Enter */
+ jvmtiEventMonitorContendedEnter MonitorContendedEnter;
+ /* 76 : Monitor Contended Entered */
+ jvmtiEventMonitorContendedEntered MonitorContendedEntered;
+ /* 77 */
+ jvmtiEventReserved reserved77;
+ /* 78 */
+ jvmtiEventReserved reserved78;
+ /* 79 */
+ jvmtiEventReserved reserved79;
+ /* 80 */
+ jvmtiEventReserved reserved80;
+ /* 81 : Garbage Collection Start */
+ jvmtiEventGarbageCollectionStart GarbageCollectionStart;
+ /* 82 : Garbage Collection Finish */
+ jvmtiEventGarbageCollectionFinish GarbageCollectionFinish;
+ /* 83 : Object Free */
+ jvmtiEventObjectFree ObjectFree;
+ /* 84 : VM Object Allocation */
+ jvmtiEventVMObjectAlloc VMObjectAlloc;
+} jvmtiEventCallbacks;
+
+
+ /* Function Interface */
+
+typedef struct jvmtiInterface_1_ {
+
+ /* 1 : RESERVED */
+ void *reserved1;
+
+ /* 2 : Set Event Notification Mode */
+ jvmtiError (JNICALL *SetEventNotificationMode) (jvmtiEnv* env,
+ jvmtiEventMode mode,
+ jvmtiEvent event_type,
+ jthread event_thread,
+ ...);
+
+ /* 3 : RESERVED */
+ void *reserved3;
+
+ /* 4 : Get All Threads */
+ jvmtiError (JNICALL *GetAllThreads) (jvmtiEnv* env,
+ jint* threads_count_ptr,
+ jthread** threads_ptr);
+
+ /* 5 : Suspend Thread */
+ jvmtiError (JNICALL *SuspendThread) (jvmtiEnv* env,
+ jthread thread);
+
+ /* 6 : Resume Thread */
+ jvmtiError (JNICALL *ResumeThread) (jvmtiEnv* env,
+ jthread thread);
+
+ /* 7 : Stop Thread */
+ jvmtiError (JNICALL *StopThread) (jvmtiEnv* env,
+ jthread thread,
+ jobject exception);
+
+ /* 8 : Interrupt Thread */
+ jvmtiError (JNICALL *InterruptThread) (jvmtiEnv* env,
+ jthread thread);
+
+ /* 9 : Get Thread Info */
+ jvmtiError (JNICALL *GetThreadInfo) (jvmtiEnv* env,
+ jthread thread,
+ jvmtiThreadInfo* info_ptr);
+
+ /* 10 : Get Owned Monitor Info */
+ jvmtiError (JNICALL *GetOwnedMonitorInfo) (jvmtiEnv* env,
+ jthread thread,
+ jint* owned_monitor_count_ptr,
+ jobject** owned_monitors_ptr);
+
+ /* 11 : Get Current Contended Monitor */
+ jvmtiError (JNICALL *GetCurrentContendedMonitor) (jvmtiEnv* env,
+ jthread thread,
+ jobject* monitor_ptr);
+
+ /* 12 : Run Agent Thread */
+ jvmtiError (JNICALL *RunAgentThread) (jvmtiEnv* env,
+ jthread thread,
+ jvmtiStartFunction proc,
+ const void* arg,
+ jint priority);
+
+ /* 13 : Get Top Thread Groups */
+ jvmtiError (JNICALL *GetTopThreadGroups) (jvmtiEnv* env,
+ jint* group_count_ptr,
+ jthreadGroup** groups_ptr);
+
+ /* 14 : Get Thread Group Info */
+ jvmtiError (JNICALL *GetThreadGroupInfo) (jvmtiEnv* env,
+ jthreadGroup group,
+ jvmtiThreadGroupInfo* info_ptr);
+
+ /* 15 : Get Thread Group Children */
+ jvmtiError (JNICALL *GetThreadGroupChildren) (jvmtiEnv* env,
+ jthreadGroup group,
+ jint* thread_count_ptr,
+ jthread** threads_ptr,
+ jint* group_count_ptr,
+ jthreadGroup** groups_ptr);
+
+ /* 16 : Get Frame Count */
+ jvmtiError (JNICALL *GetFrameCount) (jvmtiEnv* env,
+ jthread thread,
+ jint* count_ptr);
+
+ /* 17 : Get Thread State */
+ jvmtiError (JNICALL *GetThreadState) (jvmtiEnv* env,
+ jthread thread,
+ jint* thread_state_ptr);
+
+ /* 18 : RESERVED */
+ void *reserved18;
+
+ /* 19 : Get Frame Location */
+ jvmtiError (JNICALL *GetFrameLocation) (jvmtiEnv* env,
+ jthread thread,
+ jint depth,
+ jmethodID* method_ptr,
+ jlocation* location_ptr);
+
+ /* 20 : Notify Frame Pop */
+ jvmtiError (JNICALL *NotifyFramePop) (jvmtiEnv* env,
+ jthread thread,
+ jint depth);
+
+ /* 21 : Get Local Variable - Object */
+ jvmtiError (JNICALL *GetLocalObject) (jvmtiEnv* env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jobject* value_ptr);
+
+ /* 22 : Get Local Variable - Int */
+ jvmtiError (JNICALL *GetLocalInt) (jvmtiEnv* env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jint* value_ptr);
+
+ /* 23 : Get Local Variable - Long */
+ jvmtiError (JNICALL *GetLocalLong) (jvmtiEnv* env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jlong* value_ptr);
+
+ /* 24 : Get Local Variable - Float */
+ jvmtiError (JNICALL *GetLocalFloat) (jvmtiEnv* env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jfloat* value_ptr);
+
+ /* 25 : Get Local Variable - Double */
+ jvmtiError (JNICALL *GetLocalDouble) (jvmtiEnv* env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jdouble* value_ptr);
+
+ /* 26 : Set Local Variable - Object */
+ jvmtiError (JNICALL *SetLocalObject) (jvmtiEnv* env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jobject value);
+
+ /* 27 : Set Local Variable - Int */
+ jvmtiError (JNICALL *SetLocalInt) (jvmtiEnv* env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jint value);
+
+ /* 28 : Set Local Variable - Long */
+ jvmtiError (JNICALL *SetLocalLong) (jvmtiEnv* env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jlong value);
+
+ /* 29 : Set Local Variable - Float */
+ jvmtiError (JNICALL *SetLocalFloat) (jvmtiEnv* env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jfloat value);
+
+ /* 30 : Set Local Variable - Double */
+ jvmtiError (JNICALL *SetLocalDouble) (jvmtiEnv* env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jdouble value);
+
+ /* 31 : Create Raw Monitor */
+ jvmtiError (JNICALL *CreateRawMonitor) (jvmtiEnv* env,
+ const char* name,
+ jrawMonitorID* monitor_ptr);
+
+ /* 32 : Destroy Raw Monitor */
+ jvmtiError (JNICALL *DestroyRawMonitor) (jvmtiEnv* env,
+ jrawMonitorID monitor);
+
+ /* 33 : Raw Monitor Enter */
+ jvmtiError (JNICALL *RawMonitorEnter) (jvmtiEnv* env,
+ jrawMonitorID monitor);
+
+ /* 34 : Raw Monitor Exit */
+ jvmtiError (JNICALL *RawMonitorExit) (jvmtiEnv* env,
+ jrawMonitorID monitor);
+
+ /* 35 : Raw Monitor Wait */
+ jvmtiError (JNICALL *RawMonitorWait) (jvmtiEnv* env,
+ jrawMonitorID monitor,
+ jlong millis);
+
+ /* 36 : Raw Monitor Notify */
+ jvmtiError (JNICALL *RawMonitorNotify) (jvmtiEnv* env,
+ jrawMonitorID monitor);
+
+ /* 37 : Raw Monitor Notify All */
+ jvmtiError (JNICALL *RawMonitorNotifyAll) (jvmtiEnv* env,
+ jrawMonitorID monitor);
+
+ /* 38 : Set Breakpoint */
+ jvmtiError (JNICALL *SetBreakpoint) (jvmtiEnv* env,
+ jmethodID method,
+ jlocation location);
+
+ /* 39 : Clear Breakpoint */
+ jvmtiError (JNICALL *ClearBreakpoint) (jvmtiEnv* env,
+ jmethodID method,
+ jlocation location);
+
+ /* 40 : RESERVED */
+ void *reserved40;
+
+ /* 41 : Set Field Access Watch */
+ jvmtiError (JNICALL *SetFieldAccessWatch) (jvmtiEnv* env,
+ jclass klass,
+ jfieldID field);
+
+ /* 42 : Clear Field Access Watch */
+ jvmtiError (JNICALL *ClearFieldAccessWatch) (jvmtiEnv* env,
+ jclass klass,
+ jfieldID field);
+
+ /* 43 : Set Field Modification Watch */
+ jvmtiError (JNICALL *SetFieldModificationWatch) (jvmtiEnv* env,
+ jclass klass,
+ jfieldID field);
+
+ /* 44 : Clear Field Modification Watch */
+ jvmtiError (JNICALL *ClearFieldModificationWatch) (jvmtiEnv* env,
+ jclass klass,
+ jfieldID field);
+
+ /* 45 : RESERVED */
+ void *reserved45;
+
+ /* 46 : Allocate */
+ jvmtiError (JNICALL *Allocate) (jvmtiEnv* env,
+ jlong size,
+ unsigned char** mem_ptr);
+
+ /* 47 : Deallocate */
+ jvmtiError (JNICALL *Deallocate) (jvmtiEnv* env,
+ unsigned char* mem);
+
+ /* 48 : Get Class Signature */
+ jvmtiError (JNICALL *GetClassSignature) (jvmtiEnv* env,
+ jclass klass,
+ char** signature_ptr,
+ char** generic_ptr);
+
+ /* 49 : Get Class Status */
+ jvmtiError (JNICALL *GetClassStatus) (jvmtiEnv* env,
+ jclass klass,
+ jint* status_ptr);
+
+ /* 50 : Get Source File Name */
+ jvmtiError (JNICALL *GetSourceFileName) (jvmtiEnv* env,
+ jclass klass,
+ char** source_name_ptr);
+
+ /* 51 : Get Class Modifiers */
+ jvmtiError (JNICALL *GetClassModifiers) (jvmtiEnv* env,
+ jclass klass,
+ jint* modifiers_ptr);
+
+ /* 52 : Get Class Methods */
+ jvmtiError (JNICALL *GetClassMethods) (jvmtiEnv* env,
+ jclass klass,
+ jint* method_count_ptr,
+ jmethodID** methods_ptr);
+
+ /* 53 : Get Class Fields */
+ jvmtiError (JNICALL *GetClassFields) (jvmtiEnv* env,
+ jclass klass,
+ jint* field_count_ptr,
+ jfieldID** fields_ptr);
+
+ /* 54 : Get Implemented Interfaces */
+ jvmtiError (JNICALL *GetImplementedInterfaces) (jvmtiEnv* env,
+ jclass klass,
+ jint* interface_count_ptr,
+ jclass** interfaces_ptr);
+
+ /* 55 : Is Interface */
+ jvmtiError (JNICALL *IsInterface) (jvmtiEnv* env,
+ jclass klass,
+ jboolean* is_interface_ptr);
+
+ /* 56 : Is Array Class */
+ jvmtiError (JNICALL *IsArrayClass) (jvmtiEnv* env,
+ jclass klass,
+ jboolean* is_array_class_ptr);
+
+ /* 57 : Get Class Loader */
+ jvmtiError (JNICALL *GetClassLoader) (jvmtiEnv* env,
+ jclass klass,
+ jobject* classloader_ptr);
+
+ /* 58 : Get Object Hash Code */
+ jvmtiError (JNICALL *GetObjectHashCode) (jvmtiEnv* env,
+ jobject object,
+ jint* hash_code_ptr);
+
+ /* 59 : Get Object Monitor Usage */
+ jvmtiError (JNICALL *GetObjectMonitorUsage) (jvmtiEnv* env,
+ jobject object,
+ jvmtiMonitorUsage* info_ptr);
+
+ /* 60 : Get Field Name (and Signature) */
+ jvmtiError (JNICALL *GetFieldName) (jvmtiEnv* env,
+ jclass klass,
+ jfieldID field,
+ char** name_ptr,
+ char** signature_ptr,
+ char** generic_ptr);
+
+ /* 61 : Get Field Declaring Class */
+ jvmtiError (JNICALL *GetFieldDeclaringClass) (jvmtiEnv* env,
+ jclass klass,
+ jfieldID field,
+ jclass* declaring_class_ptr);
+
+ /* 62 : Get Field Modifiers */
+ jvmtiError (JNICALL *GetFieldModifiers) (jvmtiEnv* env,
+ jclass klass,
+ jfieldID field,
+ jint* modifiers_ptr);
+
+ /* 63 : Is Field Synthetic */
+ jvmtiError (JNICALL *IsFieldSynthetic) (jvmtiEnv* env,
+ jclass klass,
+ jfieldID field,
+ jboolean* is_synthetic_ptr);
+
+ /* 64 : Get Method Name (and Signature) */
+ jvmtiError (JNICALL *GetMethodName) (jvmtiEnv* env,
+ jmethodID method,
+ char** name_ptr,
+ char** signature_ptr,
+ char** generic_ptr);
+
+ /* 65 : Get Method Declaring Class */
+ jvmtiError (JNICALL *GetMethodDeclaringClass) (jvmtiEnv* env,
+ jmethodID method,
+ jclass* declaring_class_ptr);
+
+ /* 66 : Get Method Modifiers */
+ jvmtiError (JNICALL *GetMethodModifiers) (jvmtiEnv* env,
+ jmethodID method,
+ jint* modifiers_ptr);
+
+ /* 67 : RESERVED */
+ void *reserved67;
+
+ /* 68 : Get Max Locals */
+ jvmtiError (JNICALL *GetMaxLocals) (jvmtiEnv* env,
+ jmethodID method,
+ jint* max_ptr);
+
+ /* 69 : Get Arguments Size */
+ jvmtiError (JNICALL *GetArgumentsSize) (jvmtiEnv* env,
+ jmethodID method,
+ jint* size_ptr);
+
+ /* 70 : Get Line Number Table */
+ jvmtiError (JNICALL *GetLineNumberTable) (jvmtiEnv* env,
+ jmethodID method,
+ jint* entry_count_ptr,
+ jvmtiLineNumberEntry** table_ptr);
+
+ /* 71 : Get Method Location */
+ jvmtiError (JNICALL *GetMethodLocation) (jvmtiEnv* env,
+ jmethodID method,
+ jlocation* start_location_ptr,
+ jlocation* end_location_ptr);
+
+ /* 72 : Get Local Variable Table */
+ jvmtiError (JNICALL *GetLocalVariableTable) (jvmtiEnv* env,
+ jmethodID method,
+ jint* entry_count_ptr,
+ jvmtiLocalVariableEntry** table_ptr);
+
+ /* 73 : RESERVED */
+ void *reserved73;
+
+ /* 74 : RESERVED */
+ void *reserved74;
+
+ /* 75 : Get Bytecodes */
+ jvmtiError (JNICALL *GetBytecodes) (jvmtiEnv* env,
+ jmethodID method,
+ jint* bytecode_count_ptr,
+ unsigned char** bytecodes_ptr);
+
+ /* 76 : Is Method Native */
+ jvmtiError (JNICALL *IsMethodNative) (jvmtiEnv* env,
+ jmethodID method,
+ jboolean* is_native_ptr);
+
+ /* 77 : Is Method Synthetic */
+ jvmtiError (JNICALL *IsMethodSynthetic) (jvmtiEnv* env,
+ jmethodID method,
+ jboolean* is_synthetic_ptr);
+
+ /* 78 : Get Loaded Classes */
+ jvmtiError (JNICALL *GetLoadedClasses) (jvmtiEnv* env,
+ jint* class_count_ptr,
+ jclass** classes_ptr);
+
+ /* 79 : Get Classloader Classes */
+ jvmtiError (JNICALL *GetClassLoaderClasses) (jvmtiEnv* env,
+ jobject initiating_loader,
+ jint* class_count_ptr,
+ jclass** classes_ptr);
+
+ /* 80 : Pop Frame */
+ jvmtiError (JNICALL *PopFrame) (jvmtiEnv* env,
+ jthread thread);
+
+ /* 81 : RESERVED */
+ void *reserved81;
+
+ /* 82 : RESERVED */
+ void *reserved82;
+
+ /* 83 : RESERVED */
+ void *reserved83;
+
+ /* 84 : RESERVED */
+ void *reserved84;
+
+ /* 85 : RESERVED */
+ void *reserved85;
+
+ /* 86 : RESERVED */
+ void *reserved86;
+
+ /* 87 : Redefine Classes */
+ jvmtiError (JNICALL *RedefineClasses) (jvmtiEnv* env,
+ jint class_count,
+ const jvmtiClassDefinition* class_definitions);
+
+ /* 88 : Get Version Number */
+ jvmtiError (JNICALL *GetVersionNumber) (jvmtiEnv* env,
+ jint* version_ptr);
+
+ /* 89 : Get Capabilities */
+ jvmtiError (JNICALL *GetCapabilities) (jvmtiEnv* env,
+ jvmtiCapabilities* capabilities_ptr);
+
+ /* 90 : Get Source Debug Extension */
+ jvmtiError (JNICALL *GetSourceDebugExtension) (jvmtiEnv* env,
+ jclass klass,
+ char** source_debug_extension_ptr);
+
+ /* 91 : Is Method Obsolete */
+ jvmtiError (JNICALL *IsMethodObsolete) (jvmtiEnv* env,
+ jmethodID method,
+ jboolean* is_obsolete_ptr);
+
+ /* 92 : Suspend Thread List */
+ jvmtiError (JNICALL *SuspendThreadList) (jvmtiEnv* env,
+ jint request_count,
+ const jthread* request_list,
+ jvmtiError* results);
+
+ /* 93 : Resume Thread List */
+ jvmtiError (JNICALL *ResumeThreadList) (jvmtiEnv* env,
+ jint request_count,
+ const jthread* request_list,
+ jvmtiError* results);
+
+ /* 94 : RESERVED */
+ void *reserved94;
+
+ /* 95 : RESERVED */
+ void *reserved95;
+
+ /* 96 : RESERVED */
+ void *reserved96;
+
+ /* 97 : RESERVED */
+ void *reserved97;
+
+ /* 98 : RESERVED */
+ void *reserved98;
+
+ /* 99 : RESERVED */
+ void *reserved99;
+
+ /* 100 : Get All Stack Traces */
+ jvmtiError (JNICALL *GetAllStackTraces) (jvmtiEnv* env,
+ jint max_frame_count,
+ jvmtiStackInfo** stack_info_ptr,
+ jint* thread_count_ptr);
+
+ /* 101 : Get Thread List Stack Traces */
+ jvmtiError (JNICALL *GetThreadListStackTraces) (jvmtiEnv* env,
+ jint thread_count,
+ const jthread* thread_list,
+ jint max_frame_count,
+ jvmtiStackInfo** stack_info_ptr);
+
+ /* 102 : Get Thread Local Storage */
+ jvmtiError (JNICALL *GetThreadLocalStorage) (jvmtiEnv* env,
+ jthread thread,
+ void** data_ptr);
+
+ /* 103 : Set Thread Local Storage */
+ jvmtiError (JNICALL *SetThreadLocalStorage) (jvmtiEnv* env,
+ jthread thread,
+ const void* data);
+
+ /* 104 : Get Stack Trace */
+ jvmtiError (JNICALL *GetStackTrace) (jvmtiEnv* env,
+ jthread thread,
+ jint start_depth,
+ jint max_frame_count,
+ jvmtiFrameInfo* frame_buffer,
+ jint* count_ptr);
+
+ /* 105 : RESERVED */
+ void *reserved105;
+
+ /* 106 : Get Tag */
+ jvmtiError (JNICALL *GetTag) (jvmtiEnv* env,
+ jobject object,
+ jlong* tag_ptr);
+
+ /* 107 : Set Tag */
+ jvmtiError (JNICALL *SetTag) (jvmtiEnv* env,
+ jobject object,
+ jlong tag);
+
+ /* 108 : Force Garbage Collection */
+ jvmtiError (JNICALL *ForceGarbageCollection) (jvmtiEnv* env);
+
+ /* 109 : Iterate Over Objects Reachable From Object */
+ jvmtiError (JNICALL *IterateOverObjectsReachableFromObject) (jvmtiEnv* env,
+ jobject object,
+ jvmtiObjectReferenceCallback object_reference_callback,
+ void* user_data);
+
+ /* 110 : Iterate Over Reachable Objects */
+ jvmtiError (JNICALL *IterateOverReachableObjects) (jvmtiEnv* env,
+ jvmtiHeapRootCallback heap_root_callback,
+ jvmtiStackReferenceCallback stack_ref_callback,
+ jvmtiObjectReferenceCallback object_ref_callback,
+ void* user_data);
+
+ /* 111 : Iterate Over Heap */
+ jvmtiError (JNICALL *IterateOverHeap) (jvmtiEnv* env,
+ jvmtiHeapObjectFilter object_filter,
+ jvmtiHeapObjectCallback heap_object_callback,
+ void* user_data);
+
+ /* 112 : Iterate Over Instances Of Class */
+ jvmtiError (JNICALL *IterateOverInstancesOfClass) (jvmtiEnv* env,
+ jclass klass,
+ jvmtiHeapObjectFilter object_filter,
+ jvmtiHeapObjectCallback heap_object_callback,
+ void* user_data);
+
+ /* 113 : RESERVED */
+ void *reserved113;
+
+ /* 114 : Get Objects With Tags */
+ jvmtiError (JNICALL *GetObjectsWithTags) (jvmtiEnv* env,
+ jint tag_count,
+ const jlong* tags,
+ jint* count_ptr,
+ jobject** object_result_ptr,
+ jlong** tag_result_ptr);
+
+ /* 115 : RESERVED */
+ void *reserved115;
+
+ /* 116 : RESERVED */
+ void *reserved116;
+
+ /* 117 : RESERVED */
+ void *reserved117;
+
+ /* 118 : RESERVED */
+ void *reserved118;
+
+ /* 119 : RESERVED */
+ void *reserved119;
+
+ /* 120 : Set JNI Function Table */
+ jvmtiError (JNICALL *SetJNIFunctionTable) (jvmtiEnv* env,
+ const jniNativeInterface* function_table);
+
+ /* 121 : Get JNI Function Table */
+ jvmtiError (JNICALL *GetJNIFunctionTable) (jvmtiEnv* env,
+ jniNativeInterface** function_table);
+
+ /* 122 : Set Event Callbacks */
+ jvmtiError (JNICALL *SetEventCallbacks) (jvmtiEnv* env,
+ const jvmtiEventCallbacks* callbacks,
+ jint size_of_callbacks);
+
+ /* 123 : Generate Events */
+ jvmtiError (JNICALL *GenerateEvents) (jvmtiEnv* env,
+ jvmtiEvent event_type);
+
+ /* 124 : Get Extension Functions */
+ jvmtiError (JNICALL *GetExtensionFunctions) (jvmtiEnv* env,
+ jint* extension_count_ptr,
+ jvmtiExtensionFunctionInfo** extensions);
+
+ /* 125 : Get Extension Events */
+ jvmtiError (JNICALL *GetExtensionEvents) (jvmtiEnv* env,
+ jint* extension_count_ptr,
+ jvmtiExtensionEventInfo** extensions);
+
+ /* 126 : Set Extension Event Callback */
+ jvmtiError (JNICALL *SetExtensionEventCallback) (jvmtiEnv* env,
+ jint extension_event_index,
+ jvmtiExtensionEvent callback);
+
+ /* 127 : Dispose Environment */
+ jvmtiError (JNICALL *DisposeEnvironment) (jvmtiEnv* env);
+
+ /* 128 : Get Error Name */
+ jvmtiError (JNICALL *GetErrorName) (jvmtiEnv* env,
+ jvmtiError error,
+ char** name_ptr);
+
+ /* 129 : Get JLocation Format */
+ jvmtiError (JNICALL *GetJLocationFormat) (jvmtiEnv* env,
+ jvmtiJlocationFormat* format_ptr);
+
+ /* 130 : Get System Properties */
+ jvmtiError (JNICALL *GetSystemProperties) (jvmtiEnv* env,
+ jint* count_ptr,
+ char*** property_ptr);
+
+ /* 131 : Get System Property */
+ jvmtiError (JNICALL *GetSystemProperty) (jvmtiEnv* env,
+ const char* property,
+ char** value_ptr);
+
+ /* 132 : Set System Property */
+ jvmtiError (JNICALL *SetSystemProperty) (jvmtiEnv* env,
+ const char* property,
+ const char* value);
+
+ /* 133 : Get Phase */
+ jvmtiError (JNICALL *GetPhase) (jvmtiEnv* env,
+ jvmtiPhase* phase_ptr);
+
+ /* 134 : Get Current Thread CPU Timer Information */
+ jvmtiError (JNICALL *GetCurrentThreadCpuTimerInfo) (jvmtiEnv* env,
+ jvmtiTimerInfo* info_ptr);
+
+ /* 135 : Get Current Thread CPU Time */
+ jvmtiError (JNICALL *GetCurrentThreadCpuTime) (jvmtiEnv* env,
+ jlong* nanos_ptr);
+
+ /* 136 : Get Thread CPU Timer Information */
+ jvmtiError (JNICALL *GetThreadCpuTimerInfo) (jvmtiEnv* env,
+ jvmtiTimerInfo* info_ptr);
+
+ /* 137 : Get Thread CPU Time */
+ jvmtiError (JNICALL *GetThreadCpuTime) (jvmtiEnv* env,
+ jthread thread,
+ jlong* nanos_ptr);
+
+ /* 138 : Get Timer Information */
+ jvmtiError (JNICALL *GetTimerInfo) (jvmtiEnv* env,
+ jvmtiTimerInfo* info_ptr);
+
+ /* 139 : Get Time */
+ jvmtiError (JNICALL *GetTime) (jvmtiEnv* env,
+ jlong* nanos_ptr);
+
+ /* 140 : Get Potential Capabilities */
+ jvmtiError (JNICALL *GetPotentialCapabilities) (jvmtiEnv* env,
+ jvmtiCapabilities* capabilities_ptr);
+
+ /* 141 : RESERVED */
+ void *reserved141;
+
+ /* 142 : Add Capabilities */
+ jvmtiError (JNICALL *AddCapabilities) (jvmtiEnv* env,
+ const jvmtiCapabilities* capabilities_ptr);
+
+ /* 143 : Relinquish Capabilities */
+ jvmtiError (JNICALL *RelinquishCapabilities) (jvmtiEnv* env,
+ const jvmtiCapabilities* capabilities_ptr);
+
+ /* 144 : Get Available Processors */
+ jvmtiError (JNICALL *GetAvailableProcessors) (jvmtiEnv* env,
+ jint* processor_count_ptr);
+
+ /* 145 : RESERVED */
+ void *reserved145;
+
+ /* 146 : RESERVED */
+ void *reserved146;
+
+ /* 147 : Get Environment Local Storage */
+ jvmtiError (JNICALL *GetEnvironmentLocalStorage) (jvmtiEnv* env,
+ void** data_ptr);
+
+ /* 148 : Set Environment Local Storage */
+ jvmtiError (JNICALL *SetEnvironmentLocalStorage) (jvmtiEnv* env,
+ const void* data);
+
+ /* 149 : Add To Bootstrap Class Loader Search */
+ jvmtiError (JNICALL *AddToBootstrapClassLoaderSearch) (jvmtiEnv* env,
+ const char* segment);
+
+ /* 150 : Set Verbose Flag */
+ jvmtiError (JNICALL *SetVerboseFlag) (jvmtiEnv* env,
+ jvmtiVerboseFlag flag,
+ jboolean value);
+
+ /* 151 : RESERVED */
+ void *reserved151;
+
+ /* 152 : RESERVED */
+ void *reserved152;
+
+ /* 153 : RESERVED */
+ void *reserved153;
+
+ /* 154 : Get Object Size */
+ jvmtiError (JNICALL *GetObjectSize) (jvmtiEnv* env,
+ jobject object,
+ jlong* size_ptr);
+
+} jvmtiInterface_1;
+
+struct _jvmtiEnv {
+ const struct jvmtiInterface_1_ *functions;
+#ifdef __cplusplus
+
+
+ jvmtiError Allocate(jlong size,
+ unsigned char** mem_ptr) {
+ return functions->Allocate(this, size, mem_ptr);
+ }
+
+ jvmtiError Deallocate(unsigned char* mem) {
+ return functions->Deallocate(this, mem);
+ }
+
+ jvmtiError GetThreadState(jthread thread,
+ jint* thread_state_ptr) {
+ return functions->GetThreadState(this, thread, thread_state_ptr);
+ }
+
+ jvmtiError GetAllThreads(jint* threads_count_ptr,
+ jthread** threads_ptr) {
+ return functions->GetAllThreads(this, threads_count_ptr, threads_ptr);
+ }
+
+ jvmtiError SuspendThread(jthread thread) {
+ return functions->SuspendThread(this, thread);
+ }
+
+ jvmtiError SuspendThreadList(jint request_count,
+ const jthread* request_list,
+ jvmtiError* results) {
+ return functions->SuspendThreadList(this, request_count, request_list, results);
+ }
+
+ jvmtiError ResumeThread(jthread thread) {
+ return functions->ResumeThread(this, thread);
+ }
+
+ jvmtiError ResumeThreadList(jint request_count,
+ const jthread* request_list,
+ jvmtiError* results) {
+ return functions->ResumeThreadList(this, request_count, request_list, results);
+ }
+
+ jvmtiError StopThread(jthread thread,
+ jobject exception) {
+ return functions->StopThread(this, thread, exception);
+ }
+
+ jvmtiError InterruptThread(jthread thread) {
+ return functions->InterruptThread(this, thread);
+ }
+
+ jvmtiError GetThreadInfo(jthread thread,
+ jvmtiThreadInfo* info_ptr) {
+ return functions->GetThreadInfo(this, thread, info_ptr);
+ }
+
+ jvmtiError GetOwnedMonitorInfo(jthread thread,
+ jint* owned_monitor_count_ptr,
+ jobject** owned_monitors_ptr) {
+ return functions->GetOwnedMonitorInfo(this, thread, owned_monitor_count_ptr, owned_monitors_ptr);
+ }
+
+ jvmtiError GetCurrentContendedMonitor(jthread thread,
+ jobject* monitor_ptr) {
+ return functions->GetCurrentContendedMonitor(this, thread, monitor_ptr);
+ }
+
+ jvmtiError RunAgentThread(jthread thread,
+ jvmtiStartFunction proc,
+ const void* arg,
+ jint priority) {
+ return functions->RunAgentThread(this, thread, proc, arg, priority);
+ }
+
+ jvmtiError SetThreadLocalStorage(jthread thread,
+ const void* data) {
+ return functions->SetThreadLocalStorage(this, thread, data);
+ }
+
+ jvmtiError GetThreadLocalStorage(jthread thread,
+ void** data_ptr) {
+ return functions->GetThreadLocalStorage(this, thread, data_ptr);
+ }
+
+ jvmtiError GetTopThreadGroups(jint* group_count_ptr,
+ jthreadGroup** groups_ptr) {
+ return functions->GetTopThreadGroups(this, group_count_ptr, groups_ptr);
+ }
+
+ jvmtiError GetThreadGroupInfo(jthreadGroup group,
+ jvmtiThreadGroupInfo* info_ptr) {
+ return functions->GetThreadGroupInfo(this, group, info_ptr);
+ }
+
+ jvmtiError GetThreadGroupChildren(jthreadGroup group,
+ jint* thread_count_ptr,
+ jthread** threads_ptr,
+ jint* group_count_ptr,
+ jthreadGroup** groups_ptr) {
+ return functions->GetThreadGroupChildren(this, group, thread_count_ptr, threads_ptr, group_count_ptr, groups_ptr);
+ }
+
+ jvmtiError GetStackTrace(jthread thread,
+ jint start_depth,
+ jint max_frame_count,
+ jvmtiFrameInfo* frame_buffer,
+ jint* count_ptr) {
+ return functions->GetStackTrace(this, thread, start_depth, max_frame_count, frame_buffer, count_ptr);
+ }
+
+ jvmtiError GetAllStackTraces(jint max_frame_count,
+ jvmtiStackInfo** stack_info_ptr,
+ jint* thread_count_ptr) {
+ return functions->GetAllStackTraces(this, max_frame_count, stack_info_ptr, thread_count_ptr);
+ }
+
+ jvmtiError GetThreadListStackTraces(jint thread_count,
+ const jthread* thread_list,
+ jint max_frame_count,
+ jvmtiStackInfo** stack_info_ptr) {
+ return functions->GetThreadListStackTraces(this, thread_count, thread_list, max_frame_count, stack_info_ptr);
+ }
+
+ jvmtiError GetFrameCount(jthread thread,
+ jint* count_ptr) {
+ return functions->GetFrameCount(this, thread, count_ptr);
+ }
+
+ jvmtiError PopFrame(jthread thread) {
+ return functions->PopFrame(this, thread);
+ }
+
+ jvmtiError GetFrameLocation(jthread thread,
+ jint depth,
+ jmethodID* method_ptr,
+ jlocation* location_ptr) {
+ return functions->GetFrameLocation(this, thread, depth, method_ptr, location_ptr);
+ }
+
+ jvmtiError NotifyFramePop(jthread thread,
+ jint depth) {
+ return functions->NotifyFramePop(this, thread, depth);
+ }
+
+ jvmtiError GetTag(jobject object,
+ jlong* tag_ptr) {
+ return functions->GetTag(this, object, tag_ptr);
+ }
+
+ jvmtiError SetTag(jobject object,
+ jlong tag) {
+ return functions->SetTag(this, object, tag);
+ }
+
+ jvmtiError ForceGarbageCollection() {
+ return functions->ForceGarbageCollection(this);
+ }
+
+ jvmtiError IterateOverObjectsReachableFromObject(jobject object,
+ jvmtiObjectReferenceCallback object_reference_callback,
+ void* user_data) {
+ return functions->IterateOverObjectsReachableFromObject(this, object, object_reference_callback, user_data);
+ }
+
+ jvmtiError IterateOverReachableObjects(jvmtiHeapRootCallback heap_root_callback,
+ jvmtiStackReferenceCallback stack_ref_callback,
+ jvmtiObjectReferenceCallback object_ref_callback,
+ void* user_data) {
+ return functions->IterateOverReachableObjects(this, heap_root_callback, stack_ref_callback, object_ref_callback, user_data);
+ }
+
+ jvmtiError IterateOverHeap(jvmtiHeapObjectFilter object_filter,
+ jvmtiHeapObjectCallback heap_object_callback,
+ void* user_data) {
+ return functions->IterateOverHeap(this, object_filter, heap_object_callback, user_data);
+ }
+
+ jvmtiError IterateOverInstancesOfClass(jclass klass,
+ jvmtiHeapObjectFilter object_filter,
+ jvmtiHeapObjectCallback heap_object_callback,
+ void* user_data) {
+ return functions->IterateOverInstancesOfClass(this, klass, object_filter, heap_object_callback, user_data);
+ }
+
+ jvmtiError GetObjectsWithTags(jint tag_count,
+ const jlong* tags,
+ jint* count_ptr,
+ jobject** object_result_ptr,
+ jlong** tag_result_ptr) {
+ return functions->GetObjectsWithTags(this, tag_count, tags, count_ptr, object_result_ptr, tag_result_ptr);
+ }
+
+ jvmtiError GetLocalObject(jthread thread,
+ jint depth,
+ jint slot,
+ jobject* value_ptr) {
+ return functions->GetLocalObject(this, thread, depth, slot, value_ptr);
+ }
+
+ jvmtiError GetLocalInt(jthread thread,
+ jint depth,
+ jint slot,
+ jint* value_ptr) {
+ return functions->GetLocalInt(this, thread, depth, slot, value_ptr);
+ }
+
+ jvmtiError GetLocalLong(jthread thread,
+ jint depth,
+ jint slot,
+ jlong* value_ptr) {
+ return functions->GetLocalLong(this, thread, depth, slot, value_ptr);
+ }
+
+ jvmtiError GetLocalFloat(jthread thread,
+ jint depth,
+ jint slot,
+ jfloat* value_ptr) {
+ return functions->GetLocalFloat(this, thread, depth, slot, value_ptr);
+ }
+
+ jvmtiError GetLocalDouble(jthread thread,
+ jint depth,
+ jint slot,
+ jdouble* value_ptr) {
+ return functions->GetLocalDouble(this, thread, depth, slot, value_ptr);
+ }
+
+ jvmtiError SetLocalObject(jthread thread,
+ jint depth,
+ jint slot,
+ jobject value) {
+ return functions->SetLocalObject(this, thread, depth, slot, value);
+ }
+
+ jvmtiError SetLocalInt(jthread thread,
+ jint depth,
+ jint slot,
+ jint value) {
+ return functions->SetLocalInt(this, thread, depth, slot, value);
+ }
+
+ jvmtiError SetLocalLong(jthread thread,
+ jint depth,
+ jint slot,
+ jlong value) {
+ return functions->SetLocalLong(this, thread, depth, slot, value);
+ }
+
+ jvmtiError SetLocalFloat(jthread thread,
+ jint depth,
+ jint slot,
+ jfloat value) {
+ return functions->SetLocalFloat(this, thread, depth, slot, value);
+ }
+
+ jvmtiError SetLocalDouble(jthread thread,
+ jint depth,
+ jint slot,
+ jdouble value) {
+ return functions->SetLocalDouble(this, thread, depth, slot, value);
+ }
+
+ jvmtiError SetBreakpoint(jmethodID method,
+ jlocation location) {
+ return functions->SetBreakpoint(this, method, location);
+ }
+
+ jvmtiError ClearBreakpoint(jmethodID method,
+ jlocation location) {
+ return functions->ClearBreakpoint(this, method, location);
+ }
+
+ jvmtiError SetFieldAccessWatch(jclass klass,
+ jfieldID field) {
+ return functions->SetFieldAccessWatch(this, klass, field);
+ }
+
+ jvmtiError ClearFieldAccessWatch(jclass klass,
+ jfieldID field) {
+ return functions->ClearFieldAccessWatch(this, klass, field);
+ }
+
+ jvmtiError SetFieldModificationWatch(jclass klass,
+ jfieldID field) {
+ return functions->SetFieldModificationWatch(this, klass, field);
+ }
+
+ jvmtiError ClearFieldModificationWatch(jclass klass,
+ jfieldID field) {
+ return functions->ClearFieldModificationWatch(this, klass, field);
+ }
+
+ jvmtiError GetLoadedClasses(jint* class_count_ptr,
+ jclass** classes_ptr) {
+ return functions->GetLoadedClasses(this, class_count_ptr, classes_ptr);
+ }
+
+ jvmtiError GetClassLoaderClasses(jobject initiating_loader,
+ jint* class_count_ptr,
+ jclass** classes_ptr) {
+ return functions->GetClassLoaderClasses(this, initiating_loader, class_count_ptr, classes_ptr);
+ }
+
+ jvmtiError GetClassSignature(jclass klass,
+ char** signature_ptr,
+ char** generic_ptr) {
+ return functions->GetClassSignature(this, klass, signature_ptr, generic_ptr);
+ }
+
+ jvmtiError GetClassStatus(jclass klass,
+ jint* status_ptr) {
+ return functions->GetClassStatus(this, klass, status_ptr);
+ }
+
+ jvmtiError GetSourceFileName(jclass klass,
+ char** source_name_ptr) {
+ return functions->GetSourceFileName(this, klass, source_name_ptr);
+ }
+
+ jvmtiError GetClassModifiers(jclass klass,
+ jint* modifiers_ptr) {
+ return functions->GetClassModifiers(this, klass, modifiers_ptr);
+ }
+
+ jvmtiError GetClassMethods(jclass klass,
+ jint* method_count_ptr,
+ jmethodID** methods_ptr) {
+ return functions->GetClassMethods(this, klass, method_count_ptr, methods_ptr);
+ }
+
+ jvmtiError GetClassFields(jclass klass,
+ jint* field_count_ptr,
+ jfieldID** fields_ptr) {
+ return functions->GetClassFields(this, klass, field_count_ptr, fields_ptr);
+ }
+
+ jvmtiError GetImplementedInterfaces(jclass klass,
+ jint* interface_count_ptr,
+ jclass** interfaces_ptr) {
+ return functions->GetImplementedInterfaces(this, klass, interface_count_ptr, interfaces_ptr);
+ }
+
+ jvmtiError IsInterface(jclass klass,
+ jboolean* is_interface_ptr) {
+ return functions->IsInterface(this, klass, is_interface_ptr);
+ }
+
+ jvmtiError IsArrayClass(jclass klass,
+ jboolean* is_array_class_ptr) {
+ return functions->IsArrayClass(this, klass, is_array_class_ptr);
+ }
+
+ jvmtiError GetClassLoader(jclass klass,
+ jobject* classloader_ptr) {
+ return functions->GetClassLoader(this, klass, classloader_ptr);
+ }
+
+ jvmtiError GetSourceDebugExtension(jclass klass,
+ char** source_debug_extension_ptr) {
+ return functions->GetSourceDebugExtension(this, klass, source_debug_extension_ptr);
+ }
+
+ jvmtiError RedefineClasses(jint class_count,
+ const jvmtiClassDefinition* class_definitions) {
+ return functions->RedefineClasses(this, class_count, class_definitions);
+ }
+
+ jvmtiError GetObjectSize(jobject object,
+ jlong* size_ptr) {
+ return functions->GetObjectSize(this, object, size_ptr);
+ }
+
+ jvmtiError GetObjectHashCode(jobject object,
+ jint* hash_code_ptr) {
+ return functions->GetObjectHashCode(this, object, hash_code_ptr);
+ }
+
+ jvmtiError GetObjectMonitorUsage(jobject object,
+ jvmtiMonitorUsage* info_ptr) {
+ return functions->GetObjectMonitorUsage(this, object, info_ptr);
+ }
+
+ jvmtiError GetFieldName(jclass klass,
+ jfieldID field,
+ char** name_ptr,
+ char** signature_ptr,
+ char** generic_ptr) {
+ return functions->GetFieldName(this, klass, field, name_ptr, signature_ptr, generic_ptr);
+ }
+
+ jvmtiError GetFieldDeclaringClass(jclass klass,
+ jfieldID field,
+ jclass* declaring_class_ptr) {
+ return functions->GetFieldDeclaringClass(this, klass, field, declaring_class_ptr);
+ }
+
+ jvmtiError GetFieldModifiers(jclass klass,
+ jfieldID field,
+ jint* modifiers_ptr) {
+ return functions->GetFieldModifiers(this, klass, field, modifiers_ptr);
+ }
+
+ jvmtiError IsFieldSynthetic(jclass klass,
+ jfieldID field,
+ jboolean* is_synthetic_ptr) {
+ return functions->IsFieldSynthetic(this, klass, field, is_synthetic_ptr);
+ }
+
+ jvmtiError GetMethodName(jmethodID method,
+ char** name_ptr,
+ char** signature_ptr,
+ char** generic_ptr) {
+ return functions->GetMethodName(this, method, name_ptr, signature_ptr, generic_ptr);
+ }
+
+ jvmtiError GetMethodDeclaringClass(jmethodID method,
+ jclass* declaring_class_ptr) {
+ return functions->GetMethodDeclaringClass(this, method, declaring_class_ptr);
+ }
+
+ jvmtiError GetMethodModifiers(jmethodID method,
+ jint* modifiers_ptr) {
+ return functions->GetMethodModifiers(this, method, modifiers_ptr);
+ }
+
+ jvmtiError GetMaxLocals(jmethodID method,
+ jint* max_ptr) {
+ return functions->GetMaxLocals(this, method, max_ptr);
+ }
+
+ jvmtiError GetArgumentsSize(jmethodID method,
+ jint* size_ptr) {
+ return functions->GetArgumentsSize(this, method, size_ptr);
+ }
+
+ jvmtiError GetLineNumberTable(jmethodID method,
+ jint* entry_count_ptr,
+ jvmtiLineNumberEntry** table_ptr) {
+ return functions->GetLineNumberTable(this, method, entry_count_ptr, table_ptr);
+ }
+
+ jvmtiError GetMethodLocation(jmethodID method,
+ jlocation* start_location_ptr,
+ jlocation* end_location_ptr) {
+ return functions->GetMethodLocation(this, method, start_location_ptr, end_location_ptr);
+ }
+
+ jvmtiError GetLocalVariableTable(jmethodID method,
+ jint* entry_count_ptr,
+ jvmtiLocalVariableEntry** table_ptr) {
+ return functions->GetLocalVariableTable(this, method, entry_count_ptr, table_ptr);
+ }
+
+ jvmtiError GetBytecodes(jmethodID method,
+ jint* bytecode_count_ptr,
+ unsigned char** bytecodes_ptr) {
+ return functions->GetBytecodes(this, method, bytecode_count_ptr, bytecodes_ptr);
+ }
+
+ jvmtiError IsMethodNative(jmethodID method,
+ jboolean* is_native_ptr) {
+ return functions->IsMethodNative(this, method, is_native_ptr);
+ }
+
+ jvmtiError IsMethodSynthetic(jmethodID method,
+ jboolean* is_synthetic_ptr) {
+ return functions->IsMethodSynthetic(this, method, is_synthetic_ptr);
+ }
+
+ jvmtiError IsMethodObsolete(jmethodID method,
+ jboolean* is_obsolete_ptr) {
+ return functions->IsMethodObsolete(this, method, is_obsolete_ptr);
+ }
+
+ jvmtiError CreateRawMonitor(const char* name,
+ jrawMonitorID* monitor_ptr) {
+ return functions->CreateRawMonitor(this, name, monitor_ptr);
+ }
+
+ jvmtiError DestroyRawMonitor(jrawMonitorID monitor) {
+ return functions->DestroyRawMonitor(this, monitor);
+ }
+
+ jvmtiError RawMonitorEnter(jrawMonitorID monitor) {
+ return functions->RawMonitorEnter(this, monitor);
+ }
+
+ jvmtiError RawMonitorExit(jrawMonitorID monitor) {
+ return functions->RawMonitorExit(this, monitor);
+ }
+
+ jvmtiError RawMonitorWait(jrawMonitorID monitor,
+ jlong millis) {
+ return functions->RawMonitorWait(this, monitor, millis);
+ }
+
+ jvmtiError RawMonitorNotify(jrawMonitorID monitor) {
+ return functions->RawMonitorNotify(this, monitor);
+ }
+
+ jvmtiError RawMonitorNotifyAll(jrawMonitorID monitor) {
+ return functions->RawMonitorNotifyAll(this, monitor);
+ }
+
+ jvmtiError SetJNIFunctionTable(const jniNativeInterface* function_table) {
+ return functions->SetJNIFunctionTable(this, function_table);
+ }
+
+ jvmtiError GetJNIFunctionTable(jniNativeInterface** function_table) {
+ return functions->GetJNIFunctionTable(this, function_table);
+ }
+
+ jvmtiError SetEventCallbacks(const jvmtiEventCallbacks* callbacks,
+ jint size_of_callbacks) {
+ return functions->SetEventCallbacks(this, callbacks, size_of_callbacks);
+ }
+
+ jvmtiError SetEventNotificationMode(jvmtiEventMode mode,
+ jvmtiEvent event_type,
+ jthread event_thread,
+ ...) {
+ return functions->SetEventNotificationMode(this, mode, event_type, event_thread);
+ }
+
+ jvmtiError GenerateEvents(jvmtiEvent event_type) {
+ return functions->GenerateEvents(this, event_type);
+ }
+
+ jvmtiError GetExtensionFunctions(jint* extension_count_ptr,
+ jvmtiExtensionFunctionInfo** extensions) {
+ return functions->GetExtensionFunctions(this, extension_count_ptr, extensions);
+ }
+
+ jvmtiError GetExtensionEvents(jint* extension_count_ptr,
+ jvmtiExtensionEventInfo** extensions) {
+ return functions->GetExtensionEvents(this, extension_count_ptr, extensions);
+ }
+
+ jvmtiError SetExtensionEventCallback(jint extension_event_index,
+ jvmtiExtensionEvent callback) {
+ return functions->SetExtensionEventCallback(this, extension_event_index, callback);
+ }
+
+ jvmtiError GetPotentialCapabilities(jvmtiCapabilities* capabilities_ptr) {
+ return functions->GetPotentialCapabilities(this, capabilities_ptr);
+ }
+
+ jvmtiError AddCapabilities(const jvmtiCapabilities* capabilities_ptr) {
+ return functions->AddCapabilities(this, capabilities_ptr);
+ }
+
+ jvmtiError RelinquishCapabilities(const jvmtiCapabilities* capabilities_ptr) {
+ return functions->RelinquishCapabilities(this, capabilities_ptr);
+ }
+
+ jvmtiError GetCapabilities(jvmtiCapabilities* capabilities_ptr) {
+ return functions->GetCapabilities(this, capabilities_ptr);
+ }
+
+ jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiTimerInfo* info_ptr) {
+ return functions->GetCurrentThreadCpuTimerInfo(this, info_ptr);
+ }
+
+ jvmtiError GetCurrentThreadCpuTime(jlong* nanos_ptr) {
+ return functions->GetCurrentThreadCpuTime(this, nanos_ptr);
+ }
+
+ jvmtiError GetThreadCpuTimerInfo(jvmtiTimerInfo* info_ptr) {
+ return functions->GetThreadCpuTimerInfo(this, info_ptr);
+ }
+
+ jvmtiError GetThreadCpuTime(jthread thread,
+ jlong* nanos_ptr) {
+ return functions->GetThreadCpuTime(this, thread, nanos_ptr);
+ }
+
+ jvmtiError GetTimerInfo(jvmtiTimerInfo* info_ptr) {
+ return functions->GetTimerInfo(this, info_ptr);
+ }
+
+ jvmtiError GetTime(jlong* nanos_ptr) {
+ return functions->GetTime(this, nanos_ptr);
+ }
+
+ jvmtiError GetAvailableProcessors(jint* processor_count_ptr) {
+ return functions->GetAvailableProcessors(this, processor_count_ptr);
+ }
+
+ jvmtiError AddToBootstrapClassLoaderSearch(const char* segment) {
+ return functions->AddToBootstrapClassLoaderSearch(this, segment);
+ }
+
+ jvmtiError GetSystemProperties(jint* count_ptr,
+ char*** property_ptr) {
+ return functions->GetSystemProperties(this, count_ptr, property_ptr);
+ }
+
+ jvmtiError GetSystemProperty(const char* property,
+ char** value_ptr) {
+ return functions->GetSystemProperty(this, property, value_ptr);
+ }
+
+ jvmtiError SetSystemProperty(const char* property,
+ const char* value) {
+ return functions->SetSystemProperty(this, property, value);
+ }
+
+ jvmtiError GetPhase(jvmtiPhase* phase_ptr) {
+ return functions->GetPhase(this, phase_ptr);
+ }
+
+ jvmtiError DisposeEnvironment() {
+ return functions->DisposeEnvironment(this);
+ }
+
+ jvmtiError SetEnvironmentLocalStorage(const void* data) {
+ return functions->SetEnvironmentLocalStorage(this, data);
+ }
+
+ jvmtiError GetEnvironmentLocalStorage(void** data_ptr) {
+ return functions->GetEnvironmentLocalStorage(this, data_ptr);
+ }
+
+ jvmtiError GetVersionNumber(jint* version_ptr) {
+ return functions->GetVersionNumber(this, version_ptr);
+ }
+
+ jvmtiError GetErrorName(jvmtiError error,
+ char** name_ptr) {
+ return functions->GetErrorName(this, error, name_ptr);
+ }
+
+ jvmtiError SetVerboseFlag(jvmtiVerboseFlag flag,
+ jboolean value) {
+ return functions->SetVerboseFlag(this, flag, value);
+ }
+
+ jvmtiError GetJLocationFormat(jvmtiJlocationFormat* format_ptr) {
+ return functions->GetJLocationFormat(this, format_ptr);
+ }
+
+#endif /* __cplusplus */
+};
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif /* __cplusplus */
+
+#endif /* !_JAVA_JVMTI_H_ */
+
diff --git a/applications/JavaOpenJPEG/java-jni/include/win32/jawt_md.h b/applications/JavaOpenJPEG/java-jni/include/win32/jawt_md.h new file mode 100644 index 00000000..5df3e469 --- /dev/null +++ b/applications/JavaOpenJPEG/java-jni/include/win32/jawt_md.h @@ -0,0 +1,41 @@ +/*
+ * @(#)jawt_md.h 1.7 03/12/19
+ *
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+#ifndef _JAVASOFT_JAWT_MD_H_
+#define _JAVASOFT_JAWT_MD_H_
+
+#include <windows.h>
+#include "jawt.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Win32-specific declarations for AWT native interface.
+ * See notes in jawt.h for an example of use.
+ */
+typedef struct jawt_Win32DrawingSurfaceInfo {
+ /* Native window, DDB, or DIB handle */
+ union {
+ HWND hwnd;
+ HBITMAP hbitmap;
+ void* pbits;
+ };
+ /*
+ * This HDC should always be used instead of the HDC returned from
+ * BeginPaint() or any calls to GetDC().
+ */
+ HDC hdc;
+ HPALETTE hpalette;
+} JAWT_Win32DrawingSurfaceInfo;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !_JAVASOFT_JAWT_MD_H_ */
diff --git a/applications/JavaOpenJPEG/java-jni/include/win32/jni_md.h b/applications/JavaOpenJPEG/java-jni/include/win32/jni_md.h new file mode 100644 index 00000000..fdc79a07 --- /dev/null +++ b/applications/JavaOpenJPEG/java-jni/include/win32/jni_md.h @@ -0,0 +1,19 @@ +/*
+ * @(#)jni_md.h 1.14 03/12/19
+ *
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+#ifndef _JAVASOFT_JNI_MD_H_
+#define _JAVASOFT_JNI_MD_H_
+
+#define JNIEXPORT __declspec(dllexport)
+#define JNIIMPORT __declspec(dllimport)
+#define JNICALL __stdcall
+
+typedef long jint;
+typedef __int64 jlong;
+typedef signed char jbyte;
+
+#endif /* !_JAVASOFT_JNI_MD_H_ */
diff --git a/applications/JavaOpenJPEG/java-jni/lib/jvm.lib b/applications/JavaOpenJPEG/java-jni/lib/jvm.lib Binary files differnew file mode 100644 index 00000000..672855a0 --- /dev/null +++ b/applications/JavaOpenJPEG/java-jni/lib/jvm.lib diff --git a/applications/JavaOpenJPEG/java-sources/org/openJpeg/OpenJPEGJavaDecoder.java b/applications/JavaOpenJPEG/java-sources/org/openJpeg/OpenJPEGJavaDecoder.java new file mode 100644 index 00000000..0bacc84f --- /dev/null +++ b/applications/JavaOpenJPEG/java-sources/org/openJpeg/OpenJPEGJavaDecoder.java @@ -0,0 +1,250 @@ +/*
+ * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2007, Professor Benoit Macq
+ * Copyright (c) 2002-2007, Patrick Piscaglia, Telemis s.a.
+ * 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. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.openJpeg;
+
+import java.util.Vector;
+
+/** This class decodes one J2K codestream into an image (width + height + depth + pixels[],
+ * using the OpenJPEG.org library.
+ * To be able to log messages, the called must register a IJavaJ2KDecoderLogger object.
+ */
+public class OpenJPEGJavaDecoder {
+
+ public interface IJavaJ2KDecoderLogger {
+ public void logDecoderMessage(String message);
+ public void logDecoderError(String message);
+ }
+
+ private static boolean isInitialized = false;
+
+ // ===== decompression parameters =============>
+ // These value may be changed for each image
+ private String[] decoder_arguments = null;
+ /** number of resolutions decompositions */
+ private int nbResolutions = -1;
+ /** the quality layers */
+ private int[] layers = null;
+
+ /** Contains the 8 bpp version of the image. May NOT be filled together with image16 or image24.<P>
+ * We store in Java the 8 or 16 bpp version of the image while the decoder uses a 32 bpp version, because <UL>
+ * <LI> the storage capacity required is smaller
+ * <LI> the transfer Java <-- C will be faster
+ * <LI> the conversion byte/short ==> int will be done faster by the C
+ * </UL>*/
+ private byte[] image8 = null;
+ /** Contains the 16 bpp version of the image. May NOT be filled together with image8 or image24*/
+ private short[] image16 = null;
+ /** Contains the 24 bpp version of the image. May NOT be filled together with image8 or image16 */
+ private int[] image24 = null;
+ /** Holds the J2K compressed bytecode to decode */
+ private byte compressedStream[] = null;
+ /** Holds the compressed version of the index file, to be used by the decoder */
+ private byte compressedIndex[] = null;
+ /** Width and Height of the image */
+ private int width = -1;
+ private int height = -1;
+ private int depth = -1;
+ /** This parameter is never used in Java but is read by the C library to know the number of resolutions to skip when decoding,
+ * i.e. if there are 5 resolutions and skipped=1 ==> decode until resolution 4. */
+ private int skippedResolutions = 0;
+
+ private Vector<IJavaJ2KDecoderLogger> loggers = new Vector();
+
+
+ public OpenJPEGJavaDecoder(String openJPEGlibraryFullPathAndName, IJavaJ2KDecoderLogger messagesAndErrorsLogger) throws ExceptionInInitializerError
+ {
+ this(openJPEGlibraryFullPathAndName);
+ loggers.addElement(messagesAndErrorsLogger);
+ }
+
+ public OpenJPEGJavaDecoder(String openJPEGlibraryFullPathAndName) throws ExceptionInInitializerError
+ {
+ if (!isInitialized) {
+ try {
+ System.load(openJPEGlibraryFullPathAndName);
+ isInitialized = true;
+ } catch (Throwable t) {
+ throw new ExceptionInInitializerError("OpenJPEG Java Decoder: probably impossible to find the C library");
+ }
+ }
+ }
+
+ public void addLogger(IJavaJ2KDecoderLogger messagesAndErrorsLogger) {
+ loggers.addElement(messagesAndErrorsLogger);
+ }
+
+ public void removeLogger(IJavaJ2KDecoderLogger messagesAndErrorsLogger) {
+ loggers.removeElement(messagesAndErrorsLogger);
+ }
+
+ public int decodeJ2KtoImage() {
+ if ((image16 == null || (image16 != null && image16.length != width*height)) && (depth==-1 || depth==16)) {
+ image16 = new short[width*height];
+ logMessage("OpenJPEGJavaDecoder.decompressImage: image16 length = " + image16.length + " (" + width + " x " + height + ") ");
+ }
+ if ((image8 == null || (image8 != null && image8.length != width*height)) && (depth==-1 || depth==8)) {
+ image8 = new byte[width*height];
+ logMessage("OpenJPEGJavaDecoder.decompressImage: image8 length = " + image8.length + " (" + width + " x " + height + ") ");
+ }
+ if ((image24 == null || (image24 != null && image24.length != width*height)) && (depth==-1 || depth==24)) {
+ image24 = new int[width*height];
+ logMessage("OpenJPEGJavaDecoder.decompressImage: image24 length = " + image24.length + " (" + width + " x " + height + ") ");
+ }
+
+ String[] arguments = new String[0 + (decoder_arguments != null ? decoder_arguments.length : 0)];
+ int offset = 0;
+ if (decoder_arguments != null) {
+ for (int i=0; i<decoder_arguments.length; i++) {
+ arguments[i+offset] = decoder_arguments[i];
+ }
+ }
+
+ return internalDecodeJ2KtoImage(arguments);
+ }
+
+ /**
+ * Decode the j2k stream given in the codestream byte[] and fills the image8, image16 or image24 array, according to the bit depth.
+ */
+ private native int internalDecodeJ2KtoImage(String[] parameters);
+
+ /** Image depth in bpp */
+ public int getDepth() {
+ return depth;
+ }
+
+ /** Image depth in bpp */
+ public void setDepth(int depth) {
+ this.depth = depth;
+ }
+
+ /** Image height in pixels */
+ public int getHeight() {
+ return height;
+ }
+
+ /** Image height in pixels */
+ public void setHeight(int height) {
+ this.height = height;
+ }
+
+ /** Number of resolutions contained in the image */
+ public int getNbResolutions() {
+ return nbResolutions;
+ }
+
+ /** Number of resolutions contained in the image */
+ public void setNbResolutions(int nbResolutions) {
+ this.nbResolutions = nbResolutions;
+ }
+
+ /** Width of the image in pixels */
+ public int getWidth() {
+ return width;
+ }
+
+ /** Width of the image in pixels */
+ public void setWidth(int width) {
+ this.width = width;
+ }
+
+ /** Contains the decompressed version of the image, if the depth in is [9,16] bpp.
+ * Returns NULL otherwise.
+ */
+ public short[] getImage16() {
+ return image16;
+ }
+
+ /** Contains the decompressed version of the image, if the depth in is [17,24] bpp and the image is in color.
+ * Returns NULL otherwise.
+ */
+ public int[] getImage24() {
+ return image24;
+ }
+
+ /** Contains the decompressed version of the image, if the depth in is [1,8] bpp.
+ * Returns NULL otherwise.
+ */
+ public byte[] getImage8() {
+ return image8;
+ }
+
+ /** Sets the compressed version of the index file for this image.
+ * This index file is used by the decompressor
+ */
+ public void setCompressedIndex(byte[] compressedIndex) {
+ this.compressedIndex = compressedIndex;
+ }
+
+ /** Sets the codestream to be decoded */
+ public void setCompressedStream(byte[] compressedStream) {
+ this.compressedStream = compressedStream;
+ }
+
+ /** @return the compressed code stream length, or -1 if not defined */
+ public long getCodestreamLength() {
+ if (compressedStream == null)
+ return -1;
+ else return compressedStream.length;
+ }
+
+ /** This method is called either directly or by the C methods */
+ public void logMessage(String message) {
+ for (IJavaJ2KDecoderLogger logger:loggers)
+ logger.logDecoderMessage(message);
+ }
+
+ /** This method is called either directly or by the C methods */
+ public void logError(String error) {
+ for (IJavaJ2KDecoderLogger logger:loggers)
+ logger.logDecoderError(error);
+ }
+
+ public void reset() {
+ nbResolutions = -1;
+ layers = null;
+ image8 = null;
+ image16 = null;
+ image24 = null;
+ compressedStream = null;
+ compressedIndex = null;
+ width = -1;
+ height = -1;
+ depth = -1;
+ }
+
+ public void setSkippedResolutions(int numberOfSkippedResolutions) {
+ skippedResolutions = numberOfSkippedResolutions;
+ }
+
+ /** Contains all the decoding arguments other than the input/output file */
+ public void setDecoderArguments(String[] argumentsForTheDecoder) {
+ decoder_arguments = argumentsForTheDecoder;
+ }
+
+
+}
diff --git a/applications/JavaOpenJPEG/java-sources/org/openJpeg/OpenJPEGJavaEncoder.java b/applications/JavaOpenJPEG/java-sources/org/openJpeg/OpenJPEGJavaEncoder.java new file mode 100644 index 00000000..2c638cfa --- /dev/null +++ b/applications/JavaOpenJPEG/java-sources/org/openJpeg/OpenJPEGJavaEncoder.java @@ -0,0 +1,338 @@ +/*
+ * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2007, Professor Benoit Macq
+ * Copyright (c) 2002-2007, Patrick Piscaglia, Telemis s.a.
+ * 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. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.openJpeg;
+
+import java.io.File;
+import java.util.Vector;
+
+/** This class encodes one image into the J2K format,
+ * using the OpenJPEG.org library.
+ * To be able to log messages, the called must register a IJavaJ2KEncoderLogger object.
+ */
+public class OpenJPEGJavaEncoder {
+
+ public interface IJavaJ2KEncoderLogger {
+ public void logEncoderMessage(String message);
+ public void logEncoderError(String message);
+ }
+
+ private static boolean isInitialized = false;
+
+ // ===== Compression parameters =============>
+ // These value may be changed for each image
+ private String[] encoder_arguments = null;
+ /** number of resolutions decompositions */
+ private int nbResolutions = -1;
+ /** the quality layers, expressed as compression rate */
+ private float[] ratioLayers = null;
+ /** the quality layers, expressed as PSNR values. This variable, if defined, has priority over the ratioLayers variable */
+ private float[] psnrLayers = null;
+
+ /** Contains the 8 bpp version of the image. May NOT be filled together with image16 or image24.<P>
+ * We store the 8 or 16 bpp version of the original image while the encoder uses a 32 bpp version, because <UL>
+ * <LI> the storage capacity required is smaller
+ * <LI> the transfer Java --> C will be faster
+ * <LI> the conversion byte/short ==> int will be done faster by the C
+ * </UL>*/
+ private byte[] image8 = null;
+ /** Contains the 16 bpp version of the image. May NOT be filled together with image8 or image24*/
+ private short[] image16 = null;
+ /** Contains the 24 bpp version of the image. May NOT be filled together with image8 or image16 */
+ private int[] image24 = null;
+ /** Holds the result of the compression, i.e. the J2K compressed bytecode */
+ private byte compressedStream[] = null;
+ /** Holds the compressed stream length, which may be smaller than compressedStream.length if this byte[] is pre-allocated */
+ private long compressedStreamLength = -1;
+ /** Holds the compressed version of the index file, returned by the encoder */
+ private byte compressedIndex[] = null;
+ /** Width and Height of the image */
+ private int width = -1;
+ private int height = -1;
+ private int depth = -1;
+ /** Tile size. We suppose the same size for the horizontal and vertical tiles.
+ * If size == -1 ==> no tiling */
+ private int tileSize = -1;
+ // <===== Compression parameters =============
+
+ private Vector<IJavaJ2KEncoderLogger> loggers = new Vector();
+
+ public OpenJPEGJavaEncoder(String openJPEGlibraryFullPathAndName, IJavaJ2KEncoderLogger messagesAndErrorsLogger) throws ExceptionInInitializerError
+ {
+ this(openJPEGlibraryFullPathAndName);
+ loggers.addElement(messagesAndErrorsLogger);
+ }
+
+ public OpenJPEGJavaEncoder(String openJPEGlibraryFullPathAndName) throws ExceptionInInitializerError
+ {
+ if (!isInitialized) {
+ try {
+ String absolutePath = (new File(openJPEGlibraryFullPathAndName)).getCanonicalPath();
+ System.load(absolutePath);
+ isInitialized = true;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw new ExceptionInInitializerError("OpenJPEG Java Encoder: probably impossible to find the C library");
+ }
+ }
+ }
+
+ public void addLogger(IJavaJ2KEncoderLogger messagesAndErrorsLogger) {
+ loggers.addElement(messagesAndErrorsLogger);
+ }
+
+ public void removeLogger(IJavaJ2KEncoderLogger messagesAndErrorsLogger) {
+ loggers.removeElement(messagesAndErrorsLogger);
+ }
+
+ /** This method compresses the given image.<P>
+ * It returns the compressed J2K codestream into the compressedStream byte[].<P>
+ * It also returns the compression index as a compressed form, into the compressedIndex byte[].<P>
+ * One of the image8, image16 or image24 arrays must be correctly initialized and filled.<P>
+ * The width, height and depth variables must be correctly filled.<P>
+ * The nbResolutions, nbLayers and if needed the float[] psnrLayers or ratioLayers must also be filled before calling this method.
+ */
+ public void encodeImageToJ2K() {
+ // Need to allocate / reallocate the compressed stream buffer ? (size = max possible size = original image size)
+ if (compressedStream== null || (compressedStream.length != width*height*depth/8)) {
+ logMessage("OpenJPEGJavaEncoder.encodeImageToJ2K: (re-)allocating " + (width*height*depth/8) + " bytes for the compressedStream");
+ compressedStream = new byte[width*height*depth/8];
+ }
+ // Arguments =
+ // - number of resolutions "-n 5" : 2
+ // - size of tile "-t 512,512" : 2
+ //
+ // Image width, height, depth and pixels are directly fetched by C from the Java class
+ int nbArgs = 2 + (tileSize == -1 ? 0 : 2) + (encoder_arguments != null ? encoder_arguments.length : 0);
+ if (psnrLayers != null && psnrLayers.length>0 && psnrLayers[0] != 0)
+ // If psnrLayers is defined and doesn't just express "lossless"
+ nbArgs += 2;
+ else if (ratioLayers != null && ratioLayers.length>0 && ratioLayers[0]!=0.0)
+ nbArgs += 2;
+ String[] arguments = new String[nbArgs];
+ int offset = 0;
+ arguments[offset] = "-n"; arguments[offset+1] = "" + nbResolutions; offset += 2;
+ if (tileSize!= -1) {
+ arguments[offset++] = "-t";
+ arguments[offset++] = "" + tileSize + "," + tileSize;
+ }
+ // If PSNR layers are defined, use them to encode the images
+ if (psnrLayers != null && psnrLayers.length>0 && psnrLayers[0]!=-1) {
+ arguments[offset++] = "-q";
+ String s = "";
+ for (int i=0; i<psnrLayers.length; i++)
+ s += psnrLayers[i] + ",";
+ arguments[offset++] = s.substring(0, s.length()-1);
+ } else if (ratioLayers != null && ratioLayers.length>0 && ratioLayers[0]!=0.0) {
+ // Specify quality ratioLayers, as compression ratios
+ arguments[offset++] = "-r";
+ String s = "";
+ for (int i=0; i<ratioLayers.length; i++)
+ s += ratioLayers[i] + ",";
+ arguments[offset++] = s.substring(0, s.length()-1);
+ }
+ if (encoder_arguments != null) {
+ for (int i=0; i<encoder_arguments.length; i++) {
+ arguments[i+offset] = encoder_arguments[i];
+ }
+ }
+ logMessage("Encoder additional arguments = " + arrayToString(arguments));
+ long startTime = (new java.util.Date()).getTime();
+ compressedStreamLength = internalEncodeImageToJ2K(arguments);
+ logMessage("compression time = " + ((new java.util.Date()).getTime() - startTime) + " msec");
+ }
+
+ /**
+ * Fills the compressedStream byte[] and the compressedIndex byte[]
+ * @return the codestream length.
+ */
+ private native long internalEncodeImageToJ2K(String[] parameters);
+
+ /** Image depth in bpp */
+ public int getDepth() {
+ return depth;
+ }
+
+ /** Image depth in bpp */
+ public void setDepth(int depth) {
+ this.depth = depth;
+ }
+
+ /** Image height in pixels */
+ public int getHeight() {
+ return height;
+ }
+
+ /** Image height in pixels */
+ public void setHeight(int height) {
+ this.height = height;
+ }
+
+ /** This method must be called in depth in [9,16].
+ * @param an array of shorts, containing width*height values
+ */
+ public void setImage16(short[] image16) {
+ this.image16 = image16;
+ }
+
+ /** This method must be called in depth in [17,24] for RGB images.
+ * @param an array of int, containing width*height values
+ */
+ public void setImage24(int[] image24) {
+ this.image24 = image24;
+ }
+
+ /** This method must be called in depth in [1,8].
+ * @param an array of bytes, containing width*height values
+ */
+ public void setImage8(byte[] image8) {
+ this.image8 = image8;
+ }
+
+ /** Return the ratioLayers, i.e. the compression ratio for each quality layer.
+ * If the last value is 0.0, last layer is lossless compressed.
+ */
+ public float[] getRatioLayers() {
+ return ratioLayers;
+ }
+
+ /**
+ * sets the quality layers.
+ * At least one level.
+ * Each level is expressed as a compression ratio (float).
+ * If the last value is 0.0, the last layer will be losslessly compressed
+ */
+ public void setRatioLayers(float[] layers) {
+ this.ratioLayers = layers;
+ }
+
+ /** Return the PSNR Layers, i.e. the target PSNR for each quality layer.
+ * If the last value is -1, last layer is lossless compressed.
+ */
+ public float[] getPsnrLayers() {
+ return psnrLayers;
+ }
+
+ /**
+ * sets the quality layers.
+ * At least one level.
+ * Each level is expressed as a target PSNR (float).
+ * If the last value is -1, the last layer will be losslessly compressed
+ */
+ public void setPsnrLayers(float[] layers) {
+ this.psnrLayers = layers;
+ }
+
+ /** Set the number of resolutions that must be created */
+ public void setNbResolutions(int nbResolutions) {
+ this.nbResolutions = nbResolutions;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ /** Width of the image, in pixels */
+ public void setWidth(int width) {
+ this.width = width;
+ }
+
+ /** Return the compressed index file.
+ * Syntax: TODO PP:
+ */
+ public byte[] getCompressedIndex() {
+ return compressedIndex;
+ }
+
+ public void setCompressedIndex(byte[] index) {
+ compressedIndex = index;
+ }
+
+ public byte[] getCompressedStream() {
+ return compressedStream;
+ }
+
+ public void reset() {
+ nbResolutions = -1;
+ ratioLayers = null;
+ psnrLayers = null;
+ image8 = null;
+ image16 = null;
+ image24 = null;
+ compressedStream = null;
+ compressedIndex = null;
+ width = -1;
+ height = -1;
+ depth = -1;
+ }
+
+ public short[] getImage16() {
+ return image16;
+ }
+
+ public int[] getImage24() {
+ return image24;
+ }
+
+ public byte[] getImage8() {
+ return image8;
+ }
+
+ /** Sets the size of the tiles. We assume square tiles */
+ public void setTileSize(int tileSize) {
+ this.tileSize = tileSize;
+ }
+
+ /** Contains all the encoding arguments other than the input/output file, compression ratio, tile size */
+ public void setEncoderArguments(String[] argumentsForTheEncoder) {
+ encoder_arguments = argumentsForTheEncoder;
+ }
+
+ public void logMessage(String message) {
+ for (IJavaJ2KEncoderLogger logger:loggers)
+ logger.logEncoderMessage(message);
+ }
+
+ public void logError(String error) {
+ for (IJavaJ2KEncoderLogger logger:loggers)
+ logger.logEncoderError(error);
+ }
+
+ public long getCompressedStreamLength() {
+ return compressedStreamLength;
+ }
+
+ private String arrayToString(String[] array) {
+ if (array == null)
+ return "NULL";
+ StringBuffer sb = new StringBuffer();
+ for (int i=0; i<array.length; i++)
+ sb.append(array[i]).append(" ");
+ sb.delete(sb.length()-1, sb.length());
+ return sb.toString();
+ }
+}
diff --git a/applications/JavaOpenJPEG/org_openJpeg_OpenJPEGJavaDecoder.h b/applications/JavaOpenJPEG/org_openJpeg_OpenJPEGJavaDecoder.h new file mode 100644 index 00000000..0e8de2e7 --- /dev/null +++ b/applications/JavaOpenJPEG/org_openJpeg_OpenJPEGJavaDecoder.h @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class org_openJpeg_OpenJPEGJavaDecoder */
+
+#ifndef _Included_org_openJpeg_OpenJPEGJavaDecoder
+#define _Included_org_openJpeg_OpenJPEGJavaDecoder
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: org_openJpeg_OpenJPEGJavaDecoder
+ * Method: internalDecodeJ2KtoImage
+ * Signature: ([Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2KtoImage
+ (JNIEnv *, jobject, jobjectArray);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/applications/JavaOpenJPEG/org_openJpeg_OpenJPEGJavaEncoder.h b/applications/JavaOpenJPEG/org_openJpeg_OpenJPEGJavaEncoder.h new file mode 100644 index 00000000..22b3d958 --- /dev/null +++ b/applications/JavaOpenJPEG/org_openJpeg_OpenJPEGJavaEncoder.h @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class org_openJpeg_OpenJPEGJavaEncoder */
+
+#ifndef _Included_org_openJpeg_OpenJPEGJavaEncoder
+#define _Included_org_openJpeg_OpenJPEGJavaEncoder
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: org_openJpeg_OpenJPEGJavaEncoder
+ * Method: internalEncodeImageToJ2K
+ * Signature: ([Ljava/lang/String;)J
+ */
+JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImageToJ2K
+ (JNIEnv *, jobject, jobjectArray);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
|
