diff options
-rw-r--r-- | openjdk/FORKED | 1 | ||||
-rw-r--r-- | openjdk/allsources.lst | 4 | ||||
-rw-r--r-- | openjdk/sun/management/FileSystemImpl.java | 40 | ||||
-rw-r--r-- | openjdk/sun/management/GcInfoBuilder.java | 214 | ||||
-rw-r--r-- | runtime/openjdk/sun.management.cs | 110 |
5 files changed, 108 insertions, 261 deletions
diff --git a/openjdk/FORKED b/openjdk/FORKED index 32b336ad..52606582 100644 --- a/openjdk/FORKED +++ b/openjdk/FORKED @@ -64,7 +64,6 @@ jdk/src/share/classes/sun/awt/image/ToolkitImage.java=sun/awt/image/ToolkitImage jdk/src/share/classes/sun/awt/SunToolkit.java=sun/awt/SunToolkit.java jdk/src/share/classes/sun/font/FontManager.java=sun/font/FontManager.java jdk/src/share/classes/sun/font/StrikeCache.java=sun/font/StrikeCache.java -jdk/src/share/classes/sun/management/GcInfoBuilder.java=sun/management/GcInfoBuilder.java jdk/src/share/classes/sun/management/ManagementFactoryHelper.java=sun/management/ManagementFactoryHelper.java jdk/src/share/classes/sun/management/VMManagementImpl.java=sun/management/VMManagementImpl.java jdk/src/share/classes/sun/misc/SharedSecrets.java=sun/misc/SharedSecrets.java diff --git a/openjdk/allsources.lst b/openjdk/allsources.lst index f19cc2ec..4911d54d 100644 --- a/openjdk/allsources.lst +++ b/openjdk/allsources.lst @@ -188,8 +188,6 @@ sun/jdbc/odbc/JdbcOdbcResultSetMetaData.java sun/jdbc/odbc/JdbcOdbcStatement.java sun/jdbc/odbc/JdbcOdbcUpdateableResultSet.java sun/jdbc/odbc/JdbcOdbcUtils.java -sun/management/FileSystemImpl.java -sun/management/GcInfoBuilder.java sun/management/ManagementFactoryHelper.java sun/management/VMManagementImpl.java sun/misc/FileURLMapper.java @@ -13173,6 +13171,7 @@ sun/security/jgss/wrapper/SunNativeProvider.java @OPENJDK@/jdk/src/share/classes/sun/management/counter/Variability.java @OPENJDK@/jdk/src/share/classes/sun/management/FileSystem.java @OPENJDK@/jdk/src/share/classes/sun/management/GarbageCollectionNotifInfoCompositeData.java +@OPENJDK@/jdk/src/share/classes/sun/management/GcInfoBuilder.java @OPENJDK@/jdk/src/share/classes/sun/management/GcInfoCompositeData.java @OPENJDK@/jdk/src/share/classes/sun/management/HotspotClassLoading.java @OPENJDK@/jdk/src/share/classes/sun/management/HotspotClassLoadingMBean.java @@ -14887,6 +14886,7 @@ sun/security/jgss/wrapper/SunNativeProvider.java @OPENJDK@/jdk/src/windows/classes/java/util/prefs/WindowsPreferences.java @OPENJDK@/jdk/src/windows/classes/java/util/prefs/WindowsPreferencesFactory.java @OPENJDK@/jdk/src/windows/classes/sun/awt/Win32ColorModel24.java +@OPENJDK@/jdk/src/windows/classes/sun/management/FileSystemImpl.java @OPENJDK@/jdk/src/windows/classes/sun/management/OperatingSystemImpl.java @OPENJDK@/jdk/src/windows/classes/sun/net/NetHooks.java @OPENJDK@/jdk/src/windows/classes/sun/net/PortConfig.java diff --git a/openjdk/sun/management/FileSystemImpl.java b/openjdk/sun/management/FileSystemImpl.java deleted file mode 100644 index 51ed8d77..00000000 --- a/openjdk/sun/management/FileSystemImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 2011 Jeroen Frijters - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jeroen Frijters - jeroen@frijters.net - -*/ -package sun.management; - -import ikvm.internal.NotYetImplementedError; -import java.io.File; - -public class FileSystemImpl extends FileSystem -{ - public boolean supportsFileSecurity(File f) - { - throw new NotYetImplementedError(); - } - - public boolean isAccessUserOnly(File f) - { - throw new NotYetImplementedError(); - } -} diff --git a/openjdk/sun/management/GcInfoBuilder.java b/openjdk/sun/management/GcInfoBuilder.java deleted file mode 100644 index abe5082f..00000000 --- a/openjdk/sun/management/GcInfoBuilder.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (c) 2003, 2008, 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 sun.management; - -import ikvm.internal.NotYetImplementedError; - -import java.lang.management.GarbageCollectorMXBean; -import java.lang.management.MemoryUsage; -import javax.management.openmbean.OpenType; -import javax.management.openmbean.SimpleType; -import javax.management.openmbean.TabularType; -import javax.management.openmbean.TabularData; -import javax.management.openmbean.TabularDataSupport; -import javax.management.openmbean.CompositeType; -import javax.management.openmbean.CompositeData; -import javax.management.openmbean.CompositeDataSupport; -import javax.management.openmbean.OpenDataException; -import com.sun.management.GcInfo; - -/** - * Helper class to build composite data. - */ -public class GcInfoBuilder { - private final GarbageCollectorMXBean gc; - private final String[] poolNames; - private String[] allItemNames; - - // GC-specific composite type: - // Each GarbageCollectorMXBean may have different GC-specific attributes - // the CompositeType for the GcInfo could be different. - private CompositeType gcInfoCompositeType; - - // GC-specific items - private final int gcExtItemCount; - private final String[] gcExtItemNames; - private final String[] gcExtItemDescs; - private final char[] gcExtItemTypes; - - GcInfoBuilder(GarbageCollectorMXBean gc, String[] poolNames) { - this.gc = gc; - this.poolNames = poolNames; - this.gcExtItemCount = getNumGcExtAttributes(gc); - this.gcExtItemNames = new String[gcExtItemCount]; - this.gcExtItemDescs = new String[gcExtItemCount]; - this.gcExtItemTypes = new char[gcExtItemCount]; - - // Fill the information about extension attributes - fillGcAttributeInfo(gc, gcExtItemCount, gcExtItemNames, - gcExtItemTypes, gcExtItemDescs); - - // lazily build the CompositeType for the GcInfo - // including the GC-specific extension attributes - this.gcInfoCompositeType = null; - } - - GcInfo getLastGcInfo() { - MemoryUsage[] usageBeforeGC = new MemoryUsage[poolNames.length]; - MemoryUsage[] usageAfterGC = new MemoryUsage[poolNames.length]; - Object[] values = new Object[gcExtItemCount]; - - return getLastGcInfo0(gc, gcExtItemCount, values, gcExtItemTypes, - usageBeforeGC, usageAfterGC); - } - - public String[] getPoolNames() { - return poolNames; - } - - int getGcExtItemCount() { - return gcExtItemCount; - } - - // Returns the CompositeType for the GcInfo including - // the extension attributes - synchronized CompositeType getGcInfoCompositeType() { - if (gcInfoCompositeType != null) - return gcInfoCompositeType; - - // First, fill with the attributes in the GcInfo - String[] gcInfoItemNames = GcInfoCompositeData.getBaseGcInfoItemNames(); - OpenType[] gcInfoItemTypes = GcInfoCompositeData.getBaseGcInfoItemTypes(); - int numGcInfoItems = gcInfoItemNames.length; - - int itemCount = numGcInfoItems + gcExtItemCount; - allItemNames = new String[itemCount]; - String[] allItemDescs = new String[itemCount]; - OpenType[] allItemTypes = new OpenType[itemCount]; - - System.arraycopy(gcInfoItemNames, 0, allItemNames, 0, numGcInfoItems); - System.arraycopy(gcInfoItemNames, 0, allItemDescs, 0, numGcInfoItems); - System.arraycopy(gcInfoItemTypes, 0, allItemTypes, 0, numGcInfoItems); - - // Then fill with the extension GC-specific attributes, if any. - if (gcExtItemCount > 0) { - fillGcAttributeInfo(gc, gcExtItemCount, gcExtItemNames, - gcExtItemTypes, gcExtItemDescs); - System.arraycopy(gcExtItemNames, 0, allItemNames, - numGcInfoItems, gcExtItemCount); - System.arraycopy(gcExtItemDescs, 0, allItemDescs, - numGcInfoItems, gcExtItemCount); - for (int i = numGcInfoItems, j = 0; j < gcExtItemCount; i++, j++) { - switch (gcExtItemTypes[j]) { - case 'Z': - allItemTypes[i] = SimpleType.BOOLEAN; - break; - case 'B': - allItemTypes[i] = SimpleType.BYTE; - break; - case 'C': - allItemTypes[i] = SimpleType.CHARACTER; - break; - case 'S': - allItemTypes[i] = SimpleType.SHORT; - break; - case 'I': - allItemTypes[i] = SimpleType.INTEGER; - break; - case 'J': - allItemTypes[i] = SimpleType.LONG; - break; - case 'F': - allItemTypes[i] = SimpleType.FLOAT; - break; - case 'D': - allItemTypes[i] = SimpleType.DOUBLE; - break; - default: - throw new AssertionError( - "Unsupported type [" + gcExtItemTypes[i] + "]"); - } - } - } - - CompositeType gict = null; - try { - final String typeName = - "sun.management." + gc.getName() + ".GcInfoCompositeType"; - - gict = new CompositeType(typeName, - "CompositeType for GC info for " + - gc.getName(), - allItemNames, - allItemDescs, - allItemTypes); - } catch (OpenDataException e) { - // shouldn't reach here - throw Util.newException(e); - } - gcInfoCompositeType = gict; - - return gcInfoCompositeType; - } - - synchronized String[] getItemNames() { - if (allItemNames == null) { - // initialize when forming the composite type - getGcInfoCompositeType(); - } - return allItemNames; - } - - // Retrieve information about extension attributes - private /*native*/ int getNumGcExtAttributes(GarbageCollectorMXBean gc){ - throw new NotYetImplementedError(); - } - - private /*native*/ void fillGcAttributeInfo(GarbageCollectorMXBean gc, - int numAttributes, - String[] attributeNames, - char[] types, - String[] descriptions){ - throw new NotYetImplementedError(); - } - - /** - * Returns the last GcInfo - * - * @param gc GarbageCollectorMXBean that the gc info is associated with. - * @param numExtAtts number of extension attributes - * @param extAttValues Values of extension attributes to be filled. - * @param before Memory usage before GC to be filled. - * @param after Memory usage after GC to be filled. - */ - private /*native*/ GcInfo getLastGcInfo0(GarbageCollectorMXBean gc, - int numExtAtts, - Object[] extAttValues, - char[] extAttTypes, - MemoryUsage[] before, - MemoryUsage[] after){ - throw new NotYetImplementedError(); - } -} diff --git a/runtime/openjdk/sun.management.cs b/runtime/openjdk/sun.management.cs index b8bfbc88..de71a26b 100644 --- a/runtime/openjdk/sun.management.cs +++ b/runtime/openjdk/sun.management.cs @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Jeroen Frijters + Copyright (C) 2011-2014 Jeroen Frijters This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -21,6 +21,7 @@ jeroen@frijters.net */ +using System; #if !FIRST_PASS using java.lang.management; #endif @@ -32,6 +33,41 @@ static class Java_sun_management_ClassLoadingImpl } } +static class Java_sun_management_FileSystemImpl +{ + public static void init0() + { + } + + public static bool isSecuritySupported0(string path) + { + throw new NotSupportedException(); + } + + public static bool isAccessUserOnly0(string path) + { + throw new NotSupportedException(); + } +} + +static class Java_sun_management_GcInfoBuilder +{ + public static int getNumGcExtAttributes(object _this, object gc) + { + throw new NotSupportedException(); + } + + public static void fillGcAttributeInfo(object _this, object gc, int numAttributes, string[] attributeNames, char[] types, string[] descriptions) + { + throw new NotSupportedException(); + } + + public static object getLastGcInfo0(object _this, object gc, int numExtAtts, object[] extAttValues, char[] extAttTypes, object[] before, object[] after) + { + throw new NotSupportedException(); + } +} + static class Java_sun_management_MemoryImpl { public static object getMemoryPools0() @@ -67,11 +103,58 @@ static class Java_sun_management_MemoryImpl } } +static class Java_sun_management_OperatingSystemImpl +{ + public static long getCommittedVirtualMemorySize0(object _this) + { + throw new System.NotImplementedException(); + } + + public static long getTotalSwapSpaceSize(object _this) + { + throw new System.NotImplementedException(); + } + + public static long getFreeSwapSpaceSize(object _this) + { + throw new System.NotImplementedException(); + } + + public static long getProcessCpuTime(object _this) + { + throw new System.NotImplementedException(); + } + + public static long getFreePhysicalMemorySize(object _this) + { + throw new System.NotImplementedException(); + } + + public static long getTotalPhysicalMemorySize(object _this) + { + throw new System.NotImplementedException(); + } + + public static double getSystemCpuLoad(object _this) + { + throw new System.NotImplementedException(); + } + + public static double getProcessCpuLoad(object _this) + { + throw new System.NotImplementedException(); + } + + public static void initialize() + { + } +} + static class Java_sun_management_ThreadImpl { public static object getThreads() { - return IKVM.NativeCode.java.lang.Thread.getThreads(); + return Java_java_lang_Thread.getThreads(); } private const int JVMTI_THREAD_STATE_ALIVE = 0x0001; @@ -161,9 +244,28 @@ static class Java_sun_management_ThreadImpl #endif } + private static int GetCurrentThreadId() + { +#pragma warning disable 618 + // On the CLR and Mono on Windows this is the (obsolete) equivalent of kernel32!GetCurrentThreadId + return System.AppDomain.GetCurrentThreadId(); +#pragma warning restore 618 + } + public static long getThreadTotalCpuTime0(long id) { - throw new System.NotImplementedException(); + if (id == 0) { + int currentId = GetCurrentThreadId(); + System.Diagnostics.ProcessThreadCollection threads = System.Diagnostics.Process.GetCurrentProcess().Threads; + foreach (System.Diagnostics.ProcessThread t in threads) { + if (t.Id == currentId) { + return (long)(t.TotalProcessorTime.Ticks * 100); + } + } + return 0; + } else { + throw new System.NotImplementedException("Only current Thread is supported."); + } } public static void getThreadTotalCpuTime1(long[] ids, long[] result) @@ -188,7 +290,7 @@ static class Java_sun_management_ThreadImpl public static void setThreadCpuTimeEnabled0(bool enable) { - throw new System.NotImplementedException(); + //ignoring, we need nothing to enable } public static void setThreadAllocatedMemoryEnabled0(bool enable) |