8068682: Deprivilege/move java.corba to the ext class loader
authormsheppar
Mon, 16 Feb 2015 00:12:13 +0000
changeset 29040 1db7d75a0f5a
parent 28895 6efe265424e3
child 29041 cda0ffc99002
8068682: Deprivilege/move java.corba to the ext class loader Reviewed-by: alanb, mchung
corba/src/java.corba/share/classes/com/sun/corba/se/spi/orb/ORB.java
corba/src/java.corba/share/classes/sun/corba/SharedSecrets.java
--- a/corba/src/java.corba/share/classes/com/sun/corba/se/spi/orb/ORB.java	Wed Jul 05 20:19:45 2017 +0200
+++ b/corba/src/java.corba/share/classes/com/sun/corba/se/spi/orb/ORB.java	Mon Feb 16 00:12:13 2015 +0000
@@ -176,42 +176,9 @@
         staticWrapper = ORBUtilSystemException.get(
             CORBALogDomains.RPC_PRESENTATION ) ;
 
-        boolean useDynamicStub =
-            ((Boolean)AccessController.doPrivileged(
-                new PrivilegedAction() {
-                    public java.lang.Object run() {
-                        return Boolean.valueOf( Boolean.getBoolean (
-                            ORBConstants.USE_DYNAMIC_STUB_PROPERTY ) ) ;
-                    }
-                }
-            )).booleanValue() ;
-
-        PresentationManager.StubFactoryFactory dynamicStubFactoryFactory =
-            (PresentationManager.StubFactoryFactory)AccessController.doPrivileged(
-                new PrivilegedAction() {
-                    public java.lang.Object run() {
-                        PresentationManager.StubFactoryFactory sff =
-                            PresentationDefaults.getProxyStubFactoryFactory() ;
+        boolean useDynamicStub = false;
 
-                        String className = System.getProperty(
-                            ORBConstants.DYNAMIC_STUB_FACTORY_FACTORY_CLASS,
-                            "com.sun.corba.se.impl.presentation.rmi.bcel.StubFactoryFactoryBCELImpl" ) ;
-
-                        try {
-                            // First try the configured class name, if any
-                            Class<?> cls =
-                                sun.corba.SharedSecrets.getJavaCorbaAccess().loadClass(className);
-                            sff = (PresentationManager.StubFactoryFactory)cls.newInstance();
-                        } catch (Exception exc) {
-                            // Use the default. Log the error as a warning.
-                            staticWrapper.errorInSettingDynamicStubFactoryFactory(
-                                exc, className ) ;
-                        }
-
-                        return sff ;
-                    }
-                }
-            ) ;
+        PresentationManager.StubFactoryFactory dynamicStubFactoryFactory = null;
 
         PresentationManager pm = new PresentationManagerImpl( useDynamicStub ) ;
         pm.setStubFactoryFactory( false,
--- a/corba/src/java.corba/share/classes/sun/corba/SharedSecrets.java	Wed Jul 05 20:19:45 2017 +0200
+++ b/corba/src/java.corba/share/classes/sun/corba/SharedSecrets.java	Mon Feb 16 00:12:13 2015 +0000
@@ -28,7 +28,9 @@
 import com.sun.corba.se.impl.io.ValueUtility;
 import sun.misc.Unsafe;
 
+import java.lang.reflect.Field;
 import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 /** A repository of "shared secrets", which are a mechanism for
     calling implementation-private methods in another package without
@@ -41,9 +43,23 @@
 
 // SharedSecrets cloned in corba repo to avoid build issues
 public class SharedSecrets {
-    private static final Unsafe unsafe = Unsafe.getUnsafe();
+    private static final Unsafe unsafe = getUnsafe();
     private static JavaCorbaAccess javaCorbaAccess;
 
+     private static Unsafe getUnsafe() {
+          PrivilegedAction<Unsafe> pa = () -> {
+               Class<?> unsafeClass = sun.misc.Unsafe.class ;
+               try {
+                    Field f = unsafeClass.getDeclaredField("theUnsafe");
+                    f.setAccessible(true);
+                    return (Unsafe) f.get(null);
+               } catch (Exception e) {
+                    throw new Error(e);
+               }
+          };
+          return AccessController.doPrivileged(pa);
+     }
+
     public static JavaCorbaAccess getJavaCorbaAccess() {
         if (javaCorbaAccess == null) {
             // Ensure ValueUtility is initialized; we know that that class