< prev index next >

src/java.base/share/classes/jdk/internal/access/SharedSecrets.java

Print this page

 20  *
 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.
 24  */
 25 
 26 package jdk.internal.access;
 27 
 28 import javax.crypto.SealedObject;
 29 import javax.crypto.spec.SecretKeySpec;
 30 import java.io.ObjectInputFilter;
 31 import java.lang.invoke.MethodHandles;
 32 import java.lang.module.ModuleDescriptor;
 33 import java.security.spec.EncodedKeySpec;
 34 import java.util.ResourceBundle;
 35 import java.util.jar.JarFile;
 36 import java.io.Console;
 37 import java.io.FileDescriptor;
 38 import java.io.FilePermission;
 39 import java.io.ObjectInputStream;


 40 import java.io.RandomAccessFile;
 41 import java.security.ProtectionDomain;
 42 import java.security.Signature;
 43 
 44 /** A repository of "shared secrets", which are a mechanism for
 45     calling implementation-private methods in another package without
 46     using reflection. A package-private class implements a public
 47     interface and provides the ability to call package-private methods
 48     within that package; the object implementing that interface is
 49     provided through a third package to which access is restricted.
 50     This framework avoids the primary disadvantage of using reflection
 51     for this purpose, namely the loss of compile-time checking. */
 52 
 53 public class SharedSecrets {
 54     private static final MethodHandles.Lookup lookup = MethodHandles.lookup();
 55     private static JavaAWTAccess javaAWTAccess;
 56     private static JavaAWTFontAccess javaAWTFontAccess;
 57     private static JavaBeansAccess javaBeansAccess;
 58     private static JavaLangAccess javaLangAccess;
 59     private static JavaLangInvokeAccess javaLangInvokeAccess;
 60     private static JavaLangModuleAccess javaLangModuleAccess;
 61     private static JavaLangRefAccess javaLangRefAccess;
 62     private static JavaLangReflectAccess javaLangReflectAccess;
 63     private static JavaIOAccess javaIOAccess;


 64     private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess;
 65     private static JavaIOFilePermissionAccess javaIOFilePermissionAccess;
 66     private static JavaIORandomAccessFileAccess javaIORandomAccessFileAccess;
 67     private static JavaObjectInputStreamReadString javaObjectInputStreamReadString;
 68     private static JavaObjectInputStreamAccess javaObjectInputStreamAccess;
 69     private static JavaObjectInputFilterAccess javaObjectInputFilterAccess;
 70     private static JavaNetInetAddressAccess javaNetInetAddressAccess;
 71     private static JavaNetHttpCookieAccess javaNetHttpCookieAccess;
 72     private static JavaNetUriAccess javaNetUriAccess;
 73     private static JavaNetURLAccess javaNetURLAccess;
 74     private static JavaNioAccess javaNioAccess;
 75     private static JavaUtilCollectionAccess javaUtilCollectionAccess;
 76     private static JavaUtilJarAccess javaUtilJarAccess;
 77     private static JavaUtilZipFileAccess javaUtilZipFileAccess;
 78     private static JavaUtilResourceBundleAccess javaUtilResourceBundleAccess;
 79     private static JavaSecurityAccess javaSecurityAccess;
 80     private static JavaSecuritySignatureAccess javaSecuritySignatureAccess;
 81     private static JavaSecuritySpecAccess javaSecuritySpecAccess;
 82     private static JavaxCryptoSealedObjectAccess javaxCryptoSealedObjectAccess;
 83     private static JavaxCryptoSpecAccess javaxCryptoSpecAccess;

227             // shared secret.
228             ensureClassInitialized(java.nio.Buffer.class);
229             access = javaNioAccess;
230         }
231         return access;
232     }
233 
234     public static void setJavaIOAccess(JavaIOAccess jia) {
235         javaIOAccess = jia;
236     }
237 
238     public static JavaIOAccess getJavaIOAccess() {
239         var access = javaIOAccess;
240         if (access == null) {
241             ensureClassInitialized(Console.class);
242             access = javaIOAccess;
243         }
244         return access;
245     }
246 


























