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

Interaction problem between Java and C++ (JNI and JAWT) using J2SE 1.6.0



    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Not an Issue
    • Affects Version/s: 6u5
    • Fix Version/s: 6
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
    • OS:


      During the testing phase of their new version od CATIA V5, Dassault Systemes seems to have bumped into a Java regression. The new version of CATIA V5 will be using J2SE 1.6.0 (versus 1.5.0 up to now)
      However one of the tests fails. This test concerns the interaction of a Java AWT based applicaiton with C++ libraries going through JNI and JAWT.
      The C++ graphical libraries need to get a handle on the window created by Java (AWT).
      This used to work fine but now they get a error message:
       "Error: Couldn't find per display information"

      A test case has been extracted and is provided here (test_case.tar). When untared you will find 4 files:

      TestJava6.java: the java program containing the main program
      TestJava6Jni.cpp: The C++ file that will be compiled to a shared library
      com_dassault_systemes_testjava6_TestJava6.h: header file for the C++
      Makefile the make file

      To build check first the Makefile and adapte if necessary the paths to your local env, then just "make all"

      To run the program:
      # java com.dassault_systemes.testjava6.TestJava6 absolute_path_to/libTestJava6Jni.so

      The libTestJava6Jni.so will be built in the directory you have downloaded the test case. To run the progrem you nedd to explicitly specify the absolute path the that library.

      To see the regression try changing the java version that executes the program:

      If you use java 1.5.0 it will work: You get the following output traces:

      Loading C++ Library: /zhome/ISV/DassaultSystemes/Java6Bug/Case/libTestJava6Jni.so

      -> XDefaultScreen
      <- XDefaultScreen 0
      -> XDisplayString
      <- XDisplayString :0.0
      -> XRootWindow
      <- XRootWindow 0x00000136
      -> XtWindowToWidget Getting in
      <- XtWindowToWidget
      handle : 0

      If you use java 1.6.0 it will not work and you get the following output traces:

      Loading C++ Library: /zhome/ISV/DassaultSystemes/Java6Bug/Case/libTestJava6Jni.so

      Java Accessibility Bridge for GNOME loaded.

      -> XDefaultScreen
      <- XDefaultScreen 0
      -> XDisplayString
      <- XDisplayString :0.0
      -> XRootWindow
      <- XRootWindow 0x00000136
      -> XtWindowToWidget Getting in
      Error: Couldn't find per display information

      First remark: we get an extra message at the launch : "Java Accessibility Bridge for GNOME loaded." that we didn't get with Java 1.5.0

      The program exits with an error on the following instruction in the C++ code:
          Widget widget = XtWindowToWidget(display, window);

      I reproduced this problem on a Ultra 45 workstation with Solaris 10 u1 as well as on my Toshiba laptop with Solaris 10 x86 (Nevada 75)
      Java versions used : J2SE 1.5.0_07 and J2SE 1.6.0 u5
      IBIS escalation # 80189239
      Setting AWT_TOOLKIT=MToolkit fixex the problem.
      Il seems as if by default Java 1.6 uses XToolkit vs. MToolkit for java 1.5
      When setting the AWT_TOOLKIT=Xtoolkit with java 1.5 we get the same cash as wiht 1.6 so this is not a regression just a change of the default between 1.5 and 1.6
      The cas can therefore be closed


          Issue Links



              son Oleg Sukhodolsky (Inactive)
              ajavansh Amir Javanshir (Inactive)
              0 Vote for this issue
              1 Start watching this issue