< prev index next >

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

Print this page
rev 51958 : 8211122: Reduce the number of internal classes made accessible to jdk.unsupported
Reviewed-by: alanb, dfuchs, kvn


   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle 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 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.misc;
  27 
  28 import javax.crypto.SealedObject;
  29 import java.io.ObjectInputFilter;
  30 import java.lang.module.ModuleDescriptor;
  31 import java.util.ResourceBundle;
  32 import java.util.jar.JarFile;
  33 import java.io.Console;
  34 import java.io.FileDescriptor;
  35 import java.io.FilePermission;
  36 import java.io.ObjectInputStream;
  37 import java.io.RandomAccessFile;
  38 import java.security.ProtectionDomain;

  39 
  40 /** A repository of "shared secrets", which are a mechanism for
  41     calling implementation-private methods in another package without
  42     using reflection. A package-private class implements a public
  43     interface and provides the ability to call package-private methods
  44     within that package; the object implementing that interface is
  45     provided through a third package to which access is restricted.
  46     This framework avoids the primary disadvantage of using reflection
  47     for this purpose, namely the loss of compile-time checking. */
  48 
  49 public class SharedSecrets {
  50     private static final Unsafe unsafe = Unsafe.getUnsafe();
  51     private static JavaUtilJarAccess javaUtilJarAccess;
  52     private static JavaLangAccess javaLangAccess;
  53     private static JavaLangModuleAccess javaLangModuleAccess;
  54     private static JavaLangInvokeAccess javaLangInvokeAccess;
  55     private static JavaLangRefAccess javaLangRefAccess;
  56     private static JavaIOAccess javaIOAccess;
  57     private static JavaNetInetAddressAccess javaNetInetAddressAccess;
  58     private static JavaNetHttpCookieAccess javaNetHttpCookieAccess;




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle 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 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 java.io.ObjectInputFilter;
  30 import java.lang.module.ModuleDescriptor;
  31 import java.util.ResourceBundle;
  32 import java.util.jar.JarFile;
  33 import java.io.Console;
  34 import java.io.FileDescriptor;
  35 import java.io.FilePermission;
  36 import java.io.ObjectInputStream;
  37 import java.io.RandomAccessFile;
  38 import java.security.ProtectionDomain;
  39 import jdk.internal.misc.Unsafe;
  40 
  41 /** A repository of "shared secrets", which are a mechanism for
  42     calling implementation-private methods in another package without
  43     using reflection. A package-private class implements a public
  44     interface and provides the ability to call package-private methods
  45     within that package; the object implementing that interface is
  46     provided through a third package to which access is restricted.
  47     This framework avoids the primary disadvantage of using reflection
  48     for this purpose, namely the loss of compile-time checking. */
  49 
  50 public class SharedSecrets {
  51     private static final Unsafe unsafe = Unsafe.getUnsafe();
  52     private static JavaUtilJarAccess javaUtilJarAccess;
  53     private static JavaLangAccess javaLangAccess;
  54     private static JavaLangModuleAccess javaLangModuleAccess;
  55     private static JavaLangInvokeAccess javaLangInvokeAccess;
  56     private static JavaLangRefAccess javaLangRefAccess;
  57     private static JavaIOAccess javaIOAccess;
  58     private static JavaNetInetAddressAccess javaNetInetAddressAccess;
  59     private static JavaNetHttpCookieAccess javaNetHttpCookieAccess;


< prev index next >