summaryrefslogtreecommitdiff
path: root/java/lang/management/MemoryUsage.java
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-07-09 20:02:03 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-07-09 20:02:03 +0000
commitb6381bad10b1fd600d1dfdc39e0919d1828e7db8 (patch)
tree5ae2686316c34e86a85711a05529329f352d3f89 /java/lang/management/MemoryUsage.java
parente7fa9f9d3d390aca116a12179d9ae3f1bc4a3771 (diff)
downloadclasspath-b6381bad10b1fd600d1dfdc39e0919d1828e7db8.tar.gz
2006-07-09 Andrew John Hughes <gnu_andrew@member.fsf.org>
* java/lang/management/MemoryUsage.java: (from(javax.management.openmbean.CompositeData)): Implemented. * java/lang/management/ThreadInfo.java: Changed to use open types throughout for the state. (ThreadInfo(long,String,String,long,long,String, long,String,long,long,boolean,StackTraceElement[])): New constructor. (checkAttribute(javax.management.openmbean.CompositeType, String, javax.management.openmbean.OpenType)): New method. (from(javax.management.openmbean.CompositeData)): Implemented. (getLockName()): Fixed to use new variable. (getLockOwnerId()): Likewise. (getLockOwnerName()): Likewise. (getThreadId()): Likewise. (getThreadName()): Likewise. (getThreadState()): Likewise. (toString()): Refactored to use new variables. * javax/management/openmbean/ArrayType.java: New file. * javax/management/openmbean/CompositeType.java: Variables should be transient, not volatile. * javax/management/openmbean/OpenDataException.java: (serialVersionUID): Added. * javax/management/openmbean/SimpleType.java: New file. * javax/management/openmbean/TabularType.java Variables should be transient, not volatile.
Diffstat (limited to 'java/lang/management/MemoryUsage.java')
-rw-r--r--java/lang/management/MemoryUsage.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/java/lang/management/MemoryUsage.java b/java/lang/management/MemoryUsage.java
index 29aa1f9f1..3c2a4cba6 100644
--- a/java/lang/management/MemoryUsage.java
+++ b/java/lang/management/MemoryUsage.java
@@ -37,6 +37,9 @@ exception statement from your version. */
package java.lang.management;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.SimpleType;
/**
* <p>
* Retains information on the usage of a particular memory
@@ -146,6 +149,48 @@ public class MemoryUsage
}
/**
+ * <p>
+ * Returns a {@link MemoryUsage} instance using the values
+ * given in the supplied
+ * {@link javax.management.openmbean.CompositeData} object.
+ * The composite data instance should contain the following
+ * attributes:
+ * </p>
+ * <ul>
+ * <li>init</li>
+ * <li>used</li>
+ * <li>committed</li>
+ * <li>max</li>
+ * </ul>
+ * <p>
+ * All should have the type, <code>java.lang.Long</code>.
+ * </p>
+ *
+ * @param data the composite data structure to take values from.
+ * @return a new instance containing the values from the
+ * composite data structure, or <code>null</code>
+ * if the data structure was also <code>null</code>.
+ * @throws IllegalArgumentException if the composite data structure
+ * does not match the structure
+ * outlined above, or the values
+ * are invalid.
+ */
+ public static MemoryUsage from(CompositeData data)
+ {
+ if (data == null)
+ return null;
+ CompositeType type = data.getCompositeType();
+ ThreadInfo.checkAttribute(type, "init", SimpleType.LONG);
+ ThreadInfo.checkAttribute(type, "used", SimpleType.LONG);
+ ThreadInfo.checkAttribute(type, "committed", SimpleType.LONG);
+ ThreadInfo.checkAttribute(type, "max", SimpleType.LONG);
+ return new MemoryUsage(((Long) data.get("init")).longValue(),
+ ((Long) data.get("used")).longValue(),
+ ((Long) data.get("committed")).longValue(),
+ ((Long) data.get("max")).longValue());
+ }
+
+ /**
* Returns the amount of memory committed for use by this
* memory pool (in bytes). This amount is guaranteed to
* be available, unlike the maximum.