提交 ad3f29c1 编写于 作者: M mchung

8025985: com.sun.management.OSMBeanFactory should not be public

Reviewed-by: alanb, erikj, ihse, jbachorik
上级 2e48c0b7
......@@ -275,19 +275,12 @@ BUILD_LIBRARIES += $(BUILD_LIBINSTRUMENT)
##########################################################################################
BUILD_LIBMANAGEMENT_SRC := $(JDK_TOPDIR)/src/share/native/sun/management \
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/management \
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/com/sun/management
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/management
BUILD_LIBMANAGEMENT_EXCLUDES :=
BUILD_LIBMANAGEMENT_CFLAGS := -I$(JDK_TOPDIR)/src/share/native/sun/management
ifneq ($(OPENJDK_TARGET_OS), windows)
BUILD_LIBMANAGEMENT_EXCLUDES += OperatingSystem_md.c
else
BUILD_LIBMANAGEMENT_EXCLUDES += UnixOperatingSystem_md.c
endif
ifneq ($(OPENJDK_TARGET_OS), solaris)
BUILD_LIBMANAGEMENT_EXCLUDES += SolarisOperatingSystem.c
endif
......
......@@ -27,17 +27,17 @@
SUNWprivate_1.1 {
global:
Java_com_sun_management_UnixOperatingSystem_getCommittedVirtualMemorySize;
Java_com_sun_management_UnixOperatingSystem_getFreePhysicalMemorySize;
Java_com_sun_management_UnixOperatingSystem_getFreeSwapSpaceSize;
Java_com_sun_management_UnixOperatingSystem_getMaxFileDescriptorCount;
Java_com_sun_management_UnixOperatingSystem_getOpenFileDescriptorCount;
Java_com_sun_management_UnixOperatingSystem_getProcessCpuLoad;
Java_com_sun_management_UnixOperatingSystem_getProcessCpuTime;
Java_com_sun_management_UnixOperatingSystem_getSystemCpuLoad;
Java_com_sun_management_UnixOperatingSystem_getTotalPhysicalMemorySize;
Java_com_sun_management_UnixOperatingSystem_getTotalSwapSpaceSize;
Java_com_sun_management_UnixOperatingSystem_initialize;
Java_sun_management_OperatingSystemImpl_getCommittedVirtualMemorySize;
Java_sun_management_OperatingSystemImpl_getFreePhysicalMemorySize;
Java_sun_management_OperatingSystemImpl_getFreeSwapSpaceSize;
Java_sun_management_OperatingSystemImpl_getMaxFileDescriptorCount;
Java_sun_management_OperatingSystemImpl_getOpenFileDescriptorCount;
Java_sun_management_OperatingSystemImpl_getProcessCpuLoad;
Java_sun_management_OperatingSystemImpl_getProcessCpuTime;
Java_sun_management_OperatingSystemImpl_getSystemCpuLoad;
Java_sun_management_OperatingSystemImpl_getTotalPhysicalMemorySize;
Java_sun_management_OperatingSystemImpl_getTotalSwapSpaceSize;
Java_sun_management_OperatingSystemImpl_initialize;
Java_sun_management_ClassLoadingImpl_setVerboseClass;
Java_sun_management_DiagnosticCommandImpl_executeDiagnosticCommand;
Java_sun_management_DiagnosticCommandImpl_getDiagnosticCommands;
......
......@@ -37,14 +37,14 @@ import sun.misc.Unsafe;
* ManagementFactory.getOperatingSystemMXBean() returns an instance
* of this class.
*/
public class OperatingSystemImpl implements OperatingSystemMXBean {
public class BaseOperatingSystemImpl implements OperatingSystemMXBean {
private final VMManagement jvm;
/**
* Constructor of OperatingSystemImpl class.
* Constructor of BaseOperatingSystemImpl class.
*/
protected OperatingSystemImpl(VMManagement vm) {
protected BaseOperatingSystemImpl(VMManagement vm) {
this.jvm = vm;
}
......
......@@ -46,7 +46,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import com.sun.management.DiagnosticCommandMBean;
import com.sun.management.OSMBeanFactory;
import com.sun.management.HotSpotDiagnosticMXBean;
import static java.lang.management.ManagementFactory.*;
......@@ -104,8 +103,7 @@ public class ManagementFactoryHelper {
public static synchronized OperatingSystemMXBean getOperatingSystemMXBean() {
if (osMBean == null) {
osMBean = (OperatingSystemImpl)
OSMBeanFactory.getOperatingSystemMXBean(jvm);
osMBean = new OperatingSystemImpl(jvm);
}
return osMBean;
}
......
/*
* Copyright (c) 2003, 2004, 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.management;
import java.lang.management.OperatingSystemMXBean;
import sun.management.VMManagement;
/**
* Operating system dependent MBean factory.
* <p>
* <b>WARNING:</b> While this class is public, it should not be treated as
* public API and its API may change in incompatable ways between dot dot
* releases and even patch releases. You should not rely on this class.
*/
@jdk.Exported(false)
public class OSMBeanFactory {
/* static factory class */
private OSMBeanFactory() {};
private static UnixOperatingSystem osMBean = null;
public static synchronized OperatingSystemMXBean
getOperatingSystemMXBean(VMManagement jvm) {
if (osMBean == null) {
osMBean = new UnixOperatingSystem(jvm);
}
return (OperatingSystemMXBean) osMBean;
}
}
......@@ -23,9 +23,7 @@
* questions.
*/
package com.sun.management;
import sun.management.VMManagement;
package sun.management;
/**
* Implementation class for the operating system.
......@@ -34,11 +32,10 @@ import sun.management.VMManagement;
* ManagementFactory.getOperatingSystemMXBean() returns an instance
* of this class.
*/
class UnixOperatingSystem
extends sun.management.OperatingSystemImpl
implements UnixOperatingSystemMXBean {
class OperatingSystemImpl extends BaseOperatingSystemImpl
implements com.sun.management.UnixOperatingSystemMXBean {
UnixOperatingSystem(VMManagement vm) {
OperatingSystemImpl(VMManagement vm) {
super(vm);
}
......
......@@ -35,7 +35,7 @@
#include <stdlib.h>
#include <dlfcn.h>
#include <pthread.h>
#include "com_sun_management_UnixOperatingSystem.h"
#include "sun_management_OperatingSystemImpl.h"
struct ticks {
uint64_t used;
......@@ -310,7 +310,7 @@ double get_process_load() {
}
JNIEXPORT jdouble JNICALL
Java_com_sun_management_UnixOperatingSystem_getSystemCpuLoad
Java_sun_management_OperatingSystemImpl_getSystemCpuLoad
(JNIEnv *env, jobject dummy)
{
if(perfInit() == 0) {
......@@ -321,7 +321,7 @@ Java_com_sun_management_UnixOperatingSystem_getSystemCpuLoad
}
JNIEXPORT jdouble JNICALL
Java_com_sun_management_UnixOperatingSystem_getProcessCpuLoad
Java_sun_management_OperatingSystemImpl_getProcessCpuLoad
(JNIEnv *env, jobject dummy)
{
if(perfInit() == 0) {
......
......@@ -23,7 +23,7 @@
* questions.
*/
#include "com_sun_management_UnixOperatingSystem.h"
#include "sun_management_OperatingSystemImpl.h"
#include <sys/time.h>
#include <mach/mach.h>
......@@ -31,7 +31,7 @@
JNIEXPORT jdouble JNICALL
Java_com_sun_management_UnixOperatingSystem_getSystemCpuLoad
Java_sun_management_OperatingSystemImpl_getSystemCpuLoad
(JNIEnv *env, jobject dummy)
{
// This code is influenced by the darwin top source
......@@ -83,7 +83,7 @@ Java_com_sun_management_UnixOperatingSystem_getSystemCpuLoad
JNIEXPORT jdouble JNICALL
Java_com_sun_management_UnixOperatingSystem_getProcessCpuLoad
Java_sun_management_OperatingSystemImpl_getProcessCpuLoad
(JNIEnv *env, jobject dummy)
{
// This code is influenced by the darwin top source
......
......@@ -28,7 +28,7 @@
#include "jlong.h"
#include "jvm.h"
#include "management.h"
#include "com_sun_management_UnixOperatingSystem.h"
#include "sun_management_OperatingSystemImpl.h"
#include <sys/types.h>
#include <sys/stat.h>
......@@ -175,14 +175,14 @@ static jlong get_total_or_available_swap_space_size(JNIEnv* env, jboolean availa
}
JNIEXPORT void JNICALL
Java_com_sun_management_UnixOperatingSystem_initialize
Java_sun_management_OperatingSystemImpl_initialize
(JNIEnv *env, jclass cls)
{
page_size = sysconf(_SC_PAGESIZE);
}
JNIEXPORT jlong JNICALL
Java_com_sun_management_UnixOperatingSystem_getCommittedVirtualMemorySize
Java_sun_management_OperatingSystemImpl_getCommittedVirtualMemorySize
(JNIEnv *env, jobject mbean)
{
#ifdef __solaris__
......@@ -249,21 +249,21 @@ Java_com_sun_management_UnixOperatingSystem_getCommittedVirtualMemorySize
}
JNIEXPORT jlong JNICALL
Java_com_sun_management_UnixOperatingSystem_getTotalSwapSpaceSize
Java_sun_management_OperatingSystemImpl_getTotalSwapSpaceSize
(JNIEnv *env, jobject mbean)
{
return get_total_or_available_swap_space_size(env, JNI_FALSE);
}
JNIEXPORT jlong JNICALL
Java_com_sun_management_UnixOperatingSystem_getFreeSwapSpaceSize
Java_sun_management_OperatingSystemImpl_getFreeSwapSpaceSize
(JNIEnv *env, jobject mbean)
{
return get_total_or_available_swap_space_size(env, JNI_TRUE);
}
JNIEXPORT jlong JNICALL
Java_com_sun_management_UnixOperatingSystem_getProcessCpuTime
Java_sun_management_OperatingSystemImpl_getProcessCpuTime
(JNIEnv *env, jobject mbean)
{
#ifdef __APPLE__
......@@ -305,7 +305,7 @@ Java_com_sun_management_UnixOperatingSystem_getProcessCpuTime
}
JNIEXPORT jlong JNICALL
Java_com_sun_management_UnixOperatingSystem_getFreePhysicalMemorySize
Java_sun_management_OperatingSystemImpl_getFreePhysicalMemorySize
(JNIEnv *env, jobject mbean)
{
#ifdef __APPLE__
......@@ -333,7 +333,7 @@ Java_com_sun_management_UnixOperatingSystem_getFreePhysicalMemorySize
}
JNIEXPORT jlong JNICALL
Java_com_sun_management_UnixOperatingSystem_getTotalPhysicalMemorySize
Java_sun_management_OperatingSystemImpl_getTotalPhysicalMemorySize
(JNIEnv *env, jobject mbean)
{
#ifdef _ALLBSD_SOURCE
......@@ -358,7 +358,7 @@ Java_com_sun_management_UnixOperatingSystem_getTotalPhysicalMemorySize
JNIEXPORT jlong JNICALL
Java_com_sun_management_UnixOperatingSystem_getOpenFileDescriptorCount
Java_sun_management_OperatingSystemImpl_getOpenFileDescriptorCount
(JNIEnv *env, jobject mbean)
{
#ifdef __APPLE__
......@@ -438,7 +438,7 @@ Java_com_sun_management_UnixOperatingSystem_getOpenFileDescriptorCount
}
JNIEXPORT jlong JNICALL
Java_com_sun_management_UnixOperatingSystem_getMaxFileDescriptorCount
Java_sun_management_OperatingSystemImpl_getMaxFileDescriptorCount
(JNIEnv *env, jobject mbean)
{
struct rlimit rlp;
......
......@@ -38,7 +38,7 @@
#include <sys/loadavg.h>
#include <jni.h>
#include "jvm.h"
#include "com_sun_management_UnixOperatingSystem.h"
#include "sun_management_OperatingSystemImpl.h"
typedef struct {
kstat_t *kstat;
......@@ -226,14 +226,14 @@ double get_process_load(void) {
}
JNIEXPORT jdouble JNICALL
Java_com_sun_management_UnixOperatingSystem_getSystemCpuLoad
Java_sun_management_OperatingSystemImpl_getSystemCpuLoad
(JNIEnv *env, jobject dummy)
{
return get_cpu_load(-1);
}
JNIEXPORT jdouble JNICALL
Java_com_sun_management_UnixOperatingSystem_getProcessCpuLoad
Java_sun_management_OperatingSystemImpl_getProcessCpuLoad
(JNIEnv *env, jobject dummy)
{
return get_process_load();
......
/*
* Copyright (c) 2003, 2004, 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.management;
import java.lang.management.OperatingSystemMXBean;
import sun.management.VMManagement;
/**
* Operating system dependent MBean factory.
* <p>
* <b>WARNING:</b> While this class is public, it should not be treated as
* public API and its API may change in incompatable ways between dot dot
* releases and even patch releases. You should not rely on this class.
*/
public class OSMBeanFactory {
/* static factory class */
private OSMBeanFactory() {};
private static OperatingSystem osMBean = null;
public static synchronized OperatingSystemMXBean
getOperatingSystemMXBean(VMManagement jvm) {
if (osMBean == null) {
osMBean = new OperatingSystem(jvm);
}
return (OperatingSystemMXBean) osMBean;
}
}
......@@ -23,9 +23,9 @@
* questions.
*/
package com.sun.management;
package sun.management;
import sun.management.VMManagement;
import java.lang.management.OperatingSystemMXBean;
/**
* Implementation class for the operating system.
......@@ -34,15 +34,14 @@ import sun.management.VMManagement;
* ManagementFactory.getOperatingSystemMXBean() returns an instance
* of this class.
*/
class OperatingSystem
extends sun.management.OperatingSystemImpl
class OperatingSystemImpl extends BaseOperatingSystemImpl
implements OperatingSystemMXBean {
// psapiLock is a lock to make sure only one thread loading
// PSAPI DLL.
private static Object psapiLock = new Object();
OperatingSystem(VMManagement vm) {
OperatingSystemImpl(VMManagement vm) {
super(vm);
}
......
......@@ -28,7 +28,7 @@
#include "jlong.h"
#include "jvm.h"
#include "management.h"
#include "com_sun_management_OperatingSystem.h"
#include "sun_management_OperatingSystemImpl.h"
#include <psapi.h>
#include <errno.h>
......@@ -77,7 +77,7 @@ static HANDLE main_process;
int perfiInit(void);
JNIEXPORT void JNICALL
Java_com_sun_management_OperatingSystem_initialize
Java_sun_management_OperatingSystemImpl_initialize
(JNIEnv *env, jclass cls)
{
main_process = GetCurrentProcess();
......@@ -85,7 +85,7 @@ Java_com_sun_management_OperatingSystem_initialize
}
JNIEXPORT jlong JNICALL
Java_com_sun_management_OperatingSystem_getCommittedVirtualMemorySize0
Java_sun_management_OperatingSystemImpl_getCommittedVirtualMemorySize0
(JNIEnv *env, jobject mbean)
{
PROCESS_MEMORY_COUNTERS pmc;
......@@ -97,7 +97,7 @@ Java_com_sun_management_OperatingSystem_getCommittedVirtualMemorySize0
}
JNIEXPORT jlong JNICALL
Java_com_sun_management_OperatingSystem_getTotalSwapSpaceSize
Java_sun_management_OperatingSystemImpl_getTotalSwapSpaceSize
(JNIEnv *env, jobject mbean)
{
MEMORYSTATUSEX ms;
......@@ -107,7 +107,7 @@ Java_com_sun_management_OperatingSystem_getTotalSwapSpaceSize
}
JNIEXPORT jlong JNICALL
Java_com_sun_management_OperatingSystem_getFreeSwapSpaceSize
Java_sun_management_OperatingSystemImpl_getFreeSwapSpaceSize
(JNIEnv *env, jobject mbean)
{
MEMORYSTATUSEX ms;
......@@ -117,7 +117,7 @@ Java_com_sun_management_OperatingSystem_getFreeSwapSpaceSize
}
JNIEXPORT jlong JNICALL
Java_com_sun_management_OperatingSystem_getProcessCpuTime
Java_sun_management_OperatingSystemImpl_getProcessCpuTime
(JNIEnv *env, jobject mbean)
{
......@@ -136,7 +136,7 @@ Java_com_sun_management_OperatingSystem_getProcessCpuTime
}
JNIEXPORT jlong JNICALL
Java_com_sun_management_OperatingSystem_getFreePhysicalMemorySize
Java_sun_management_OperatingSystemImpl_getFreePhysicalMemorySize
(JNIEnv *env, jobject mbean)
{
MEMORYSTATUSEX ms;
......@@ -146,7 +146,7 @@ Java_com_sun_management_OperatingSystem_getFreePhysicalMemorySize
}
JNIEXPORT jlong JNICALL
Java_com_sun_management_OperatingSystem_getTotalPhysicalMemorySize
Java_sun_management_OperatingSystemImpl_getTotalPhysicalMemorySize
(JNIEnv *env, jobject mbean)
{
MEMORYSTATUSEX ms;
......@@ -927,14 +927,14 @@ perfInit(void) {
}
JNIEXPORT jdouble JNICALL
Java_com_sun_management_OperatingSystem_getSystemCpuLoad
Java_sun_management_OperatingSystemImpl_getSystemCpuLoad
(JNIEnv *env, jobject dummy)
{
return perfGetCPULoad(-1);
}
JNIEXPORT jdouble JNICALL
Java_com_sun_management_OperatingSystem_getProcessCpuLoad
Java_sun_management_OperatingSystemImpl_getProcessCpuLoad
(JNIEnv *env, jobject dummy)
{
return perfGetProcessLoad();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册