JNI bug?

Marco Trudel mtrudel@gmx.ch
Tue Jan 30 10:31:00 GMT 2007


David Daney wrote:
> Marco Trudel wrote:
>>
>>
>> But the question remains: What to do about this? I have no idea where to
>> look for this problem or what to do against. I would like to have the
>> same behavior, but it's not worth it if it's a huge thing to implement...
>>
> Perhaps in jni.cc in the function array_from_valist().  You could try 
> something like this:
> 
> for (int i = 0; i < arg_types->length; ++i)
> {
>    values[i].j = 0; // Clean garbage out of the union so that buggy JNI 
> code looking for jint where it should be looking for jboolean will work.
> .
> .
> .

What do others think? If the solution is that small, I'd be willing to 
do it and I would vote for doing it since there are libraries out there 
which need this.

> Note that I have not tested the code so I have no idea if it would work  
> I don't even think we should do something like this, but it might work 
> for you in a pinch.

I now fixed the library I use. But others might not be able to and it 
would be sad to hear "GCJ is broken" just because they use code that is 
broken but which works with a Sun JVM.
Anyway, is the code really broken? Isn't the device of Java to always 
initialize everything to 0?


Marco



More information about the Java mailing list