author | sherman |
Tue, 30 Aug 2011 11:53:11 -0700 | |
changeset 10419 | 12c063b39232 |
parent 5506 | 202f599c92aa |
child 14342 | 8435a30053c1 |
permissions | -rw-r--r-- |
1327
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
1 |
/* |
5506 | 2 |
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. |
1327
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
4 |
* |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
1327
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
1327
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
10 |
* |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
15 |
* accompanied this code). |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
16 |
* |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
20 |
* |
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
1327
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
24 |
*/ |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
25 |
|
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
26 |
package com.sun.servicetag; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
27 |
|
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
28 |
import java.lang.reflect.Field; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
29 |
import java.lang.reflect.Method; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
30 |
import java.lang.reflect.InvocationTargetException; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
31 |
import java.io.IOException; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
32 |
import java.net.URI; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
33 |
|
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
34 |
/** |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
35 |
* BrowserSupport class. |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
36 |
* |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
37 |
* The implementation of the com.sun.servicetag API needs to be |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
38 |
* compiled with JDK 5 as well since the consumer of this API |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
39 |
* may require to support JDK 5 (e.g. NetBeans). |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
40 |
* |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
41 |
* The Desktop.browse() method can be backported in this class |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
42 |
* if needed. The current implementation only supports JDK 6. |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
43 |
*/ |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
44 |
class BrowserSupport { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
45 |
private static boolean isBrowseSupported = false; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
46 |
private static Method browseMethod = null; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
47 |
private static Object desktop = null; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
48 |
private static volatile Boolean result = false; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
49 |
|
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
50 |
|
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
51 |
private static void initX() { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
52 |
if (desktop != null) { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
53 |
return; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
54 |
} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
55 |
boolean supported = false; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
56 |
Method browseM = null; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
57 |
Object desktopObj = null; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
58 |
try { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
59 |
// Determine if java.awt.Desktop is supported |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
60 |
Class<?> desktopCls = Class.forName("java.awt.Desktop", true, null); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
61 |
Method getDesktopM = desktopCls.getMethod("getDesktop"); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
62 |
browseM = desktopCls.getMethod("browse", URI.class); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
63 |
|
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
64 |
Class<?> actionCls = Class.forName("java.awt.Desktop$Action", true, null); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
65 |
final Method isDesktopSupportedMethod = desktopCls.getMethod("isDesktopSupported"); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
66 |
Method isSupportedMethod = desktopCls.getMethod("isSupported", actionCls); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
67 |
Field browseField = actionCls.getField("BROWSE"); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
68 |
// isDesktopSupported calls getDefaultToolkit which can block |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
69 |
// infinitely, see 6636099 for details, to workaround we call |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
70 |
// in a thread and time it out, noting that the issue is specific |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
71 |
// to X11, it does not hurt for Windows. |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
72 |
Thread xthread = new Thread() { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
73 |
public void run() { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
74 |
try { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
75 |
// support only if Desktop.isDesktopSupported() and |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
76 |
// Desktop.isSupported(Desktop.Action.BROWSE) return true. |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
77 |
result = (Boolean) isDesktopSupportedMethod.invoke(null); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
78 |
} catch (IllegalAccessException e) { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
79 |
// should never reach here |
10419
12c063b39232
7084245: Update usages of InternalError to use exception chaining
sherman
parents:
5506
diff
changeset
|
80 |
throw new InternalError("Desktop.getDesktop() method not found", e); |
1327
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
81 |
} catch (InvocationTargetException e) { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
82 |
// browser not supported |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
83 |
if (Util.isVerbose()) { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
84 |
e.printStackTrace(); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
85 |
} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
86 |
} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
87 |
} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
88 |
}; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
89 |
// set it to daemon, so that the vm will exit. |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
90 |
xthread.setDaemon(true); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
91 |
xthread.start(); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
92 |
try { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
93 |
xthread.join(5 * 1000); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
94 |
} catch (InterruptedException ie) { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
95 |
// ignore the exception |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
96 |
} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
97 |
if (result.booleanValue()) { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
98 |
desktopObj = getDesktopM.invoke(null); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
99 |
result = (Boolean) isSupportedMethod.invoke(desktopObj, browseField.get(null)); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
100 |
supported = result.booleanValue(); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
101 |
} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
102 |
} catch (IllegalAccessException e) { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
103 |
// should never reach here |
10419
12c063b39232
7084245: Update usages of InternalError to use exception chaining
sherman
parents:
5506
diff
changeset
|
104 |
throw new InternalError("Desktop.getDesktop() method not found", e); |
12c063b39232
7084245: Update usages of InternalError to use exception chaining
sherman
parents:
5506
diff
changeset
|
105 |
} catch (ReflectiveOperationException e) { |
1327
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
106 |
// browser not supported |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
107 |
if (Util.isVerbose()) { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
108 |
e.printStackTrace(); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
109 |
} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
110 |
} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
111 |
isBrowseSupported = supported; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
112 |
browseMethod = browseM; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
113 |
desktop = desktopObj; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
114 |
} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
115 |
|
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
116 |
static boolean isSupported() { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
117 |
initX(); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
118 |
return isBrowseSupported; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
119 |
} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
120 |
|
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
121 |
/** |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
122 |
* Launches the default browser to display a {@code URI}. |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
123 |
* If the default browser is not able to handle the specified |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
124 |
* {@code URI}, the application registered for handling |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
125 |
* {@code URIs} of the specified type is invoked. The application |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
126 |
* is determined from the protocol and path of the {@code URI}, as |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
127 |
* defined by the {@code URI} class. |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
128 |
* <p> |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
129 |
* This method calls the Desktop.getDesktop().browse() method. |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
130 |
* <p> |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
131 |
* @param uri the URI to be displayed in the user default browser |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
132 |
* |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
133 |
* @throws NullPointerException if {@code uri} is {@code null} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
134 |
* @throws UnsupportedOperationException if the current platform |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
135 |
* does not support the {@link Desktop.Action#BROWSE} action |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
136 |
* @throws IOException if the user default browser is not found, |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
137 |
* or it fails to be launched, or the default handler application |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
138 |
* failed to be launched |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
139 |
* @throws IllegalArgumentException if the necessary permissions |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
140 |
* are not available and the URI can not be converted to a {@code URL} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
141 |
*/ |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
142 |
static void browse(URI uri) throws IOException { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
143 |
if (uri == null) { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
144 |
throw new NullPointerException("null uri"); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
145 |
} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
146 |
if (!isSupported()) { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
147 |
throw new UnsupportedOperationException("Browse operation is not supported"); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
148 |
} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
149 |
|
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
150 |
// Call Desktop.browse() method |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
151 |
try { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
152 |
if (Util.isVerbose()) { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
153 |
System.out.println("desktop: " + desktop + ":browsing..." + uri); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
154 |
} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
155 |
browseMethod.invoke(desktop, uri); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
156 |
} catch (IllegalAccessException e) { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
157 |
// should never reach here |
10419
12c063b39232
7084245: Update usages of InternalError to use exception chaining
sherman
parents:
5506
diff
changeset
|
158 |
throw new InternalError("Desktop.getDesktop() method not found", e); |
1327
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
159 |
} catch (InvocationTargetException e) { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
160 |
Throwable x = e.getCause(); |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
161 |
if (x != null) { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
162 |
if (x instanceof UnsupportedOperationException) { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
163 |
throw (UnsupportedOperationException) x; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
164 |
} else if (x instanceof IllegalArgumentException) { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
165 |
throw (IllegalArgumentException) x; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
166 |
} else if (x instanceof IOException) { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
167 |
throw (IOException) x; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
168 |
} else if (x instanceof SecurityException) { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
169 |
throw (SecurityException) x; |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
170 |
} else { |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
171 |
// ignore |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
172 |
} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
173 |
} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
174 |
} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
175 |
} |
912486b03832
6581243: Service Tag and Product Registration Support in JDK 7
mchung
parents:
diff
changeset
|
176 |
} |