Lately I've been making a Selenium WebDriver implementation for Java's built-in WebKit.
I spent an absurd amount of time trying to figure out how to let multiple instances of the browser operate concurrently without affecting each other. E.g., if a resource request is in progress, then a second request to the same resource simply uses the output of the first (which is a problem if it's stateful output for the user).
After reading most of the JavaFX and WebKit codebases I realized that isolation is not possible without recompiling a modified WebKit. So then I set about figuring out how to isolate Java code. But most solutions are half-baked, are only academic research projects, or require a special JVM.
However, if you load JavaFX along with native libs into a classloader for each browser instance, then they're effectively isolated. The downside is that objects of the same class have completely different un-castable types if they're from different classloaders.
So then I needed to use reflection to lookup classnames at runtime and resolve them dynamically.
Anyhow, http://i.imgur.com/ovxVHW9.png
https://github.com/MachinePublishers/jBrowserDriver