[rfc][icedtea-web] Fix for PR1251: AppContext has wrong context classloader
Adam Domurad
adomurad at redhat.com
Tue Jan 15 08:53:30 PST 2013
This fixes one of the (numerous) issues in ADOMII, and fixes SweetHome3D
furniture dragging.
I'll preface by saying, I'm not particularly fond of the changes in this
patch, but they have to be done to fix JNLP applications that load
resources on the Swing thread, like eg SweetHome3D.
The patch adds a flag to JNLPClassLoader that specifies whether it has
been initialized. The default for getInstance remains the same, it grabs
an initialized JNLPClassLoader. However an alternate getInstance was
added to be able to grab JNLPClassLoader that hasn't been fully initialized.
The problem with initialization:
- To create AppContext we need JNLPClassLoader object constructed
- To construct JNLPClassLoader we must initialize it
- Initializing JNLPClassLoader implies downloading all resources,
and updating Swing components
However, we cannot update swing components before we create our
AppContext, or the result will be a mess (eg unclickable popups).
In essence, it's a bootstrapping problem. So the patch makes it possible
to get a constructed JNLPClassLoader, which is initialized in a separate
step.
What else was tried ?
The only other option is to set the context classloader to some
other classloader. A proxy classloader can be created that initially
points to the system classloader, but can be set to JNLPClassLoader
after it is created. Determined too much of a hack, and getParent cannot
be properly proxied.
Basically with this patch, the life-time of the context classloaders for
each thread is:
1. By default system classloader is context classloader.
2. Create new AppContext, capture JNLPClassLoader that isn't yet
valid. Ensure we keep using system classloader as context classloader
for all threads.
3. Initialize JNLPClassLoader. Before start of applet, ensure all
threads context classloaders are set to (now initialized) JNLPClassLoader.
Recommendations welcome -- it was a lot of deliberation before I decided
to take this route. If someone has a simpler/cleaner solution than by
all means suggest it!
Reproducer changelog:
2013-XX-XX Adam Domurad <adomurad at redhat.com>
*
tests/reproducers/signed/AppContextHasJNLPClassLoader/resources/AppContextHasJNLPClassLoader.html:
Test AppContext context classloader from HTML applet
*
tests/reproducers/signed/AppContextHasJNLPClassLoader/resources/AppContextHasJNLPClassLoader.jnlp:
Test AppContext context classloader from JNLP application
*
tests/reproducers/signed/AppContextHasJNLPClassLoader/resources/AppContextHasJNLPClassLoaderForJNLPApplet.jnlp:
Test AppContext context classloader from JNLP applet
*
tests/reproducers/signed/AppContextHasJNLPClassLoader/srcs/AppContextHasJNLPClassLoader.java:
Print out context classloader for thread & AppContext, for
current thread & Swing thread.
*
tests/reproducers/signed/AppContextHasJNLPClassLoader/testcases/AppContextHasJNLPClassLoaderTest.java:
Test runner for AppContextHasJNLPClassLoader
REPRODUCER NOTES:
This exposes an additional bug in JNLP applets. start/init incorrectly
runs on the Swing thread, and invokeAndWait hangs forever. I'm not sure
how this wasn't caught, but the JNLP applet reproducer is broken pending
a separate bug fix.
Fixes changelog:
2013-XX-XX Adam Domurad <adomurad at redhat.com>
Fix PR1251: AppContext has wrong context classloader
* netx/net/sourceforge/jnlp/Launcher.java:
Remove unused context flag. Make new AppContext capture not-yet-
initialized JNLPClassLoader.
* netx/net/sourceforge/jnlp/NetxPanel.java:
Move PluginBridge initialization into constructor.
Make new AppContext capture not-yet-initialized JNLPClassLoader.
* netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java:
Add initialization flag. Move part of constructor into initialize
method. Modify getInstance to allow temporarily bypassing
initialization.
* netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
(createAppContext): New, creates an AppContext that captures the given
(not necessarily yet valid)
-Adam
-------------- next part --------------
A non-text attachment was scrubbed...
Name: app-context-fix.patch
Type: text/x-patch
Size: 16043 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20130115/2070ed0e/app-context-fix.patch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: appcontext-reproducer.patch
Type: text/x-patch
Size: 16483 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20130115/2070ed0e/appcontext-reproducer.patch
More information about the distro-pkg-dev
mailing list