/[gentoo-x86]/dev-java/icedtea-web/files/fix-plugin-in-icedtea-7.patch
Gentoo

Contents of /dev-java/icedtea-web/files/fix-plugin-in-icedtea-7.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Sat Mar 3 21:51:26 2012 UTC (2 years, 6 months ago) by caster
Branch: MAIN
Changes since 1.1: +0 -67 lines
Fix the patch, bug #406715. Thanks to Flameeyes.

(Portage version: 2.2.0_alpha89/cvs/Linux x86_64)

1 caster 1.1
2     # HG changeset patch
3     # User Denis Lila <dlila@redhat.com>
4     # Date 1304110685 14400
5     # Node ID 77640d74d21c2303b64bbc05583a3850db564894
6     # Parent f0647c9385358b4fc3fe747ba7b95b9117c2f681
7     Fix appcontext related plugin bugs.
8    
9     diff -r f0647c938535 -r 77640d74d21c netx/net/sourceforge/jnlp/Launcher.java
10     --- a/netx/net/sourceforge/jnlp/Launcher.java Sat Jan 07 02:48:05 2012 -0500
11     +++ b/netx/net/sourceforge/jnlp/Launcher.java Fri Apr 29 16:58:05 2011 -0400
12     @@ -33,7 +33,6 @@
13    
14     import net.sourceforge.jnlp.cache.CacheUtil;
15     import net.sourceforge.jnlp.cache.UpdatePolicy;
16     -import net.sourceforge.jnlp.runtime.AppThreadGroup;
17     import net.sourceforge.jnlp.runtime.AppletInstance;
18     import net.sourceforge.jnlp.runtime.ApplicationInstance;
19     import net.sourceforge.jnlp.runtime.JNLPClassLoader;
20     @@ -707,7 +706,7 @@
21     throw new ClassNotFoundException("Can't do a codebase look up and there are no jars. Failing sooner rather than later");
22     }
23    
24     - AppThreadGroup group = (AppThreadGroup) Thread.currentThread().getThreadGroup();
25     + ThreadGroup group = Thread.currentThread().getThreadGroup();
26    
27     String appletName = file.getApplet().getMainClass();
28    
29     @@ -723,7 +722,6 @@
30     else
31     appletInstance = new AppletInstance(file, group, loader, applet, cont);
32    
33     - group.setApplication(appletInstance);
34     loader.setApplication(appletInstance);
35    
36     setContextClassLoaderForAllThreads(appletInstance.getThreadGroup(), appletInstance.getClassLoader());
37     @@ -770,10 +768,9 @@
38     protected ApplicationInstance createApplication(JNLPFile file) throws LaunchException {
39     try {
40     JNLPClassLoader loader = JNLPClassLoader.getInstance(file, updatePolicy);
41     - AppThreadGroup group = (AppThreadGroup) Thread.currentThread().getThreadGroup();
42     + ThreadGroup group = Thread.currentThread().getThreadGroup();
43    
44     ApplicationInstance app = new ApplicationInstance(file, group, loader);
45     - group.setApplication(app);
46     loader.setApplication(app);
47    
48     return app;
49     @@ -789,16 +786,16 @@
50     * then this method simply returns the existing ThreadGroup. The applet
51     * ThreadGroup has to be created at an earlier point in the applet code.
52     */
53     - protected AppThreadGroup createThreadGroup(JNLPFile file) {
54     - AppThreadGroup appThreadGroup = null;
55     + protected ThreadGroup createThreadGroup(JNLPFile file) {
56     + ThreadGroup tg = null;
57    
58     if (file instanceof PluginBridge) {
59     - appThreadGroup = (AppThreadGroup) Thread.currentThread().getThreadGroup();
60     + tg = Thread.currentThread().getThreadGroup();
61     } else {
62     - appThreadGroup = new AppThreadGroup(mainGroup, file.getTitle());
63     + tg = new ThreadGroup(mainGroup, file.getTitle());
64     }
65    
66     - return appThreadGroup;
67     + return tg;
68     }
69    
70     /**
71     diff -r f0647c938535 -r 77640d74d21c netx/net/sourceforge/jnlp/NetxPanel.java
72     --- a/netx/net/sourceforge/jnlp/NetxPanel.java Sat Jan 07 02:48:05 2012 -0500
73     +++ b/netx/net/sourceforge/jnlp/NetxPanel.java Fri Apr 29 16:58:05 2011 -0400
74     @@ -23,12 +23,13 @@
75     package net.sourceforge.jnlp;
76    
77     import net.sourceforge.jnlp.AppletLog;
78     -import net.sourceforge.jnlp.runtime.AppThreadGroup;
79     import net.sourceforge.jnlp.runtime.AppletInstance;
80     import net.sourceforge.jnlp.runtime.JNLPRuntime;
81    
82     import java.net.URL;
83     import java.util.Hashtable;
84     +import java.util.concurrent.ConcurrentHashMap;
85     +import java.util.concurrent.ConcurrentMap;
86    
87     import sun.applet.AppletViewerPanel;
88     import sun.awt.SunToolkit;
89     @@ -44,9 +45,58 @@
90     private boolean exitOnFailure = true;
91     private AppletInstance appInst = null;
92     private boolean appletAlive;
93     + private final String uKey;
94     +
95     + // We use this so that we can create exactly one thread group
96     + // for all panels with the same uKey.
97     + private static final ConcurrentMap<String, ThreadGroup> uKeyToTG =
98     + new ConcurrentHashMap<String, ThreadGroup>();
99     +
100     + // This map is actually a set (unfortunately there is no ConcurrentSet
101     + // in java.util.concurrent). If KEY is in this map, then we know that
102     + // an app context has been created for the panel that has uKey.equals(KEY),
103     + // so we avoid creating it a second time for panels with the same uKey.
104     + // Because it's a set, only the keys matter. However, we can't insert
105     + // null values in because if we did, we couldn't use null checks to see
106     + // if a key was absent before a putIfAbsent.
107     + private static final ConcurrentMap<String, Boolean> appContextCreated =
108     + new ConcurrentHashMap<String, Boolean>();
109    
110     public NetxPanel(URL documentURL, Hashtable<String, String> atts) {
111     super(documentURL, atts);
112     +
113     + /* According to http://download.oracle.com/javase/6/docs/technotes/guides/deployment/deployment-guide/applet-compatibility.html,
114     + * classloaders are shared iff these properties match:
115     + * codebase, cache_archive, java_archive, archive
116     + *
117     + * To achieve this, we create the uniquekey based on those 4 values,
118     + * always in the same order. The initial "<NAME>=" parts ensure a
119     + * bad tag cannot trick the loader into getting shared with another.
120     + */
121     +
122     + // Firefox sometimes skips the codebase if it is default -- ".",
123     + // so set it that way if absent
124     + String codebaseAttr = atts.get("codebase") != null ?
125     + atts.get("codebase") : ".";
126     +
127     + String cache_archiveAttr = atts.get("cache_archive") != null ?
128     + atts.get("cache_archive") : "";
129     +
130     + String java_archiveAttr = atts.get("java_archive") != null ?
131     + atts.get("java_archive") : "";
132     +
133     + String archiveAttr = atts.get("archive") != null ?
134     + atts.get("archive") : "";
135     +
136     + this.uKey = "codebase=" + codebaseAttr +
137     + "cache_archive=" + cache_archiveAttr +
138     + "java_archive=" + java_archiveAttr +
139     + "archive=" + archiveAttr;
140     +
141     + // when this was being done (incorrectly) in Launcher, the call was
142     + // new AppThreadGroup(mainGroup, file.getTitle());
143     + ThreadGroup tg = new ThreadGroup(Launcher.mainGroup, this.documentURL.toString());
144     + uKeyToTG.putIfAbsent(this.uKey, tg);
145     }
146    
147     // overloaded constructor, called when initialized via plugin
148     @@ -58,18 +108,6 @@
149     }
150    
151     @Override
152     - public void run() {
153     - /*
154     - * create an AppContext for this thread associated with this particular
155     - * plugin instance (which runs in a different thread group from the rest
156     - * of the plugin).
157     - */
158     - SunToolkit.createNewAppContext();
159     -
160     - super.run();
161     - }
162     -
163     - @Override
164     protected void showAppletException(Throwable t) {
165     /*
166     * Log any exceptions thrown while loading, initializing, starting,
167     @@ -78,7 +116,7 @@
168     AppletLog.log(t);
169     super.showAppletException(t);
170     }
171     -
172     +
173     //Overriding to use Netx classloader. You might need to relax visibility
174     //in sun.applet.AppletPanel for runLoader().
175     protected void runLoader() {
176     @@ -90,7 +128,7 @@
177     getCode(),
178     getWidth(),
179     getHeight(),
180     - atts);
181     + atts, uKey);
182    
183     doInit = true;
184     dispatchAppletEvent(APPLET_LOADING, null);
185     @@ -154,11 +192,7 @@
186     }
187     }
188    
189     - // when this was being done (incorrectly) in Launcher, the call was
190     - // new AppThreadGroup(mainGroup, file.getTitle());
191     - ThreadGroup tg = new AppThreadGroup(Launcher.mainGroup,
192     - this.documentURL.toString());
193     - handler = new Thread(tg, this);
194     + handler = new Thread(getThreadGroup(), this);
195     handler.start();
196     }
197    
198     @@ -174,4 +208,19 @@
199     public boolean isAlive() {
200     return handler != null && handler.isAlive() && this.appletAlive;
201     }
202     +
203     + public ThreadGroup getThreadGroup() {
204     + return uKeyToTG.get(uKey);
205     + }
206     +
207     + public void createNewAppContext() {
208     + if (Thread.currentThread().getThreadGroup() != getThreadGroup()) {
209     + throw new RuntimeException("createNewAppContext called from the wrong thread.");
210     + }
211     + // only create a new context if one hasn't already been created for the
212     + // applets with this unique key.
213     + if (null == appContextCreated.putIfAbsent(uKey, Boolean.TRUE)) {
214     + SunToolkit.createNewAppContext();
215     + }
216     + }
217     }
218     diff -r f0647c938535 -r 77640d74d21c netx/net/sourceforge/jnlp/PluginBridge.java
219     --- a/netx/net/sourceforge/jnlp/PluginBridge.java Sat Jan 07 02:48:05 2012 -0500
220     +++ b/netx/net/sourceforge/jnlp/PluginBridge.java Fri Apr 29 16:58:05 2011 -0400
221     @@ -44,7 +44,8 @@
222     private boolean codeBaseLookup;
223    
224     public PluginBridge(URL codebase, URL documentBase, String jar, String main,
225     - int width, int height, Hashtable<String, String> atts)
226     + int width, int height, Hashtable<String, String> atts,
227     + String uKey)
228     throws Exception {
229     specVersion = new Version("1.0");
230     fileVersion = new Version("1.1");
231     @@ -132,34 +133,7 @@
232     else
233     security = null;
234    
235     - /* According to http://download.oracle.com/javase/6/docs/technotes/guides/deployment/deployment-guide/applet-compatibility.html,
236     - * classloaders are shared iff these properties match:
237     - * codebase, cache_archive, java_archive, archive
238     - *
239     - * To achieve this, we create the uniquekey based on those 4 values,
240     - * always in the same order. The initial "<NAME>=" parts ensure a
241     - * bad tag cannot trick the loader into getting shared with another.
242     - */
243     -
244     - // Firefox sometimes skips the codebase if it is default -- ".",
245     - // so set it that way if absent
246     - String codebaseAttr = atts.get("codebase") != null ?
247     - atts.get("codebase") : ".";
248     -
249     - String cache_archiveAttr = atts.get("cache_archive") != null ?
250     - atts.get("cache_archive") : "";
251     -
252     - String java_archiveAttr = atts.get("java_archive") != null ?
253     - atts.get("java_archive") : "";
254     -
255     - String archiveAttr = atts.get("archive") != null ?
256     - atts.get("archive") : "";
257     -
258     - this.uniqueKey = "codebase=" + codebaseAttr +
259     - "cache_archive=" + cache_archiveAttr +
260     - "java_archive=" + java_archiveAttr +
261     - "archive=" + archiveAttr;
262     -
263     + this.uniqueKey = uKey;
264     usePack = false;
265     useVersion = false;
266     String jargs = atts.get("java_arguments");
267     diff -r f0647c938535 -r 77640d74d21c plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
268     --- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java Sat Jan 07 02:48:05 2012 -0500
269     +++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java Fri Apr 29 16:58:05 2011 -0400
270     @@ -123,10 +123,10 @@
271     class PluginAppletPanelFactory {
272    
273     public AppletPanel createPanel(PluginStreamHandler streamhandler,
274     - int identifier,
275     - long handle, int x, int y,
276     - final URL doc,
277     - final Hashtable<String, String> atts) {
278     + final int identifier,
279     + final long handle, int x, int y,
280     + final URL doc,
281     + final Hashtable<String, String> atts) {
282     final NetxPanel panel = AccessController.doPrivileged(new PrivilegedAction<NetxPanel>() {
283     public NetxPanel run() {
284     NetxPanel panel = new NetxPanel(doc, atts, false);
285     @@ -136,13 +136,29 @@
286     }
287     });
288    
289     - // create the frame.
290     - PluginAppletViewer.framePanel(identifier, handle, panel);
291     + // Framing the panel needs to happen in a thread whose thread group
292     + // is the same as the threadgroup of the applet thread. If this
293     + // isn't the case, the awt eventqueue thread's context classloader
294     + // won't be set to a JNLPClassLoader, and when an applet class needs
295     + // to be loaded from the awt eventqueue, it won't be found.
296     + Thread panelInit = new Thread(panel.getThreadGroup(), new Runnable() {
297     + @Override public void run() {
298     + panel.createNewAppContext();
299     + // create the frame.
300     + PluginAppletViewer.framePanel(identifier, handle, panel);
301     + panel.init();
302     + // Start the applet
303     + initEventQueue(panel);
304     + }
305     + }, "NetXPanel initializer");
306    
307     - panel.init();
308     -
309     - // Start the applet
310     - initEventQueue(panel);
311     + panelInit.start();
312     + while(panelInit.isAlive()) {
313     + try {
314     + panelInit.join();
315     + } catch (InterruptedException e) {
316     + }
317     + }
318    
319     // Wait for the panel to initialize
320     PluginAppletViewer.waitForAppletInit(panel);

  ViewVC Help
Powered by ViewVC 1.1.20