views:

356

answers:

1

I am using Eclipse Cocao on Mac OS X 10.5.7, and the program hangs on the innocent line below while initializing variables. If I take it out, the program proceeds.

Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();

This line works fine in XP, Vista, Server 2003, and Mac OS X 10.4.11. I have no idea why it infinitely hangs now in 10.5. Any ideas?

Update: This appears to me to be a bug when using Cocoa Eclipse and Cocoa SWT. I can reproduce the example from Thorbjørn below without any problem. When I run the test program here though, I get the hanging behavior.

import java.awt.Dimension;
import org.eclipse.swt.widgets.Display;

public class Foo{
static Display display = new Display();

public Foo(){
Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
System.out.println(screenSize);
}

public static void main(String[] args){
Foo test = new Foo();
}
}
+1  A: 

The following code completes with Eclipse Cocoa 3.5 under OS X 10.5 on a MacBook with both Java 1.5 and Java 6.

package main;

import java.awt.Dimension;

public class Foo {

    public static void main(String[] args) {
     Dimension screenSize = java.awt.Toolkit.getDefaultToolkit()
       .getScreenSize();
     System.out.println(screenSize);
    }
}

You will have to provide more details about how your system is different from mine.

Thorbjørn Ravn Andersen
My system is a brand new out of the box mini. I updated it as far as I can with software update (Java 1.5 then came with it). I am using Eclipse Cocoa 3.5 and SWT Cocoa 3.5. Not being a Mac user, I do not know what properties of the machine could be causing it.
Ken
Mac Mini OS is 10.5.7
Ken
Another Note: I do get a bunch of "_NSAutoreleaseNoPool()" entries in my Eclipse console as the program loads. Might be a factor to this, not sure how to resolve those.
Ken
Cocoa is a brand new platform so you may trigger a bug that should be reported and fixed. Try with the Carbon SWT to see if it works better.
Thorbjørn Ravn Andersen
I initially was using Carbon (for both Eclipse and SWT) and it was not doing this behavior. I read Carbon is being phased out and thought I should maybe just use Cocoa. When using Carbon Eclipse 3.5 with Carbon SWT 3.5 the program does not hang. Not sure if the true problem is Cocoa Eclipse or because of Cocoa SWT.
Ken
Unless you really, really have the need, go with the Carbon one for now for production, and then just report the issue in the Eclipse bugzilla. If you can, create a small example showing the behaviour or consider letting the developers have access to your source code
Thorbjørn Ravn Andersen
Using the code I posted above, can you reproduce this behavior on your end? Just seeing if this is somehow just my machine, but I doubt it seeing that the machine is brand new.
Ken
Yes, I can, with Java 1.5 (32 bit). Pausing the JVM reveals no call stack for the main thread. Please report this to Eclipse with your sample program.
Thorbjørn Ravn Andersen