changeset 949:e5f8d3bb9704

Merge
author mchung
date Thu, 08 Sep 2016 18:25:01 -0700
parents d9b3cf2dd4d2 bccaaccfc58a
children cbdc0699e357
files
diffstat 3 files changed, 11 insertions(+), 115 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.corba/share/classes/module-info.java	Thu Sep 08 17:40:49 2016 -0700
+++ b/src/java.corba/share/classes/module-info.java	Thu Sep 08 18:25:01 2016 -0700
@@ -28,8 +28,8 @@
  */
 @Deprecated(since="9", forRemoval=true)
 module java.corba {
-    requires public java.desktop;
-    requires public java.rmi;
+    requires transitive java.desktop;
+    requires transitive java.rmi;
     requires java.logging;
     requires java.naming;
     requires java.transaction;
@@ -70,8 +70,8 @@
     exports com.sun.corba.se.impl.util to jdk.rmic;
 
     // JNDI CosNaming provider
-    exports dynamic com.sun.jndi.cosnaming to java.naming;
-    exports dynamic com.sun.jndi.url.corbaname to java.naming;
-    exports dynamic com.sun.jndi.url.iiop to java.naming;
-    exports dynamic com.sun.jndi.url.iiopname to java.naming;
+    exports com.sun.jndi.cosnaming to java.naming;
+    exports com.sun.jndi.url.corbaname to java.naming;
+    exports com.sun.jndi.url.iiop to java.naming;
+    exports com.sun.jndi.url.iiopname to java.naming;
 }
--- a/src/java.corba/share/classes/sun/corba/Bridge.java	Thu Sep 08 17:40:49 2016 -0700
+++ b/src/java.corba/share/classes/sun/corba/Bridge.java	Thu Sep 08 18:25:01 2016 -0700
@@ -26,7 +26,6 @@
 package sun.corba ;
 
 import java.lang.reflect.Field ;
-import java.lang.reflect.Method ;
 import java.lang.reflect.Constructor ;
 import java.lang.reflect.InvocationTargetException ;
 
@@ -76,81 +75,11 @@
         new BridgePermission( "getBridge" ) ;
     private static Bridge bridge = null ;
 
-    // latestUserDefinedLoader() is a private static method
-    // in ObjectInputStream in JDK 1.3 through 1.5.
-    // We use reflection in a doPrivileged block to get a
-    // Method reference and make it accessible.
-    private final Method latestUserDefinedLoaderMethod ;
     private final Unsafe unsafe ;
     private final ReflectionFactory reflectionFactory ;
 
-    private Method getLatestUserDefinedLoaderMethod()
-    {
-        return (Method) AccessController.doPrivileged(
-            new PrivilegedAction()
-            {
-                public Object run()
-                {
-                    Method result = null;
-
-                    try {
-                        Class io = ObjectInputStream.class;
-                        result = io.getDeclaredMethod(
-                            "latestUserDefinedLoader", NO_ARGS);
-                        result.setAccessible(true);
-                    } catch (NoSuchMethodException nsme) {
-                        Error err = new Error( "java.io.ObjectInputStream" +
-                            " latestUserDefinedLoader " + nsme );
-                        err.initCause(nsme) ;
-                        throw err ;
-                    }
-
-                    return result;
-                }
-            }
-        );
-    }
-
-    private Unsafe getUnsafe() {
-        Field fld = (Field)AccessController.doPrivileged(
-            new PrivilegedAction()
-            {
-                public Object run()
-                {
-                    Field fld = null ;
-
-                    try {
-                        Class unsafeClass = jdk.internal.misc.Unsafe.class ;
-                        fld = unsafeClass.getDeclaredField( "theUnsafe" ) ;
-                        fld.setAccessible( true ) ;
-                        return fld ;
-                    } catch (NoSuchFieldException exc) {
-                        Error err = new Error( "Could not access Unsafe" ) ;
-                        err.initCause( exc ) ;
-                        throw err ;
-                    }
-                }
-            }
-        ) ;
-
-        Unsafe unsafe = null;
-
-        try {
-            unsafe = (Unsafe)(fld.get( null )) ;
-        } catch (Throwable t) {
-            Error err = new Error( "Could not access Unsafe" ) ;
-            err.initCause( t ) ;
-            throw err ;
-        }
-
-        return unsafe ;
-    }
-
-
-    private Bridge()
-    {
-        latestUserDefinedLoaderMethod = getLatestUserDefinedLoaderMethod();
-        unsafe = getUnsafe() ;
+    private Bridge() {
+        unsafe = Unsafe.getUnsafe() ;
         reflectionFactory = (ReflectionFactory)AccessController.doPrivileged(
             new ReflectionFactory.GetReflectionFactoryAction());
     }
@@ -182,23 +111,8 @@
     /** Obtain the latest user defined ClassLoader from the call stack.
      * This is required by the RMI-IIOP specification.
      */
-    public final ClassLoader getLatestUserDefinedLoader()
-    {
-        try {
-            // Invoke the ObjectInputStream.latestUserDefinedLoader method
-            return (ClassLoader)latestUserDefinedLoaderMethod.invoke(null,
-                                                                     (Object[])NO_ARGS);
-        } catch (InvocationTargetException ite) {
-            Error err = new Error(
-                "sun.corba.Bridge.latestUserDefinedLoader: " + ite ) ;
-            err.initCause( ite ) ;
-            throw err ;
-        } catch (IllegalAccessException iae) {
-            Error err = new Error(
-                "sun.corba.Bridge.latestUserDefinedLoader: " + iae ) ;
-            err.initCause( iae ) ;
-            throw err ;
-        }
+    public final ClassLoader getLatestUserDefinedLoader() {
+        return jdk.internal.misc.VM.latestUserDefinedLoader();
     }
 
     /**
--- a/src/java.corba/share/classes/sun/corba/SharedSecrets.java	Thu Sep 08 17:40:49 2016 -0700
+++ b/src/java.corba/share/classes/sun/corba/SharedSecrets.java	Thu Sep 08 18:25:01 2016 -0700
@@ -28,10 +28,6 @@
 import com.sun.corba.se.impl.io.ValueUtility;
 import jdk.internal.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
     using reflection. A package-private class implements a public
@@ -43,23 +39,9 @@
 
 // SharedSecrets cloned in corba repo to avoid build issues
 public class SharedSecrets {
-    private static final Unsafe unsafe = getUnsafe();
+    private static final Unsafe unsafe = Unsafe.getUnsafe();
     private static JavaCorbaAccess javaCorbaAccess;
 
-     private static Unsafe getUnsafe() {
-          PrivilegedAction<Unsafe> pa = () -> {
-               Class<?> unsafeClass = jdk.internal.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