JDK-7124994 : [macosx] GUI app is stuck in i18n testing (caused by reference cast)
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2011-12-26
  • Updated: 2012-10-09
  • Resolved: 2012-03-22
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 7
7u4 b11Fixed
Description
This is to port http://java.net/jira/browse/MACOSX_PORT-780 from Jira to bugtraq. 

Environment:
Mac OS X 10.7.2
JDK 7 b222 (problem does not happen in previous build like b221)

Description:

Unzip the attached zip file in one directory. 

[jdkhome]/bin/javac *.java
[jdkhome]/bin/java captureOnScreen

The expected behaivor is that a windows will display. When jdk is b222, the program is stuck there and never ends. The Java frame can not be displayed.

If using previous build like b221, the Java frame can be displayed correctly and everything works fine.

The attached source files are extracted from Java i18n testing framework (Global Suite Media Server) and they are simplified by me as much as possible.

captureOnScreen.java is an AWT Frame with flowlayout. It initializes an instance of class LWRenderTest which implements interface MediaServerTestCase and GUITestCase. The LWRenderTest object initializes an instance of class FontEffectTest which is a subclass of JPanel with some swing components on it.

At captureOnScreen.java, there is the cast between interfaces:
MediaServerTestCase tc = ((MediaServerTestCase)cl.newInstance()); 
LightWeightGUITestCase test = (LightWeightGUITestCase)tc;

If we do not use the refernce cast (conversion), the problem will disapear. The Java Frame can be displayed and the program runs fine in b222. The program without the cast between two interfaces:

//MediaServerTestCase tc = ((MediaServerTestCase)cl.newInstance());
LightWeightGUITestCase test = (LightWeightGUITestCase)cl.newInstance();

Since cast between interfaces is supported in Java and the program with interface cast works fine in previous build like b221, I'd like to file it as a JDK bug.

The interface cast seems to be meaningless in the attached source file, but it's necessary in the real testing framework of media server.

Comments
EVALUATION replaceSurfaceData and addDropTarget should use separate locks
25-01-2012

SUGGESTED FIX http://hg.openjdk.java.net/jdk7u/jdk7u-osx/jdk/rev/4a8cbf11c3b4
25-01-2012