diff -r df3ce8a3d2aa javafx-ui-common/src/com/sun/javafx/application/LauncherImpl.java --- a/javafx-ui-common/src/com/sun/javafx/application/LauncherImpl.java Wed Mar 06 16:26:43 2013 +0100 +++ b/javafx-ui-common/src/com/sun/javafx/application/LauncherImpl.java Wed Mar 06 15:07:28 2013 -0500 @@ -653,22 +653,24 @@ PlatformImpl.addListener(listener); try { - Preloader pldr = null; + final Preloader [] pldr = new Preloader [1]; if (preloaderClass != null) { - // Construct an instance of the preloader and call its init - // method on this thread. Then call the start method on the FX thread. - try { - Constructor c = preloaderClass.getConstructor(); - pldr = c.newInstance(); - // Set startup parameters - ParametersImpl.registerParameters(pldr, new ParametersImpl(args)); - } catch (Throwable t) { - System.err.println("Exception in Preloader constructor"); - pConstructorError = t; - error = true; - } + PlatformImpl.runAndWait(new Runnable() { + @Override public void run() { + try { + Constructor c = preloaderClass.getConstructor(); + pldr[0] = c.newInstance(); + // Set startup parameters + ParametersImpl.registerParameters(pldr[0], new ParametersImpl(args)); + } catch (Throwable t) { + System.err.println("Exception in Preloader constructor"); + pConstructorError = t; + error = true; + } + } + }); } - currentPreloader = pldr; + currentPreloader = pldr[0]; // Call init method unless exit called or error detected if (currentPreloader != null && !error && !exitCalled.get()) { @@ -710,7 +712,7 @@ // Construct an instance of the application and call its init // method on this thread. Then call the start method on the FX thread. - Application app = null; + final Application [] app = new Application [1]; if (!error && !exitCalled.get()) { if (currentPreloader != null) { if (simulateSlowProgress) { @@ -724,18 +726,22 @@ StateChangeNotification.Type.BEFORE_LOAD, null); } - try { - Constructor c = appClass.getConstructor(); - app = c.newInstance(); - // Set startup parameters - ParametersImpl.registerParameters(app, new ParametersImpl(args)); - } catch (Throwable t) { - System.err.println("Exception in Application constructor"); - constructorError = t; - error = true; - } + PlatformImpl.runAndWait(new Runnable() { + @Override public void run() { + try { + final Constructor c = appClass.getConstructor(); + app[0] = c.newInstance(); + // Set startup parameters + ParametersImpl.registerParameters(app[0], new ParametersImpl(args)); + } catch (Throwable t) { + System.err.println("Exception in Application constructor"); + constructorError = t; + error = true; + } + } + }); } - final Application theApp = app; + final Application theApp = app[0]; // Call init method unless exit called or error detected if (!error && !exitCalled.get()) {