JDK-4197740 : ClassCastException error in JDK 1.2 - JFC
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.2.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.6
  • CPU: generic
  • Submitted: 1998-12-15
  • Updated: 1999-01-18
  • Resolved: 1999-01-18
Related Reports
Duplicate :  
Description
tushar.patel@West 1998-12-15
Here is a problem in JDK 1.2 latest revision.

The code:

class HelpMI extends MyMenuItem {
	private JFrame     mainFrame;
	private HelpDialog   helpDialog;

	public HelpMI(String name, JFrame mainFrame, Font font) {
		super(name, font);
		this.mainFrame = mainFrame;
		addActionListener( new HelpML());
	}
 
	class HelpML implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			helpDialog = new HelpDialog(mainFrame);
		}
	}
}

public class HelpDialog {
	// Constants
	private static final String    TITLE = "Help";

	public HelpDialog(JFrame parent) {
		JOptionPane.showMessageDialog(parent, "Help is not implemented.",
			TITLE, JOptionPane.PLAIN_MESSAGE);
	}
}


causes the exception:

java.lang.ClassCastException: java.awt.AWTEventMulticaster
        at
java.awt.Toolkit$ToolkitEventMulticaster.remove(Toolkit.java:1159)
        at java.awt.Toolkit.removeAWTEventListener(Toolkit.java:1122)
        at java.awt.LightweightDispatcher$2.run(Container.java:1847)
        at java.security.AccessController.doPrivileged(Compiled Code)
        at
java.awt.LightweightDispatcher.stopListeningForOtherDrags(Compiled Code)
        at java.awt.LightweightDispatcher.trackMouseEnterExit(Compiled
Code)
        at java.awt.LightweightDispatcher.processMouseEvent(Compiled
Code)
        at java.awt.LightweightDispatcher.dispatchEvent(Compiled Code)
        at java.awt.Container.dispatchEventImpl(Compiled Code)
        at java.awt.Window.dispatchEventImpl(Compiled Code)
        at java.awt.Component.dispatchEvent(Compiled Code)
        at java.awt.EventQueue.dispatchEvent(Compiled Code)
        at java.awt.EventDispatchThread.run(Compiled Code)


When the mouse is moved off the main parent frame, after the dialog was
created 
a second time, the Exception occurs.

SunOS javamind 5.6 Generic_105181-05 sun4u sparc SUNW,Ultra-1-Engine
java full version "Solaris_JDK_1.2_01_dev05_fcsK"


Comments
EVALUATION I thought we fixed this. Fred, could you take a look? david.mendenhall@eng 1999-01-06 The Java version label displayed at the bottom of the "Description" text shows the "K" build of the FCS workspace, which was built on September 17th of last year. This bug, which is a duplicate of #4178589, was fixed on October 7th, in the "N" build (src/share/classes/java/awt/Toolkit.java revision 1.121.1.1). I will close this bug as a duplicate of #4178589. If any problems do remain, please reopen that bug. I can't reproduce this particular bug, because the test case is incomplete. Not only does it not compile, but it lacks a main(). Please provide test cases which are complete and ready to run. Thank you! fred.ecks@Eng 1999-01-17
17-01-1999