247     public static void setJavaIOFileDescriptorAccess(JavaIOFileDescriptorAccess jiofda) {
248         javaIOFileDescriptorAccess = jiofda;
249     }
250 
251     public static JavaIOFilePermissionAccess getJavaIOFilePermissionAccess() {
252         var access = javaIOFilePermissionAccess;
253         if (access == null) {
254             ensureClassInitialized(FilePermission.class);
255             access = javaIOFilePermissionAccess;
256         }
257         return access;
258     }
259 
260     public static void setJavaIOFilePermissionAccess(JavaIOFilePermissionAccess jiofpa) {
261         javaIOFilePermissionAccess = jiofpa;
262     }
263 
264     public static JavaIOFileDescriptorAccess getJavaIOFileDescriptorAccess() {
265         var access = javaIOFileDescriptorAccess;
266         if (access == null) {

 20  *
 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.
 24  */
 25 
 26 package jdk.internal.access;
 27 
 28 import javax.crypto.SealedObject;
 29 import javax.crypto.spec.SecretKeySpec;
 30 import java.io.ObjectInputFilter;
 31 import java.lang.invoke.MethodHandles;
 32 import java.lang.module.ModuleDescriptor;
 33 import java.security.spec.EncodedKeySpec;
 34 import java.util.ResourceBundle;
 35 import java.util.jar.JarFile;
 36 import java.io.Console;
 37 import java.io.FileDescriptor;
 38 import java.io.FilePermission;
 39 import java.io.ObjectInputStream;
 40 import java.io.PrintStream;
 41 import java.io.PrintWriter;
 42 import java.io.RandomAccessFile;
 43 import java.security.ProtectionDomain;
 44 import java.security.Signature;
 45 
 46 /** A repository of "shared secrets", which are a mechanism for
 47     calling implementation-private methods in another package without
 48     using reflection. A package-private class implements a public
 49     interface and provides the ability to call package-private methods
 50     within that package; the object implementing that interface is
 51     provided through a third package to which access is restricted.
 52     This framework avoids the primary disadvantage of using reflection
 53     for this purpose, namely the loss of compile-time checking. */
 54 
 55 public class SharedSecrets {
 56     private static final MethodHandles.Lookup lookup = MethodHandles.lookup();
 57     private static JavaAWTAccess javaAWTAccess;
 58     private static JavaAWTFontAccess javaAWTFontAccess;
 59     private static JavaBeansAccess javaBeansAccess;
 60     private static JavaLangAccess javaLangAccess;
 61     private static JavaLangInvokeAccess javaLangInvokeAccess;
 62     private static JavaLangModuleAccess javaLangModuleAccess;
 63     private static JavaLangRefAccess javaLangRefAccess;
 64     private static JavaLangReflectAccess javaLangReflectAccess;
 65     private static JavaIOAccess javaIOAccess;
 66     private static JavaIOPrintStreamAccess javaIOPrintStreamAccess;
 67     private static JavaIOPrintWriterAccess javaIOPrintWriterAccess;
 68     private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess;
 69     private static JavaIOFilePermissionAccess javaIOFilePermissionAccess;
 70     private static JavaIORandomAccessFileAccess javaIORandomAccessFileAccess;
 71     private static JavaObjectInputStreamReadString javaObjectInputStreamReadString;
 72     private static JavaObjectInputStreamAccess javaObjectInputStreamAccess;
 73     private static JavaObjectInputFilterAccess javaObjectInputFilterAccess;
 74     private static JavaNetInetAddressAccess javaNetInetAddressAccess;
 75     private static JavaNetHttpCookieAccess javaNetHttpCookieAccess;
 76     private static JavaNetUriAccess javaNetUriAccess;
 77     private static JavaNetURLAccess javaNetURLAccess;
 78     private static JavaNioAccess javaNioAccess;
 79     private static JavaUtilCollectionAccess javaUtilCollectionAccess;
 80     private static JavaUtilJarAccess javaUtilJarAccess;
 81     private static JavaUtilZipFileAccess javaUtilZipFileAccess;
 82     private static JavaUtilResourceBundleAccess javaUtilResourceBundleAccess;
 83     private static JavaSecurityAccess javaSecurityAccess;
 84     private static JavaSecuritySignatureAccess javaSecuritySignatureAccess;
 85     private static JavaSecuritySpecAccess javaSecuritySpecAccess;
 86     private static JavaxCryptoSealedObjectAccess javaxCryptoSealedObjectAccess;
 87     private static JavaxCryptoSpecAccess javaxCryptoSpecAccess;

231             // shared secret.
232             ensureClassInitialized(java.nio.Buffer.class);
233             access = javaNioAccess;
234         }
235         return access;
236     }
237 
238     public static void setJavaIOAccess(JavaIOAccess jia) {
239         javaIOAccess = jia;
240     }
241 
242     public static JavaIOAccess getJavaIOAccess() {
243         var access = javaIOAccess;
244         if (access == null) {
245             ensureClassInitialized(Console.class);
246             access = javaIOAccess;
247         }
248         return access;
249     }
250 
251     public static void setJavaIOCPrintWriterAccess(JavaIOPrintWriterAccess a) {
252         javaIOPrintWriterAccess = a;
253     }
254 
255     public static JavaIOPrintWriterAccess getJavaIOPrintWriterAccess() {
256         var access = javaIOPrintWriterAccess;
257         if (access == null) {
258             ensureClassInitialized(PrintWriter.class);
259             access = javaIOPrintWriterAccess;
260         }
261         return access;
262     }
263 
264     public static void setJavaIOCPrintStreamAccess(JavaIOPrintStreamAccess a) {
265         javaIOPrintStreamAccess = a;
266     }
267 
268     public static JavaIOPrintStreamAccess getJavaIOPrintStreamAccess() {
269         var access = javaIOPrintStreamAccess;
270         if (access == null) {
271             ensureClassInitialized(PrintStream.class);
272             access = javaIOPrintStreamAccess;
273         }
274         return access;
275     }
276 
277     public static void setJavaIOFileDescriptorAccess(JavaIOFileDescriptorAccess jiofda) {
278         javaIOFileDescriptorAccess = jiofda;
279     }
280 
281     public static JavaIOFilePermissionAccess getJavaIOFilePermissionAccess() {
282         var access = javaIOFilePermissionAccess;
283         if (access == null) {
284             ensureClassInitialized(FilePermission.class);
285             access = javaIOFilePermissionAccess;
286         }
287         return access;
288     }
289 
290     public static void setJavaIOFilePermissionAccess(JavaIOFilePermissionAccess jiofpa) {
291         javaIOFilePermissionAccess = jiofpa;
292     }
293 
294     public static JavaIOFileDescriptorAccess getJavaIOFileDescriptorAccess() {
295         var access = javaIOFileDescriptorAccess;
296         if (access == null) {
< prev index next >