Bug 290970 - [SWT/AWT] SWT_AWT Bridge doesn't appear to be working
[SWT/AWT] SWT_AWT Bridge doesn't appear to be working
Status: RESOLVED INVALID
Product: Platform
Classification: Eclipse
Component: SWT
4.0
Macintosh Mac OS X - Carbon (unsup.)
: P3 major with 3 votes (vote)
: ---
Assigned To: Project Inbox CLA Friend
Silenio Quarti CLA Friend
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2009-09-30 16:59 EDT by Ken Keefe CLA Friend
Modified: 2009-10-06 02:55 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ken Keefe CLA Friend 2009-09-30 16:59:31 EDT
User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3
Build Identifier: M20090917-0800  (Target is the same)

I am running Mac OS X 10.5.8 and I have Java 1.5.0_20-b02-315.

I have tried this with the Cocoa and the Carbon versions of the RCP SDK as my target. I have also tested this on a Ubuntu machine and it works without a hitch. I get the following error when running a simple toy application that tries to open a JFrame from within an RCP application regardless of whether I am using Cocoa or Carbon:

Hello RCP World!
2009-09-30 15:54:33.825 java[59157:80f] [Java CocoaComponent compatibility mode]: Enabled
2009-09-30 15:54:33.826 java[59157:80f] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000
2009-09-30 15:54:34.056 java[59157:1c103] *** -[NSConditionLock unlock]: lock (<NSConditionLock: 0x143850> '(null)') unlocked when not locked
2009-09-30 15:54:34.056 java[59157:1c103] *** Break on _NSLockError() to debug.
2009-09-30 15:54:34.159 java[59157:1c103] *** -[NSConditionLock unlock]: lock (<NSConditionLock: 0x144140> '(null)') unlocked when not locked
2009-09-30 15:54:34.160 java[59157:1c103] *** Break on _NSLockError() to debug.
2009-09-30 15:54:34.465 java[59157:1c103] *** -[NSConditionLock unlock]: lock (<NSConditionLock: 0x19e6d0> '(null)') unlocked when not locked
2009-09-30 15:54:34.466 java[59157:1c103] *** Break on _NSLockError() to debug.
2009-09-30 15:54:34.568 java[59157:1c103] *** -[NSConditionLock unlock]: lock (<NSConditionLock: 0x199ff0> '(null)') unlocked when not locked
2009-09-30 15:54:34.569 java[59157:1c103] *** Break on _NSLockError() to debug.
2009-09-30 15:54:34.670 java[59157:1c103] *** -[NSConditionLock unlock]: lock (<NSConditionLock: 0x19eaf0> '(null)') unlocked when not locked
2009-09-30 15:54:34.671 java[59157:1c103] *** Break on _NSLockError() to debug.
2009-09-30 15:54:34.773 java[59157:1c103] *** -[NSConditionLock unlock]: lock (<NSConditionLock: 0x19ed30> '(null)') unlocked when not locked
2009-09-30 15:54:34.773 java[59157:1c103] *** Break on _NSLockError() to debug.
2009-09-30 15:54:34.876 java[59157:1c103] *** -[NSConditionLock unlock]: lock (<NSConditionLock: 0x19f020> '(null)') unlocked when not locked
2009-09-30 15:54:34.877 java[59157:1c103] *** Break on _NSLockError() to debug.
2009-09-30 15:54:34.977 java[59157:1c103] *** -[NSConditionLock unlock]: lock (<NSConditionLock: 0x19f0d0> '(null)') unlocked when not locked
2009-09-30 15:54:34.978 java[59157:1c103] *** Break on _NSLockError() to debug.
Closing down...


Here is the code in the RCP application: 


package headlesstest;

import javax.swing.JFrame;
import javax.swing.JLabel;

import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;

/**
 * This class controls all aspects of the application's execution
 */
public class Application implements IApplication {

	/*
	 * (non-Javadoc)
	 * 
	 * @seeorg.eclipse.equinox.app.IApplicationstart(org.eclipse.equinox.app.
	 * IApplicationContext)
	 */

