8145544: Move sun.misc.VM to jdk.internal.misc

Reviewed-by: alanb, mullan, weijun
This commit is contained in:
Chris Hegarty 2016-01-06 10:01:44 +00:00
parent 6739382299
commit aa0ef2e9f5
46 changed files with 86 additions and 77 deletions

View File

@ -274,12 +274,12 @@ SUNWprivate_1.1 {
Java_sun_reflect_Reflection_getClassAccessFlags;
Java_sun_misc_Version_getJdkVersionInfo;
Java_sun_misc_Version_getJvmVersionInfo;
Java_sun_misc_VM_latestUserDefinedLoader;
Java_sun_misc_VM_getuid;
Java_sun_misc_VM_geteuid;
Java_sun_misc_VM_getgid;
Java_sun_misc_VM_getegid;
Java_sun_misc_VM_initialize;
Java_jdk_internal_misc_VM_latestUserDefinedLoader;
Java_jdk_internal_misc_VM_getuid;
Java_jdk_internal_misc_VM_geteuid;
Java_jdk_internal_misc_VM_getgid;
Java_jdk_internal_misc_VM_getegid;
Java_jdk_internal_misc_VM_initialize;
Java_sun_misc_VMSupport_initAgentProperties;
Java_sun_misc_VMSupport_getVMTemporaryDirectory;

View File

@ -2135,7 +2135,7 @@ public class ObjectInputStream
* corresponding modifications to the above class.
*/
private static ClassLoader latestUserDefinedLoader() {
return sun.misc.VM.latestUserDefinedLoader();
return jdk.internal.misc.VM.latestUserDefinedLoader();
}
/**

View File

@ -56,6 +56,7 @@ import java.util.HashMap;
import java.util.Objects;
import java.util.StringJoiner;
import jdk.internal.misc.Unsafe;
import jdk.internal.misc.VM;
import jdk.internal.HotSpotIntrinsicCandidate;
import sun.reflect.CallerSensitive;
import sun.reflect.ConstantPool;
@ -360,9 +361,9 @@ public final class Class<T> implements java.io.Serializable,
// Reflective call to get caller class is only needed if a security manager
// is present. Avoid the overhead of making this call otherwise.
caller = Reflection.getCallerClass();
if (sun.misc.VM.isSystemDomainLoader(loader)) {
if (VM.isSystemDomainLoader(loader)) {
ClassLoader ccl = ClassLoader.getClassLoader(caller);
if (!sun.misc.VM.isSystemDomainLoader(ccl)) {
if (!VM.isSystemDomainLoader(ccl)) {
sm.checkPermission(
SecurityConstants.GET_CLASSLOADER_PERMISSION);
}

View File

@ -28,6 +28,7 @@ package java.lang;
import java.lang.annotation.Native;
import java.util.Objects;
import jdk.internal.HotSpotIntrinsicCandidate;
import jdk.internal.misc.VM;
import static java.lang.String.COMPACT_STRINGS;
import static java.lang.String.LATIN1;
@ -1018,7 +1019,7 @@ public final class Integer extends Number implements Comparable<Integer> {
* may be controlled by the {@code -XX:AutoBoxCacheMax=<size>} option.
* During VM initialization, java.lang.Integer.IntegerCache.high property
* may be set and saved in the private system properties in the
* sun.misc.VM class.
* jdk.internal.misc.VM class.
*/
private static class IntegerCache {
@ -1030,7 +1031,7 @@ public final class Integer extends Number implements Comparable<Integer> {
// high value may be configured by property
int h = 127;
String integerCacheHighPropValue =
sun.misc.VM.getSavedProperty("java.lang.Integer.IntegerCache.high");
VM.getSavedProperty("java.lang.Integer.IntegerCache.high");
if (integerCacheHighPropValue != null) {
try {
int i = parseInt(integerCacheHighPropValue);

View File

@ -24,7 +24,7 @@
*/
package java.lang;
import sun.misc.VM;
import jdk.internal.misc.VM;
import java.io.PrintStream;
import java.lang.StackWalker.Option;

View File

@ -46,6 +46,7 @@ import sun.reflect.annotation.AnnotationType;
import jdk.internal.HotSpotIntrinsicCandidate;
import jdk.internal.misc.JavaLangAccess;;
import jdk.internal.misc.SharedSecrets;;
import jdk.internal.misc.VM;
import jdk.internal.logger.LoggerFinderLoader;
import jdk.internal.logger.LazyLoggers;
import jdk.internal.logger.LocalizedLoggerWrapper;
@ -1817,12 +1818,12 @@ public final class System {
// removed from the system properties.
//
// See java.lang.Integer.IntegerCache and the
// sun.misc.VM.saveAndRemoveProperties method for example.
// VM.saveAndRemoveProperties method for example.
//
// Save a private copy of the system properties object that
// can only be accessed by the internal implementation. Remove
// certain system properties that are not intended for public access.
sun.misc.VM.saveAndRemoveProperties(props);
VM.saveAndRemoveProperties(props);
lineSeparator = props.getProperty("line.separator");
@ -1846,7 +1847,7 @@ public final class System {
// set for the class libraries. Currently this is no-op everywhere except
// for Windows where the process-wide error mode is set before the java.io
// classes are used.
sun.misc.VM.initializeOSEnvironment();
VM.initializeOSEnvironment();
// The main thread is not added to its thread group in the same
// way as other threads; we must do it ourselves here.
@ -1857,10 +1858,10 @@ public final class System {
setJavaLangAccess();
// Subsystems that are invoked during initialization can invoke
// sun.misc.VM.isBooted() in order to avoid doing things that should
// VM.isBooted() in order to avoid doing things that should
// wait until the application class loader has been set up.
// IMPORTANT: Ensure that this remains the last initialization action!
sun.misc.VM.booted();
VM.booted();
}
private static void setJavaLangAccess() {

View File

@ -1869,7 +1869,7 @@ class Thread implements Runnable {
*/
public State getState() {
// get current thread state
return sun.misc.VM.toThreadState(threadStatus);
return jdk.internal.misc.VM.toThreadState(threadStatus);
}
// Added in JSR-166

View File

@ -27,7 +27,7 @@ package java.lang;
import java.io.PrintStream;
import java.util.Arrays;
import sun.misc.VM;
import jdk.internal.misc.VM;
/**
* A thread group represents a set of threads. In addition, a thread

View File

@ -24,7 +24,7 @@
*/
package java.lang;
import sun.misc.VM;
import jdk.internal.misc.VM;
import java.io.*;
import java.util.*;

View File

@ -1836,7 +1836,7 @@ return mh1;
return false;
}
ClassLoader loader = defc.getClassLoader();
if (!sun.misc.VM.isSystemDomainLoader(loader)) {
if (!jdk.internal.misc.VM.isSystemDomainLoader(loader)) {
ClassLoader sysl = ClassLoader.getSystemClassLoader();
boolean found = false;
while (sysl != null) {

View File

@ -29,7 +29,7 @@ import java.security.PrivilegedAction;
import java.security.AccessController;
import jdk.internal.misc.JavaLangAccess;
import jdk.internal.misc.SharedSecrets;
import sun.misc.VM;
import jdk.internal.misc.VM;
final class Finalizer extends FinalReference<Object> { /* Package-private; must be in
same package as the Reference

View File

@ -26,6 +26,7 @@
package java.lang.ref;
import java.util.function.Consumer;
import jdk.internal.misc.VM;
/**
* Reference queues, to which registered reference objects are appended by the
@ -73,7 +74,7 @@ public class ReferenceQueue<T> {
// Volatiles ensure ordering.
r.queue = ENQUEUED;
if (r instanceof FinalReference) {
sun.misc.VM.addFinalRefCount(1);
VM.addFinalRefCount(1);
}
lock.notifyAll();
return true;
@ -93,7 +94,7 @@ public class ReferenceQueue<T> {
r.next = r;
queueLength--;
if (r instanceof FinalReference) {
sun.misc.VM.addFinalRefCount(-1);
VM.addFinalRefCount(-1);
}
return r;
}

View File

@ -34,7 +34,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.BiFunction;
import sun.misc.VM;
import jdk.internal.misc.VM;
import sun.reflect.CallerSensitive;
import sun.reflect.Reflection;
import sun.reflect.misc.ReflectUtil;

View File

@ -1242,7 +1242,7 @@ public final class URL implements java.io.Serializable {
private static ThreadLocal<Object> gate = new ThreadLocal<>();
private static URLStreamHandler lookupViaProviders(final String protocol) {
if (!sun.misc.VM.isBooted())
if (!jdk.internal.misc.VM.isBooted())
return null;
if (gate.get() != null)

View File

@ -31,7 +31,7 @@ import jdk.internal.misc.JavaNioAccess;
import jdk.internal.misc.JavaLangRefAccess;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.Unsafe;
import sun.misc.VM;
import jdk.internal.misc.VM;
/**
* Access to bits, native and otherwise.

View File

@ -30,7 +30,7 @@ package java.nio;
import java.io.FileDescriptor;
import sun.misc.Cleaner;
import jdk.internal.misc.Unsafe;
import sun.misc.VM;
import jdk.internal.misc.VM;
import sun.nio.ch.DirectBuffer;

View File

@ -43,6 +43,7 @@ import java.util.ServiceLoader;
import java.util.ServiceConfigurationError;
import java.util.SortedMap;
import java.util.TreeMap;
import jdk.internal.misc.VM;
import sun.misc.ASCIICaseInsensitiveComparator;
import sun.nio.cs.StandardCharsets;
import sun.nio.cs.ThreadLocalCoders;
@ -281,7 +282,7 @@ public abstract class Charset
static boolean atBugLevel(String bl) { // package-private
String level = bugLevel;
if (level == null) {
if (!sun.misc.VM.isBooted())
if (!VM.isBooted())
return false;
bugLevel = level = AccessController.doPrivileged(
new GetPropertyAction("sun.nio.cs.bugLevel", ""));
@ -394,7 +395,7 @@ public abstract class Charset
// that loader to be prematurely initialized with incomplete
// information.
//
if (!sun.misc.VM.isBooted())
if (!VM.isBooted())
return null;
if (gate.get() != null)
@ -445,7 +446,7 @@ public abstract class Charset
}
private static Charset lookupExtendedCharset(String charsetName) {
if (!sun.misc.VM.isBooted()) // see lookupViaProviders()
if (!VM.isBooted()) // see lookupViaProviders()
return null;
CharsetProvider[] ecps = ExtendedProviderHolder.extendedProviders;
for (CharsetProvider cp : ecps) {

View File

@ -69,7 +69,7 @@ import static java.time.LocalTime.NANOS_PER_MILLI;
import java.io.Serializable;
import java.util.Objects;
import java.util.TimeZone;
import sun.misc.VM;
import jdk.internal.misc.VM;
/**
* A clock providing access to the current instant, date and time using a time-zone.

View File

@ -48,7 +48,7 @@ import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import sun.misc.InnocuousThread;
import sun.misc.VM;
import jdk.internal.misc.VM;
import sun.util.logging.PlatformLogger;
import jdk.internal.logger.LazyLoggers.LazyLoggerAccessor;

View File

@ -32,7 +32,7 @@ import java.lang.System.LoggerFinder;
import java.lang.System.Logger;
import java.lang.ref.WeakReference;
import java.util.Objects;
import sun.misc.VM;
import jdk.internal.misc.VM;
import sun.util.logging.PlatformLogger;
/**

View File

@ -30,7 +30,7 @@ import java.security.ProtectionDomain;
import sun.reflect.CallerSensitive;
import sun.reflect.Reflection;
import sun.misc.VM;
import jdk.internal.misc.VM;
import jdk.internal.HotSpotIntrinsicCandidate;

View File

@ -23,7 +23,7 @@
* questions.
*/
package sun.misc;
package jdk.internal.misc;
import static java.lang.Thread.State.*;
import java.util.Properties;

View File

@ -23,7 +23,7 @@
* questions.
*/
package sun.misc;
package jdk.internal.misc;
/** @deprecated */
@Deprecated

View File

@ -66,6 +66,7 @@ import java.util.TreeSet;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import jdk.internal.misc.VM;
public enum LauncherHelper {
INSTANCE;
@ -86,9 +87,9 @@ public enum LauncherHelper {
private static final String PROP_SETTINGS = "Property settings:";
private static final String LOCALE_SETTINGS = "Locale settings:";
// sync with java.c and sun.misc.VM
// sync with java.c and jdk.internal.misc.VM
private static final String diagprop = "sun.java.launcher.diag";
static final boolean trace = sun.misc.VM.getSavedProperty(diagprop) != null;
static final boolean trace = VM.getSavedProperty(diagprop) != null;
private static final String defaultBundleName =
"sun.launcher.resources.launcher";

View File

@ -32,6 +32,7 @@ import sun.reflect.CallerSensitive;
import sun.reflect.Reflection;
import jdk.internal.HotSpotIntrinsicCandidate;
import jdk.internal.misc.VM;
/**

View File

@ -389,7 +389,7 @@ public class Util {
static boolean atBugLevel(String bl) { // package-private
if (bugLevel == null) {
if (!sun.misc.VM.isBooted())
if (!jdk.internal.misc.VM.isBooted())
return false;
String value = AccessController.doPrivileged(
new GetPropertyAction("sun.nio.ch.bugLevel"));

View File

@ -156,12 +156,12 @@ public class StandardCharsets extends CharsetProvider {
private boolean initialized = false;
/* provider the sun.nio.cs.map property fir sjis/ms932 mapping hack
/* provider the sun.nio.cs.map property fir sjis/ms932 mapping hack
*/
private void init() {
if (initialized)
return;
if (!sun.misc.VM.isBooted())
if (!jdk.internal.misc.VM.isBooted())
return;
initialized = true;

View File

@ -29,6 +29,7 @@ import java.lang.reflect.*;
import java.util.HashMap;
import java.util.Map;
import jdk.internal.HotSpotIntrinsicCandidate;
import jdk.internal.misc.VM;
/** Common utility routines used by both java.lang and
java.lang.reflect */
@ -335,7 +336,7 @@ public class Reflection {
*/
public static boolean isCallerSensitive(Method m) {
final ClassLoader loader = m.getDeclaringClass().getClassLoader();
if (sun.misc.VM.isSystemDomainLoader(loader) || isExtClassLoader(loader)) {
if (VM.isSystemDomainLoader(loader) || isExtClassLoader(loader)) {
return m.isAnnotationPresent(CallerSensitive.class);
}
return false;

View File

@ -28,7 +28,7 @@
#include "jvm.h"
#include "jdk_util.h"
#include "sun_misc_VM.h"
#include "jdk_internal_misc_VM.h"
/* Only register the performance-critical methods */
static JNINativeMethod methods[] = {
@ -36,12 +36,12 @@ static JNINativeMethod methods[] = {
};
JNIEXPORT jobject JNICALL
Java_sun_misc_VM_latestUserDefinedLoader(JNIEnv *env, jclass cls) {
Java_jdk_internal_misc_VM_latestUserDefinedLoader(JNIEnv *env, jclass cls) {
return JVM_LatestUserDefinedLoader(env);
}
JNIEXPORT void JNICALL
Java_sun_misc_VM_initialize(JNIEnv *env, jclass cls) {
Java_jdk_internal_misc_VM_initialize(JNIEnv *env, jclass cls) {
if (!JDK_InitJvmHandle()) {
JNU_ThrowInternalError(env, "Handle for JVM not found for symbol lookup");
return;
@ -50,8 +50,8 @@ Java_sun_misc_VM_initialize(JNIEnv *env, jclass cls) {
// Registers implementations of native methods described in methods[]
// above.
// In particular, registers JVM_GetNanoTimeAdjustment as the implementation
// of the native sun.misc.VM.getNanoTimeAdjustment - avoiding the cost of
// introducing a Java_sun_misc_VM_getNanoTimeAdjustment wrapper
// of the native VM.getNanoTimeAdjustment - avoiding the cost of
// introducing a Java_jdk_internal_misc_VM_getNanoTimeAdjustment wrapper
(*env)->RegisterNatives(env, cls,
methods, sizeof(methods)/sizeof(methods[0]));
}

View File

@ -23,12 +23,12 @@
* questions.
*/
package sun.misc;
package jdk.internal.misc;
public class OSEnvironment {
/*
* Initialize any miscellenous operating system settings that need to be set
* Initialize any miscellaneous operating system settings that need to be set
* for the class libraries.
*/
public static void initialize() {

View File

@ -28,25 +28,25 @@
JNIEXPORT jlong JNICALL
Java_sun_misc_VM_getuid(JNIEnv *env, jclass thisclass) {
Java_jdk_internal_misc_VM_getuid(JNIEnv *env, jclass thisclass) {
return getuid();
}
JNIEXPORT jlong JNICALL
Java_sun_misc_VM_geteuid(JNIEnv *env, jclass thisclass) {
Java_jdk_internal_misc_VM_geteuid(JNIEnv *env, jclass thisclass) {
return geteuid();
}
JNIEXPORT jlong JNICALL
Java_sun_misc_VM_getgid(JNIEnv *env, jclass thisclass) {
Java_jdk_internal_misc_VM_getgid(JNIEnv *env, jclass thisclass) {
return getgid();
}
JNIEXPORT jlong JNICALL
Java_sun_misc_VM_getegid(JNIEnv *env, jclass thisclass) {
Java_jdk_internal_misc_VM_getegid(JNIEnv *env, jclass thisclass) {
return getegid();
}

View File

@ -23,14 +23,14 @@
* questions.
*/
package sun.misc;
package jdk.internal.misc;
import sun.io.Win32ErrorMode;
public class OSEnvironment {
/*
* Initialize any miscellenous operating system settings that need to be set
* Initialize any miscellaneous operating system settings that need to be set
* for the class libraries.
* <p>
* At this time only the process-wide error mode needs to be set.

View File

@ -66,7 +66,7 @@ public class Win32ErrorMode {
* has completed.
*/
public static void initialize() {
if (!sun.misc.VM.isBooted()) {
if (!jdk.internal.misc.VM.isBooted()) {
String s = System.getProperty("sun.io.allowCriticalErrorMessageBox");
if (s == null || s.equals(Boolean.FALSE.toString())) {
long mode = setErrorMode(0);

View File

@ -27,28 +27,28 @@
JNIEXPORT jlong JNICALL
Java_sun_misc_VM_getuid(JNIEnv *env, jclass thisclass) {
Java_jdk_internal_misc_VM_getuid(JNIEnv *env, jclass thisclass) {
/* -1 means function not available. */
return -1;
}
JNIEXPORT jlong JNICALL
Java_sun_misc_VM_geteuid(JNIEnv *env, jclass thisclass) {
Java_jdk_internal_misc_VM_geteuid(JNIEnv *env, jclass thisclass) {
/* -1 means function not available. */
return -1;
}
JNIEXPORT jlong JNICALL
Java_sun_misc_VM_getgid(JNIEnv *env, jclass thisclass) {
Java_jdk_internal_misc_VM_getgid(JNIEnv *env, jclass thisclass) {
/* -1 means function not available. */
return -1;
}
JNIEXPORT jlong JNICALL
Java_sun_misc_VM_getegid(JNIEnv *env, jclass thisclass) {
Java_jdk_internal_misc_VM_getegid(JNIEnv *env, jclass thisclass) {
/* -1 means function not available. */
return -1;

View File

@ -639,7 +639,7 @@ public class FileHandler extends StreamHandler {
continue;
} else if (ch2 == 'h') {
file = new File(System.getProperty("user.home"));
if (sun.misc.VM.isSetUID()) {
if (jdk.internal.misc.VM.isSetUID()) {
// Ok, we are in a set UID program. For safety's sake
// we disallow attempts to open files relative to %h.
throw new IOException("can't use %h in set UID program");

View File

@ -583,7 +583,7 @@ public class ManagementFactory {
ClassLoader loader =
AccessController.doPrivileged(
(PrivilegedAction<ClassLoader>) () -> cls.getClassLoader());
if (!sun.misc.VM.isSystemDomainLoader(loader)) {
if (!jdk.internal.misc.VM.isSystemDomainLoader(loader)) {
throw new IllegalArgumentException(mxbeanName +
" is not a platform MXBean");
}

View File

@ -473,7 +473,7 @@ public class ManagementFactoryHelper {
public static Thread.State toThreadState(int state) {
// suspended and native bits may be set in state
int threadStatus = state & ~JMM_THREAD_STATE_FLAG_MASK;
return sun.misc.VM.toThreadState(threadStatus);
return jdk.internal.misc.VM.toThreadState(threadStatus);
}
// These values are defined in jmm.h

View File

@ -59,7 +59,7 @@ class MemoryImpl extends NotificationEmitterSupport
}
public int getObjectPendingFinalizationCount() {
return sun.misc.VM.getFinalRefCount();
return jdk.internal.misc.VM.getFinalRefCount();
}
public void gc() {

View File

@ -262,7 +262,7 @@ public class MarshalInputStream extends ObjectInputStream {
* if only code from the null class loader is on the stack.
*/
private static ClassLoader latestUserDefinedLoader() {
return sun.misc.VM.latestUserDefinedLoader();
return jdk.internal.misc.VM.latestUserDefinedLoader();
}
/**

View File

@ -397,7 +397,7 @@ public class FileCredentialsCache extends CredentialsCache
*/
if (osname != null && !osname.startsWith("Windows")) {
long uid = sun.misc.VM.getuid();
long uid = jdk.internal.misc.VM.getuid();
if (uid != -1) {
name = File.separator + "tmp" +
File.separator + stdCacheNameComponent + "_" + uid;

View File

@ -60,7 +60,7 @@ import sun.security.krb5.internal.ReplayCache;
*
* service_euid
*
* in which euid is available as sun.misc.VM.geteuid().
* in which euid is available as jdk.internal.misc.VM.geteuid().
*
* The file has a header:
*
@ -107,7 +107,7 @@ public class DflCache extends ReplayCache {
private static long uid;
static {
// Available on Solaris, Linux and Mac. Otherwise, -1 and no _euid suffix
uid = sun.misc.VM.geteuid();
uid = jdk.internal.misc.VM.geteuid();
}
public DflCache (String source) {

View File

@ -97,7 +97,7 @@ public class ExtendedCharsets extends AbstractCharsetProvider {
protected void init() {
if (initialized)
return;
if (!sun.misc.VM.isBooted())
if (!jdk.internal.misc.VM.isBooted())
return;
String map = getProperty("sun.nio.cs.map");

View File

@ -24,7 +24,7 @@
/*
* @test
* @bug 4530538
* @modules java.base/sun.misc
* @modules java.base/jdk.internal.misc
* java.management
* @summary Basic unit test of
* RuntimeMXBean.getObjectPendingFinalizationCount()
@ -50,10 +50,10 @@ public class Pending {
private static void printFinalizerInstanceCount() {
if (!trace) return;
int count = sun.misc.VM.getFinalRefCount();
int count = jdk.internal.misc.VM.getFinalRefCount();
System.out.println(INDENT + "Finalizable object Count = " + count);
count = sun.misc.VM.getPeakFinalRefCount();
count = jdk.internal.misc.VM.getPeakFinalRefCount();
System.out.println(INDENT + "Peak Finalizable object Count = " + count);
}

View File

@ -21,13 +21,13 @@
* questions.
*/
import java.util.Objects;
import sun.misc.VM;
import jdk.internal.misc.VM;
/**
* @test
* @bug 8068730
* @summary tests that VM.getgetNanoTimeAdjustment() works as expected.
* @modules java.base/sun.misc
* @modules java.base/jdk.internal.misc
* @run main GetNanoTimeAdjustment
* @author danielfuchs
*/

View File

@ -78,7 +78,7 @@ public class ReplayCacheTestProc {
mode = -1;
}
uid = sun.misc.VM.geteuid();
uid = jdk.internal.misc.VM.geteuid();
KDC kdc = KDC.create(OneKDC.REALM, HOST, 0, true);
for (int i=0; i<nu; i++) {

View File

@ -1,4 +1,5 @@
modules java.base/sun.misc \
modules java.base/jdk.internal.misc \
java.base/sun.misc \
java.base/sun.net.spi.nameservice \
java.base/sun.security.util \
java.security.jgss/sun.security.jgss \