This patch adds three new 1.6 classes. Changelog:
2006-12-25 Andrew John Hughes <[EMAIL PROTECTED]>
* java/beans/ConstructorProperties.java:
New file.
* java/lang/management/LockInfo.java:
Likewise.
* java/lang/management/MonitorInfo.java:
Likewise.
--
Andrew :-)
Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html
public class gcj extends Freedom implements Java { ... }
Index: java/beans/ConstructorProperties.java
===================================================================
RCS file: java/beans/ConstructorProperties.java
diff -N java/beans/ConstructorProperties.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ java/beans/ConstructorProperties.java 25 Dec 2006 00:46:22 -0000
@@ -0,0 +1,72 @@
+/* ConstructorProperties.java - Associate constructor params with props
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.beans;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
+
+/**
+ * An annotation used to associate the parameters of a
+ * constructor with the accessor methods that later provide
+ * access to these values. For example, the parameters of
+ * the constructor <code>Person(String name, int age)</code>
+ * may be linked to the bean's two accessors, <code>getName()</code>
+ * and <code>getAge()</code> using
+ * <code>@ConstructorProperties({"name","age"})</code>.
+ *
+ * @author Andrew John Hughes ([EMAIL PROTECTED])
+ * @since 1.6
+ */
[EMAIL PROTECTED] @Retention(RUNTIME) @Target(CONSTRUCTOR)
+public @interface ConstructorProperties
+{
+
+ /**
+ * Contains the name of the accessor methods associated
+ * with each constructor parameter.
+ *
+ * @return the accessor method names corresponding to the
+ * constructor parameters.
+ */
+ String[] value();
+
+}
Index: java/lang/management/LockInfo.java
===================================================================
RCS file: java/lang/management/LockInfo.java
diff -N java/lang/management/LockInfo.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ java/lang/management/LockInfo.java 25 Dec 2006 00:46:22 -0000
@@ -0,0 +1,114 @@
+/* LockInfo.java - Information on a lock.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.management;
+
+import java.beans.ConstructorProperties;
+
+/**
+ * Provides information on a lock held by a thread.
+ * A lock can be either a built-in monitor, an
+ * <emph>ownable synchronizer</emph> (i.e. a subclass
+ * of [EMAIL PROTECTED]
java.util.concurrent.locks.AbstractOwnableSynchronizer}),
+ * or a [EMAIL PROTECTED] java.util.concurrent.locks.Condition}
+ * object.
+ *
+ * @author Andrew John Hughes ([EMAIL PROTECTED])
+ * @since 1.6
+ */
+public class LockInfo
+{
+
+ /**
+ * The class name of the lock object.
+ */
+ private String className;
+
+ /**
+ * The identity hash code of the lock object.
+ */
+ private int identityHashCode;
+
+ /**
+ * Constructs a new [EMAIL PROTECTED] LockInfo} object with the
+ * specified class name and identity hash code.
+ *
+ * @param className the name of the class of the lock object.
+ * @param identityHashCode the identity hash code of the
+ * lock object.
+ */
+ @ConstructorProperties({"className","identityHashCode"})
+ public LockInfo(String className, int identityHashCode)
+ {
+ this.className = className;
+ this.identityHashCode = identityHashCode;
+ }
+
+ /**
+ * Returns the class name of the lock object.
+ *
+ * @return the class name of the lock object.
+ */
+ public String getClassName()
+ {
+ return className;
+ }
+
+ /**
+ * Returns the identity hash code of the lock object.
+ *
+ * @return the identity hash code of the lock object.
+ */
+ public int getIdentityHashCode()
+ {
+ return identityHashCode;
+ }
+
+ /**
+ * Returns a textual representation of the lock,
+ * constructed by concatenating the class name,
+ * <code>'@'</code> and the identity hash code
+ * in unsigned hexadecimal form.
+ *
+ * @return a textual representation of the lock.
+ */
+ public String toString()
+ {
+ return className + '@' + Integer.toHexString(identityHashCode);
+ }
+
+}
Index: java/lang/management/MonitorInfo.java
===================================================================
RCS file: java/lang/management/MonitorInfo.java
diff -N java/lang/management/MonitorInfo.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ java/lang/management/MonitorInfo.java 25 Dec 2006 00:46:22 -0000
@@ -0,0 +1,179 @@
+/* MonitorInfo.java - Information on a monitor lock.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.management;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.SimpleType;
+
+/**
+ * Provides information on a monitor lock held by a thread.
+ * A monitor lock is obtained when a thread enters a synchronized
+ * block or method.
+ *
+ * @author Andrew John Hughes ([EMAIL PROTECTED])
+ * @since 1.6
+ */
+public class MonitorInfo
+ extends LockInfo
+{
+
+ /**
+ * The stack depth at which the lock was obtained.
+ */
+ public int stackDepth;
+
+ /**
+ * The stack frame at which the lock was obtained.
+ */
+ public StackTraceElement stackFrame;
+
+ /**
+ * Constructs a new [EMAIL PROTECTED] MonitorInfo} using the specified
+ * lock class name and identity hash code, and the given
+ * stack depth and frame.
+ *
+ * @param className the class name of the lock object.
+ * @param identityHashCode the identity hash code of the lock object.
+ * @param stackDepth the depth of the stack at which the lock
+ * was obtained.
+ * @param stackFrame the frame of the stack at which the lock was
+ * obtained.
+ * @throws IllegalArgumentException if the stack depth and frame are
+ * inconsistent i.e. the frame is
+ * <code>null</code> but the depth is
+ * ≥ 0, or the frame is not
+ * <code>null</code> but the depth is
+ * < 0.
+ */
+ public MonitorInfo(String className, int identityHashCode, int stackDepth,
+ StackTraceElement stackFrame)
+ {
+ super(className, identityHashCode);
+ if (stackFrame == null && stackDepth >= 0)
+ throw new IllegalArgumentException("The stack frame is null, but the " +
+ "stack depth is greater than or equal
" +
+ "to zero.");
+ if (stackFrame != null && stackDepth < 0)
+ throw new IllegalArgumentException("The stack frame is not null, but the
" +
+ "stack depth is less than zero.");
+ this.stackDepth = stackDepth;
+ this.stackFrame = stackFrame;
+ }
+
+ /**
+ * <p>
+ * Returns a [EMAIL PROTECTED] MonitorInfo} instance using the values
+ * given in the supplied
+ * [EMAIL PROTECTED] javax.management.openmbean.CompositeData} object.
+ * The composite data instance should contain the following
+ * attributes with the specified types:
+ * </p>
+ * <table>
+ * <th><td>Name</td><td>Type</td></th>
+ * <tr><td>className</td><td>java.lang.String</td></tr>
+ * <tr><td>identityHashCode</td><td>java.lang.Integer</td></tr>
+ * <tr><td>lockedStackDepth</td><td>java.lang.Integer</td></tr>
+ * <tr><td>lockedStackFrame</td><td>javax.management.openmbean.CompositeData
+ * </td></tr>
+ * </table>
+ * <p>
+ * The stack trace is further described as:
+ * </p>
+ * <table>
+ * <th><td>Name</td><td>Type</td></th>
+ * <tr><td>className</td><td>java.lang.String</td></tr>
+ * <tr><td>methodName</td><td>java.lang.String</td></tr>
+ * <tr><td>fileName</td><td>java.lang.String</td></tr>
+ * <tr><td>lineNumber</td><td>java.lang.Integer</td></tr>
+ * <tr><td>nativeMethod</td><td>java.lang.Boolean</td></tr>
+ * </table>
+ *
+ * @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.
+ */
+ public static MonitorInfo from(CompositeData data)
+ {
+ if (data == null)
+ return null;
+ CompositeType type = data.getCompositeType();
+ ThreadInfo.checkAttribute(type, "ClassName", SimpleType.STRING);
+ ThreadInfo.checkAttribute(type, "IdentityHashCode", SimpleType.INTEGER);
+ ThreadInfo.checkAttribute(type, "LockedStackDepth", SimpleType.INTEGER);
+ ThreadInfo.checkAttribute(type, "LockedStackFrame",
+ ThreadInfo.getStackTraceType());
+ CompositeData frame = (CompositeData) data.get("LockedStackFrame");
+ return new MonitorInfo((String) data.get("ClassName"),
+ (Integer) data.get("IdentityHashCode"),
+ (Integer) data.get("LockedStackDepth"),
+ new StackTraceElement((String)
frame.get("ClassName"),
+ (String)
frame.get("MethodName"),
+ (String) frame.get("FileName"),
+ (Integer)
frame.get("LineNumber")));
+ }
+
+ /**
+ * Returns the depth of the stack at which the lock was obtained.
+ * This works as an index into the array returned by
+ * [EMAIL PROTECTED] ThreadInfo#getStackTrace()}.
+ *
+ * @return the depth of the stack at which the lock was obtained,
+ * or a negative number if this information is unavailable.
+ */
+ public int getLockedStackDepth()
+ {
+ return stackDepth;
+ }
+
+ /**
+ * Returns the stack frame at which the lock was obtained.
+ *
+ * @return the stack frame at which the lock was obtained,
+ * or <code>null</code> if this informati0on is unavailable.
+ */
+ public StackTraceElement getLockedStackFrame()
+ {
+ return stackFrame;
+ }
+
+}
Index: java/lang/management/ThreadInfo.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/management/ThreadInfo.java,v
retrieving revision 1.7
diff -u -3 -p -u -r1.7 ThreadInfo.java
--- java/lang/management/ThreadInfo.java 24 Dec 2006 00:10:46 -0000
1.7
+++ java/lang/management/ThreadInfo.java 25 Dec 2006 00:46:22 -0000
@@ -170,6 +170,12 @@ public class ThreadInfo
private static ThreadMXBean bean = null;
/**
+ * Cache the [EMAIL PROTECTED] javax.management.openmbean.CompositeType}
+ * for the [EMAIL PROTECTED] StackTraceElement}.
+ */
+ private static CompositeType seType;
+
+ /**
* Constructs a new [EMAIL PROTECTED] ThreadInfo} corresponding
* to the thread specified.
*
@@ -287,6 +293,44 @@ public class ThreadInfo
}
/**
+ * Returns the [EMAIL PROTECTED] javax.management.openmbean.CompositeType}
for
+ * a [EMAIL PROTECTED] StackTraceElement}.
+ *
+ * @return the type for the stack trace element.
+ */
+ static CompositeType getStackTraceType()
+ {
+ if (seType == null)
+ try
+ {
+ seType = new CompositeType(StackTraceElement.class.getName(),
+ "An element of a stack trace",
+ new String[] { "className", "methodName",
+ "fileName", "lineNumber",
+ "nativeMethod"
+ },
+ new String[] { "Name of the class",
+ "Name of the method",
+ "Name of the source code
file",
+ "Line number",
+ "True if this is a native
method"
+ },
+ new OpenType[] {
+ SimpleType.STRING, SimpleType.STRING,
+ SimpleType.STRING, SimpleType.INTEGER,
+ SimpleType.BOOLEAN
+ });
+ }
+ catch (OpenDataException e)
+ {
+ throw new IllegalStateException("Something went wrong in creating " +
+ "the composite data type for the " +
+ "stack trace element.", e);
+ }
+ return seType;
+ }
+
+ /**
* <p>
* Returns a [EMAIL PROTECTED] ThreadInfo} instance using the values
* given in the supplied
@@ -350,31 +394,14 @@ public class ThreadInfo
checkAttribute(type, "LockOwnerName", SimpleType.STRING);
try
{
- CompositeType seType =
- new CompositeType(StackTraceElement.class.getName(),
- "An element of a stack trace",
- new String[] { "className", "methodName",
- "fileName", "lineNumber",
- "nativeMethod"
- },
- new String[] { "Name of the class",
- "Name of the method",
- "Name of the source code file",
- "Line number",
- "True if this is a native method"
- },
- new OpenType[] {
- SimpleType.STRING, SimpleType.STRING,
- SimpleType.STRING, SimpleType.INTEGER,
- SimpleType.BOOLEAN
- });
- checkAttribute(type, "StackTrace", new ArrayType(1, seType));
+ checkAttribute(type, "StackTrace",
+ new ArrayType(1, getStackTraceType()));
}
catch (OpenDataException e)
{
throw new IllegalStateException("Something went wrong in creating " +
- "the composite data type for the " +
- "stack trace element.", e);
+ "the array for the stack trace
element.",
+ e);
}
CompositeData[] dTraces = (CompositeData[]) data.get("StackTrace");
StackTraceElement[] traces = new StackTraceElement[dTraces.length];
signature.asc
Description: Digital signature
