1 | /* package-info.java
|
---|
2 | Copyright (C) 2014 Red Hat, Inc.
|
---|
3 |
|
---|
4 | This file is part of IcedTea.
|
---|
5 |
|
---|
6 | IcedTea is free software; you can redistribute it and/or modify it under the
|
---|
7 | terms of the GNU General Public License as published by the Free Software
|
---|
8 | Foundation, version 2.
|
---|
9 |
|
---|
10 | IcedTea is distributed in the hope that it will be useful, but WITHOUT ANY
|
---|
11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
---|
12 | PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU General Public License along with
|
---|
15 | IcedTea; see the file COPYING. If not, write to the
|
---|
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
---|
17 | 02110-1301 USA.
|
---|
18 |
|
---|
19 | Linking this library statically or dynamically with other modules is making a
|
---|
20 | combined work based on this library. Thus, the terms and conditions of the GNU
|
---|
21 | General Public License cover the whole combination.
|
---|
22 |
|
---|
23 | As a special exception, the copyright holders of this library give you
|
---|
24 | permission to link this library with independent modules to produce an
|
---|
25 | executable, regardless of the license terms of these independent modules, and
|
---|
26 | to copy and distribute the resulting executable under terms of your choice,
|
---|
27 | provided that you also meet, for each linked independent module, the terms and
|
---|
28 | conditions of the license of that module. An independent module is a module
|
---|
29 | which is not derived from or based on this library. If you modify this library,
|
---|
30 | you may extend this exception to your version of the library, but you are not
|
---|
31 | obligated to do so. If you do not wish to do so, delete this exception
|
---|
32 | statement from your version.*/
|
---|
33 | package sun.applet;
|
---|
34 |
|
---|
35 | import java.applet.Applet;
|
---|
36 | import java.lang.reflect.Field;
|
---|
37 | import java.lang.reflect.InvocationTargetException;
|
---|
38 | import java.lang.reflect.Method;
|
---|
39 | import java.net.URL;
|
---|
40 | import java.util.Hashtable;
|
---|
41 |
|
---|
42 | public abstract class AppletViewerPanelAccess extends AppletViewerPanel {
|
---|
43 |
|
---|
44 | public AppletViewerPanelAccess(URL documentURL, Hashtable<String, String> atts) {
|
---|
45 | super(documentURL, atts);
|
---|
46 | }
|
---|
47 |
|
---|
48 | protected URL getDocumentURL() {
|
---|
49 | try {
|
---|
50 | Field field = AppletViewerPanel.class.getDeclaredField("documentURL");
|
---|
51 | field.setAccessible(true);
|
---|
52 | return (URL) field.get(this);
|
---|
53 | } catch (IllegalAccessException ex1) {
|
---|
54 | throw new RuntimeException(ex1);
|
---|
55 | } catch (IllegalArgumentException ex2) {
|
---|
56 | throw new RuntimeException(ex2);
|
---|
57 | } catch (NoSuchFieldException ex3) {
|
---|
58 | throw new RuntimeException(ex3);
|
---|
59 | } catch (SecurityException ex4) {
|
---|
60 | throw new RuntimeException(ex4);
|
---|
61 | }
|
---|
62 | }
|
---|
63 |
|
---|
64 | protected void setApplet(Applet iapplet) {
|
---|
65 | try {
|
---|
66 | Field field = AppletPanel.class.getDeclaredField("applet");
|
---|
67 | field.setAccessible(true);
|
---|
68 | field.set(this, iapplet);
|
---|
69 | } catch (IllegalAccessException ex1) {
|
---|
70 | throw new RuntimeException(ex1);
|
---|
71 | } catch (IllegalArgumentException ex2) {
|
---|
72 | throw new RuntimeException(ex2);
|
---|
73 | } catch (NoSuchFieldException ex3) {
|
---|
74 | throw new RuntimeException(ex3);
|
---|
75 | } catch (SecurityException ex4) {
|
---|
76 | throw new RuntimeException(ex4);
|
---|
77 | }
|
---|
78 | }
|
---|
79 |
|
---|
80 | @Override
|
---|
81 | public void run() {
|
---|
82 | // this is copypasted chunk from AppletPanel.run (the only current
|
---|
83 | // call of runLoader). Pray it do not change
|
---|
84 | Thread curThread = Thread.currentThread();
|
---|
85 | if (curThread == loaderThread) {
|
---|
86 | ourRunLoader();
|
---|
87 | return;
|
---|
88 | }
|
---|
89 |
|
---|
90 | super.run();
|
---|
91 | }
|
---|
92 |
|
---|
93 | /**
|
---|
94 | * NOTE. We cannot override private method, and this call is unused and useless.
|
---|
95 | * But kept for record of troubles to run on any openjdk.
|
---|
96 | * upstream patch posted http://mail.openjdk.java.net/pipermail/awt-dev/2014-May/007828.html
|
---|
97 | */
|
---|
98 | private void superRunLoader() {
|
---|
99 | try {
|
---|
100 | Class klazz = AppletPanel.class;
|
---|
101 | Method runLoaderMethod = klazz.getDeclaredMethod("runLoader");
|
---|
102 | runLoaderMethod.setAccessible(true);
|
---|
103 | runLoaderMethod.invoke(getApplet());
|
---|
104 | } catch (IllegalAccessException ex1) {
|
---|
105 | throw new RuntimeException(ex1);
|
---|
106 | } catch (IllegalArgumentException ex2) {
|
---|
107 | throw new RuntimeException(ex2);
|
---|
108 | } catch (NoSuchMethodException ex3) {
|
---|
109 | throw new RuntimeException(ex3);
|
---|
110 | } catch (SecurityException ex4) {
|
---|
111 | throw new RuntimeException(ex4);
|
---|
112 | } catch (InvocationTargetException ex5) {
|
---|
113 | throw new RuntimeException(ex5);
|
---|
114 | }
|
---|
115 | }
|
---|
116 |
|
---|
117 |
|
---|
118 | protected URL getBaseURL() {
|
---|
119 | try {
|
---|
120 | Field field = AppletViewerPanel.class
|
---|
121 | .getDeclaredField("baseURL");
|
---|
122 | field.setAccessible(
|
---|
123 | true);
|
---|
124 | return (URL) field.get(
|
---|
125 | this);
|
---|
126 | } catch (IllegalAccessException ex1) {
|
---|
127 | throw new RuntimeException(ex1);
|
---|
128 | } catch (IllegalArgumentException ex2) {
|
---|
129 | throw new RuntimeException(ex2);
|
---|
130 | } catch (NoSuchFieldException ex3) {
|
---|
131 | throw new RuntimeException(ex3);
|
---|
132 | } catch (SecurityException ex4) {
|
---|
133 | throw new RuntimeException(ex4);
|
---|
134 | }
|
---|
135 |
|
---|
136 | }
|
---|
137 |
|
---|
138 |
|
---|
139 | @Override
|
---|
140 | //remaining stub of unpatched jdk
|
---|
141 | protected synchronized void createAppletThread() {
|
---|
142 | throw new RuntimeException("Not yet implemented");
|
---|
143 | //no need to call super, is overriden, and not used in upstream
|
---|
144 | //AppletViewerPanel or AppletPanel
|
---|
145 | }
|
---|
146 |
|
---|
147 | abstract protected void ourRunLoader();
|
---|
148 |
|
---|
149 | }
|
---|