8140606: Update library code to use internal Unsafe
Reviewed-by: alanb, mchung, psandoz, weijun
--- a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/corba/RequestImpl.java Wed Jul 05 20:59:28 2017 +0200
+++ b/corba/src/java.corba/share/classes/com/sun/corba/se/impl/corba/RequestImpl.java Wed Nov 11 11:31:21 2015 +0000
@@ -65,7 +65,6 @@
import com.sun.corba.se.spi.logging.CORBALogDomains;
import com.sun.corba.se.impl.logging.ORBUtilSystemException;
import com.sun.corba.se.impl.corba.AsynchInvoke;
-import com.sun.corba.se.impl.transport.ManagedLocalsThread;
public class RequestImpl
extends Request
@@ -256,7 +255,7 @@
public synchronized void send_deferred()
{
AsynchInvoke invokeObject = new AsynchInvoke(_orb, this, false);
- new ManagedLocalsThread(invokeObject).start();
+ new sun.misc.ManagedLocalsThread(invokeObject).start();
}
public synchronized boolean poll_response()
--- a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/javax/rmi/CORBA/Util.java Wed Jul 05 20:59:28 2017 +0200
+++ b/corba/src/java.corba/share/classes/com/sun/corba/se/impl/javax/rmi/CORBA/Util.java Wed Nov 11 11:31:21 2015 +0000
@@ -112,7 +112,6 @@
import com.sun.corba.se.impl.logging.UtilSystemException;
import com.sun.corba.se.spi.logging.CORBALogDomains;
import sun.corba.SharedSecrets;
-import com.sun.corba.se.impl.transport.ManagedLocalsThread;
/**
@@ -752,7 +751,7 @@
}
}
-class KeepAlive extends ManagedLocalsThread
+class KeepAlive extends sun.misc.ManagedLocalsThread
{
boolean quit = false;
--- a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/oa/poa/POAImpl.java Wed Jul 05 20:59:28 2017 +0200
+++ b/corba/src/java.corba/share/classes/com/sun/corba/se/impl/oa/poa/POAImpl.java Wed Nov 11 11:31:21 2015 +0000
@@ -103,7 +103,6 @@
import com.sun.corba.se.impl.orbutil.concurrent.SyncUtil ;
import com.sun.corba.se.impl.orbutil.concurrent.ReentrantMutex ;
import com.sun.corba.se.impl.orbutil.concurrent.CondVar ;
-import com.sun.corba.se.impl.transport.ManagedLocalsThread;
/**
* POAImpl is the implementation of the Portable Object Adapter. It
@@ -517,7 +516,7 @@
// Converted from anonymous class to local class
// so that we can call performDestroy() directly.
- static class DestroyThread extends ManagedLocalsThread {
+ static class DestroyThread extends sun.misc.ManagedLocalsThread {
private boolean wait ;
private boolean etherealize ;
private boolean debug ;
--- a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/oa/poa/POAManagerImpl.java Wed Jul 05 20:59:28 2017 +0200
+++ b/corba/src/java.corba/share/classes/com/sun/corba/se/impl/oa/poa/POAManagerImpl.java Wed Nov 11 11:31:21 2015 +0000
@@ -48,7 +48,6 @@
import com.sun.corba.se.impl.logging.POASystemException ;
import com.sun.corba.se.impl.orbutil.ORBUtility ;
-import com.sun.corba.se.impl.transport.ManagedLocalsThread;
/** POAManagerImpl is the implementation of the POAManager interface.
* Its public methods are activate(), hold_requests(), discard_requests()
@@ -358,7 +357,7 @@
if (wait_for_completion)
deactivator.run() ;
else {
- Thread thr = new ManagedLocalsThread(deactivator) ;
+ Thread thr = new sun.misc.ManagedLocalsThread(deactivator) ;
thr.start() ;
}
} finally {
--- a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/oa/poa/POAPolicyMediatorImpl_R_USM.java Wed Jul 05 20:59:28 2017 +0200
+++ b/corba/src/java.corba/share/classes/com/sun/corba/se/impl/oa/poa/POAPolicyMediatorImpl_R_USM.java Wed Nov 11 11:31:21 2015 +0000
@@ -49,7 +49,6 @@
import com.sun.corba.se.spi.oa.OAInvocationInfo ;
import com.sun.corba.se.spi.oa.NullServant ;
-import com.sun.corba.se.impl.transport.ManagedLocalsThread;
/** Implementation of POARequesHandler that provides policy specific
* operations on the POA.
@@ -303,7 +302,7 @@
throw new WrongPolicy();
}
- class Etherealizer extends ManagedLocalsThread {
+ class Etherealizer extends sun.misc.ManagedLocalsThread {
private POAPolicyMediatorImpl_R_USM mediator ;
private ActiveObjectMap.Key key ;
private AOMEntry entry ;
--- a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java Wed Jul 05 20:59:28 2017 +0200
+++ b/corba/src/java.corba/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java Wed Nov 11 11:31:21 2015 +0000
@@ -165,7 +165,6 @@
import com.sun.corba.se.impl.logging.ORBUtilSystemException;
import com.sun.corba.se.impl.copyobject.CopierManagerImpl;
import com.sun.corba.se.impl.presentation.rmi.PresentationManagerImpl;
-import com.sun.corba.se.impl.transport.ManagedLocalsThread;
/**
* The JavaIDL ORB implementation.
@@ -692,7 +691,7 @@
for (int i = 0; i < req.length; i++) {
AsynchInvoke invokeObject = new AsynchInvoke( this,
(com.sun.corba.se.impl.corba.RequestImpl)req[i], true);
- new ManagedLocalsThread(invokeObject).start();
+ new sun.misc.ManagedLocalsThread(invokeObject).start();
}
}
--- a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/orbutil/threadpool/ThreadPoolImpl.java Wed Jul 05 20:59:28 2017 +0200
+++ b/corba/src/java.corba/share/classes/com/sun/corba/se/impl/orbutil/threadpool/ThreadPoolImpl.java Wed Nov 11 11:31:21 2015 +0000
@@ -54,7 +54,6 @@
import com.sun.corba.se.impl.logging.ORBUtilSystemException;
import com.sun.corba.se.impl.orbutil.ORBConstants;
import com.sun.corba.se.spi.logging.CORBALogDomains;
-import com.sun.corba.se.impl.transport.ManagedLocalsThread;
public class ThreadPoolImpl implements ThreadPool
{
@@ -460,7 +459,7 @@
}
- private class WorkerThread extends ManagedLocalsThread implements Closeable
+ private class WorkerThread extends sun.misc.ManagedLocalsThread implements Closeable
{
private Work currentWork;
private int threadId = 0; // unique id for the thread
--- a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/transport/ManagedLocalsThread.java Wed Jul 05 20:59:28 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.corba.se.impl.transport;
-
-import sun.misc.Unsafe;
-import java.lang.reflect.Field;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/**
- * A thread that has it's thread locals, and inheritable thread
- * locals erased on construction.
- */
-public class ManagedLocalsThread extends Thread {
- private static final Unsafe UNSAFE;
- private static final long THREAD_LOCALS;
- private static final long INHERITABLE_THREAD_LOCALS;
-
- public ManagedLocalsThread () {
- super();
- }
-
- public ManagedLocalsThread(String name) {
- super(name);
- eraseThreadLocals();
- }
- public ManagedLocalsThread(Runnable target) {
- super(target);
- eraseThreadLocals();
- }
-
- public ManagedLocalsThread(Runnable target, String name) {
- super(target, name);
- eraseThreadLocals();
- }
-
- public ManagedLocalsThread(ThreadGroup group, Runnable target, String name) {
- super(group, target, name);
- eraseThreadLocals();
- }
-
- public ManagedLocalsThread(ThreadGroup group, String name) {
- super(group, name);
- eraseThreadLocals();
- }
-
- /**
- * Drops all thread locals (and inherited thread locals).
- */
- public final void eraseThreadLocals() {
- UNSAFE.putObject(this, THREAD_LOCALS, null);
- UNSAFE.putObject(this, INHERITABLE_THREAD_LOCALS, null);
- }
-
- 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);
- }
-
- private static long getThreadFieldOffset(String fieldName) {
- PrivilegedAction<Long> pa = () -> {
- Class<?> t = Thread.class;
- long fieldOffset;
- try {
- fieldOffset = UNSAFE.objectFieldOffset(t
- .getDeclaredField("inheritableThreadLocals"));
- } catch (Exception e) {
- throw new Error(e);
- }
- return fieldOffset;
- };
- return AccessController.doPrivileged(pa);
- }
-
- static {
- UNSAFE = getUnsafe();
- try {
- THREAD_LOCALS = getThreadFieldOffset("threadLocals");
- INHERITABLE_THREAD_LOCALS = getThreadFieldOffset("inheritableThreadLocals");
- } catch (Exception e) {
- throw new Error(e);
- }
- }
-}
--- a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java Wed Jul 05 20:59:28 2017 +0200
+++ b/corba/src/java.corba/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java Wed Nov 11 11:31:21 2015 +0000
@@ -57,7 +57,7 @@
*/
class SelectorImpl
extends
- ManagedLocalsThread
+ sun.misc.ManagedLocalsThread
implements
com.sun.corba.se.pept.transport.Selector
{
--- a/corba/src/java.corba/share/classes/sun/corba/Bridge.java Wed Jul 05 20:59:28 2017 +0200
+++ b/corba/src/java.corba/share/classes/sun/corba/Bridge.java Wed Nov 11 11:31:21 2015 +0000
@@ -36,7 +36,7 @@
import java.security.Permission;
import java.security.PrivilegedAction;
-import sun.misc.Unsafe ;
+import jdk.internal.misc.Unsafe ;
import sun.reflect.ReflectionFactory ;
/** This class provides the methods for fundamental JVM operations
@@ -120,7 +120,7 @@
Field fld = null ;
try {
- Class unsafeClass = sun.misc.Unsafe.class ;
+ Class unsafeClass = jdk.internal.misc.Unsafe.class ;
fld = unsafeClass.getDeclaredField( "theUnsafe" ) ;
fld.setAccessible( true ) ;
return fld ;
--- a/corba/src/java.corba/share/classes/sun/corba/SharedSecrets.java Wed Jul 05 20:59:28 2017 +0200
+++ b/corba/src/java.corba/share/classes/sun/corba/SharedSecrets.java Wed Nov 11 11:31:21 2015 +0000
@@ -26,7 +26,7 @@
package sun.corba;
import com.sun.corba.se.impl.io.ValueUtility;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
import java.lang.reflect.Field;
import java.security.AccessController;
@@ -48,7 +48,7 @@
private static Unsafe getUnsafe() {
PrivilegedAction<Unsafe> pa = () -> {
- Class<?> unsafeClass = sun.misc.Unsafe.class ;
+ Class<?> unsafeClass = jdk.internal.misc.Unsafe.class ;
try {
Field f = unsafeClass.getDeclaredField("theUnsafe");
f.setAccessible(true);