Different behavior for newStringUTF() for Sun JVM and IBM Jvm

L

Lasse

While changing environment for our application into IBM's JVM (build
1.4.1) we suddenly run into problems with Swedish chars like ÖÄÅ when
returning them from our native calls.

Some testing helped us to isolate the error into a row in the code
where we return the result from our c-code into an array in the Java
layer:

(*env)->SetObjectArrayElement(env,ret,i, (*env)->NewStringUTF(env,
word));

When running the compile code with -verbose, the following infromation
shows up:
Loaded java.io.CharConversionException from
/opt/IBMJava2-141/bin/../jre/lib/core.jar

After changeing back into SUN's JVM (build 1.4.2_03-b02) everything
works fine again. The same for SUN's Build 1.3.1 and Build 1.3.0.

Just courios if anybody knows if this is a documented bug/feature for
the IBM JVM? Have someone else discovered the same problem and perhaps
have a solution / answar for the behavior?

Som furter env. information:
Linux ES release 2.1 (Panama)
gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-118.7.2)

IBM JVM:
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1)
Classic VM (build 1.4.1, J2RE 1.4.1 IBM build cxia321411-20030930 (JIT
enabled: jitc))

SUN JVM:
java version "1.4.2_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02)
Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode)
 
J

Jon A. Cruz

Lasse said:
While changing environment for our application into IBM's JVM (build
1.4.1) we suddenly run into problems with Swedish chars like ÖÄÅ when
returning them from our native calls.

Some testing helped us to isolate the error into a row in the code
where we return the result from our c-code into an array in the Java
layer:

(*env)->SetObjectArrayElement(env,ret,i, (*env)->NewStringUTF(env,
word));

Soo... what exactly are the bytes you are feeding to that call? Are they
proper UTF-8 bytes, or are you feeding the local charset 8-bit encoding
instead?
When running the compile code with -verbose, the following infromation
shows up:
Loaded java.io.CharConversionException from
/opt/IBMJava2-141/bin/../jre/lib/core.jar

Sounds like it's yelling at you for feeding it some malformed data.

Did you use the JNI calls to check for errors? You should be calling
that after each call into JNI. If so, you'd probably see the result of
that exception.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top