	public Object start(IApplicationContext context) throws Exception {
		System.out.println("Hello RCP World!");
		javax.swing.SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				createAndShowGUI();
			}
		});
		Thread.sleep(10000);
		System.out.println("Closing down...");
		return IApplication.EXIT_OK;
	}

	private static void createAndShowGUI() {
		// Create and set up the window.
		JFrame frame = new JFrame("HelloWorldSwing");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		// Add the ubiquitous "Hello World" label.
		JLabel label = new JLabel("Hello World");
		frame.getContentPane().add(label);
		// Display the window.
		frame.setSize(400, 400);
		frame.pack();
		frame.setVisible(true);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.equinox.app.IApplicationstop()
	 */
	public void stop() {
		// nothing to do
	}
}


Reproducible: Always

Steps to Reproduce:
1. Create a new headless RCP application in Eclipse
2. Use the carbon or cocoa version of the RCP SDK as your target platform
3. Add the code I listed above in the details
4. Execute the application from the plugin.xml file.
Comment 1 Kevin Barnes CLA Friend 2009-10-01 11:02:27 EDT
There is no SWT in your example code.

Please see the SWT_AWT snippets. http://eclipse.org/swt/snippets/#awt

If you are just trying to put an AWT from end on your app, you'll need to be sure that you aren't launching the vm with -XstartOnFirstThread on mac.
Comment 2 Andrew Niefer CLA Friend 2009-10-01 11:14:20 EDT
The eclipse launcher implicitly launches java on the first thread with or without the -XstartOnFirstThread.  To use awt with the eclipse launcher you will need the argument "--launcher.secondThread"
Comment 3 Andrew Niefer CLA Friend 2009-10-01 11:15:00 EDT
(In reply to comment #2)
> The eclipse launcher implicitly launches java on the first thread with or
> without the -XstartOnFirstThread.  To use awt with the eclipse launcher you
> will need the argument "--launcher.secondThread"

This is a program argument, not a vm argument
Comment 4 Ken Keefe CLA Friend 2009-10-01 12:19:53 EDT
(In reply to comment #3)
> (In reply to comment #2)
> > The eclipse launcher implicitly launches java on the first thread with or
> > without the -XstartOnFirstThread.  To use awt with the eclipse launcher you
> > will need the argument "--launcher.secondThread"
> 
> This is a program argument, not a vm argument

Thanks for the help, I am just trying to use an awt front end on my Eclipse app. I tried your suggestions about the --launcher.secondThread as a program argument. Unfortunately, I am still getting the same error messages and behavior. 

Also, why does this only happen on OSX? This same application, without the additional arguments worked without a problem in Ubuntu.

Thanks again!
Comment 5 Ken Keefe CLA Friend 2009-10-01 15:12:11 EDT
(In reply to comment #4)
> (In reply to comment #3)
> > (In reply to comment #2)
> > > The eclipse launcher implicitly launches java on the first thread with or
> > > without the -XstartOnFirstThread.  To use awt with the eclipse launcher you
> > > will need the argument "--launcher.secondThread"
> > 
> > This is a program argument, not a vm argument
> 
> Thanks for the help, I am just trying to use an awt front end on my Eclipse
> app. I tried your suggestions about the --launcher.secondThread as a program
> argument. Unfortunately, I am still getting the same error messages and
> behavior. 
> 
> Also, why does this only happen on OSX? This same application, without the
> additional arguments worked without a problem in Ubuntu.
> 
> Thanks again!

I found some documentation about the --launcher.secondThread argument that if this is used, SWT cannot be used later. Let me explain a little more about what I am trying to do and maybe you can give me a push in the right direction. I have a large SWING app that I am trying to move over to an Eclipse RCP app slowly over time. As a first step, I thought that I would start a basic eclipse application and then call the first JFrame from the existing code and then go from there. Then, over time, I can begin replacing SWING components with SWT and RCP components.

I should also mention that I already have a plugin containing an SWT based application that I want to incorporate into my current SWING app. So, I need to be able to run both swing and swt at the same time. Is this possible? Can you point me to a working example?

Thanks!
Comment 6 Marcel Austenfeld CLA Friend 2009-10-06 02:55:06 EDT
I can reproduce this bug. I want to port my rcp application to Mac OS X. I
get this error message at startup and if i resize my application (when the active
perspective embedds a swing component).
Any help is appreciated!