Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4391019
Votes 1
Synopsis Referencing a lot of fonts under Java and CDE will crash CDE
Category java:classes_2d
Reported Against 1.3
Release Fixed
State 11-Closed, duplicate of 4396244, bug
Priority: 4-Low
Related Bugs 4396244
Submit Date 20-NOV-2000
Description




java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)


Compile and run the following program.  Click on fonts.  Wait for the list of
fonts to come up.  Start scrolling the font list as quickly as possible.
Eventually, not only will the program crash but you are forced out of CDE into
the logon screen.

---------------------------

import java.lang.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;

public class SysView extends JFrame {
    static JFrame sysview = null;

    public SysView() {
	super("System Information");
        Container cp = getContentPane();

	{
	    Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
	    for (int i = 0; i < fonts.length; i++) {
		if (fonts[i].getName().equals("sansserif")) {
		    Font f = fonts[i].deriveFont(cp.getFont().getSize());
		    setFont(f);
		    break;
		}
	    }
	    fonts = null;
	}

	sysview = this;
        setSize(800, 550);
        setLocation(50, 50);
        // setTitle("System Information");
        JTable thisTable = new JTable(new SystemPropertiesTableModel());
        JScrollPane sp = new JScrollPane(thisTable);
        JTabbedPane tabbedPane = new JTabbedPane();
        cp.add(tabbedPane);
        tabbedPane.add("System Properties", sp);
	
        thisTable = new JTable(new FontsTableModel());
        thisTable.setRowHeight(26);
        thisTable.setDefaultRenderer(Font.class, new FontSampleRenderer((float)15.0, "The quick brown fox jumps over the lazy dog."));
        sp = new JScrollPane(thisTable);
        tabbedPane.add("Fonts", sp);
        addWindowListener(new WindowAdapter(){
            public void windowClosing(WindowEvent event) {
		sysview.setVisible(false);
		sysview.dispose();
                System.exit(0);
            }
	});
    }
    
    
    public static void main(String[] args) {
        (new SysView()).setVisible(true);
    }
}


class SystemPropertiesTableModel extends DefaultTableModel {
    
    static Object[][] dataArray;
    
    static Object[] columnNames = {"Property", "Value"};
    
    static {
	
        Vector v = new Vector();
        Properties props = System.getProperties();
	
        Enumeration enum = props.propertyNames();
        while(enum.hasMoreElements()) {
            String name = (String) enum.nextElement();
            String prop = props.getProperty(name);
            Object[] row = {name, prop};
            v.addElement(row);
            
        }
	
        dataArray = new Object[v.size()][2];
        for(int j=0; j<v.size(); j++) dataArray[j] = (Object[]) v.elementAt(j);
    }
    
    public boolean isCellEditable(int row, int column) {
        return false;
    }
    
    
    public SystemPropertiesTableModel() {
        super((Object[][]) dataArray, columnNames);
    }
}


class FontsTableModel extends DefaultTableModel {
    
    static Object[][] dataArray;
    
    static Object[] columnNames = {"Font", "Sample"};
    
    static {
        Font[] fonts =
GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
        dataArray = new Object[fonts.length][1];
        for(int j=0; j<fonts.length; j++) {
            Object[] row = {fonts[j].getName(), fonts[j]};
            dataArray[j] = row;
        }
    }
    
    public FontsTableModel() {
        super(dataArray, columnNames);
    }
    
    public boolean isCellEditable(int row, int column) {
        return false;
    }
    
    public Class getColumnClass(int column) {
        switch(column) {
	case 0:
	    return String.class;
	case 1:
	    return Font.class;
        }
        return Object.class;
    }
}


class FontSampleRenderer implements TableCellRenderer {
    
    String sampleString =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    
    float size = 12;
    
    Hashtable cache = new Hashtable(50, 10);
    
    protected static Border noFocusBorder = new EmptyBorder(1,2,1,2);
    
    public FontSampleRenderer(){
        
    }
    
    public FontSampleRenderer(float size, String sampleString) {
        this();
        this.size = size;
        if (sampleString != null)
	    this.sampleString = sampleString;
    }
    
    
    
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,  int row, int column) {
	
        JLabel textField = (JLabel) cache.get(value);
        if (textField == null) {
            java.awt.Font f = (java.awt.Font) value;
            textField = new JLabel(sampleString);
            textField.setOpaque(true);
            Font font = f.deriveFont(size);
            textField.setFont(font);
            cache.put(value, textField);
        }
	
        if (isSelected) {
            textField.setForeground(table.getSelectionForeground());
            textField.setBackground(table.getSelectionBackground());
        }
        else {
            textField.setForeground(table.getForeground());
            textField.setBackground(table.getBackground());
        }
	
        if (hasFocus) {
           
textField.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
            if (table.isCellEditable(row, column)) {
               
textField.setForeground(UIManager.getColor("Table.focusCellForeground"));
               
textField.setBackground(UIManager.getColor("Table.focusCellBackground"));
            }
        }
	else {
            textField.setBorder(noFocusBorder);
        }
	
        return textField;
    }
}

The patches installed in my Ultra 10 machine are:
106980-13, 107636-05, 107544-03, 106541-12, 109104-04
108376-16, 106950-13, 107081-23, 106300-09, 106327-08
(Review ID: 111995) 
======================================================================
Work Around
N/A
Evaluation
Looks like a new X server bug. We need to produce a C test case and ship it
over to the xserver group.
  xxxxx@xxxxx   2000-12-12
===============================

This appears to be the same as 4396244

  xxxxx@xxxxx   2001-01-30
========================
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang