From c77268c09c590aa44926e3f93833d03a0934b523 Mon Sep 17 00:00:00 2001 From: Gabriel Tofvesson Date: Wed, 15 Mar 2017 23:32:19 +0100 Subject: [PATCH] Initial commit --- .idea/compiler.xml | 23 +++++++ .idea/description.html | 2 + .idea/encodings.xml | 5 ++ .idea/gradle.xml | 7 +++ .idea/kotlinc.xml | 7 +++ .idea/misc.xml | 12 ++++ .idea/modules.xml | 8 +++ .idea/uiDesigner.xml | 125 +++++++++++++++++++++++++++++++++++++ .idea/vcs.xml | 7 +++ DankTest.iml | 12 ++++ src/sample/Controller.java | 4 ++ src/sample/Main.java | 62 ++++++++++++++++++ src/sample/sample.fxml | 8 +++ 13 files changed, 282 insertions(+) create mode 100644 .idea/compiler.xml create mode 100644 .idea/description.html create mode 100644 .idea/encodings.xml create mode 100644 .idea/gradle.xml create mode 100644 .idea/kotlinc.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 .idea/vcs.xml create mode 100644 DankTest.iml create mode 100644 src/sample/Controller.java create mode 100644 src/sample/Main.java create mode 100644 src/sample/sample.fxml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..217af47 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/.idea/description.html b/.idea/description.html new file mode 100644 index 0000000..cc10d56 --- /dev/null +++ b/.idea/description.html @@ -0,0 +1,2 @@ +Simple JavaFX 2.0 application that includes simple .fxml file with attached controller and Main class to quick start. Artifact to build JavaFX application is provided. + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..157a0c1 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..1c24f9a --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..a4e3dc8 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..8ae5a70 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..3b00020 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..def6a6a --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/DankTest.iml b/DankTest.iml new file mode 100644 index 0000000..d5c0743 --- /dev/null +++ b/DankTest.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/sample/Controller.java b/src/sample/Controller.java new file mode 100644 index 0000000..54e5bd1 --- /dev/null +++ b/src/sample/Controller.java @@ -0,0 +1,4 @@ +package sample; + +public class Controller { +} diff --git a/src/sample/Main.java b/src/sample/Main.java new file mode 100644 index 0000000..2f70e0b --- /dev/null +++ b/src/sample/Main.java @@ -0,0 +1,62 @@ +package sample; + +import com.sun.javafx.application.LauncherImpl; +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; +import sun.misc.Unsafe; +import java.lang.reflect.Field; +import java.util.concurrent.atomic.AtomicBoolean; + +public class Main extends Application { + + @Override + public void start(Stage primaryStage) throws Exception{ + Parent root = FXMLLoader.load(getClass().getResource("sample.fxml")); + primaryStage.setTitle("Hello World"); + primaryStage.setScene(new Scene(root, 300, 275)); + primaryStage.show(); + } + + + public static void main(String[] args) throws Throwable{ + + // Start first JavaFX thread + Thread t = new Thread(() -> { try { resetJFXTracker(); launch(args); }catch(Exception ignored){} }); + t.setDaemon(true); + t.start(); + Thread.sleep(2); + + Thread t1 = new Thread(() -> { resetJFXTracker(); try { launch(args); }catch(Exception ignored){} }); + t1.setDaemon(true); + t1.start(); + Thread.sleep(2); + + Thread t2 = new Thread(() -> { resetJFXTracker(); try { launch(args); }catch(Exception ignored){} }); + t2.setDaemon(true); + t2.start(); + Thread.sleep(2); + + resetJFXTracker(); + // Start second JavaFX thread + try { launch(args); }catch(Exception ignored){} + } + + public static void resetJFXTracker(){ + try { + // Get unsafe + final Unsafe u; + Field f1 = Unsafe.class.getDeclaredField("theUnsafe"); + f1.setAccessible(true); + u = (Unsafe) f1.get(null); + + // Modify some memory + Field f = AtomicBoolean.class.getDeclaredField("value"); + Field f2 = LauncherImpl.class.getDeclaredField("launchCalled"); + f2.setAccessible(true); + u.putIntVolatile(f2.get(null), u.objectFieldOffset(f), 0); + }catch(Exception ignored){} + } +} diff --git a/src/sample/sample.fxml b/src/sample/sample.fxml new file mode 100644 index 0000000..363237a --- /dev/null +++ b/src/sample/sample.fxml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file