Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Run configuration with "-ws" argument unexpected behavior
Run configuration with "-ws" argument unexpected behavior [message #1006117] Wed, 30 January 2013 00:48 Go to next message
Ryan Rupp is currently offline Ryan RuppFriend
Messages: 1
Registered: January 2013
Junior Member
Eclipse version:
Version: Juno Service Release 1
Build id: 20121004-1855

OS: OS X 10.8.2

I've developed a program which takes in the argument "-ws", so for the Run Configuration for it I have set the argument "-ws <myarg>" via the Arguments tab but this results in some odd behavior. Basically when I set that argument what happens is if I debug the first line of the main method the code is actually being executed in a daemon thread called "Thread-1" instead of the "main" thread. If I remove the "ws" argument then things work as expected and my main method is being executed by the "main" non-daemon thread.

Now, it looks like Eclipse supports a runtime argument "-ws" listed here but my understanding is this is a runtime argument that is passed when launching Eclipse itself, not a program launched from of Eclipse. This was my only guess as to why this may be happening, either some bug or I have to suppress that somehow.

To reproduce you can use the following code:

public class Test {
	
	public static void main(String[] args) {
		System.out.println("Thread Name: " + Thread.currentThread().getName() + " IS Daemon: " + Thread.currentThread().isDaemon());
	}
}


Then add a Run Configuration that uses Test as the entry point and set a run argument of "-ws". This may only be reproducible on OSX, I only started seeing this issue when I got my macbook pro, I previously ran the code fine on a Windows box with no problem (although I can't verify again because I don't have the Windows box setup anymore).
Re: Run configuration with "-ws" argument unexpected behavior [message #1008298 is a reply to message #1006117] Mon, 11 February 2013 19:50 Go to previous message
Michael Rennie is currently offline Michael RennieFriend
Messages: 65
Registered: July 2009
Location: Canada
Member
This is because when you use the -ws argument we assume that you are trying to launch an Eclipse instance that will end up using SWT. On the Mac, SWT cannot run
in the main thread so we append the -XStartOnFirstThread argument when we see the -ws argument.

This was provided to fix the following bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=156343

In 4.3 we added support where you can tell Eclipse to not set the -XStartOnFirstThread argument regardless of how you are trying to launch. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=211625 for more information.

Perhaps you could rename your argument to -Dws (or something else) to avoid overloading the one used by Eclipse?
Previous Topic:Programmatically build eclipse plugin
Next Topic:Custom Hover Over/Value Viewer For Specific Type
Goto Forum:
  


Current Time: Thu Dec 18 21:22:12 GMT 2014

Powered by FUDForum. Page generated in 0.10371 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software