[kaffe] AWT runntime bug

Justin Dearing jdearing@cuthbeat.com
Tue Mar 11 04:40:01 2003


--=-vEkDDB02F6L14ctES1Kz
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hello all,
I wrote the attached class that runs fine on Sun's JDK. However, when I
run it on Kaffe I get the error at the bottom of the email. It freezes
at the exception and the Frame is never displayed. I have to crtl-c out
of it. If I simply comment out one off the drawButton() calls it works
fine in Kaffe. I tried the latest cvs code, tried binaries compiled
against both kaffes and sun's sdk and I even tried using jikes with
kaffe's bootclasspath. I assume its some kind of garbage collection
issue. Any insight would be helpful



bash-2.05b$ kaffe exceptionFrame
null
java.lang.ArrayIndexOutOfBoundsException
        at java.awt.GridBagLayout.getGrid(GridBagLayout.java:366)
        at
java.awt.GridBagLayout.layoutContainer(GridBagLayout.java:452)
        at java.awt.Container.layout(Container.java:387)
        at java.awt.Frame.layout(Frame.java:153)
        at java.awt.Container.doLayout(Container.java:186)
        at java.awt.Container.validateTree(Container.java:731)
        at java.awt.Container.validate(Container.java:724)
        at java.awt.Window.show(Window.java:360)
        at exceptionFrame.main(exceptionFrame.java:100)
bash-2.05b$ 


--=-vEkDDB02F6L14ctES1Kz
Content-Disposition: attachment; filename=exceptionFrame.java
Content-Type: text/x-java; name=exceptionFrame.java; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

import java.awt.*;
import java.awt.event.*;

public class exceptionFrame extends Frame 
implements WindowListener {
	
	Button cmdClose;
	GridBagLayout gbl;
	GridBagConstraints gbc;
	TextArea txtConsole;

	public exceptionFrame() {
		super();
		Dimension d = new Dimension (300, 250);
		gbl = new GridBagLayout();
		gbc = new GridBagConstraints();
		setLayout (gbl);
		setSize (d.width, d.height);
		drawFrame ();
		addWindowListener (this);
	}

	protected Button drawButton (String name, ActionListener al) {
		Button cmdButton = new Button (name);
		gbl.setConstraints (cmdButton, gbc);
		cmdButton.addActionListener (al);
		add (cmdButton);
		return cmdButton;
	}

	private TextArea drawConsole () {
		TextArea txt = new TextArea ();
		gbl.setConstraints (txt, gbc);
		add (txt);
		return txt;
	}
	
	protected void drawFrame () {
		Button cmdOpen, cmdClose;
		gbc.fill = GridBagConstraints.BOTH;
		gbc.gridwidth = GridBagConstraints.REMAINDER;
		gbc.weightx = 1.0;
		gbc.weighty = 2.0;
		drawTitle ();
		gbc.weighty = 4.0;
		txtConsole = drawConsole ();
		gbc.weighty = 1.0;
		gbc.gridheight = GridBagConstraints.REMAINDER;
		gbc.gridwidth = GridBagConstraints.RELATIVE;
		drawButton ("Open", new onOpen());
		gbc.gridwidth = GridBagConstraints.REMAINDER;
		drawButton ("Close", new onClose());
	}

	private void drawTitle () {
		Font fntTitle = new Font ("SansSerif", Font.PLAIN, 24);
		Label lblTitle = new Label ();
		lblTitle.setAlignment (Label.CENTER);
		lblTitle.setFont (fntTitle);
		lblTitle.setText ("tapeMaster");
		lblTitle.doLayout();
		add(lblTitle);
		gbl.setConstraints (lblTitle, gbc);
	}

	protected class onClose implements ActionListener {
		public onClose () {}

		public void actionPerformed (ActionEvent ae) {System.exit (0);}
	}

	protected class onOpen implements ActionListener {
		public onOpen () {}

		public void actionPerformed (ActionEvent ae) {
			try {Runtime.getRuntime().exec ("ls -l");}
			catch (Exception e) {e.printStackTrace();}
		}
	}

	public void windowActivated (WindowEvent e) {}

	public void windowClosed (WindowEvent e) {System.exit (0);}

	public void windowClosing (WindowEvent e) {System.exit (0);}

	public void windowDeactivated (WindowEvent e) {}

	public void windowDeiconified (WindowEvent e) {}

	public void windowIconified (WindowEvent e) {}

	public void windowOpened (WindowEvent e) {}

	public void window (WindowEvent e) {}

	public static void main (String s[]) {
		try {
			exceptionFrame Test = new exceptionFrame();
			Test.show();
		} catch (Exception e) {
			System.err.println (e.getMessage());
			e.printStackTrace ();
		}
	}
}


--=-vEkDDB02F6L14ctES1Kz--