I have an embryonic Java Web Start application with a single class. It runs on Windows and Linux but gets the dreaded Invalid Thread Access error on Mac OS X. I realise that
This is an answer to the secondary question, "How can you tell if the -XstartOnFirstThread argument is actually being read by the VM?" (or the related question, "how can you detect if -XstartOnFirstThread was passed to the VM?") I looked at java.lang.management.RuntimeMXBean.getInputArguments(), but -XstartOnFirstThread is not included in the returned List. After some research, I was able to figure out something, so I hope this helps someone else who was in my shoes.
According to this link, there are several environment variables set by the launcher. Among them are:
JAVA_MAIN_CLASS_pid
JAVA_STARTED_ON_FIRST_THREAD_pid
Use System.getenv() to obtain a Map of the environment variables. From there, you can iterate through the entrySet() until you find an Entry with a getKey() whose return value starts with "JAVA_MAIN_CLASS_" . If the discovered Entry's getValue() contains the name of your main class, you can use the rest of the key to determine the pid.
Once you have the pid, look up the string "JAVA_STARTED_ON_FIRST_THREAD_pid" in the environment Map. If it exists and has the value "1", the process was started with -XstartOnFirstThread. Otherwise, the process was started without the flag.
This probably won't work in an unsigned WebStart application, since the System.getenv() method is prohibited by default. But in a signed webstart application, or in a regular Java application, this does work.
Hope that helps,