Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8062130

can't print wide character when using JNI

    XMLWordPrintable

Details

    • b140
    • 7
    • x86
    • linux_ubuntu

    Description

      FULL PRODUCT VERSION :
      java version "1.7.0_71"


      ADDITIONAL OS VERSION INFORMATION :
      Mint 32-bit
      Linux alex-VirtualBox 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:08:14 UTC 2014 i686 i686 i686 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      This problem appears only in 32-bit! On my 64-bit machine, it is working correctly.

      I'm using JNI. In my Java code, I call a function in a C file.

      In the C file, when I'm using fwprint(stdout, L"something"), it doesn't work. It silently failed. I can see this behaviour from JDK 1.7.0!
      With JDK 1.6.0, it is working.

      What is interesting, is when I call fwide(stdout, 0). It returns 0, so I should be able to use wide char. But no...


      REGRESSION. Last worked in version 6u45

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.6.0_45"

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      I posted a question on stackoverflow: http://stackoverflow.com/questions/26422455/how-to-print-wide-character-using-jni

      1) create a java file
      2) create a C file
      3) in the C file, use fwprintf(stdout, L"something");


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expect to see "something" to be printed out in the console
      ACTUAL -
      nothing appear

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      there is no error message, it failed silently

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      JNIFoo.java
      public class JNIFoo {
          public native void nativeFoo();

          static {
              System.loadLibrary("foo");
          }

          public void print () {
              nativeFoo();
              System.out.println("The end");
          }

          public static void main(String[] args) {
              (new JNIFoo()).print();
              return;
          }
      }

      foo.c
      #include <stdio.h>
      #include <stdlib.h>
      #include <string.h>
      #include <jni.h>
      #include "JNIFoo.h"

      JNIEXPORT void JNICALL Java_JNIFoo_nativeFoo (JNIEnv *env, jobject obj)
      {
        // fwide(stdout, 0); -> return 0
        fwprintf(stdout, L"using fWprintf\n");
        fflush(stdout);
      }

      javac JNIFoo.java
      javah -jni JNIFoo
      gcc -shared -fpic -o libfoo.so -I/path/to/jdk/include -I/path/to/jdk/include/linux foo.c

      jdk1.6.0_45/bin/java -Djava.library.path=/path/to/jni_test JNIFoo
      jdk1.7.0/bin/java -Djava.library.path=/path/to/jni_test JNIFoo

      ---------- END SOURCE ----------

      Attachments

        1. 7_3982.OCRWonly.log
          95 kB
        2. 7_3982.readelf
          13 kB
        3. 7_3982.wholeStrace.log
          927 kB
        4. 7_3983.OCRWonly.log
          95 kB
        5. 7_3983.readelf
          13 kB
        6. 7_3983.wholeStrace.log
          930 kB
        7. C99.pdf
          1.35 MB
        8. foo.c
          0.5 kB
        9. JNIFoo.java
          0.3 kB
        10. mapfile-test.zip
          2 kB
        11. readel.dynsym.diff.png
          readel.dynsym.diff.png
          433 kB

        Issue Links

          Activity

            People

              lpriima Lev Priima
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: