changeset 1683:b3563151fe42 jdk8u171-b09

8198494: 8u171 and 8u172 - Build failure on non-SE Linux Platforms Reviewed-by: dfuchs, rriggs, coffeys, aefimov
author rpatil
date Tue, 27 Feb 2018 19:59:46 -0800
parents f674dc8cc85f
children 6a9efc037460
files src/share/classes/com/sun/corba/se/impl/ior/StubIORImpl.java src/share/classes/sun/corba/SharedSecrets.java
diffstat 2 files changed, 28 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/corba/se/impl/ior/StubIORImpl.java	Tue Feb 27 11:27:04 2018 -0800
+++ b/src/share/classes/com/sun/corba/se/impl/ior/StubIORImpl.java	Tue Feb 27 19:59:46 2018 -0800
@@ -31,9 +31,9 @@
 
 package com.sun.corba.se.impl.ior;
 
-import java.io.ObjectInputStream ;
-import java.io.ObjectOutputStream ;
-import java.io.IOException ;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import sun.corba.SharedSecrets;
 
 import org.omg.CORBA.ORB ;
 
@@ -46,7 +46,6 @@
 // other vendor's ORBs.
 import com.sun.corba.se.spi.presentation.rmi.StubAdapter ;
 import com.sun.corba.se.impl.orbutil.HexOutputStream ;
-import sun.corba.SharedSecrets;
 
 /**
  * This class implements a very simply IOR representation
--- a/src/share/classes/sun/corba/SharedSecrets.java	Tue Feb 27 11:27:04 2018 -0800
+++ b/src/share/classes/sun/corba/SharedSecrets.java	Tue Feb 27 19:59:46 2018 -0800
@@ -29,8 +29,7 @@
 import sun.misc.JavaOISAccess;
 import sun.misc.Unsafe;
 
-import java.io.ObjectInputStream;
-import java.security.AccessController;
+import java.lang.reflect.Method;
 
 /** A repository of "shared secrets", which are a mechanism for
     calling implementation-private methods in another package without
@@ -45,8 +44,32 @@
 public class SharedSecrets {
     private static final Unsafe unsafe = Unsafe.getUnsafe();
     private static JavaCorbaAccess javaCorbaAccess;
+    private static final Method getJavaOISAccessMethod;
     private static JavaOISAccess javaOISAccess;
 
+    // Initialize getJavaOISAccessMethod using reflection.
+    static {
+        try {
+            Class sharedSecret = Class.forName("sun.misc.SharedSecrets");
+            getJavaOISAccessMethod =
+                    sharedSecret.getMethod("getJavaOISAccess");
+        } catch (Exception e) {
+            throw new ExceptionInInitializerError(e);
+        }
+    }
+
+    public static JavaOISAccess getJavaOISAccess() {
+        if (javaOISAccess == null) {
+            try {
+                javaOISAccess =
+                        (JavaOISAccess) getJavaOISAccessMethod.invoke(null);
+            } catch (Exception e) {
+                throw new ExceptionInInitializerError(e);
+            }
+        }
+        return javaOISAccess;
+    }
+
     public static JavaCorbaAccess getJavaCorbaAccess() {
         if (javaCorbaAccess == null) {
             // Ensure ValueUtility is initialized; we know that that class
@@ -59,16 +82,4 @@
     public static void setJavaCorbaAccess(JavaCorbaAccess access) {
         javaCorbaAccess = access;
     }
-
-    public static void setJavaOISAccess(JavaOISAccess access) {
-        javaOISAccess = access;
-    }
-
-    public static JavaOISAccess getJavaOISAccess() {
-        if (javaOISAccess == null)
-            unsafe.ensureClassInitialized(ObjectInputStream.class);
-
-        return javaOISAccess;
-    }
-
 }