[Ikvm-commit] ikvm/runtime/openjdk sun.management.cs,1.8,1.9
Brought to you by:
jfrijters
|
From: Small S. <sma...@us...> - 2014-12-17 12:10:03
|
Update of /cvsroot/ikvm/ikvm/runtime/openjdk In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv4745/runtime/openjdk Modified Files: sun.management.cs Log Message: implements OperatingSystemMXBean.getFreePhysicalMemorySize and OperatingSystemMXBean.getTotalPhysicalMemorySize Index: sun.management.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/openjdk/sun.management.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** sun.management.cs 10 Jun 2014 12:31:41 -0000 1.8 --- sun.management.cs 17 Dec 2014 12:10:00 -0000 1.9 *************** *** 23,26 **** --- 23,27 ---- */ using System; + using System.Reflection; #if !FIRST_PASS using java.lang.management; *************** *** 106,109 **** --- 107,133 ---- static class Java_sun_management_OperatingSystemImpl { + private static long getComputerInfo(string property){ + #pragma warning disable 618 + Assembly asm = Assembly.LoadWithPartialName("Microsoft.VisualBasic"); + #pragma warning restore 618 + if (asm != null) + { + Type type = asm.GetType("Microsoft.VisualBasic.Devices.ComputerInfo"); + if (type != null) + { + try + { + ulong result = (ulong)type.GetProperty(property).GetValue(Activator.CreateInstance(type), null); + return (long)result; + } + catch (TargetInvocationException) + { + // Mono does not implement this property + } + } + } + throw new System.NotImplementedException(); + } + public static long getCommittedVirtualMemorySize0(object _this) { *************** *** 128,137 **** public static long getFreePhysicalMemorySize(object _this) { ! throw new System.NotImplementedException(); } public static long getTotalPhysicalMemorySize(object _this) { ! throw new System.NotImplementedException(); } --- 152,161 ---- public static long getFreePhysicalMemorySize(object _this) { ! return getComputerInfo("AvailablePhysicalMemory"); } public static long getTotalPhysicalMemorySize(object _this) { ! return getComputerInfo("TotalPhysicalMemory"); } |