Mercurial > hg > release > icedtea6-1.5
changeset 564:3130b7dd604d cacao
2008-01-14 Lillian Angel <langel@redhat.com>
* patches/icedtea-libraries.patch
(jpegdecoder.c): Changed dlopen calls to use full-paths and to check
/usr/lib64, if libjpeg.so is not found in /usr/lib. Cannot depend on
default search paths in this case.
(imageioJPEG.c): Likewise.
author | Lillian Angel <langel@redhat.com> |
---|---|
date | Mon, 14 Jan 2008 00:41:35 -0500 |
parents | cb115b6a2f98 |
children | c4653967115c |
files | ChangeLog patches/icedtea-libraries.patch |
diffstat | 2 files changed, 810 insertions(+), 798 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sun Jan 13 23:31:01 2008 -0500 +++ b/ChangeLog Mon Jan 14 00:41:35 2008 -0500 @@ -1,3 +1,11 @@ +2008-01-14 Lillian Angel <langel@redhat.com> + + * patches/icedtea-libraries.patch + (jpegdecoder.c): Changed dlopen calls to use full-paths and to check + /usr/lib64, if libjpeg.so is not found in /usr/lib. Cannot depend on + default search paths in this case. + (imageioJPEG.c): Likewise. + 2008-01-13 Lillian Angel <langel@redhat.com> Fixes Bug #98
--- a/patches/icedtea-libraries.patch Sun Jan 13 23:31:01 2008 -0500 +++ b/patches/icedtea-libraries.patch Mon Jan 14 00:41:35 2008 -0500 @@ -9,804 +9,6 @@ # # Add to ambient vpath to get files in a subdirectory # ---- openjdk.old/jdk/src/share/native/sun/awt/image/jpeg/jpegdecoder.c 2007-10-12 04:03:48.000000000 -0400 -+++ openjdk/jdk/src/share/native/sun/awt/image/jpeg/jpegdecoder.c 2007-10-24 22:15:52.000000000 -0400 -@@ -45,7 +45,9 @@ - #undef boolean - #undef FAR - #include <jpeglib.h> --#include "jerror.h" -+#include <jerror.h> -+#include <dlfcn.h> -+ - - /* The method IDs we cache. Note that the last two belongs to the - * java.io.InputStream class. -@@ -56,6 +58,32 @@ - static jmethodID InputStream_readID; - static jmethodID InputStream_availableID; - -+typedef struct jpeg_error_mgr * (*fn_jpegstderror)(struct jpeg_error_mgr *); -+typedef void (*fn_jpegcreatedecompress)(j_decompress_ptr, int, size_t); -+typedef boolean (*fn_jpegresynctorestart)(j_decompress_ptr, int); -+typedef JDIMENSION (*fn_jpegreadscanlines)(j_decompress_ptr, JSAMPARRAY, JDIMENSION); -+typedef boolean (*fn_jpegfinishoutput)(j_decompress_ptr); -+typedef int (*fn_jpegreadheader)(j_decompress_ptr, boolean); -+typedef boolean (*fn_jpegstartdecompress)(j_decompress_ptr); -+typedef boolean (*fn_jpeghasmultiplescans)(j_decompress_ptr); -+typedef void (*fn_jpegdestroydecompress)(j_decompress_ptr); -+typedef int (*fn_jpegconsumeinput)(j_decompress_ptr); -+typedef boolean (*fn_jpegfinishdecompress)(j_decompress_ptr); -+typedef boolean (*fn_jpegstartoutput)(j_decompress_ptr, int); -+ -+fn_jpegstderror jpegstderror; -+fn_jpegstartoutput jpegstartoutput; -+fn_jpegfinishdecompress jpegfinishdecompress; -+fn_jpegconsumeinput jpegconsumeinput; -+fn_jpegdestroydecompress jpegdestroydecompress; -+fn_jpeghasmultiplescans jpeghasmultiplescans; -+fn_jpegstartdecompress jpegstartdecompress; -+fn_jpegreadheader jpegreadheader; -+fn_jpegfinishoutput jpegfinishoutput; -+fn_jpegreadscanlines jpegreadscanlines; -+fn_jpegresynctorestart jpegresynctorestart; -+fn_jpegcreatedecompress jpegcreatedecompress; -+ - /* Initialize the Java VM instance variable when the library is - first loaded */ - JavaVM *jvm; -@@ -462,6 +490,68 @@ - Java_sun_awt_image_JPEGImageDecoder_initIDs(JNIEnv *env, jclass cls, - jclass InputStreamClass) - { -+ void *handle = dlopen("libjpeg.so", RTLD_LAZY | RTLD_GLOBAL); -+ -+ jpegstderror = (fn_jpegstderror)dlsym(handle, "jpeg_std_error"); -+ if (jpegstderror == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegdestroydecompress = (fn_jpegdestroydecompress)dlsym(handle, "jpeg_destroy_decompress"); -+ if (jpegdestroydecompress == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegcreatedecompress = (fn_jpegcreatedecompress)dlsym(handle, "jpeg_CreateDecompress"); -+ if (jpegcreatedecompress == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegreadheader = (fn_jpegreadheader)dlsym(handle, "jpeg_read_header"); -+ if (jpegreadheader == NULL) { -+ dlclose(handle); -+ } -+ -+ jpeghasmultiplescans = (fn_jpeghasmultiplescans)dlsym(handle, "jpeg_has_multiple_scans"); -+ if (jpeghasmultiplescans == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegstartdecompress = (fn_jpegstartdecompress)dlsym(handle, "jpeg_start_decompress"); -+ if (jpegstartdecompress == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegconsumeinput = (fn_jpegconsumeinput)dlsym(handle, "jpeg_consume_input"); -+ if (jpegconsumeinput == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegstartoutput = (fn_jpegstartoutput)dlsym(handle, "jpeg_start_output"); -+ if (jpegstartoutput == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegfinishdecompress = (fn_jpegfinishdecompress)dlsym(handle, "jpeg_finish_decompress"); -+ if (jpegfinishdecompress == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegreadscanlines = (fn_jpegreadscanlines)dlsym(handle, "jpeg_read_scanlines"); -+ if (jpegreadscanlines == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegfinishoutput = (fn_jpegfinishoutput)dlsym(handle, "jpeg_finish_output"); -+ if (jpegfinishoutput == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegresynctorestart = (fn_jpegresynctorestart)dlsym(handle, "jpeg_resync_to_restart"); -+ if (jpegresynctorestart == NULL) { -+ dlclose(handle); -+ } -+ - sendHeaderInfoID = (*env)->GetMethodID(env, cls, "sendHeaderInfo", - "(IIZZZ)Z"); - sendPixelsByteID = (*env)->GetMethodID(env, cls, "sendPixels", "([BI)Z"); -@@ -519,7 +609,7 @@ - /* Step 1: allocate and initialize JPEG decompression object */ - - /* We set up the normal JPEG error routines, then override error_exit. */ -- cinfo.err = jpeg_std_error(&jerr.pub); -+ cinfo.err = jpegstderror(&jerr.pub); - jerr.pub.error_exit = sun_jpeg_error_exit; - - /* We need to setup our own print routines */ -@@ -530,7 +620,7 @@ - /* If we get here, the JPEG code has signaled an error. - * We need to clean up the JPEG object, close the input file, and return. - */ -- jpeg_destroy_decompress(&cinfo); -+ jpegdestroydecompress(&cinfo); - RELEASE_ARRAYS(env, &jsrc); - if (!(*env)->ExceptionOccurred(env)) { - char buffer[JMSG_LENGTH_MAX]; -@@ -541,7 +631,7 @@ - return; - } - /* Now we can initialize the JPEG decompression object. */ -- jpeg_create_decompress(&cinfo); -+ jpegcreatedecompress(&cinfo, JPEG_LIB_VERSION, (size_t) sizeof(struct jpeg_decompress_struct)); - - /* Step 2: specify data source (eg, a file) */ - -@@ -555,17 +645,17 @@ - jsrc.pub.init_source = sun_jpeg_init_source; - jsrc.pub.fill_input_buffer = sun_jpeg_fill_input_buffer; - jsrc.pub.skip_input_data = sun_jpeg_skip_input_data; -- jsrc.pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ -+ jsrc.pub.resync_to_restart = jpegresynctorestart; /* use default method */ - jsrc.pub.term_source = sun_jpeg_term_source; - if (!GET_ARRAYS(env, &jsrc)) { -- jpeg_destroy_decompress(&cinfo); -+ jpegdestroydecompress(&cinfo); - return; - } - /* Step 3: read file parameters with jpeg_read_header() */ - -- (void) jpeg_read_header(&cinfo, TRUE); -+ (void) jpegreadheader(&cinfo, TRUE); - /* select buffered-image mode if it is a progressive JPEG only */ -- buffered_mode = cinfo.buffered_image = jpeg_has_multiple_scans(&cinfo); -+ buffered_mode = cinfo.buffered_image = jpeghasmultiplescans(&cinfo); - grayscale = (cinfo.out_color_space == JCS_GRAYSCALE); - #ifdef YCCALPHA - hasalpha = (cinfo.out_color_space == JCS_RGBA); -@@ -584,7 +674,7 @@ - grayscale, hasalpha, buffered_mode); - if ((*env)->ExceptionOccurred(env) || !ret) { - /* No more interest in this image... */ -- jpeg_destroy_decompress(&cinfo); -+ jpegdestroydecompress(&cinfo); - return; - } - /* Make a one-row-high sample array with enough room to expand to ints */ -@@ -595,7 +685,7 @@ - } - - if (jsrc.hOutputBuffer == 0 || !GET_ARRAYS(env, &jsrc)) { -- jpeg_destroy_decompress(&cinfo); -+ jpegdestroydecompress(&cinfo); - return; - } - -@@ -613,7 +703,7 @@ - - /* Step 5: Start decompressor */ - -- jpeg_start_decompress(&cinfo); -+ jpegstartdecompress(&cinfo); - - /* We may need to do some setup of our own at this point before reading - * the data. After jpeg_start_decompress() we have the correct scaled -@@ -638,28 +728,28 @@ - do { - sun_jpeg_fill_suspended_buffer(&cinfo); - jsrc.suspendable = TRUE; -- ret = jpeg_consume_input(&cinfo); -+ ret = jpegconsumeinput(&cinfo); - jsrc.suspendable = FALSE; - } while (ret != JPEG_SUSPENDED && ret != JPEG_REACHED_EOI); - if (ret == JPEG_REACHED_EOI) { - final_pass = TRUE; - cinfo.dct_method = JDCT_ISLOW; - } -- jpeg_start_output(&cinfo, cinfo.input_scan_number); -+ jpegstartoutput(&cinfo, cinfo.input_scan_number); - } - while (cinfo.output_scanline < cinfo.output_height) { - if (! final_pass) { - do { - sun_jpeg_fill_suspended_buffer(&cinfo); - jsrc.suspendable = TRUE; -- ret = jpeg_consume_input(&cinfo); -+ ret = jpegconsumeinput(&cinfo); - jsrc.suspendable = FALSE; - } while (ret != JPEG_SUSPENDED && ret != JPEG_REACHED_EOI); - if (ret == JPEG_REACHED_EOI) { - break; - } - } -- (void) jpeg_read_scanlines(&cinfo, (JSAMPARRAY) &(jsrc.outbuf), 1); -+ (void) jpegreadscanlines(&cinfo, (JSAMPARRAY) &(jsrc.outbuf), 1); - - if (grayscale) { - RELEASE_ARRAYS(env, &jsrc); -@@ -695,18 +785,18 @@ - if ((*env)->ExceptionOccurred(env) || !ret || - !GET_ARRAYS(env, &jsrc)) { - /* No more interest in this image... */ -- jpeg_destroy_decompress(&cinfo); -+ jpegdestroydecompress(&cinfo); - return; - } - } - if (buffered_mode) { -- jpeg_finish_output(&cinfo); -+ jpegfinishoutput(&cinfo); - } - } while (! final_pass); - - /* Step 7: Finish decompression */ - -- (void) jpeg_finish_decompress(&cinfo); -+ (void) jpegfinishdecompress(&cinfo); - /* We can ignore the return value since suspension is not possible - * with the stdio data source. - * (nor with the Java data source) -@@ -715,7 +805,7 @@ - /* Step 8: Release JPEG decompression object */ - - /* This is an important step since it will release a good deal of memory. */ -- jpeg_destroy_decompress(&cinfo); -+ jpegdestroydecompress(&cinfo); - - /* After finish_decompress, we can close the input file. - * Here we postpone it until after no more JPEG errors are possible, ---- openjdk.old/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c 2007-10-12 04:03:48.000000000 -0400 -+++ openjdk/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c 2007-10-24 22:21:25.000000000 -0400 -@@ -51,7 +51,9 @@ - - /* headers from the JPEG library */ - #include <jpeglib.h> --#include "jerror.h" -+#include <jerror.h> -+ -+#include <dlfcn.h> - - #undef MAX - #define MAX(a,b) ((a) > (b) ? (a) : (b)) -@@ -75,6 +77,62 @@ - static jfieldID JPEGHuffmanTable_lengthsID; - static jfieldID JPEGHuffmanTable_valuesID; - -+static void initIDs(); -+ -+typedef struct jpeg_error_mgr * (*fn_jpegstderror)(struct jpeg_error_mgr *); -+typedef boolean (*fn_jpegresynctorestart)(j_decompress_ptr, int); -+typedef JDIMENSION (*fn_jpegreadscanlines)(j_decompress_ptr, JSAMPARRAY, JDIMENSION); -+typedef boolean (*fn_jpegfinishoutput)(j_decompress_ptr); -+typedef int (*fn_jpegreadheader)(j_decompress_ptr, boolean); -+typedef boolean (*fn_jpegstartdecompress)(j_decompress_ptr); -+typedef boolean (*fn_jpeghasmultiplescans)(j_decompress_ptr); -+typedef boolean (*fn_jpegfinishdecompress)(j_decompress_ptr); -+typedef boolean (*fn_jpegstartoutput)(j_decompress_ptr, int); -+typedef void (*fn_jpegabort)(j_common_ptr); -+typedef void (*fn_jpegabortdecompress)(j_decompress_ptr); -+typedef JHUFF_TBL * (*fn_jpegallochufftable)(j_common_ptr); -+typedef JQUANT_TBL * (*fn_jpegallocquanttable)(j_common_ptr); -+typedef void (*fn_jpegcreatecompress)(j_compress_ptr, int, size_t); -+typedef void (*fn_jpegcreatedecompress)(j_decompress_ptr, int, size_t); -+typedef void (*fn_jpegdestroy)(j_common_ptr); -+typedef void (*fn_jpegfinishcompress)(j_compress_ptr); -+typedef boolean (*fn_jpeginputcomplete)(j_decompress_ptr); -+typedef void (*fn_jpegsavemarkers)(j_decompress_ptr, int, unsigned int); -+typedef void (*fn_jpegsetcolorspace)(j_compress_ptr, J_COLOR_SPACE); -+typedef void (*fn_jpegsetdefaults)(j_compress_ptr); -+typedef void (*fn_jpegsimpleprogression)(j_compress_ptr); -+typedef void (*fn_jpegstartcompress)(j_compress_ptr, boolean); -+typedef void (*fn_jpegsuppresstables)(j_compress_ptr, boolean); -+typedef JDIMENSION (*fn_jpegwritescanlines)(j_compress_ptr, JSAMPARRAY, JDIMENSION); -+typedef void (*fn_jpegwritetables)(j_compress_ptr); -+ -+fn_jpegabort jpegabort; -+fn_jpegabortdecompress jpegabortdecompress; -+fn_jpegallochufftable jpegallochufftable; -+fn_jpegallocquanttable jpegallocquanttable; -+fn_jpegcreatecompress jpegcreatecompress; -+fn_jpegcreatedecompress jpegcreatedecompress; -+fn_jpegdestroy jpegdestroy; -+fn_jpegfinishcompress jpegfinishcompress; -+fn_jpeginputcomplete jpeginputcomplete; -+fn_jpegsavemarkers jpegsavemarkers; -+fn_jpegsetcolorspace jpegsetcolorspace; -+fn_jpegsetdefaults jpegsetdefaults; -+fn_jpegsimpleprogression jpegsimpleprogression; -+fn_jpegstartcompress jpegstartcompress; -+fn_jpegsuppresstables jpegsuppresstables; -+fn_jpegwritescanlines jpegwritescanlines; -+fn_jpegwritetables jpegwritetables; -+fn_jpegstderror jpegstderror; -+fn_jpegstartoutput jpegstartoutput; -+fn_jpegfinishdecompress jpegfinishdecompress; -+fn_jpeghasmultiplescans jpeghasmultiplescans; -+fn_jpegstartdecompress jpegstartdecompress; -+fn_jpegreadheader jpegreadheader; -+fn_jpegfinishoutput jpegfinishoutput; -+fn_jpegreadscanlines jpegreadscanlines; -+fn_jpegresynctorestart jpegresynctorestart; -+ - /* - * Defined in jpegdecoder.c. Copy code from there if and - * when that disappears. */ -@@ -606,7 +664,7 @@ - return; - } - -- jpeg_abort(cinfo); // Frees any markers, but not tables -+ jpegabort(cinfo); // Frees any markers, but not tables - - } - -@@ -631,7 +689,7 @@ - return; - } - -- jpeg_abort(cinfo); // Does not reset tables -+ jpegabort(cinfo); // Does not reset tables - - } - -@@ -649,7 +707,7 @@ - free(cinfo->dest); - cinfo->dest = NULL; - } -- jpeg_destroy(info); -+ jpegdestroy(info); - free(info); - } - } -@@ -685,14 +743,14 @@ - decomp = (j_decompress_ptr) cinfo; - if (decomp->quant_tbl_ptrs[i] == NULL) { - decomp->quant_tbl_ptrs[i] = -- jpeg_alloc_quant_table(cinfo); -+ jpegallocquanttable(cinfo); - } - quant_ptr = decomp->quant_tbl_ptrs[i]; - } else { - comp = (j_compress_ptr) cinfo; - if (comp->quant_tbl_ptrs[i] == NULL) { - comp->quant_tbl_ptrs[i] = -- jpeg_alloc_quant_table(cinfo); -+ jpegallocquanttable(cinfo); - } - quant_ptr = comp->quant_tbl_ptrs[i]; - } -@@ -768,14 +826,14 @@ - decomp = (j_decompress_ptr) cinfo; - if (decomp->dc_huff_tbl_ptrs[i] == NULL) { - decomp->dc_huff_tbl_ptrs[i] = -- jpeg_alloc_huff_table(cinfo); -+ jpegallochufftable(cinfo); - } - huff_ptr = decomp->dc_huff_tbl_ptrs[i]; - } else { - comp = (j_compress_ptr) cinfo; - if (comp->dc_huff_tbl_ptrs[i] == NULL) { - comp->dc_huff_tbl_ptrs[i] = -- jpeg_alloc_huff_table(cinfo); -+ jpegallochufftable(cinfo); - } - huff_ptr = comp->dc_huff_tbl_ptrs[i]; - } -@@ -789,14 +847,14 @@ - decomp = (j_decompress_ptr) cinfo; - if (decomp->ac_huff_tbl_ptrs[i] == NULL) { - decomp->ac_huff_tbl_ptrs[i] = -- jpeg_alloc_huff_table(cinfo); -+ jpegallochufftable(cinfo); - } - huff_ptr = decomp->ac_huff_tbl_ptrs[i]; - } else { - comp = (j_compress_ptr) cinfo; - if (comp->ac_huff_tbl_ptrs[i] == NULL) { - comp->ac_huff_tbl_ptrs[i] = -- jpeg_alloc_huff_table(cinfo); -+ jpegallochufftable(cinfo); - } - huff_ptr = comp->ac_huff_tbl_ptrs[i]; - } -@@ -1337,6 +1395,8 @@ - jclass ImageInputStreamClass, - jclass qTableClass, - jclass huffClass) { -+ -+ initIDs(); - - ImageInputStream_readID = (*env)->GetMethodID(env, - ImageInputStreamClass, -@@ -1422,7 +1482,7 @@ - } - - /* We set up the normal JPEG error routines, then override error_exit. */ -- cinfo->err = jpeg_std_error(&(jerr->pub)); -+ cinfo->err = jpegstderror(&(jerr->pub)); - jerr->pub.error_exit = sun_jpeg_error_exit; - /* We need to setup our own print routines */ - jerr->pub.output_message = sun_jpeg_output_message; -@@ -1439,11 +1499,11 @@ - } - - /* Perform library initialization */ -- jpeg_create_decompress(cinfo); -+ jpegcreatedecompress(cinfo, JPEG_LIB_VERSION, (size_t) sizeof(struct jpeg_decompress_struct)); - - // Set up to keep any APP2 markers, as these might contain ICC profile - // data -- jpeg_save_markers(cinfo, ICC_MARKER, 0xFFFF); -+ jpegsavemarkers(cinfo, ICC_MARKER, 0xFFFF); - - /* - * Now set up our source. -@@ -1461,7 +1521,7 @@ - cinfo->src->init_source = imageio_init_source; - cinfo->src->fill_input_buffer = imageio_fill_input_buffer; - cinfo->src->skip_input_data = imageio_skip_input_data; -- cinfo->src->resync_to_restart = jpeg_resync_to_restart; // use default -+ cinfo->src->resync_to_restart = jpegresynctorestart; // use default - cinfo->src->term_source = imageio_term_source; - - /* set up the association to persist for future calls */ -@@ -1579,7 +1639,7 @@ - src->bytes_in_buffer = 0; - } - -- ret = jpeg_read_header(cinfo, FALSE); -+ ret = jpegreadheader(cinfo, FALSE); - - if (ret == JPEG_HEADER_TABLES_ONLY) { - retval = JNI_TRUE; -@@ -1700,7 +1760,7 @@ - cinfo->num_components, - read_icc_profile(env, cinfo)); - if (reset) { -- jpeg_abort_decompress(cinfo); -+ jpegabortdecompress(cinfo); - } - } - -@@ -1896,7 +1956,7 @@ - TRUE); - } - -- progressive = jpeg_has_multiple_scans(cinfo); -+ progressive = jpeghasmultiplescans(cinfo); - if (progressive) { - cinfo->buffered_image = TRUE; - cinfo->input_scan_number = minProgressivePass+1; // Java count from 0 -@@ -1908,7 +1968,7 @@ - - data->streamBuf.suspendable = FALSE; - -- jpeg_start_decompress(cinfo); -+ jpegstartdecompress(cinfo); - - // loop over progressive passes - done = FALSE; -@@ -1916,7 +1976,7 @@ - if (progressive) { - // initialize the next pass. Note that this skips up to - // the first interesting pass. -- jpeg_start_output(cinfo, cinfo->input_scan_number); -+ jpegstartoutput(cinfo, cinfo->input_scan_number); - if (wantUpdates) { - (*env)->CallVoidMethod(env, this, - JPEGImageReader_passStartedID, -@@ -1932,7 +1992,7 @@ - // Skip until the first interesting line - while ((data->abortFlag == JNI_FALSE) - && ((jint)cinfo->output_scanline < sourceYStart)) { -- jpeg_read_scanlines(cinfo, &scanLinePtr, 1); -+ jpegreadscanlines(cinfo, &scanLinePtr, 1); - } - - scanlineLimit = sourceYStart+sourceHeight; -@@ -1945,7 +2005,7 @@ - while ((data->abortFlag == JNI_FALSE) - && ((jint)cinfo->output_scanline < scanlineLimit)) { - -- jpeg_read_scanlines(cinfo, &scanLinePtr, 1); -+ jpegreadscanlines(cinfo, &scanLinePtr, 1); - - // Now mangle it into our buffer - out = data->pixelBuf.buf.bp; -@@ -1993,13 +2053,13 @@ - skipLines = linesLeft; - } - for(i = 0; i < skipLines; i++) { -- jpeg_read_scanlines(cinfo, &scanLinePtr, 1); -+ jpegreadscanlines(cinfo, &scanLinePtr, 1); - } - } - if (progressive) { -- jpeg_finish_output(cinfo); // Increments pass counter -+ jpegfinishoutput(cinfo); // Increments pass counter - // Call Java to notify pass complete -- if (jpeg_input_complete(cinfo) -+ if (jpeginputcomplete(cinfo) - || (cinfo->input_scan_number > maxProgressivePass)) { - done = TRUE; - } -@@ -2019,9 +2079,9 @@ - if (cinfo->output_scanline == cinfo->output_height) { - // if ((cinfo->output_scanline == cinfo->output_height) && - //(jpeg_input_complete(cinfo))) { // We read the whole file -- jpeg_finish_decompress(cinfo); -+ jpegfinishdecompress(cinfo); - } else { -- jpeg_abort_decompress(cinfo); -+ jpegabortdecompress(cinfo); - } - - free(scanLinePtr); -@@ -2067,7 +2127,7 @@ - - cinfo = (j_decompress_ptr) data->jpegObj; - -- jpeg_abort_decompress(cinfo); -+ jpegabortdecompress(cinfo); - } - - -@@ -2273,6 +2333,141 @@ - - /********************** end of destination manager ************/ - -+METHODDEF(void) -+initIDs() -+{ -+ void *handle = dlopen("libjpeg.so", RTLD_LAZY | RTLD_GLOBAL); -+ jpegstderror = (fn_jpegstderror)dlsym(handle, "jpeg_std_error"); -+ if (jpegstderror == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegreadheader = (fn_jpegreadheader)dlsym(handle, "jpeg_read_header"); -+ if (jpegreadheader == NULL) { -+ dlclose(handle); -+ } -+ -+ jpeghasmultiplescans = (fn_jpeghasmultiplescans)dlsym(handle, "jpeg_has_multiple_scans"); -+ if (jpeghasmultiplescans == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegstartdecompress = (fn_jpegstartdecompress)dlsym(handle, "jpeg_start_decompress"); -+ if (jpegstartdecompress == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegstartoutput = (fn_jpegstartoutput)dlsym(handle, "jpeg_start_output"); -+ if (jpegstartoutput == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegfinishdecompress = (fn_jpegfinishdecompress)dlsym(handle, "jpeg_finish_decompress"); -+ if (jpegfinishdecompress == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegreadscanlines = (fn_jpegreadscanlines)dlsym(handle, "jpeg_read_scanlines"); -+ if (jpegreadscanlines == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegfinishoutput = (fn_jpegfinishoutput)dlsym(handle, "jpeg_finish_output"); -+ if (jpegfinishoutput == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegresynctorestart = (fn_jpegresynctorestart)dlsym(handle, "jpeg_resync_to_restart"); -+ if (jpegresynctorestart == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegabort = (fn_jpegabort)dlsym(handle, "jpeg_abort"); -+ if (jpegabort == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegabortdecompress = (fn_jpegabortdecompress)dlsym(handle, "jpeg_abort_decompress"); -+ if (jpegabortdecompress == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegallochufftable = (fn_jpegallochufftable)dlsym(handle, "jpeg_alloc_huff_table"); -+ if (jpegallochufftable == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegallocquanttable = (fn_jpegallocquanttable)dlsym(handle, "jpeg_alloc_quant_table"); -+ if (jpegallocquanttable == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegcreatecompress = (fn_jpegcreatecompress)dlsym(handle, "jpeg_CreateCompress"); -+ if (jpegcreatecompress == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegcreatedecompress = (fn_jpegcreatedecompress)dlsym(handle, "jpeg_CreateDecompress"); -+ if (jpegcreatedecompress == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegdestroy = (fn_jpegdestroy)dlsym(handle, "jpeg_destroy"); -+ if (jpegdestroy == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegfinishcompress = (fn_jpegfinishcompress)dlsym(handle, "jpeg_finish_compress"); -+ if (jpegfinishcompress == NULL) { -+ dlclose(handle); -+ } -+ -+ jpeginputcomplete = (fn_jpeginputcomplete)dlsym(handle, "jpeg_input_complete"); -+ if (jpeginputcomplete == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegsavemarkers = (fn_jpegsavemarkers)dlsym(handle, "jpeg_save_markers"); -+ if (jpegsavemarkers == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegsetcolorspace = (fn_jpegsetcolorspace)dlsym(handle, "jpeg_set_colorspace"); -+ if (jpegsetcolorspace == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegsetdefaults = (fn_jpegsetdefaults)dlsym(handle, "jpeg_set_defaults"); -+ if (jpegsetdefaults == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegsimpleprogression = (fn_jpegsimpleprogression)dlsym(handle, "jpeg_simple_progression"); -+ if (jpegsimpleprogression == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegstartcompress = (fn_jpegstartcompress)dlsym(handle, "jpeg_start_compress"); -+ if (jpegstartcompress == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegsuppresstables = (fn_jpegsuppresstables)dlsym(handle, "jpeg_suppress_tables"); -+ if (jpegsuppresstables == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegwritescanlines = (fn_jpegwritescanlines)dlsym(handle, "jpeg_write_scanlines"); -+ if (jpegwritescanlines == NULL) { -+ dlclose(handle); -+ } -+ -+ jpegwritetables = (fn_jpegwritetables)dlsym(handle, "jpeg_write_tables"); -+ if (jpegwritetables == NULL) { -+ dlclose(handle); -+ } -+} -+ - /********************** Writer JNI calls **********************/ - - -@@ -2284,6 +2479,8 @@ - jclass qTableClass, - jclass huffClass) { - -+ initIDs(); -+ - ImageOutputStream_writeID = (*env)->GetMethodID(env, - IOSClass, - "write", -@@ -2357,7 +2554,7 @@ - } - - /* We set up the normal JPEG error routines, then override error_exit. */ -- cinfo->err = jpeg_std_error(&(jerr->pub)); -+ cinfo->err = jpegstderror(&(jerr->pub)); - jerr->pub.error_exit = sun_jpeg_error_exit; - /* We need to setup our own print routines */ - jerr->pub.output_message = sun_jpeg_output_message; -@@ -2374,7 +2571,7 @@ - } - - /* Perform library initialization */ -- jpeg_create_compress(cinfo); -+ jpegcreatecompress(cinfo, JPEG_LIB_VERSION, (size_t) sizeof(struct jpeg_compress_struct)); - - /* Now set up the destination */ - dest = malloc(sizeof(struct jpeg_destination_mgr)); -@@ -2483,7 +2680,7 @@ - return; - } - -- jpeg_suppress_tables(cinfo, TRUE); // Suppress writing of any current -+ jpegsuppresstables(cinfo, TRUE); // Suppress writing of any current - - data->streamBuf.suspendable = FALSE; - if (qtables != NULL) { -@@ -2498,7 +2695,7 @@ - DCHuffmanTables, ACHuffmanTables, TRUE); - } - -- jpeg_write_tables(cinfo); // Flushes the buffer for you -+ jpegwritetables(cinfo); // Flushes the buffer for you - RELEASE_ARRAYS(env, data, NULL); - } - -@@ -2662,9 +2859,9 @@ - cinfo->input_components = numBands; - cinfo->in_color_space = inCs; - -- jpeg_set_defaults(cinfo); -+ jpegsetdefaults(cinfo); - -- jpeg_set_colorspace(cinfo, outCs); -+ jpegsetcolorspace(cinfo, outCs); - - cinfo->optimize_coding = optimize; - -@@ -2701,7 +2898,7 @@ - (*env)->ReleaseIntArrayElements(env, QtableSelectors, - qsels, JNI_ABORT); - -- jpeg_suppress_tables(cinfo, TRUE); // Disable writing any current -+ jpegsuppresstables(cinfo, TRUE); // Disable writing any current - - qlen = setQTables(env, (j_common_ptr) cinfo, qtables, writeDQT); - -@@ -2726,7 +2923,7 @@ - - if (progressive) { - if (numScans == 0) { // then use default scans -- jpeg_simple_progression(cinfo); -+ jpegsimpleprogression(cinfo); - } else { - cinfo->num_scans = numScans; - // Copy the scanInfo to a local array -@@ -2768,7 +2965,7 @@ - #endif - - // start the compressor; tables must already be set -- jpeg_start_compress(cinfo, FALSE); // Leaves sent_table alone -+ jpegstartcompress(cinfo, FALSE); // Leaves sent_table alone - - if (haveMetadata) { - // Flush the buffer -@@ -2829,7 +3026,7 @@ - } - } - // write it out -- jpeg_write_scanlines(cinfo, (JSAMPARRAY)&scanLinePtr, 1); -+ jpegwritescanlines(cinfo, (JSAMPARRAY)&scanLinePtr, 1); - targetLine += stepY; - } - -@@ -2838,9 +3035,9 @@ - * so use jpeg_abort instead of jpeg_finish_compress. - */ - if (cinfo->next_scanline == cinfo->image_height) { -- jpeg_finish_compress(cinfo); // Flushes buffer with term_dest -+ jpegfinishcompress(cinfo); // Flushes buffer with term_dest - } else { -- jpeg_abort((j_common_ptr)cinfo); -+ jpegabort((j_common_ptr)cinfo); - } - - if (scale != NULL) { --- oldopenjdk/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h 2007-10-12 04:03:44.000000000 -0400 +++ openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h 2007-11-02 15:48:45.000000000 -0400 @@ -87,11 +87,7 @@ @@ -25539,3 +24741,805 @@ endif endif #LINUX endif #PLATFORM +--- origopenjdk/jdk/src/share/native/sun/awt/image/jpeg/jpegdecoder.c 2008-01-04 18:21:02.000000000 -0500 ++++ openjdk/jdk/src/share/native/sun/awt/image/jpeg/jpegdecoder.c 2008-01-13 23:54:15.000000000 -0500 +@@ -45,7 +45,9 @@ + #undef boolean + #undef FAR + #include <jpeglib.h> +-#include "jerror.h" ++#include <jerror.h> ++#include <dlfcn.h> ++ + + /* The method IDs we cache. Note that the last two belongs to the + * java.io.InputStream class. +@@ -56,6 +58,32 @@ + static jmethodID InputStream_readID; + static jmethodID InputStream_availableID; + ++typedef struct jpeg_error_mgr * (*fn_jpegstderror)(struct jpeg_error_mgr *); ++typedef void (*fn_jpegcreatedecompress)(j_decompress_ptr, int, size_t); ++typedef boolean (*fn_jpegresynctorestart)(j_decompress_ptr, int); ++typedef JDIMENSION (*fn_jpegreadscanlines)(j_decompress_ptr, JSAMPARRAY, JDIMENSION); ++typedef boolean (*fn_jpegfinishoutput)(j_decompress_ptr); ++typedef int (*fn_jpegreadheader)(j_decompress_ptr, boolean); ++typedef boolean (*fn_jpegstartdecompress)(j_decompress_ptr); ++typedef boolean (*fn_jpeghasmultiplescans)(j_decompress_ptr); ++typedef void (*fn_jpegdestroydecompress)(j_decompress_ptr); ++typedef int (*fn_jpegconsumeinput)(j_decompress_ptr); ++typedef boolean (*fn_jpegfinishdecompress)(j_decompress_ptr); ++typedef boolean (*fn_jpegstartoutput)(j_decompress_ptr, int); ++ ++fn_jpegstderror jpegstderror; ++fn_jpegstartoutput jpegstartoutput; ++fn_jpegfinishdecompress jpegfinishdecompress; ++fn_jpegconsumeinput jpegconsumeinput; ++fn_jpegdestroydecompress jpegdestroydecompress; ++fn_jpeghasmultiplescans jpeghasmultiplescans; ++fn_jpegstartdecompress jpegstartdecompress; ++fn_jpegreadheader jpegreadheader; ++fn_jpegfinishoutput jpegfinishoutput; ++fn_jpegreadscanlines jpegreadscanlines; ++fn_jpegresynctorestart jpegresynctorestart; ++fn_jpegcreatedecompress jpegcreatedecompress; ++ + /* Initialize the Java VM instance variable when the library is + first loaded */ + JavaVM *jvm; +@@ -462,6 +490,70 @@ + Java_sun_awt_image_JPEGImageDecoder_initIDs(JNIEnv *env, jclass cls, + jclass InputStreamClass) + { ++ void *handle = dlopen("/usr/lib/libjpeg.so", RTLD_LAZY | RTLD_GLOBAL); ++ if (handle == NULL) ++ handle = dlopen("/usr/lib64/libjpeg.so", RTLD_LAZY | RTLD_GLOBAL); ++ ++ jpegstderror = (fn_jpegstderror)dlsym(handle, "jpeg_std_error"); ++ if (jpegstderror == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegdestroydecompress = (fn_jpegdestroydecompress)dlsym(handle, "jpeg_destroy_decompress"); ++ if (jpegdestroydecompress == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegcreatedecompress = (fn_jpegcreatedecompress)dlsym(handle, "jpeg_CreateDecompress"); ++ if (jpegcreatedecompress == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegreadheader = (fn_jpegreadheader)dlsym(handle, "jpeg_read_header"); ++ if (jpegreadheader == NULL) { ++ dlclose(handle); ++ } ++ ++ jpeghasmultiplescans = (fn_jpeghasmultiplescans)dlsym(handle, "jpeg_has_multiple_scans"); ++ if (jpeghasmultiplescans == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegstartdecompress = (fn_jpegstartdecompress)dlsym(handle, "jpeg_start_decompress"); ++ if (jpegstartdecompress == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegconsumeinput = (fn_jpegconsumeinput)dlsym(handle, "jpeg_consume_input"); ++ if (jpegconsumeinput == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegstartoutput = (fn_jpegstartoutput)dlsym(handle, "jpeg_start_output"); ++ if (jpegstartoutput == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegfinishdecompress = (fn_jpegfinishdecompress)dlsym(handle, "jpeg_finish_decompress"); ++ if (jpegfinishdecompress == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegreadscanlines = (fn_jpegreadscanlines)dlsym(handle, "jpeg_read_scanlines"); ++ if (jpegreadscanlines == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegfinishoutput = (fn_jpegfinishoutput)dlsym(handle, "jpeg_finish_output"); ++ if (jpegfinishoutput == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegresynctorestart = (fn_jpegresynctorestart)dlsym(handle, "jpeg_resync_to_restart"); ++ if (jpegresynctorestart == NULL) { ++ dlclose(handle); ++ } ++ + sendHeaderInfoID = (*env)->GetMethodID(env, cls, "sendHeaderInfo", + "(IIZZZ)Z"); + sendPixelsByteID = (*env)->GetMethodID(env, cls, "sendPixels", "([BI)Z"); +@@ -519,7 +611,7 @@ + /* Step 1: allocate and initialize JPEG decompression object */ + + /* We set up the normal JPEG error routines, then override error_exit. */ +- cinfo.err = jpeg_std_error(&jerr.pub); ++ cinfo.err = jpegstderror(&jerr.pub); + jerr.pub.error_exit = sun_jpeg_error_exit; + + /* We need to setup our own print routines */ +@@ -530,7 +622,7 @@ + /* If we get here, the JPEG code has signaled an error. + * We need to clean up the JPEG object, close the input file, and return. + */ +- jpeg_destroy_decompress(&cinfo); ++ jpegdestroydecompress(&cinfo); + RELEASE_ARRAYS(env, &jsrc); + if (!(*env)->ExceptionOccurred(env)) { + char buffer[JMSG_LENGTH_MAX]; +@@ -541,7 +633,7 @@ + return; + } + /* Now we can initialize the JPEG decompression object. */ +- jpeg_create_decompress(&cinfo); ++ jpegcreatedecompress(&cinfo, JPEG_LIB_VERSION, (size_t) sizeof(struct jpeg_decompress_struct)); + + /* Step 2: specify data source (eg, a file) */ + +@@ -555,17 +647,17 @@ + jsrc.pub.init_source = sun_jpeg_init_source; + jsrc.pub.fill_input_buffer = sun_jpeg_fill_input_buffer; + jsrc.pub.skip_input_data = sun_jpeg_skip_input_data; +- jsrc.pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ ++ jsrc.pub.resync_to_restart = jpegresynctorestart; /* use default method */ + jsrc.pub.term_source = sun_jpeg_term_source; + if (!GET_ARRAYS(env, &jsrc)) { +- jpeg_destroy_decompress(&cinfo); ++ jpegdestroydecompress(&cinfo); + return; + } + /* Step 3: read file parameters with jpeg_read_header() */ + +- (void) jpeg_read_header(&cinfo, TRUE); ++ (void) jpegreadheader(&cinfo, TRUE); + /* select buffered-image mode if it is a progressive JPEG only */ +- buffered_mode = cinfo.buffered_image = jpeg_has_multiple_scans(&cinfo); ++ buffered_mode = cinfo.buffered_image = jpeghasmultiplescans(&cinfo); + grayscale = (cinfo.out_color_space == JCS_GRAYSCALE); + #ifdef YCCALPHA + hasalpha = (cinfo.out_color_space == JCS_RGBA); +@@ -584,7 +676,7 @@ + grayscale, hasalpha, buffered_mode); + if ((*env)->ExceptionOccurred(env) || !ret) { + /* No more interest in this image... */ +- jpeg_destroy_decompress(&cinfo); ++ jpegdestroydecompress(&cinfo); + return; + } + /* Make a one-row-high sample array with enough room to expand to ints */ +@@ -595,7 +687,7 @@ + } + + if (jsrc.hOutputBuffer == 0 || !GET_ARRAYS(env, &jsrc)) { +- jpeg_destroy_decompress(&cinfo); ++ jpegdestroydecompress(&cinfo); + return; + } + +@@ -613,7 +705,7 @@ + + /* Step 5: Start decompressor */ + +- jpeg_start_decompress(&cinfo); ++ jpegstartdecompress(&cinfo); + + /* We may need to do some setup of our own at this point before reading + * the data. After jpeg_start_decompress() we have the correct scaled +@@ -638,28 +730,28 @@ + do { + sun_jpeg_fill_suspended_buffer(&cinfo); + jsrc.suspendable = TRUE; +- ret = jpeg_consume_input(&cinfo); ++ ret = jpegconsumeinput(&cinfo); + jsrc.suspendable = FALSE; + } while (ret != JPEG_SUSPENDED && ret != JPEG_REACHED_EOI); + if (ret == JPEG_REACHED_EOI) { + final_pass = TRUE; + cinfo.dct_method = JDCT_ISLOW; + } +- jpeg_start_output(&cinfo, cinfo.input_scan_number); ++ jpegstartoutput(&cinfo, cinfo.input_scan_number); + } + while (cinfo.output_scanline < cinfo.output_height) { + if (! final_pass) { + do { + sun_jpeg_fill_suspended_buffer(&cinfo); + jsrc.suspendable = TRUE; +- ret = jpeg_consume_input(&cinfo); ++ ret = jpegconsumeinput(&cinfo); + jsrc.suspendable = FALSE; + } while (ret != JPEG_SUSPENDED && ret != JPEG_REACHED_EOI); + if (ret == JPEG_REACHED_EOI) { + break; + } + } +- (void) jpeg_read_scanlines(&cinfo, (JSAMPARRAY) &(jsrc.outbuf), 1); ++ (void) jpegreadscanlines(&cinfo, (JSAMPARRAY) &(jsrc.outbuf), 1); + + if (grayscale) { + RELEASE_ARRAYS(env, &jsrc); +@@ -695,18 +787,18 @@ + if ((*env)->ExceptionOccurred(env) || !ret || + !GET_ARRAYS(env, &jsrc)) { + /* No more interest in this image... */ +- jpeg_destroy_decompress(&cinfo); ++ jpegdestroydecompress(&cinfo); + return; + } + } + if (buffered_mode) { +- jpeg_finish_output(&cinfo); ++ jpegfinishoutput(&cinfo); + } + } while (! final_pass); + + /* Step 7: Finish decompression */ + +- (void) jpeg_finish_decompress(&cinfo); ++ (void) jpegfinishdecompress(&cinfo); + /* We can ignore the return value since suspension is not possible + * with the stdio data source. + * (nor with the Java data source) +@@ -715,7 +807,7 @@ + /* Step 8: Release JPEG decompression object */ + + /* This is an important step since it will release a good deal of memory. */ +- jpeg_destroy_decompress(&cinfo); ++ jpegdestroydecompress(&cinfo); + + /* After finish_decompress, we can close the input file. + * Here we postpone it until after no more JPEG errors are possible, +--- origopenjdk/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c 2008-01-04 18:21:02.000000000 -0500 ++++ openjdk/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c 2008-01-13 23:53:42.000000000 -0500 +@@ -51,7 +51,9 @@ + + /* headers from the JPEG library */ + #include <jpeglib.h> +-#include "jerror.h" ++#include <jerror.h> ++ ++#include <dlfcn.h> + + #undef MAX + #define MAX(a,b) ((a) > (b) ? (a) : (b)) +@@ -75,6 +77,62 @@ + static jfieldID JPEGHuffmanTable_lengthsID; + static jfieldID JPEGHuffmanTable_valuesID; + ++static void initIDs(); ++ ++typedef struct jpeg_error_mgr * (*fn_jpegstderror)(struct jpeg_error_mgr *); ++typedef boolean (*fn_jpegresynctorestart)(j_decompress_ptr, int); ++typedef JDIMENSION (*fn_jpegreadscanlines)(j_decompress_ptr, JSAMPARRAY, JDIMENSION); ++typedef boolean (*fn_jpegfinishoutput)(j_decompress_ptr); ++typedef int (*fn_jpegreadheader)(j_decompress_ptr, boolean); ++typedef boolean (*fn_jpegstartdecompress)(j_decompress_ptr); ++typedef boolean (*fn_jpeghasmultiplescans)(j_decompress_ptr); ++typedef boolean (*fn_jpegfinishdecompress)(j_decompress_ptr); ++typedef boolean (*fn_jpegstartoutput)(j_decompress_ptr, int); ++typedef void (*fn_jpegabort)(j_common_ptr); ++typedef void (*fn_jpegabortdecompress)(j_decompress_ptr); ++typedef JHUFF_TBL * (*fn_jpegallochufftable)(j_common_ptr); ++typedef JQUANT_TBL * (*fn_jpegallocquanttable)(j_common_ptr); ++typedef void (*fn_jpegcreatecompress)(j_compress_ptr, int, size_t); ++typedef void (*fn_jpegcreatedecompress)(j_decompress_ptr, int, size_t); ++typedef void (*fn_jpegdestroy)(j_common_ptr); ++typedef void (*fn_jpegfinishcompress)(j_compress_ptr); ++typedef boolean (*fn_jpeginputcomplete)(j_decompress_ptr); ++typedef void (*fn_jpegsavemarkers)(j_decompress_ptr, int, unsigned int); ++typedef void (*fn_jpegsetcolorspace)(j_compress_ptr, J_COLOR_SPACE); ++typedef void (*fn_jpegsetdefaults)(j_compress_ptr); ++typedef void (*fn_jpegsimpleprogression)(j_compress_ptr); ++typedef void (*fn_jpegstartcompress)(j_compress_ptr, boolean); ++typedef void (*fn_jpegsuppresstables)(j_compress_ptr, boolean); ++typedef JDIMENSION (*fn_jpegwritescanlines)(j_compress_ptr, JSAMPARRAY, JDIMENSION); ++typedef void (*fn_jpegwritetables)(j_compress_ptr); ++ ++fn_jpegabort jpegabort; ++fn_jpegabortdecompress jpegabortdecompress; ++fn_jpegallochufftable jpegallochufftable; ++fn_jpegallocquanttable jpegallocquanttable; ++fn_jpegcreatecompress jpegcreatecompress; ++fn_jpegcreatedecompress jpegcreatedecompress; ++fn_jpegdestroy jpegdestroy; ++fn_jpegfinishcompress jpegfinishcompress; ++fn_jpeginputcomplete jpeginputcomplete; ++fn_jpegsavemarkers jpegsavemarkers; ++fn_jpegsetcolorspace jpegsetcolorspace; ++fn_jpegsetdefaults jpegsetdefaults; ++fn_jpegsimpleprogression jpegsimpleprogression; ++fn_jpegstartcompress jpegstartcompress; ++fn_jpegsuppresstables jpegsuppresstables; ++fn_jpegwritescanlines jpegwritescanlines; ++fn_jpegwritetables jpegwritetables; ++fn_jpegstderror jpegstderror; ++fn_jpegstartoutput jpegstartoutput; ++fn_jpegfinishdecompress jpegfinishdecompress; ++fn_jpeghasmultiplescans jpeghasmultiplescans; ++fn_jpegstartdecompress jpegstartdecompress; ++fn_jpegreadheader jpegreadheader; ++fn_jpegfinishoutput jpegfinishoutput; ++fn_jpegreadscanlines jpegreadscanlines; ++fn_jpegresynctorestart jpegresynctorestart; ++ + /* + * Defined in jpegdecoder.c. Copy code from there if and + * when that disappears. */ +@@ -606,7 +664,7 @@ + return; + } + +- jpeg_abort(cinfo); // Frees any markers, but not tables ++ jpegabort(cinfo); // Frees any markers, but not tables + + } + +@@ -631,7 +689,7 @@ + return; + } + +- jpeg_abort(cinfo); // Does not reset tables ++ jpegabort(cinfo); // Does not reset tables + + } + +@@ -649,7 +707,7 @@ + free(cinfo->dest); + cinfo->dest = NULL; + } +- jpeg_destroy(info); ++ jpegdestroy(info); + free(info); + } + } +@@ -685,14 +743,14 @@ + decomp = (j_decompress_ptr) cinfo; + if (decomp->quant_tbl_ptrs[i] == NULL) { + decomp->quant_tbl_ptrs[i] = +- jpeg_alloc_quant_table(cinfo); ++ jpegallocquanttable(cinfo); + } + quant_ptr = decomp->quant_tbl_ptrs[i]; + } else { + comp = (j_compress_ptr) cinfo; + if (comp->quant_tbl_ptrs[i] == NULL) { + comp->quant_tbl_ptrs[i] = +- jpeg_alloc_quant_table(cinfo); ++ jpegallocquanttable(cinfo); + } + quant_ptr = comp->quant_tbl_ptrs[i]; + } +@@ -768,14 +826,14 @@ + decomp = (j_decompress_ptr) cinfo; + if (decomp->dc_huff_tbl_ptrs[i] == NULL) { + decomp->dc_huff_tbl_ptrs[i] = +- jpeg_alloc_huff_table(cinfo); ++ jpegallochufftable(cinfo); + } + huff_ptr = decomp->dc_huff_tbl_ptrs[i]; + } else { + comp = (j_compress_ptr) cinfo; + if (comp->dc_huff_tbl_ptrs[i] == NULL) { + comp->dc_huff_tbl_ptrs[i] = +- jpeg_alloc_huff_table(cinfo); ++ jpegallochufftable(cinfo); + } + huff_ptr = comp->dc_huff_tbl_ptrs[i]; + } +@@ -789,14 +847,14 @@ + decomp = (j_decompress_ptr) cinfo; + if (decomp->ac_huff_tbl_ptrs[i] == NULL) { + decomp->ac_huff_tbl_ptrs[i] = +- jpeg_alloc_huff_table(cinfo); ++ jpegallochufftable(cinfo); + } + huff_ptr = decomp->ac_huff_tbl_ptrs[i]; + } else { + comp = (j_compress_ptr) cinfo; + if (comp->ac_huff_tbl_ptrs[i] == NULL) { + comp->ac_huff_tbl_ptrs[i] = +- jpeg_alloc_huff_table(cinfo); ++ jpegallochufftable(cinfo); + } + huff_ptr = comp->ac_huff_tbl_ptrs[i]; + } +@@ -1337,6 +1395,8 @@ + jclass ImageInputStreamClass, + jclass qTableClass, + jclass huffClass) { ++ ++ initIDs(); + + ImageInputStream_readID = (*env)->GetMethodID(env, + ImageInputStreamClass, +@@ -1422,7 +1482,7 @@ + } + + /* We set up the normal JPEG error routines, then override error_exit. */ +- cinfo->err = jpeg_std_error(&(jerr->pub)); ++ cinfo->err = jpegstderror(&(jerr->pub)); + jerr->pub.error_exit = sun_jpeg_error_exit; + /* We need to setup our own print routines */ + jerr->pub.output_message = sun_jpeg_output_message; +@@ -1439,11 +1499,11 @@ + } + + /* Perform library initialization */ +- jpeg_create_decompress(cinfo); ++ jpegcreatedecompress(cinfo, JPEG_LIB_VERSION, (size_t) sizeof(struct jpeg_decompress_struct)); + + // Set up to keep any APP2 markers, as these might contain ICC profile + // data +- jpeg_save_markers(cinfo, ICC_MARKER, 0xFFFF); ++ jpegsavemarkers(cinfo, ICC_MARKER, 0xFFFF); + + /* + * Now set up our source. +@@ -1461,7 +1521,7 @@ + cinfo->src->init_source = imageio_init_source; + cinfo->src->fill_input_buffer = imageio_fill_input_buffer; + cinfo->src->skip_input_data = imageio_skip_input_data; +- cinfo->src->resync_to_restart = jpeg_resync_to_restart; // use default ++ cinfo->src->resync_to_restart = jpegresynctorestart; // use default + cinfo->src->term_source = imageio_term_source; + + /* set up the association to persist for future calls */ +@@ -1579,7 +1639,7 @@ + src->bytes_in_buffer = 0; + } + +- ret = jpeg_read_header(cinfo, FALSE); ++ ret = jpegreadheader(cinfo, FALSE); + + if (ret == JPEG_HEADER_TABLES_ONLY) { + retval = JNI_TRUE; +@@ -1700,7 +1760,7 @@ + cinfo->num_components, + read_icc_profile(env, cinfo)); + if (reset) { +- jpeg_abort_decompress(cinfo); ++ jpegabortdecompress(cinfo); + } + } + +@@ -1896,7 +1956,7 @@ + TRUE); + } + +- progressive = jpeg_has_multiple_scans(cinfo); ++ progressive = jpeghasmultiplescans(cinfo); + if (progressive) { + cinfo->buffered_image = TRUE; + cinfo->input_scan_number = minProgressivePass+1; // Java count from 0 +@@ -1908,7 +1968,7 @@ + + data->streamBuf.suspendable = FALSE; + +- jpeg_start_decompress(cinfo); ++ jpegstartdecompress(cinfo); + + // loop over progressive passes + done = FALSE; +@@ -1916,7 +1976,7 @@ + if (progressive) { + // initialize the next pass. Note that this skips up to + // the first interesting pass. +- jpeg_start_output(cinfo, cinfo->input_scan_number); ++ jpegstartoutput(cinfo, cinfo->input_scan_number); + if (wantUpdates) { + (*env)->CallVoidMethod(env, this, + JPEGImageReader_passStartedID, +@@ -1932,7 +1992,7 @@ + // Skip until the first interesting line + while ((data->abortFlag == JNI_FALSE) + && ((jint)cinfo->output_scanline < sourceYStart)) { +- jpeg_read_scanlines(cinfo, &scanLinePtr, 1); ++ jpegreadscanlines(cinfo, &scanLinePtr, 1); + } + + scanlineLimit = sourceYStart+sourceHeight; +@@ -1945,7 +2005,7 @@ + while ((data->abortFlag == JNI_FALSE) + && ((jint)cinfo->output_scanline < scanlineLimit)) { + +- jpeg_read_scanlines(cinfo, &scanLinePtr, 1); ++ jpegreadscanlines(cinfo, &scanLinePtr, 1); + + // Now mangle it into our buffer + out = data->pixelBuf.buf.bp; +@@ -1993,13 +2053,13 @@ + skipLines = linesLeft; + } + for(i = 0; i < skipLines; i++) { +- jpeg_read_scanlines(cinfo, &scanLinePtr, 1); ++ jpegreadscanlines(cinfo, &scanLinePtr, 1); + } + } + if (progressive) { +- jpeg_finish_output(cinfo); // Increments pass counter ++ jpegfinishoutput(cinfo); // Increments pass counter + // Call Java to notify pass complete +- if (jpeg_input_complete(cinfo) ++ if (jpeginputcomplete(cinfo) + || (cinfo->input_scan_number > maxProgressivePass)) { + done = TRUE; + } +@@ -2019,9 +2079,9 @@ + if (cinfo->output_scanline == cinfo->output_height) { + // if ((cinfo->output_scanline == cinfo->output_height) && + //(jpeg_input_complete(cinfo))) { // We read the whole file +- jpeg_finish_decompress(cinfo); ++ jpegfinishdecompress(cinfo); + } else { +- jpeg_abort_decompress(cinfo); ++ jpegabortdecompress(cinfo); + } + + free(scanLinePtr); +@@ -2067,7 +2127,7 @@ + + cinfo = (j_decompress_ptr) data->jpegObj; + +- jpeg_abort_decompress(cinfo); ++ jpegabortdecompress(cinfo); + } + + +@@ -2273,6 +2333,143 @@ + + /********************** end of destination manager ************/ + ++METHODDEF(void) ++initIDs() ++{ ++ void *handle = dlopen("/usr/lib/libjpeg.so", RTLD_LAZY | RTLD_GLOBAL); ++ if (handle == NULL) ++ handle = dlopen("/usr/lib64/libjpeg.so", RTLD_LAZY | RTLD_GLOBAL); ++ jpegstderror = (fn_jpegstderror)dlsym(handle, "jpeg_std_error"); ++ if (jpegstderror == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegreadheader = (fn_jpegreadheader)dlsym(handle, "jpeg_read_header"); ++ if (jpegreadheader == NULL) { ++ dlclose(handle); ++ } ++ ++ jpeghasmultiplescans = (fn_jpeghasmultiplescans)dlsym(handle, "jpeg_has_multiple_scans"); ++ if (jpeghasmultiplescans == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegstartdecompress = (fn_jpegstartdecompress)dlsym(handle, "jpeg_start_decompress"); ++ if (jpegstartdecompress == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegstartoutput = (fn_jpegstartoutput)dlsym(handle, "jpeg_start_output"); ++ if (jpegstartoutput == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegfinishdecompress = (fn_jpegfinishdecompress)dlsym(handle, "jpeg_finish_decompress"); ++ if (jpegfinishdecompress == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegreadscanlines = (fn_jpegreadscanlines)dlsym(handle, "jpeg_read_scanlines"); ++ if (jpegreadscanlines == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegfinishoutput = (fn_jpegfinishoutput)dlsym(handle, "jpeg_finish_output"); ++ if (jpegfinishoutput == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegresynctorestart = (fn_jpegresynctorestart)dlsym(handle, "jpeg_resync_to_restart"); ++ if (jpegresynctorestart == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegabort = (fn_jpegabort)dlsym(handle, "jpeg_abort"); ++ if (jpegabort == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegabortdecompress = (fn_jpegabortdecompress)dlsym(handle, "jpeg_abort_decompress"); ++ if (jpegabortdecompress == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegallochufftable = (fn_jpegallochufftable)dlsym(handle, "jpeg_alloc_huff_table"); ++ if (jpegallochufftable == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegallocquanttable = (fn_jpegallocquanttable)dlsym(handle, "jpeg_alloc_quant_table"); ++ if (jpegallocquanttable == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegcreatecompress = (fn_jpegcreatecompress)dlsym(handle, "jpeg_CreateCompress"); ++ if (jpegcreatecompress == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegcreatedecompress = (fn_jpegcreatedecompress)dlsym(handle, "jpeg_CreateDecompress"); ++ if (jpegcreatedecompress == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegdestroy = (fn_jpegdestroy)dlsym(handle, "jpeg_destroy"); ++ if (jpegdestroy == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegfinishcompress = (fn_jpegfinishcompress)dlsym(handle, "jpeg_finish_compress"); ++ if (jpegfinishcompress == NULL) { ++ dlclose(handle); ++ } ++ ++ jpeginputcomplete = (fn_jpeginputcomplete)dlsym(handle, "jpeg_input_complete"); ++ if (jpeginputcomplete == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegsavemarkers = (fn_jpegsavemarkers)dlsym(handle, "jpeg_save_markers"); ++ if (jpegsavemarkers == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegsetcolorspace = (fn_jpegsetcolorspace)dlsym(handle, "jpeg_set_colorspace"); ++ if (jpegsetcolorspace == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegsetdefaults = (fn_jpegsetdefaults)dlsym(handle, "jpeg_set_defaults"); ++ if (jpegsetdefaults == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegsimpleprogression = (fn_jpegsimpleprogression)dlsym(handle, "jpeg_simple_progression"); ++ if (jpegsimpleprogression == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegstartcompress = (fn_jpegstartcompress)dlsym(handle, "jpeg_start_compress"); ++ if (jpegstartcompress == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegsuppresstables = (fn_jpegsuppresstables)dlsym(handle, "jpeg_suppress_tables"); ++ if (jpegsuppresstables == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegwritescanlines = (fn_jpegwritescanlines)dlsym(handle, "jpeg_write_scanlines"); ++ if (jpegwritescanlines == NULL) { ++ dlclose(handle); ++ } ++ ++ jpegwritetables = (fn_jpegwritetables)dlsym(handle, "jpeg_write_tables"); ++ if (jpegwritetables == NULL) { ++ dlclose(handle); ++ } ++} ++ + /********************** Writer JNI calls **********************/ + + +@@ -2284,6 +2481,8 @@ + jclass qTableClass, + jclass huffClass) { + ++ initIDs(); ++ + ImageOutputStream_writeID = (*env)->GetMethodID(env, + IOSClass, + "write", +@@ -2357,7 +2556,7 @@ + } + + /* We set up the normal JPEG error routines, then override error_exit. */ +- cinfo->err = jpeg_std_error(&(jerr->pub)); ++ cinfo->err = jpegstderror(&(jerr->pub)); + jerr->pub.error_exit = sun_jpeg_error_exit; + /* We need to setup our own print routines */ + jerr->pub.output_message = sun_jpeg_output_message; +@@ -2374,7 +2573,7 @@ + } + + /* Perform library initialization */ +- jpeg_create_compress(cinfo); ++ jpegcreatecompress(cinfo, JPEG_LIB_VERSION, (size_t) sizeof(struct jpeg_compress_struct)); + + /* Now set up the destination */ + dest = malloc(sizeof(struct jpeg_destination_mgr)); +@@ -2483,7 +2682,7 @@ + return; + } + +- jpeg_suppress_tables(cinfo, TRUE); // Suppress writing of any current ++ jpegsuppresstables(cinfo, TRUE); // Suppress writing of any current + + data->streamBuf.suspendable = FALSE; + if (qtables != NULL) { +@@ -2498,7 +2697,7 @@ + DCHuffmanTables, ACHuffmanTables, TRUE); + } + +- jpeg_write_tables(cinfo); // Flushes the buffer for you ++ jpegwritetables(cinfo); // Flushes the buffer for you + RELEASE_ARRAYS(env, data, NULL); + } + +@@ -2662,9 +2861,9 @@ + cinfo->input_components = numBands; + cinfo->in_color_space = inCs; + +- jpeg_set_defaults(cinfo); ++ jpegsetdefaults(cinfo); + +- jpeg_set_colorspace(cinfo, outCs); ++ jpegsetcolorspace(cinfo, outCs); + + cinfo->optimize_coding = optimize; + +@@ -2701,7 +2900,7 @@ + (*env)->ReleaseIntArrayElements(env, QtableSelectors, + qsels, JNI_ABORT); + +- jpeg_suppress_tables(cinfo, TRUE); // Disable writing any current ++ jpegsuppresstables(cinfo, TRUE); // Disable writing any current + + qlen = setQTables(env, (j_common_ptr) cinfo, qtables, writeDQT); + +@@ -2726,7 +2925,7 @@ + + if (progressive) { + if (numScans == 0) { // then use default scans +- jpeg_simple_progression(cinfo); ++ jpegsimpleprogression(cinfo); + } else { + cinfo->num_scans = numScans; + // Copy the scanInfo to a local array +@@ -2768,7 +2967,7 @@ + #endif + + // start the compressor; tables must already be set +- jpeg_start_compress(cinfo, FALSE); // Leaves sent_table alone ++ jpegstartcompress(cinfo, FALSE); // Leaves sent_table alone + + if (haveMetadata) { + // Flush the buffer +@@ -2829,7 +3028,7 @@ + } + } + // write it out +- jpeg_write_scanlines(cinfo, (JSAMPARRAY)&scanLinePtr, 1); ++ jpegwritescanlines(cinfo, (JSAMPARRAY)&scanLinePtr, 1); + targetLine += stepY; + } + +@@ -2838,9 +3037,9 @@ + * so use jpeg_abort instead of jpeg_finish_compress. + */ + if (cinfo->next_scanline == cinfo->image_height) { +- jpeg_finish_compress(cinfo); // Flushes buffer with term_dest ++ jpegfinishcompress(cinfo); // Flushes buffer with term_dest + } else { +- jpeg_abort((j_common_ptr)cinfo); ++ jpegabort((j_common_ptr)cinfo); + } + + if (scale != NULL) {