views:

303

answers:

4

We have a very strange error occurring at a developer site which we are unable to replicate ourselves.

A developer in Poland has recently upgraded his Windows XP Service Pack 3 machine to 4Gb of Ram When he did so he started experiencing graphical errors in java programs using IBM JDK 1.5 This errors only occur in IBM JDK 1.5 and not in any other version.

The problem manifests itself when you create a button or control on a form and move the mouse over it.

We have a test program

import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JFrame;

public class GraphicTest {
    public static void main(String args[]) {
     JFrame frame = new JFrame("GraphicTest");
     frame.getContentPane().setLayout(new FlowLayout());
     frame.setSize(200, 200);
     JButton button = new JButton("Test button");
     button.setVisible(true);
     frame.getContentPane().add(button);
     frame.setVisible(true);
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}

which shows the problem straight away.

However the problem doesn't arise on my own machine when I upgrade the same windows version to 4Gb of Ram.

Has anyone else ever seen an issue like this?

Just to clarify this a bit, this issue only happens with IBM JDK 1.5 and only happens when we have 4Gb of Ram. It doesn't happen on any other version of the JDKs and if we reduce the amount of memory to 3 Gb the problem disappears.

A: 

The first obvious thing to always say is: Confine usage of Swing components to the AWT Event Dispatch Thread (EDT).

public class GraphicTest {
    public static void main(final String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                runEDT();
            }
        });
    }
    private static void runEDT() {
        assert java.awt.EventQueue.isDispatchThread();
        JFrame frame = new JFrame("GraphicTest");
        ...

I don't know why memory size would be important. Perhaps it affects the timings in someway. Perhaps the JVM decides it is running on a server-class machine and runs with more aggressive optimisation.

Tom Hawtin - tackline
In other words, you think this might be fixed by extracting a createAndShowGui() method and doing an invokeLater()?
Michael Myers
+3  A: 

Try reducing the hardware optimization in Windows' graphics drivers (accessible through the extended display control panel). If the machine in question has an onboard graphics adapter that uses a part of the main memory, then upgrading RAM might expose problems in the driver (or the RAM may even be faulty).

Michael Borgwardt
Turns out this was exactly the problem, both developers had the same graphics chipset, Intel G31/G33 Chipset and with hardware acceleration turned down the graphic problems disappeared.
It may be possible to fix the problem by updating the graphics drivers.
Michael Borgwardt
We tried that with the latest graphics drivers and still the error occurs. I guess they just need to either keep the foot off the accelerator or get a new card. Thanks for all the help.
+1  A: 

Just to rule out the hardware failure hypothesis: have the developer test his RAM. Memtest86 will do this.

Olivier
We have had the developer use 2 different machines, both machines using the memory from the other one, and on both occassions they see the same problem, but we cant reproduce it on machines in our own office.
+1  A: 

I had exactly the same thing on an IBM box with 3.24 G of memory: All swing apps would display - but the text (on menus, forms, buttons - everywhere it seems) were blank.

The same swing program running on Sun JDK worked no problem.

I reduced the Hardware Acceleration from 'Full' to 'None' ( on the Plug and Play Monitor settings off 'advanced' in display) - using an Intel(r) 82865G graphics card.

Now swing apps work just fine it seems.

Good spot...

monojohnny