[pHash-support] throwing exceptions from the binding code into the java glue

Alexander Kjäll - alaTest alex at alatest.com
Wed May 19 06:04:04 PDT 2010


Sounds like a good thing to disable exceptions, is this an option to the 
configure script?

I looked at the code in the CVS version of CImg:

if (setjmp(jerr.setjmp_buffer)) { // JPEG error
   throw CImgIOException(_cimg_instance
            "load_jpeg() : Error message returned by libjpeg : %s.",

(around line 30766 in CImg.h)

And it doesn't look like the throwing of the exception is optional, but 
it was a pretty long time since I programmed c++ seriously, so I might 
be totally out on this one.

When I have had some more time to look at how this work I try to think 
up a good structure for sending the error's into java.

best regards
Alexander Kjäll

On 2010-05-17 18:04, Evan Klinger wrote:
> Hello,
> Currently we disable CImg exceptions during compilation since they add
> considerable overhead. I understand the value they provide, but I'm
> wondering if it's possible to have them disabled in CImg/pHash and
> simply check the return code from CImg functions and throw exceptions
> in the Java code only. For example, if the CImg jpeg load function
> fails, the returned pointer will be NULL which can be tested and then
> throw your IllegalImageException in Java.
> Evan
> 2010/5/17 Alexander Kjäll - alaTest<alex at alatest.com>:
>> Hi again
>> I solved my problem with libjpeg by upgrading my installation of the CImg
>> library to the latest version.
>> The next step is to make the exceptions that the CImg library throws visible
>> to the java code, i wrote a small patch and a corresponding java exception
>> class as a testcase on how it would be possible to do this.
>> the exception class should be placed in bindings/java/org/pHash/exceptions/
>> This is a rather incomplete patch, and I don't think it should be included
>> right away.
>> But I would like to get some feedback if you think this is the right
>> direction to take the java bindings, before I spend more time on it.
>> Any feedback is greatly appreciated.
>> best regards
>> Alexander Kjäll
>> --
>> Developer
>> alex at alatest.com
>> +468343115
>> _______________________________________________
>> pHash-support mailing list
>> pHash-support at lists.phash.org
>> http://lists.phash.org/listinfo.cgi/phash-support-phash.org

alex at alatest.com

More information about the pHash-support mailing list