[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Re: Mac OS X 10.5 (Leopard), OpenGL and StartOnFirstThread
|
Jens, here is yet another symptom of an issue between swt jnilib and the
leopard jvm.
/dan
In article <fhfdu9$bpb$1@xxxxxxxxxxxxxxxxx>,
Jens v.P. <developer@xxxxxxxxx> wrote:
> Hi,
>
> after installing Mac OS X 10.5 (Leopard), I cannot start an OpneGL
> based plugin anymore. This is the error message:
>
> Unhandled event loop exception
> Can't start the AWT because Java was started on the first thread. Make
> sure StartOnFirstThread is not specified in your application's
> Info.plist or on the command line
>
> The funny things:
>
> - StartOnFirstThread is already removed from the eclipse.ini file
> - The very same plugin is running when launched as a runtime instance
> - There is actually no AWT code involved! Here's a snippet from the
> ViewerPart where the error occurs:
>
> @Override
> public void createPartControl(Composite parent) {
> GLData data = new GLData();
> org.eclipse.swt.opengl.GLData data.doubleBuffer = true;
> org.eclipse.swt.opengl.GLCanvas canvas = new GLCanvas(parent,
> SWT.NONE, data);
> ...
> }
>
> The very same code was running without problems with Tiger...
> (latest Eclipse Version 3.3.1.1)
>
> Since the code _is_ running when startet in the debugger or as a
> runtime instance, I think there should be some workaround? Does anyone
> had the same problem?
>
> Jens
Really hard to elaborate, but in the most basic test case....
This pure SWT application seems to work:
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
public class HelloWorld {
 private Display display;
 private Shell shell;
 public HelloWorld() {
getClassLoader("before instantiation of first swt object");
  setUpDisplay();
  getClassLoader("after instantiation of swt objects");
  createLabel();
  createMenuBar();
  revealDisplay();
  Â
 }
 private void setUpDisplay() {
  display = new Display();
  shell = new Shell(display);
  shell.setSize(200, 100);
  shell.setText("SWTGreeter");
 }
 private void createMenuBar() {
  Menu menu = new Menu(shell, SWT.BAR);
  shell.setMenuBar(menu);
  MenuItem fileMenuItem = new MenuItem(menu, SWT.CASCADE);
  fileMenuItem.setText("File");
  MenuItem editMenuItem = new MenuItem(menu, SWT.CASCADE);
  editMenuItem.setText("Edit");
 }
 private void createLabel() {
  Label label = new Label(shell, SWT.CENTER);
  label.setText("Hello SWT");
  label.setBounds(shell.getClientArea());
 }
 private void revealDisplay() {
  shell.open();
  while (!shell.isDisposed()) {
   if (!display.readAndDispatch())
    display.sleep();
  }
  display.dispose();
 }
 Â
 private void getClassLoader(String loc) {
 ClassLoader cl = Thread.currentThread().getContextClassLoader();
 System.out.println(loc+": classloader resolvable? "+(cl!=null));
 }
 public static void main(String[] args) {
 ClassLoader cl = Thread.currentThread().getContextClassLoader();
 System.out.println("classloader from static main resolvable? " +
(cl != null));
 new HelloWorld();
  Â
 }
}
responding when run within eclipse:
classloader from static main resolvable? false
before instantiation of first swt object: classloader resolvable? false
after instantiation of swt objects: classloader resolvable? false
Invalid memory access of location 00000000 eip=0045c2ab
knowing of course that SWT is an older version:
org.eclipse.swt.carbon.macosx_3.3.2.v3347a.jar
and responding when run at the commandline:
Montana:~/Documents/workspace/swt_test$ ./run.sh
launching HelloWorld with
./bin:./libswt/org.eclipse.swt_3.3.2.v3347.jar:./libswt/org.eclipse.swt.c
arbon.macosx_3.3.2.v3347a.jar SWT from eclipse/Resources/MacOSX...
java -cp
./bin:./libswt/org.eclipse.swt_3.3.2.v3347.jar:./libswt/org.eclipse.swt.c
arbon.macosx_3.3.2.v3347a.jar HelloWorld
classloader from static main resolvable? true
before instantiation of first swt object: classloader resolvable? true
./run.sh: line 5:  3743 Segmentation fault    java -cp $CLASSPATH
HelloWorld
now try with latest swt daily (11/17)
launching HelloWorld with ./bin:./swt-3/swt.jar
java -cp ./bin:./swt-3/swt.jar HelloWorld
classloader from static main resolvable? true
before instantiation of first swt object: classloader resolvable? true
./run.sh: line 11:  3745 Segmentation fault    java -cp $CLASSPATH
HelloWorld
launching with startOnFirstThread
java -XstartOnFirstThread -cp ./bin:./swt-3/swt.jar HelloWorld
classloader from static main resolvable? false
before instantiation of first swt object: classloader resolvable? false
after instantiation of swt objects: classloader resolvable? false
Invalid memory access of location 00000000 eip=0045c2ab
./run.sh: line 14:  3748 Bus error        java
-XstartOnFirstThread -cp $CLASSPATH HelloWorld
In summary:
when SWT works (the third launch), the root classloader doesn't.