author | mullan |
Fri, 09 Apr 2010 07:21:46 -0700 | |
changeset 5288 | e91651d24b2a |
parent 5183 | 7825d97c4cf2 |
child 5462 | cb614e59f7f9 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5288
e91651d24b2a
6909281: 6u19 b99(pit):Error loading first applet in browser session( both FF && IE, windows ): NPE is thrown
mullan
parents:
5183
diff
changeset
|
2 |
* Copyright 2002-2010 Sun Microsystems, Inc. All Rights Reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Sun designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Sun in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
* have any questions. |
|
24 |
*/ |
|
25 |
||
26 |
package sun.misc; |
|
27 |
||
28 |
import java.util.jar.JarFile; |
|
29 |
import java.io.Console; |
|
30 |
import java.io.File; |
|
31 |
import java.io.FileDescriptor; |
|
5288
e91651d24b2a
6909281: 6u19 b99(pit):Error loading first applet in browser session( both FF && IE, windows ): NPE is thrown
mullan
parents:
5183
diff
changeset
|
32 |
import java.security.ProtectionDomain; |
2 | 33 |
|
34 |
/** A repository of "shared secrets", which are a mechanism for |
|
35 |
calling implementation-private methods in another package without |
|
36 |
using reflection. A package-private class implements a public |
|
37 |
interface and provides the ability to call package-private methods |
|
38 |
within that package; the object implementing that interface is |
|
39 |
provided through a third package to which access is restricted. |
|
40 |
This framework avoids the primary disadvantage of using reflection |
|
41 |
for this purpose, namely the loss of compile-time checking. */ |
|
42 |
||
43 |
public class SharedSecrets { |
|
44 |
private static final Unsafe unsafe = Unsafe.getUnsafe(); |
|
45 |
private static JavaUtilJarAccess javaUtilJarAccess; |
|
46 |
private static JavaLangAccess javaLangAccess; |
|
47 |
private static JavaIOAccess javaIOAccess; |
|
48 |
private static JavaNetAccess javaNetAccess; |
|
1143
645d4b930f93
6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
2
diff
changeset
|
49 |
private static JavaNioAccess javaNioAccess; |
2 | 50 |
private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess; |
5183
7825d97c4cf2
6633872: Policy/PolicyFile leak dynamic ProtectionDomains.
mullan
parents:
2277
diff
changeset
|
51 |
private static JavaSecurityProtectionDomainAccess javaSecurityProtectionDomainAccess; |
2 | 52 |
|
53 |
public static JavaUtilJarAccess javaUtilJarAccess() { |
|
54 |
if (javaUtilJarAccess == null) { |
|
55 |
// Ensure JarFile is initialized; we know that that class |
|
56 |
// provides the shared secret |
|
57 |
unsafe.ensureClassInitialized(JarFile.class); |
|
58 |
} |
|
59 |
return javaUtilJarAccess; |
|
60 |
} |
|
61 |
||
62 |
public static void setJavaUtilJarAccess(JavaUtilJarAccess access) { |
|
63 |
javaUtilJarAccess = access; |
|
64 |
} |
|
65 |
||
66 |
public static void setJavaLangAccess(JavaLangAccess jla) { |
|
67 |
javaLangAccess = jla; |
|
68 |
} |
|
69 |
||
70 |
public static JavaLangAccess getJavaLangAccess() { |
|
71 |
return javaLangAccess; |
|
72 |
} |
|
73 |
||
74 |
public static void setJavaNetAccess(JavaNetAccess jna) { |
|
75 |
javaNetAccess = jna; |
|
76 |
} |
|
77 |
||
78 |
public static JavaNetAccess getJavaNetAccess() { |
|
79 |
return javaNetAccess; |
|
80 |
} |
|
81 |
||
1143
645d4b930f93
6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
2
diff
changeset
|
82 |
public static void setJavaNioAccess(JavaNioAccess jna) { |
645d4b930f93
6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
2
diff
changeset
|
83 |
javaNioAccess = jna; |
645d4b930f93
6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
2
diff
changeset
|
84 |
} |
645d4b930f93
6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
2
diff
changeset
|
85 |
|
645d4b930f93
6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
2
diff
changeset
|
86 |
public static JavaNioAccess getJavaNioAccess() { |
645d4b930f93
6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
2
diff
changeset
|
87 |
if (javaNioAccess == null) { |
645d4b930f93
6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
2
diff
changeset
|
88 |
// Ensure java.nio.ByteOrder is initialized; we know that |
645d4b930f93
6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
2
diff
changeset
|
89 |
// this class initializes java.nio.Bits that provides the |
645d4b930f93
6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
2
diff
changeset
|
90 |
// shared secret. |
645d4b930f93
6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
2
diff
changeset
|
91 |
unsafe.ensureClassInitialized(java.nio.ByteOrder.class); |
645d4b930f93
6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
2
diff
changeset
|
92 |
} |
645d4b930f93
6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
2
diff
changeset
|
93 |
return javaNioAccess; |
645d4b930f93
6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
2
diff
changeset
|
94 |
} |
645d4b930f93
6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
2
diff
changeset
|
95 |
|
2 | 96 |
public static void setJavaIOAccess(JavaIOAccess jia) { |
97 |
javaIOAccess = jia; |
|
98 |
} |
|
99 |
||
100 |
public static JavaIOAccess getJavaIOAccess() { |
|
101 |
if (javaIOAccess == null) { |
|
102 |
unsafe.ensureClassInitialized(Console.class); |
|
103 |
} |
|
104 |
return javaIOAccess; |
|
105 |
} |
|
106 |
||
107 |
public static void setJavaIOFileDescriptorAccess(JavaIOFileDescriptorAccess jiofda) { |
|
108 |
javaIOFileDescriptorAccess = jiofda; |
|
109 |
} |
|
110 |
||
111 |
public static JavaIOFileDescriptorAccess getJavaIOFileDescriptorAccess() { |
|
112 |
if (javaIOFileDescriptorAccess == null) |
|
113 |
unsafe.ensureClassInitialized(FileDescriptor.class); |
|
114 |
||
115 |
return javaIOFileDescriptorAccess; |
|
116 |
} |
|
117 |
||
5183
7825d97c4cf2
6633872: Policy/PolicyFile leak dynamic ProtectionDomains.
mullan
parents:
2277
diff
changeset
|
118 |
public static void setJavaSecurityProtectionDomainAccess |
7825d97c4cf2
6633872: Policy/PolicyFile leak dynamic ProtectionDomains.
mullan
parents:
2277
diff
changeset
|
119 |
(JavaSecurityProtectionDomainAccess jspda) { |
7825d97c4cf2
6633872: Policy/PolicyFile leak dynamic ProtectionDomains.
mullan
parents:
2277
diff
changeset
|
120 |
javaSecurityProtectionDomainAccess = jspda; |
7825d97c4cf2
6633872: Policy/PolicyFile leak dynamic ProtectionDomains.
mullan
parents:
2277
diff
changeset
|
121 |
} |
7825d97c4cf2
6633872: Policy/PolicyFile leak dynamic ProtectionDomains.
mullan
parents:
2277
diff
changeset
|
122 |
|
7825d97c4cf2
6633872: Policy/PolicyFile leak dynamic ProtectionDomains.
mullan
parents:
2277
diff
changeset
|
123 |
public static JavaSecurityProtectionDomainAccess |
7825d97c4cf2
6633872: Policy/PolicyFile leak dynamic ProtectionDomains.
mullan
parents:
2277
diff
changeset
|
124 |
getJavaSecurityProtectionDomainAccess() { |
5288
e91651d24b2a
6909281: 6u19 b99(pit):Error loading first applet in browser session( both FF && IE, windows ): NPE is thrown
mullan
parents:
5183
diff
changeset
|
125 |
if (javaSecurityProtectionDomainAccess == null) |
e91651d24b2a
6909281: 6u19 b99(pit):Error loading first applet in browser session( both FF && IE, windows ): NPE is thrown
mullan
parents:
5183
diff
changeset
|
126 |
unsafe.ensureClassInitialized(ProtectionDomain.class); |
5183
7825d97c4cf2
6633872: Policy/PolicyFile leak dynamic ProtectionDomains.
mullan
parents:
2277
diff
changeset
|
127 |
return javaSecurityProtectionDomainAccess; |
7825d97c4cf2
6633872: Policy/PolicyFile leak dynamic ProtectionDomains.
mullan
parents:
2277
diff
changeset
|
128 |
} |
2 | 129 |
} |