JDK-6682966 : Interaction problem between Java and C++ (JNI and JAWT) using J2SE 1.6.0
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6u5
  • Priority: P2
  • Status: Closed
  • Resolution: Not an Issue
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2008-04-01
  • Updated: 2010-07-29
  • Resolved: 2008-04-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6Resolved
Related Reports
Relates :  
Relates :  
Description
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