Merge remote-tracking branch 'aosp/master' into add-jdi am: 3a164764fa am: ba8828616b
am: 9abe8a2bd9
Change-Id: Ief7f04c13e5727ee0bf453857cad2107fe5c1245
diff --git a/src/share/classes/com/sun/jdi/AbsentInformationException.java b/src/share/classes/com/sun/jdi/AbsentInformationException.java
new file mode 100644
index 0000000..36ac31e
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/AbsentInformationException.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Thrown to indicate line number or variable information is not available.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public class AbsentInformationException extends Exception
+{
+ private static final long serialVersionUID = 4988939309582416373L;
+ public AbsentInformationException()
+ {
+ super();
+ }
+
+ public AbsentInformationException(String s)
+ {
+ super(s);
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/Accessible.java b/src/share/classes/com/sun/jdi/Accessible.java
new file mode 100644
index 0000000..a1886b7
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/Accessible.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Provides information on the accessibility of a type or type component.
+ * Mirrors for program elements which allow an
+ * an access specifier (private, protected, public) provide information
+ * on that part of the declaration through this interface.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface Accessible {
+
+ /**
+ * Returns the Java<sup><font size=-2>TM</font></sup>
+ * programming language modifiers, encoded in an integer.
+ * <p>
+ * The modifier encodings are defined in
+ * <cite>The Java™ Virtual Machine Specification</cite>
+ * in the <code>access_flag</code> tables for classes(section 4.1), fields(section 4.5), and methods(section 4.6).
+ */
+ public int modifiers();
+
+ /**
+ * Determines if this object mirrors a private item.
+ * For {@link ArrayType}, the return value depends on the
+ * array component type. For primitive arrays the return value
+ * is always false. For object arrays, the return value is the
+ * same as would be returned for the component type.
+ * For primitive classes, such as {@link java.lang.Integer#TYPE},
+ * the return value is always false.
+ *
+ * @return <code>true</code> for items with private access;
+ * <code>false</code> otherwise.
+ */
+ boolean isPrivate();
+
+ /**
+ * Determines if this object mirrors a package private item.
+ * A package private item is declared with no access specifier.
+ * For {@link ArrayType}, the return value depends on the
+ * array component type. For primitive arrays the return value
+ * is always false. For object arrays, the return value is the
+ * same as would be returned for the component type.
+ * For primitive classes, such as {@link java.lang.Integer#TYPE},
+ * the return value is always false.
+ *
+ * @return <code>true</code> for items with package private access;
+ * <code>false</code> otherwise.
+ */
+ boolean isPackagePrivate();
+
+ /**
+ * Determines if this object mirrors a protected item.
+ * For {@link ArrayType}, the return value depends on the
+ * array component type. For primitive arrays the return value
+ * is always false. For object arrays, the return value is the
+ * same as would be returned for the component type.
+ * For primitive classes, such as {@link java.lang.Integer#TYPE},
+ * the return value is always false.
+ *
+ * @return <code>true</code> for items with private access;
+ * <code>false</code> otherwise.
+ */
+ boolean isProtected();
+
+ /**
+ * Determines if this object mirrors a public item.
+ * For {@link ArrayType}, the return value depends on the
+ * array component type. For primitive arrays the return value
+ * is always true. For object arrays, the return value is the
+ * same as would be returned for the component type.
+ * For primitive classes, such as {@link java.lang.Integer#TYPE},
+ * the return value is always true.
+ *
+ * @return <code>true</code> for items with public access;
+ * <code>false</code> otherwise.
+ */
+ boolean isPublic();
+}
diff --git a/src/share/classes/com/sun/jdi/ArrayReference.java b/src/share/classes/com/sun/jdi/ArrayReference.java
new file mode 100644
index 0000000..d4cf64b
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/ArrayReference.java
@@ -0,0 +1,210 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+import java.util.List;
+
+/**
+ * Provides access to an array object and its components in the target VM.
+ * Each array component is mirrored by a {@link Value} object.
+ * The array components, in aggregate, are placed in {@link java.util.List}
+ * objects instead of arrays for consistency with the rest of the API and
+ * for interoperability with other APIs.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ArrayReference extends ObjectReference {
+
+ /**
+ * Returns the number of components in this array.
+ *
+ * @return the integer count of components in this array.
+ */
+ int length();
+
+ /**
+ * Returns an array component value.
+ *
+ * @param index the index of the component to retrieve
+ * @return the {@link Value} at the given index.
+ * @throws java.lang.IndexOutOfBoundsException if
+ * <CODE><I>index</I></CODE> is outside the range of this array,
+ * that is, if either of the following are true:
+ * <PRE>
+ * <I>index</I> < 0
+ * <I>index</I> >= {@link #length() length()} </PRE>
+ */
+ Value getValue(int index);
+
+ /**
+ * Returns all of the components in this array.
+ *
+ * @return a list of {@link Value} objects, one for each array
+ * component ordered by array index. For zero length arrays,
+ * an empty list is returned.
+ */
+ List<Value> getValues();
+
+ /**
+ * Returns a range of array components.
+ *
+ * @param index the index of the first component to retrieve
+ * @param length the number of components to retrieve, or -1 to
+ * retrieve all components to the end of this array.
+ * @return a list of {@link Value} objects, one for each requested
+ * array component ordered by array index. When there are
+ * no elements in the specified range (e.g.
+ * <CODE><I>length</I></CODE> is zero) an empty list is returned
+ *
+ * @throws java.lang.IndexOutOfBoundsException if the range
+ * specified with <CODE><I>index</I></CODE> and
+ * <CODE><I>length</I></CODE> is not within the range of the array,
+ * that is, if either of the following are true:
+ * <PRE>
+ * <I>index</I> < 0
+ * <I>index</I> > {@link #length() length()} </PRE>
+ * or if <CODE><I>length</I> != -1</CODE> and
+ * either of the following are true:
+ * <PRE>
+ * <I>length</I> < 0
+ * <I>index</I> + <I>length</I> > {@link #length() length()}</PRE>
+ */
+ List<Value> getValues(int index, int length);
+
+ /**
+ * Replaces an array component with another value.
+ * <p>
+ * Object values must be assignment compatible with the component type
+ * (This implies that the component type must be loaded through the
+ * declaring class's class loader). Primitive values must be
+ * either assignment compatible with the component type or must be
+ * convertible to the component type without loss of information.
+ * See JLS section 5.2 for more information on assignment
+ * compatibility.
+ *
+ * @param value the new value
+ * @param index the index of the component to set
+ * @throws java.lang.IndexOutOfBoundsException if
+ * <CODE><I>index</I></CODE> is outside the range of this array,
+ * that is, if either of the following are true:
+ * <PRE>
+ * <I>index</I> < 0
+ * <I>index</I> >= {@link #length() length()} </PRE>
+ * @throws InvalidTypeException if the type of <CODE><I>value</I></CODE>
+ * is not compatible with the declared type of array components.
+ * @throws ClassNotLoadedException if the array component type
+ * has not yet been loaded
+ * through the appropriate class loader.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ *
+ * @see ArrayType#componentType()
+ */
+ void setValue(int index, Value value)
+ throws InvalidTypeException,
+ ClassNotLoadedException;
+
+ /**
+ * Replaces all array components with other values. If the given
+ * list is larger in size than the array, the values at the
+ * end of the list are ignored.
+ * <p>
+ * Object values must be assignment compatible with the element type
+ * (This implies that the component type must be loaded through the
+ * enclosing class's class loader). Primitive values must be
+ * either assignment compatible with the component type or must be
+ * convertible to the component type without loss of information.
+ * See JLS section 5.2 for more information on assignment
+ * compatibility.
+ *
+ * @param values a list of {@link Value} objects to be placed
+ * in this array. If <CODE><I>values</I>.size()</CODE> is
+ * less that the length of the array, the first
+ * <CODE><I>values</I>.size()</CODE> elements are set.
+ * @throws InvalidTypeException if any of the
+ * new <CODE><I>values</I></CODE>
+ * is not compatible with the declared type of array components.
+ * @throws ClassNotLoadedException if the array component
+ * type has not yet been loaded
+ * through the appropriate class loader.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ *
+ * @see ArrayType#componentType()
+ */
+ void setValues(List<? extends Value> values)
+ throws InvalidTypeException,
+ ClassNotLoadedException;
+
+ /**
+ * Replaces a range of array components with other values.
+ * <p>
+ * Object values must be assignment compatible with the component type
+ * (This implies that the component type must be loaded through the
+ * enclosing class's class loader). Primitive values must be
+ * either assignment compatible with the component type or must be
+ * convertible to the component type without loss of information.
+ * See JLS section 5.2 for more information on assignment
+ * compatibility.
+ *
+ * @param index the index of the first component to set.
+ * @param values a list of {@link Value} objects to be placed
+ * in this array.
+ * @param srcIndex the index of the first source value to use.
+ * @param length the number of components to set, or -1 to set
+ * all components to the end of this array or the end of
+ * <CODE><I>values</I></CODE> (whichever comes first).
+ * @throws InvalidTypeException if any element of
+ * <CODE><I>values</I></CODE>
+ * is not compatible with the declared type of array components.
+ * @throws java.lang.IndexOutOfBoundsException if the
+ * array range specified with
+ * <CODE><I>index</I></CODE> and <CODE><I>length</I></CODE>
+ * is not within the range of the array,
+ * or if the source range specified with
+ * <CODE><I>srcIndex</I></CODE> and <CODE><I>length</I></CODE>
+ * is not within <CODE><I>values</I></CODE>,
+ * that is, if any of the following are true:
+ * <PRE>
+ * <I>index</I> < 0
+ * <I>index</I> > {@link #length() length()}
+ * <I>srcIndex</I> < 0
+ * <I>srcIndex</I> > <I>values</I>.size() </PRE>
+ * or if <CODE><I>length</I> != -1</CODE> and any of the
+ * following are true:
+ * <PRE>
+ * <I>length</I> < 0
+ * <I>index</I> + <I>length</I> > {@link #length() length()}
+ * <I>srcIndex</I> + <I>length</I> > <I>values</I>.size() </PRE>
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ * @see ArrayType#componentType()
+ */
+ void setValues(int index, List<? extends Value> values, int srcIndex, int length)
+ throws InvalidTypeException,
+ ClassNotLoadedException;
+}
diff --git a/src/share/classes/com/sun/jdi/ArrayType.java b/src/share/classes/com/sun/jdi/ArrayType.java
new file mode 100644
index 0000000..45c4f4d
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/ArrayType.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+import java.util.List;
+
+/**
+ * Provides access to the class of an array and the type of
+ * its components in the target VM.
+ *
+ * @see ArrayReference
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ArrayType extends ReferenceType {
+
+ /**
+ * Creates a new instance of this array class in the target VM.
+ * The array is created with the given length and each component
+ * is initialized to is standard default value.
+ *
+ * @param length the number of components in the new array
+ * @return the newly created {@link ArrayReference} mirroring
+ * the new object in the target VM.
+ *
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ */
+ ArrayReference newInstance(int length);
+
+ /**
+ * Gets the JNI signature of the components of this
+ * array class. The signature
+ * describes the declared type of the components. If the components
+ * are objects, their actual type in a particular run-time context
+ * may be a subclass of the declared class.
+ *
+ * @return a string containing the JNI signature of array components.
+ */
+ String componentSignature();
+
+ /**
+ * Returns a text representation of the component
+ * type of this array.
+ *
+ * @return a text representation of the component type.
+ */
+ String componentTypeName();
+
+ /**
+ * Returns the component type of this array,
+ * as specified in the array declaration.
+ * <P>
+ * Note: The component type of a array will always be
+ * created or loaded before the array - see
+ * <cite>The Java™ Virtual Machine Specification</cite>,
+ * section 5.3.3 - Creating Array Classes.
+ * However, although the component type will be loaded it may
+ * not yet be prepared, in which case the type will be returned
+ * but attempts to perform some operations on the returned type
+ * (e.g. {@link ReferenceType#fields() fields()}) will throw
+ * a {@link ClassNotPreparedException}.
+ * Use {@link ReferenceType#isPrepared()} to determine if
+ * a reference type is prepared.
+ *
+ * @see Type
+ * @see Field#type() Field.type() - for usage examples
+ * @return the {@link Type} of this array's components.
+ */
+ Type componentType() throws ClassNotLoadedException;
+}
diff --git a/src/share/classes/com/sun/jdi/BooleanType.java b/src/share/classes/com/sun/jdi/BooleanType.java
new file mode 100644
index 0000000..7bf98c8
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/BooleanType.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * The type of all primitive <code>boolean</code> values
+ * accessed in the target VM. Calls to {@link Value#type} will return an
+ * implementor of this interface.
+ *
+ * @see BooleanValue
+ *
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface BooleanType extends PrimitiveType {
+}
diff --git a/src/share/classes/com/sun/jdi/BooleanValue.java b/src/share/classes/com/sun/jdi/BooleanValue.java
new file mode 100644
index 0000000..73297fa
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/BooleanValue.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Provides access to a primitive <code>boolean</code> value in
+ * the target VM.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface BooleanValue extends PrimitiveValue {
+
+ /**
+ * Returns this BooleanValue as a boolean.
+ *
+ * @return the <code>boolean</code> mirrored by this object.
+ */
+ boolean value();
+
+ /**
+ * Compares the specified Object with this BooleanValue for equality.
+ *
+ * @return true if the Object is a BooleanValue and if applying "=="
+ * to the two mirrored primitives would evaluate to true; false
+ * otherwise.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns the hash code value for this BooleanValue.
+ *
+ * @return the integer hash code
+ */
+ int hashCode();
+}
diff --git a/src/share/classes/com/sun/jdi/Bootstrap.java b/src/share/classes/com/sun/jdi/Bootstrap.java
new file mode 100644
index 0000000..8ab0954
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/Bootstrap.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Initial class that provides access to the default implementation
+ * of JDI interfaces. A debugger application uses this class to access the
+ * single instance of the {@link VirtualMachineManager} interface.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+
+@jdk.Exported
+public class Bootstrap extends Object {
+
+ /**
+ * Returns the virtual machine manager.
+ *
+ * <p> May throw an unspecified error if initialization of the
+ * {@link com.sun.jdi.VirtualMachineManager} fails or if
+ * the virtual machine manager is unable to locate or create
+ * any {@link com.sun.jdi.connect.Connector Connectors}. </p>
+ * <p>
+ * @throws java.lang.SecurityException if a security manager has been
+ * installed and it denies {@link JDIPermission}
+ * <tt>("virtualMachineManager")</tt> or other unspecified
+ * permissions required by the implementation.
+ * </p>
+ */
+ static public synchronized VirtualMachineManager virtualMachineManager() {
+ return com.sun.tools.jdi.VirtualMachineManagerImpl.virtualMachineManager();
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/ByteType.java b/src/share/classes/com/sun/jdi/ByteType.java
new file mode 100644
index 0000000..dc83cc3
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/ByteType.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * The type of all primitive byte values accessed in
+ * the target VM. Calls to {@link Value#type} will return an
+ * implementor of this interface.
+ *
+ * @see ByteValue
+ *
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ByteType extends PrimitiveType {
+}
diff --git a/src/share/classes/com/sun/jdi/ByteValue.java b/src/share/classes/com/sun/jdi/ByteValue.java
new file mode 100644
index 0000000..a16ecd0
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/ByteValue.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Provides access to a primitive <code>byte</code> value in the target VM.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ByteValue extends PrimitiveValue, Comparable<ByteValue> {
+
+ /**
+ * Returns this ByteValue as a <code>byte</code>.
+ *
+ * @return the <code>byte</code> mirrored by this object.
+ */
+ byte value();
+
+ /**
+ * Compares the specified Object with this ByteValue for equality.
+ *
+ * @return true if the Object is a ByteValue and if applying "=="
+ * to the two mirrored primitives would evaluate to true; false
+ * otherwise.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns the hash code value for this BooleanValue.
+ *
+ * @return the integer hash code
+ */
+ int hashCode();
+}
diff --git a/src/share/classes/com/sun/jdi/CharType.java b/src/share/classes/com/sun/jdi/CharType.java
new file mode 100644
index 0000000..fab5a16
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/CharType.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * The type of all primitive char values accessed in
+ * the target VM. Calls to {@link Value#type} will return an
+ * implementor of this interface.
+ *
+ * @see CharValue
+ *
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface CharType extends PrimitiveType {
+}
diff --git a/src/share/classes/com/sun/jdi/CharValue.java b/src/share/classes/com/sun/jdi/CharValue.java
new file mode 100644
index 0000000..2f9d630
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/CharValue.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Provides access to a primitive <code>char</code> value in
+ * the target VM.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface CharValue extends PrimitiveValue, Comparable<CharValue> {
+
+ /**
+ * Returns this CharValue as a <code>char</code>.
+ *
+ * @return the <code>char</code> mirrored by this object.
+ */
+ char value();
+
+ /**
+ * Compares the specified Object with this CharValue for equality.
+ *
+ * @return true if the Object is a CharValue and if applying "=="
+ * to the two mirrored primitives would evaluate to true; false
+ * otherwise.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns the hash code value for this CharValue.
+ *
+ * @return the integer hash code
+ */
+ int hashCode();
+}
diff --git a/src/share/classes/com/sun/jdi/ClassLoaderReference.java b/src/share/classes/com/sun/jdi/ClassLoaderReference.java
new file mode 100644
index 0000000..b8363ae
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/ClassLoaderReference.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+import java.util.List;
+
+/**
+ * A class loader object from the target VM.
+ * A ClassLoaderReference is an {@link ObjectReference} with additional
+ * access to classloader-specific information from the target VM. Instances
+ * ClassLoaderReference are obtained through calls to
+ * {@link ReferenceType#classLoader}
+ *
+ * @see ObjectReference
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ClassLoaderReference extends ObjectReference {
+
+ /**
+ * Returns a list of all loaded classes that were defined by this
+ * class loader. No ordering of this list guaranteed.
+ * <P>
+ * The returned list will include reference types
+ * loaded at least to the point of preparation and
+ * types (like array) for which preparation is
+ * not defined.
+ *
+ * @return a List of {@link ReferenceType} objects mirroring types
+ * loaded by this class loader. The list has length 0 if no types
+ * have been defined by this classloader.
+ */
+ List<ReferenceType> definedClasses();
+
+ /**
+ * Returns a list of all classes for which this class loader has
+ * been recorded as the initiating loader in the target VM.
+ * The list contains ReferenceTypes defined directly by this loader
+ * (as returned by {@link #definedClasses}) and any types for which
+ * loading was delegated by this class loader to another class loader.
+ * <p>
+ * The visible class list has useful properties with respect to
+ * the type namespace. A particular type name will occur at most
+ * once in the list. Each field or variable declared with that
+ * type name in a class defined by
+ * this class loader must be resolved to that single type.
+ * <p>
+ * No ordering of the returned list is guaranteed.
+ * <p>
+ * See
+ * <cite>The Java™ Virtual Machine Specification</cite>,
+ * section 5.3 - Creation and Loading
+ * for more information on the initiating classloader.
+ * <p>
+ * Note that unlike {@link #definedClasses()}
+ * and {@link VirtualMachine#allClasses()},
+ * some of the returned reference types may not be prepared.
+ * Attempts to perform some operations on unprepared reference types
+ * (e.g. {@link ReferenceType#fields() fields()}) will throw
+ * a {@link ClassNotPreparedException}.
+ * Use {@link ReferenceType#isPrepared()} to determine if
+ * a reference type is prepared.
+ *
+ * @return a List of {@link ReferenceType} objects mirroring classes
+ * initiated by this class loader. The list has length 0 if no classes
+ * are visible to this classloader.
+ */
+ List<ReferenceType> visibleClasses();
+}
diff --git a/src/share/classes/com/sun/jdi/ClassNotLoadedException.java b/src/share/classes/com/sun/jdi/ClassNotLoadedException.java
new file mode 100644
index 0000000..3493185
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/ClassNotLoadedException.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Thrown to indicate that the requested class has
+ * not yet been loaded through the appropriate class loader.
+ * <p>
+ * Due to the lazy class linking performed by many VMs, it is
+ * possible for a field or variable to be visible in a program
+ * before the associated class is loaded. Until the class is loaded
+ * all that is available is a signature string. If an attempt is made to
+ * set the value of such a field or variable from JDI, the appropriate
+ * type checking cannot be done because the destination class has not been
+ * loaded. The same is true for the element class of array elements.
+ * <p>
+ * It is not advisable to solve this problem by attempting a class load on
+ * the fly in this case. There are two problems in having the debugger load
+ * a class instead of waiting for it to load over the normal course
+ * of events.
+ * <ul>
+ * <li>There can be no guarantee that running the appropriate class
+ * loader won't cause a deadlock in loading the
+ * class. Class loaders can consist of arbitrary
+ * Java<sup><font size=-2>TM</font></sup> programming language code and the
+ * class loading methods are usually synchronized. Most of the work
+ * done by a debugger happens when threads are suspended. If another
+ * application thread is suspended within the same class loader,
+ * a deadlock is very possible.
+ * <li>Changing the order in which classes are normally loaded may either mask
+ * or reveal bugs in the application. An unintrusive debugger should strive
+ * to leave unchanged the behavior of the application being debugged.
+ * </ul>
+ * To avoid these potential problems, this exception is thrown.
+ * <p>
+ * Note that this exception will be thrown until the class in question
+ * is visible to the class loader of enclosing class. (That is, the
+ * class loader of the enclosing class must be an <i>initiating</i> class
+ * loader for the class in question.)
+ * See
+ * <cite>The Java™ Virtual Machine Specification</cite>
+ * for more details.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public class ClassNotLoadedException extends Exception
+{
+ private static final long serialVersionUID = -6242978768444298722L;
+ private String className;
+
+ public ClassNotLoadedException(String className) {
+ super();
+ this.className = className;
+ }
+
+ public ClassNotLoadedException(String className, String message) {
+ super(message);
+ this.className = className;
+ }
+
+ public String className() {
+ return className;
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/ClassNotPreparedException.java b/src/share/classes/com/sun/jdi/ClassNotPreparedException.java
new file mode 100644
index 0000000..528b36e
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/ClassNotPreparedException.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Thrown to indicate that the requested operation cannot be
+ * completed because the specified class has not yet been prepared.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public class ClassNotPreparedException extends RuntimeException {
+ private static final long serialVersionUID = -6120698967144079642L;
+ public ClassNotPreparedException()
+ {
+ super();
+ }
+
+ public ClassNotPreparedException(String s)
+ {
+ super(s);
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/ClassObjectReference.java b/src/share/classes/com/sun/jdi/ClassObjectReference.java
new file mode 100644
index 0000000..79a306a
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/ClassObjectReference.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 1999, 2013, 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.jdi;
+
+/**
+ * An instance of java.lang.Class from the target VM.
+ * Use this interface to access type information
+ * for the class, array, or interface that this object reflects.
+ *
+ * @see ReferenceType
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ClassObjectReference extends ObjectReference {
+
+ /**
+ * Returns the {@link ReferenceType} corresponding to this
+ * class object. The returned type can be used to obtain
+ * detailed information about the class.
+ *
+ * @return the {@link ReferenceType} reflected by this class object.
+ */
+ ReferenceType reflectedType();
+}
diff --git a/src/share/classes/com/sun/jdi/ClassType.java b/src/share/classes/com/sun/jdi/ClassType.java
new file mode 100644
index 0000000..296f2e7
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/ClassType.java
@@ -0,0 +1,373 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+import java.util.List;
+
+/**
+ * A mirror of a class in the target VM. A ClassType is a refinement
+ * of {@link ReferenceType} that applies to true classes in the JLS
+ * sense of the definition (not an interface, not an array type). Any
+ * {@link ObjectReference} that mirrors an instance of such a class
+ * will have a ClassType as its type.
+ *
+ * @see ObjectReference
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ClassType extends ReferenceType {
+ /**
+ * Gets the superclass of this class.
+ *
+ * @return a {@link ClassType} that mirrors the superclass
+ * of this class in the target VM. If no such class exists,
+ * returns null
+ */
+ ClassType superclass();
+
+ /**
+ * Gets the interfaces directly implemented by this class.
+ * Only the interfaces that are declared with the "implements"
+ * keyword in this class are included.
+ *
+ * @return a List of {@link InterfaceType} objects each mirroring
+ * a direct interface this ClassType in the target VM.
+ * If none exist, returns a zero length List.
+ * @throws ClassNotPreparedException if this class not yet been
+ * prepared.
+ */
+ List<InterfaceType> interfaces();
+
+ /**
+ * Gets the interfaces directly and indirectly implemented
+ * by this class. Interfaces returned by {@link ClassType#interfaces}
+ * are returned as well all superinterfaces.
+ *
+ * @return a List of {@link InterfaceType} objects each mirroring
+ * an interface of this ClassType in the target VM.
+ * If none exist, returns a zero length List.
+ * @throws ClassNotPreparedException if this class not yet been
+ * prepared.
+ */
+ List<InterfaceType> allInterfaces();
+
+ /**
+ * Gets the currently loaded, direct subclasses of this class.
+ * No ordering of this list is guaranteed.
+ *
+ * @return a List of {@link ClassType} objects each mirroring a loaded
+ * subclass of this class in the target VM. If no such classes
+ * exist, this method returns a zero-length list.
+ */
+ List<ClassType> subclasses();
+
+ /**
+ * Determine if this class was declared as an enum.
+ * @return <code>true</code> if this class was declared as an enum; false
+ * otherwise.
+ */
+ boolean isEnum();
+
+ /**
+ * Assigns a value to a static field.
+ * The {@link Field} must be valid for this ClassType; that is,
+ * it must be from the mirrored object's class or a superclass of that class.
+ * The field must not be final.
+ * <p>
+ * Object values must be assignment compatible with the field type
+ * (This implies that the field type must be loaded through the
+ * enclosing class' class loader). Primitive values must be
+ * either assignment compatible with the field type or must be
+ * convertible to the field type without loss of information.
+ * See JLS section 5.2 for more information on assignment
+ * compatibility.
+ *
+ * @param field the field to set.
+ * @param value the value to be assigned.
+ * @throws java.lang.IllegalArgumentException if the field is
+ * not static, the field is final, or the field does not exist
+ * in this class.
+ * @throws ClassNotLoadedException if the field type has not yet been loaded
+ * through the appropriate class loader.
+ * @throws InvalidTypeException if the value's type does not match
+ * the field's declared type.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ */
+ void setValue(Field field, Value value)
+ throws InvalidTypeException, ClassNotLoadedException;
+
+ /** Perform method invocation with only the invoking thread resumed */
+ static final int INVOKE_SINGLE_THREADED = 0x1;
+
+ /**
+ * Invokes the specified static {@link Method} in the
+ * target VM. The
+ * specified method can be defined in this class,
+ * or in a superclass.
+ * The method must be a static method
+ * but not a static initializer.
+ * Use {@link ClassType#newInstance} to create a new object and
+ * run its constructor.
+ * <p>
+ * The method invocation will occur in the specified thread.
+ * Method invocation can occur only if the specified thread
+ * has been suspended by an event which occurred in that thread.
+ * Method invocation is not supported
+ * when the target VM has been suspended through
+ * {@link VirtualMachine#suspend} or when the specified thread
+ * is suspended through {@link ThreadReference#suspend}.
+ * <p>
+ * The specified method is invoked with the arguments in the specified
+ * argument list. The method invocation is synchronous; this method
+ * does not return until the invoked method returns in the target VM.
+ * If the invoked method throws an exception, this method will throw
+ * an {@link InvocationException} which contains a mirror to the exception
+ * object thrown.
+ * <p>
+ * Object arguments must be assignment compatible with the argument type
+ * (This implies that the argument type must be loaded through the
+ * enclosing class' class loader). Primitive arguments must be
+ * either assignment compatible with the argument type or must be
+ * convertible to the argument type without loss of information.
+ * If the method being called accepts a variable number of arguments,
+ * then the last argument type is an array of some component type.
+ * The argument in the matching position can be omitted, or can be null,
+ * an array of the same component type, or an argument of the
+ * component type followed by any number of other arguments of the same
+ * type. If the argument is omitted, then a 0 length array of the
+ * component type is passed. The component type can be a primitive type.
+ * Autoboxing is not supported.
+ *
+ * See Section 5.2 of
+ * <cite>The Java™ Language Specification</cite>
+ * for more information on assignment compatibility.
+ * <p>
+ * By default, all threads in the target VM are resumed while
+ * the method is being invoked if they were previously
+ * suspended by an event or by {@link VirtualMachine#suspend} or
+ * {@link ThreadReference#suspend}. This is done to prevent the deadlocks
+ * that will occur if any of the threads own monitors
+ * that will be needed by the invoked method.
+ * Note, however, that this implicit resume acts exactly like
+ * {@link ThreadReference#resume}, so if the thread's suspend
+ * count is greater than 1, it will remain in a suspended state
+ * during the invocation and thus a deadlock could still occur.
+ * By default, when the invocation completes,
+ * all threads in the target VM are suspended, regardless their state
+ * before the invocation.
+ * It is possible that
+ * breakpoints or other events might occur during the invocation.
+ * This can cause deadlocks as described above. It can also cause a deadlock
+ * if invokeMethod is called from the client's event handler thread. In this
+ * case, this thread will be waiting for the invokeMethod to complete and
+ * won't read the EventSet that comes in for the new event. If this
+ * new EventSet is SUSPEND_ALL, then a deadlock will occur because no
+ * one will resume the EventSet. To avoid this, all EventRequests should
+ * be disabled before doing the invokeMethod, or the invokeMethod should
+ * not be done from the client's event handler thread.
+ * <p>
+ * The resumption of other threads during the invocation can be prevented
+ * by specifying the {@link #INVOKE_SINGLE_THREADED}
+ * bit flag in the <code>options</code> argument; however,
+ * there is no protection against or recovery from the deadlocks
+ * described above, so this option should be used with great caution.
+ * Only the specified thread will be resumed (as described for all
+ * threads above). Upon completion of a single threaded invoke, the invoking thread
+ * will be suspended once again. Note that any threads started during
+ * the single threaded invocation will not be suspended when the
+ * invocation completes.
+ * <p>
+ * If the target VM is disconnected during the invoke (for example, through
+ * {@link VirtualMachine#dispose}) the method invocation continues.
+ *
+ * @param thread the thread in which to invoke.
+ * @param method the {@link Method} to invoke.
+ * @param arguments the list of {@link Value} arguments bound to the
+ * invoked method. Values from the list are assigned to arguments
+ * in the order they appear in the method signature.
+ * @param options the integer bit flag options.
+ * @return a {@link Value} mirror of the invoked method's return value.
+ * @throws java.lang.IllegalArgumentException if the method is not
+ * a member of this class or a superclass, if the size of the argument list
+ * does not match the number of declared arguments for the method, or
+ * if the method is an initializer, constructor or static intializer.
+ * @throws {@link InvalidTypeException} if any argument in the
+ * argument list is not assignable to the corresponding method argument
+ * type.
+ * @throws ClassNotLoadedException if any argument type has not yet been loaded
+ * through the appropriate class loader.
+ * @throws IncompatibleThreadStateException if the specified thread has not
+ * been suspended by an event.
+ * @throws InvocationException if the method invocation resulted in
+ * an exception in the target VM.
+ * @throws InvalidTypeException If the arguments do not meet this requirement --
+ * Object arguments must be assignment compatible with the argument
+ * type. This implies that the argument type must be
+ * loaded through the enclosing class' class loader.
+ * Primitive arguments must be either assignment compatible with the
+ * argument type or must be convertible to the argument type without loss
+ * of information. See JLS section 5.2 for more information on assignment
+ * compatibility.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ */
+ Value invokeMethod(ThreadReference thread, Method method,
+ List<? extends Value> arguments, int options)
+ throws InvalidTypeException,
+ ClassNotLoadedException,
+ IncompatibleThreadStateException,
+ InvocationException;
+
+ /**
+ * Constructs a new instance of this type, using
+ * the given constructor {@link Method} in the
+ * target VM. The
+ * specified constructor must be defined in this class.
+ * <p>
+ * Instance creation will occur in the specified thread.
+ * Instance creation can occur only if the specified thread
+ * has been suspended by an event which occurred in that thread.
+ * Instance creation is not supported
+ * when the target VM has been suspended through
+ * {@link VirtualMachine#suspend} or when the specified thread
+ * is suspended through {@link ThreadReference#suspend}.
+ * <p>
+ * The specified constructor is invoked with the arguments in the specified
+ * argument list. The invocation is synchronous; this method
+ * does not return until the constructor returns in the target VM.
+ * If the invoked method throws an
+ * exception, this method will throw an {@link InvocationException}
+ * which contains a mirror to the exception object thrown.
+ * <p>
+ * Object arguments must be assignment compatible with the argument type
+ * (This implies that the argument type must be loaded through the
+ * enclosing class' class loader). Primitive arguments must be
+ * either assignment compatible with the argument type or must be
+ * convertible to the argument type without loss of information.
+ * If the method being called accepts a variable number of arguments,
+ * then the last argument type is an array of some component type.
+ * The argument in the matching position can be omitted, or can be null,
+ * an array of the same component type, or an argument of the
+ * component type, followed by any number of other arguments of the same
+ * type. If the argument is omitted, then a 0 length array of the
+ * component type is passed. The component type can be a primitive type.
+ * Autoboxing is not supported.
+ *
+ * See section 5.2 of
+ * <cite>The Java™ Language Specification</cite>
+ * for more information on assignment compatibility.
+ * <p>
+ * By default, all threads in the target VM are resumed while
+ * the method is being invoked if they were previously
+ * suspended by an event or by {@link VirtualMachine#suspend} or
+ * {@link ThreadReference#suspend}. This is done to prevent the deadlocks
+ * that will occur if any of the threads own monitors
+ * that will be needed by the invoked method. It is possible that
+ * breakpoints or other events might occur during the invocation.
+ * Note, however, that this implicit resume acts exactly like
+ * {@link ThreadReference#resume}, so if the thread's suspend
+ * count is greater than 1, it will remain in a suspended state
+ * during the invocation. By default, when the invocation completes,
+ * all threads in the target VM are suspended, regardless their state
+ * before the invocation.
+ * <p>
+ * The resumption of other threads during the invocation can be prevented
+ * by specifying the {@link #INVOKE_SINGLE_THREADED}
+ * bit flag in the <code>options</code> argument; however,
+ * there is no protection against or recovery from the deadlocks
+ * described above, so this option should be used with great caution.
+ * Only the specified thread will be resumed (as described for all
+ * threads above). Upon completion of a single threaded invoke, the invoking thread
+ * will be suspended once again. Note that any threads started during
+ * the single threaded invocation will not be suspended when the
+ * invocation completes.
+ * <p>
+ * If the target VM is disconnected during the invoke (for example, through
+ * {@link VirtualMachine#dispose}) the method invocation continues.
+ *
+ * @param thread the thread in which to invoke.
+ * @param method the constructor {@link Method} to invoke.
+ * @param arguments the list of {@link Value} arguments bound to the
+ * invoked constructor. Values from the list are assigned to arguments
+ * in the order they appear in the constructor signature.
+ * @param options the integer bit flag options.
+ * @return an {@link ObjectReference} mirror of the newly created
+ * object.
+ * @throws java.lang.IllegalArgumentException if the method is not
+ * a member of this class, if the size of the argument list
+ * does not match the number of declared arguments for the constructor,
+ * or if the method is not a constructor.
+ * @throws {@link InvalidTypeException} if any argument in the
+ * argument list is not assignable to the corresponding method argument
+ * type.
+ * @throws ClassNotLoadedException if any argument type has not yet been loaded
+ * through the appropriate class loader.
+ * @throws IncompatibleThreadStateException if the specified thread has not
+ * been suspended by an event.
+ * @throws InvocationException if the method invocation resulted in
+ * an exception in the target VM.
+ * @throws InvalidTypeException If the arguments do not meet this requirement --
+ * Object arguments must be assignment compatible with the argument
+ * type. This implies that the argument type must be
+ * loaded through the enclosing class' class loader.
+ * Primitive arguments must be either assignment compatible with the
+ * argument type or must be convertible to the argument type without loss
+ * of information. See JLS section 5.2 for more information on assignment
+ * compatibility.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only
+ * - see {@link VirtualMachine#canBeModified()}.
+ */
+ ObjectReference newInstance(ThreadReference thread, Method method,
+ List<? extends Value> arguments, int options)
+ throws InvalidTypeException,
+ ClassNotLoadedException,
+ IncompatibleThreadStateException,
+ InvocationException;
+
+ /**
+ * Returns a the single non-abstract {@link Method} visible from
+ * this class that has the given name and signature.
+ * See {@link ReferenceType#methodsByName(java.lang.String, java.lang.String)}
+ * for information on signature format.
+ * <p>
+ * The returned method (if non-null) is a component of
+ * {@link ClassType}.
+ *
+ * @see ReferenceType#visibleMethods
+ * @see ReferenceType#methodsByName(java.lang.String name)
+ * @see ReferenceType#methodsByName(java.lang.String name, java.lang.String signature)
+ * @param name the name of the method to find.
+ * @param signature the signature of the method to find
+ * @return the {@link Method} that matches the given
+ * name and signature or <code>null</code> if there is no match.
+ * @throws ClassNotPreparedException if methods are not yet available
+ * because the class has not yet been prepared.
+ */
+ Method concreteMethodByName(String name, String signature);
+}
diff --git a/src/share/classes/com/sun/jdi/DoubleType.java b/src/share/classes/com/sun/jdi/DoubleType.java
new file mode 100644
index 0000000..d40da78
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/DoubleType.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * The type of all primitive double values accessed in
+ * the target VM. Calls to {@link Value#type} will return an
+ * implementor of this interface.
+ *
+ * @see DoubleValue
+ *
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface DoubleType extends PrimitiveType {
+}
diff --git a/src/share/classes/com/sun/jdi/DoubleValue.java b/src/share/classes/com/sun/jdi/DoubleValue.java
new file mode 100644
index 0000000..e2f9cc2
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/DoubleValue.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Provides access to a primitive <code>double</code> value in
+ * the target VM.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface DoubleValue extends PrimitiveValue, Comparable<DoubleValue> {
+
+ /**
+ * Returns this DoubleValue as a <code>double</code>.
+ *
+ * @return the <code>double</code> mirrored by this object.
+ */
+ double value();
+
+ /**
+ * Compares the specified Object with this DoubleValue for equality.
+ *
+ * @return true if the Object is a DoubleValue and if applying "=="
+ * to the two mirrored primitives would evaluate to true; false
+ * otherwise.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns the hash code value for this DoubleValue.
+ *
+ * @return the integer hash code
+ */
+ int hashCode();
+}
diff --git a/src/share/classes/com/sun/jdi/Field.java b/src/share/classes/com/sun/jdi/Field.java
new file mode 100644
index 0000000..00e2b75
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/Field.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * A class or instance variable in the target VM.
+ * See {@link TypeComponent}
+ * for general information about Field and Method mirrors.
+ *
+ * @see ObjectReference
+ * @see ReferenceType
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface Field extends TypeComponent, Comparable<Field> {
+
+ /**
+ * Returns a text representation of the type
+ * of this field.
+ * Where the type is the type specified in the declaration
+ * of this field.
+ * <P>
+ * This type name is always available even if
+ * the type has not yet been created or loaded.
+ *
+ * @return a String representing the
+ * type of this field.
+ */
+ String typeName();
+
+ /**
+ * Returns the type of this field.
+ * Where the type is the type specified in the declaration
+ * of this field.
+ * <P>
+ * For example, if a target class defines:
+ * <PRE>
+ * short s;
+ * Date d;
+ * byte[] ba;</PRE>
+ * And the JDI client defines these <CODE>Field</CODE> objects:
+ * <PRE>
+ * Field sField = targetClass.fieldByName("s");
+ * Field dField = targetClass.fieldByName("d");
+ * Field baField = targetClass.fieldByName("ba");</PRE>
+ * to mirror the corresponding fields, then <CODE>sField.type()</CODE>
+ * is a {@link ShortType}, <CODE>dField.type()</CODE> is the
+ * {@link ReferenceType} for <CODE>java.util.Date</CODE> and
+ * <CODE>((ArrayType)(baField.type())).componentType()</CODE> is a
+ * {@link ByteType}.
+ * <P>
+ * Note: if the type of this field is a reference type (class,
+ * interface, or array) and it has not been created or loaded
+ * by the declaring type's class loader - that is,
+ * {@link TypeComponent#declaringType <CODE>declaringType()</CODE>}
+ * <CODE>.classLoader()</CODE>,
+ * then ClassNotLoadedException will be thrown.
+ * Also, a reference type may have been loaded but not yet prepared,
+ * in which case the type will be returned
+ * but attempts to perform some operations on the returned type
+ * (e.g. {@link ReferenceType#fields() fields()}) will throw
+ * a {@link ClassNotPreparedException}.
+ * Use {@link ReferenceType#isPrepared()} to determine if
+ * a reference type is prepared.
+ *
+ * @see Type
+ * @return the {@link Type} of this field.
+ * @throws ClassNotLoadedException if the type has not yet been loaded
+ * or created through the appropriate class loader.
+ */
+ Type type() throws ClassNotLoadedException;
+
+ /**
+ * Determine if this is a transient field.
+ *
+ * @return <code>true</code> if this field is transient; false otherwise.
+ */
+ boolean isTransient();
+
+ /**
+ * Determine if this is a volatile field.
+ *
+ * @return <code>true</code> if this field is volatile; false otherwise.
+ */
+ boolean isVolatile();
+
+ /**
+ * Determine if this is a field that represents an enum constant.
+ * @return <code>true</code> if this field represents an enum constant;
+ * false otherwise.
+ */
+ boolean isEnumConstant();
+
+ /**
+ * Compares the specified Object with this field for equality.
+ *
+ * @return true if the Object is a Field and if both
+ * mirror the same field (declared in the same class or interface, in
+ * the same VM).
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns the hash code value for this Field.
+ *
+ * @return the integer hash code
+ */
+ int hashCode();
+}
diff --git a/src/share/classes/com/sun/jdi/FloatType.java b/src/share/classes/com/sun/jdi/FloatType.java
new file mode 100644
index 0000000..29cb99a
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/FloatType.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * The type of all primitive float values accessed in
+ * the target VM. Calls to {@link Value#type} will return an
+ * implementor of this interface.
+ *
+ * @see FloatValue
+ *
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface FloatType extends PrimitiveType {
+}
diff --git a/src/share/classes/com/sun/jdi/FloatValue.java b/src/share/classes/com/sun/jdi/FloatValue.java
new file mode 100644
index 0000000..aa3be62
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/FloatValue.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Provides access to a primitive <code>float</code> value in
+ * the target VM.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface FloatValue extends PrimitiveValue, Comparable<FloatValue> {
+
+ /**
+ * Returns this FloatValue as a float.
+ *
+ * @return the <code>float</code> mirrored by this object.
+ */
+ float value();
+
+ /**
+ * Compares the specified Object with this FloatValue for equality.
+ *
+ * @return true if the Object is a FloatValue and if applying "=="
+ * to the two mirrored primitives would evaluate to true; false
+ * otherwise.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns the hash code value for this FloatValue.
+ *
+ * @return the integer hash code
+ */
+ int hashCode();
+}
diff --git a/src/share/classes/com/sun/jdi/IncompatibleThreadStateException.java b/src/share/classes/com/sun/jdi/IncompatibleThreadStateException.java
new file mode 100644
index 0000000..11e110f
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/IncompatibleThreadStateException.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Thrown to indicate that the requested operation cannot be
+ * completed while the specified thread is in its current state.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public class IncompatibleThreadStateException extends Exception {
+ private static final long serialVersionUID = 6199174323414551389L;
+
+ public IncompatibleThreadStateException() {
+ super();
+ }
+
+ public IncompatibleThreadStateException(String s) {
+ super(s);
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/InconsistentDebugInfoException.java b/src/share/classes/com/sun/jdi/InconsistentDebugInfoException.java
new file mode 100644
index 0000000..8fe3ae9
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/InconsistentDebugInfoException.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 1999, 2013, 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.jdi;
+
+/**
+ * Thrown to indicate that there is an inconistency in the debug
+ * information provided by the target VM. For example, this exception
+ * is thrown if there is a type mismatch between a retrieved value's
+ * runtime type and its declared type as reported by the target VM.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public class InconsistentDebugInfoException extends RuntimeException {
+ private static final long serialVersionUID = 7964236415376861808L;
+ public InconsistentDebugInfoException() {
+ super();
+ }
+
+ public InconsistentDebugInfoException(String s) {
+ super(s);
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/IntegerType.java b/src/share/classes/com/sun/jdi/IntegerType.java
new file mode 100644
index 0000000..f19b6de
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/IntegerType.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * The type of all primitive <code>int</code> values
+ * accessed in the target VM. Calls to {@link Value#type} will return an
+ * implementor of this interface.
+ *
+ * @see IntegerValue
+ *
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface IntegerType extends PrimitiveType {
+}
diff --git a/src/share/classes/com/sun/jdi/IntegerValue.java b/src/share/classes/com/sun/jdi/IntegerValue.java
new file mode 100644
index 0000000..b8a10a8
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/IntegerValue.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Provides access to a primitive <code>int</code> value in
+ * the target VM.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface IntegerValue extends PrimitiveValue, Comparable<IntegerValue> {
+
+ /**
+ * Returns this IntegerValue as an int.
+ *
+ * @return the <code>int</code> mirrored by this object.
+ */
+ int value();
+
+ /**
+ * Compares the specified Object with this IntegerValue for equality.
+ *
+ * @return true if the Object is an IntegerValue and if applying "=="
+ * to the two mirrored primitives would evaluate to true; false
+ * otherwise.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns the hash code value for this IntegerValue.
+ *
+ * @return the integer hash code
+ */
+ int hashCode();
+}
diff --git a/src/share/classes/com/sun/jdi/InterfaceType.java b/src/share/classes/com/sun/jdi/InterfaceType.java
new file mode 100644
index 0000000..9436e48
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/InterfaceType.java
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+import java.util.List;
+
+/**
+ * A mirror of an interface in the target VM. An InterfaceType is
+ * a refinement of {@link ReferenceType} that applies to true interfaces
+ * in the JLS sense of the definition (not a class, not an array type).
+ * An interface type will never be returned by
+ * {@link ObjectReference#referenceType}, but it may be in the list
+ * of implemented interfaces for a {@link ClassType} that is returned
+ * by that method.
+ *
+ * @see ObjectReference
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface InterfaceType extends ReferenceType {
+ /**
+ * Gets the interfaces directly extended by this interface.
+ * The returned list contains only those interfaces this
+ * interface has declared to be extended.
+ *
+ * @return a List of {@link InterfaceType} objects each mirroring
+ * an interface extended by this interface.
+ * If none exist, returns a zero length List.
+ * @throws ClassNotPreparedException if this class not yet been
+ * prepared.
+ */
+ List<InterfaceType> superinterfaces();
+
+ /**
+ * Gets the currently prepared interfaces which directly extend this
+ * interface. The returned list contains only those interfaces that
+ * declared this interface in their "extends" clause.
+ *
+ * @return a List of {@link InterfaceType} objects each mirroring
+ * an interface extending this interface.
+ * If none exist, returns a zero length List.
+ */
+ List<InterfaceType> subinterfaces();
+
+ /**
+ * Gets the currently prepared classes which directly implement this
+ * interface. The returned list contains only those classes that
+ * declared this interface in their "implements" clause.
+ *
+ * @return a List of {@link ClassType} objects each mirroring
+ * a class implementing this interface.
+ * If none exist, returns a zero length List.
+ */
+ List<ClassType> implementors();
+
+ /**
+ * Invokes the specified static {@link Method} in the
+ * target VM. The
+ * specified method must be defined in this interface.
+ * The method must be a static method
+ * but not a static initializer.
+ * <p>
+ * The method invocation will occur in the specified thread.
+ * Method invocation can occur only if the specified thread
+ * has been suspended by an event which occurred in that thread.
+ * Method invocation is not supported
+ * when the target VM has been suspended through
+ * {@link VirtualMachine#suspend} or when the specified thread
+ * is suspended through {@link ThreadReference#suspend}.
+ * <p>
+ * The specified method is invoked with the arguments in the specified
+ * argument list. The method invocation is synchronous; this method
+ * does not return until the invoked method returns in the target VM.
+ * If the invoked method throws an exception, this method will throw
+ * an {@link InvocationException} which contains a mirror to the exception
+ * object thrown.
+ * <p>
+ * Object arguments must be assignment compatible with the argument type
+ * (This implies that the argument type must be loaded through the
+ * enclosing class' class loader). Primitive arguments must be
+ * either assignment compatible with the argument type or must be
+ * convertible to the argument type without loss of information.
+ * If the method being called accepts a variable number of arguments,
+ * then the last argument type is an array of some component type.
+ * The argument in the matching position can be omitted, or can be null,
+ * an array of the same component type, or an argument of the
+ * component type followed by any number of other arguments of the same
+ * type. If the argument is omitted, then a 0 length array of the
+ * component type is passed. The component type can be a primitive type.
+ * Autoboxing is not supported.
+ *
+ * See Section 5.2 of
+ * <cite>The Java™ Language Specification</cite>
+ * for more information on assignment compatibility.
+ * <p>
+ * By default, all threads in the target VM are resumed while
+ * the method is being invoked if they were previously
+ * suspended by an event or by {@link VirtualMachine#suspend} or
+ * {@link ThreadReference#suspend}. This is done to prevent the deadlocks
+ * that will occur if any of the threads own monitors
+ * that will be needed by the invoked method.
+ * Note, however, that this implicit resume acts exactly like
+ * {@link ThreadReference#resume}, so if the thread's suspend
+ * count is greater than 1, it will remain in a suspended state
+ * during the invocation and thus a deadlock could still occur.
+ * By default, when the invocation completes,
+ * all threads in the target VM are suspended, regardless their state
+ * before the invocation.
+ * It is possible that
+ * breakpoints or other events might occur during the invocation.
+ * This can cause deadlocks as described above. It can also cause a deadlock
+ * if invokeMethod is called from the client's event handler thread. In this
+ * case, this thread will be waiting for the invokeMethod to complete and
+ * won't read the EventSet that comes in for the new event. If this
+ * new EventSet is SUSPEND_ALL, then a deadlock will occur because no
+ * one will resume the EventSet. To avoid this, all EventRequests should
+ * be disabled before doing the invokeMethod, or the invokeMethod should
+ * not be done from the client's event handler thread.
+ * <p>
+ * The resumption of other threads during the invocation can be prevented
+ * by specifying the {@link #INVOKE_SINGLE_THREADED}
+ * bit flag in the <code>options</code> argument; however,
+ * there is no protection against or recovery from the deadlocks
+ * described above, so this option should be used with great caution.
+ * Only the specified thread will be resumed (as described for all
+ * threads above). Upon completion of a single threaded invoke, the invoking thread
+ * will be suspended once again. Note that any threads started during
+ * the single threaded invocation will not be suspended when the
+ * invocation completes.
+ * <p>
+ * If the target VM is disconnected during the invoke (for example, through
+ * {@link VirtualMachine#dispose}) the method invocation continues.
+ *
+ * @param thread the thread in which to invoke.
+ * @param method the {@link Method} to invoke.
+ * @param arguments the list of {@link Value} arguments bound to the
+ * invoked method. Values from the list are assigned to arguments
+ * in the order they appear in the method signature.
+ * @param options the integer bit flag options.
+ * @return a {@link Value} mirror of the invoked method's return value.
+ * @throws java.lang.IllegalArgumentException if the method is not
+ * a member of this interface, if the size of the argument list
+ * does not match the number of declared arguments for the method, or
+ * if the method is not static or is a static initializer.
+ * @throws {@link InvalidTypeException} if any argument in the
+ * argument list is not assignable to the corresponding method argument
+ * type.
+ * @throws ClassNotLoadedException if any argument type has not yet been loaded
+ * through the appropriate class loader.
+ * @throws IncompatibleThreadStateException if the specified thread has not
+ * been suspended by an event.
+ * @throws InvocationException if the method invocation resulted in
+ * an exception in the target VM.
+ * @throws InvalidTypeException If the arguments do not meet this requirement --
+ * Object arguments must be assignment compatible with the argument
+ * type. This implies that the argument type must be
+ * loaded through the enclosing class' class loader.
+ * Primitive arguments must be either assignment compatible with the
+ * argument type or must be convertible to the argument type without loss
+ * of information. See JLS section 5.2 for more information on assignment
+ * compatibility.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ *
+ * @since 1.8
+ */
+ default Value invokeMethod(ThreadReference thread, Method method,
+ List<? extends Value> arguments, int options)
+ throws InvalidTypeException,
+ ClassNotLoadedException,
+ IncompatibleThreadStateException,
+ InvocationException {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/InternalException.java b/src/share/classes/com/sun/jdi/InternalException.java
new file mode 100644
index 0000000..b688ca5
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/InternalException.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 1999, 2013, 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.jdi;
+
+/**
+ * Thrown to indicate that an unexpected internal error has
+ * occurred.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public class InternalException extends RuntimeException {
+ private static final long serialVersionUID = -9171606393104480607L;
+ private int errorCode;
+
+ public InternalException() {
+ super();
+ this.errorCode = 0;
+ }
+
+ public InternalException(String s) {
+ super(s);
+ this.errorCode = 0;
+ }
+
+ public InternalException(int errorCode) {
+ super();
+ this.errorCode = errorCode;
+ }
+
+ public InternalException(String s, int errorCode) {
+ super(s);
+ this.errorCode = errorCode;
+ }
+
+ public int errorCode() {
+ return errorCode;
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/InvalidCodeIndexException.java b/src/share/classes/com/sun/jdi/InvalidCodeIndexException.java
new file mode 100644
index 0000000..928f741
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/InvalidCodeIndexException.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Thrown to indicate that the requested operation cannot be
+ * completed because the specified code index is not valid.
+ *
+ * @deprecated This exception is no longer thrown
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+@Deprecated
+public class InvalidCodeIndexException extends RuntimeException {
+ private static final long serialVersionUID = 7416010225133747805L;
+ public InvalidCodeIndexException() {
+ super();
+ }
+
+ public InvalidCodeIndexException(String s) {
+ super(s);
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/InvalidLineNumberException.java b/src/share/classes/com/sun/jdi/InvalidLineNumberException.java
new file mode 100644
index 0000000..0786d52
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/InvalidLineNumberException.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Thrown to indicate that the requested operation cannot be
+ * completed because the specified line number is not valid.
+ *
+ * @deprecated This exception is no longer thrown
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+@Deprecated
+public class InvalidLineNumberException extends RuntimeException {
+ private static final long serialVersionUID = 4048709912372692875L;
+ public InvalidLineNumberException() {
+ super();
+ }
+
+ public InvalidLineNumberException(String s) {
+ super(s);
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/InvalidStackFrameException.java b/src/share/classes/com/sun/jdi/InvalidStackFrameException.java
new file mode 100644
index 0000000..2f28d07
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/InvalidStackFrameException.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Thrown to indicate that the requested operation cannot be
+ * completed because the specified stack frame is no longer valid.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public class InvalidStackFrameException extends RuntimeException {
+ private static final long serialVersionUID = -1919378296505827922L;
+ public InvalidStackFrameException() {
+ super();
+ }
+
+ public InvalidStackFrameException(String s) {
+ super(s);
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/InvalidTypeException.java b/src/share/classes/com/sun/jdi/InvalidTypeException.java
new file mode 100644
index 0000000..299c447
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/InvalidTypeException.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Thrown to indicate a type mismatch in setting the value of a field
+ * or variable, or in specifying the return value of a method.
+ *
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public class InvalidTypeException extends Exception {
+ private static final long serialVersionUID = 2256667231949650806L;
+
+ public InvalidTypeException() {
+ super();
+ }
+
+ public InvalidTypeException(String s) {
+ super(s);
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/InvocationException.java b/src/share/classes/com/sun/jdi/InvocationException.java
new file mode 100644
index 0000000..1f8179e
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/InvocationException.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Thrown to indicate an exception occurred in an invoked method within
+ * the target VM.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public class InvocationException extends Exception {
+ private static final long serialVersionUID = 6066780907971918568L;
+ ObjectReference exception;
+
+ public InvocationException(ObjectReference exception) {
+ super("Exception occurred in target VM");
+ this.exception = exception;
+ }
+
+ public ObjectReference exception() {
+ return exception;
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/JDIPermission.java b/src/share/classes/com/sun/jdi/JDIPermission.java
new file mode 100644
index 0000000..7c3fad7
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/JDIPermission.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2004, 2013, 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.jdi;
+
+/**
+ * The <code>JDIPermission</code> class represents access rights to
+ * the <code>VirtualMachineManager</code>. This is the permission
+ * which the SecurityManager will check when code that is running with
+ * a SecurityManager requests access to the VirtualMachineManager, as
+ * defined in the Java Debug Interface (JDI) for the Java platform.
+ * <P>
+ * A <code>JDIPermission</code> object contains a name (also referred
+ * to as a "target name") but no actions list; you either have the
+ * named permission or you don't.
+ * <P>
+ * The following table provides a summary description of what the
+ * permission allows, and discusses the risks of granting code the
+ * permission.
+ * <P>
+ * <table border=1 cellpadding=5 summary="Table shows permission
+ * target name, what the permission allows, and associated risks">
+ * <tr>
+ * <th>Permission Target Name</th>
+ * <th>What the Permission Allows</th>
+ * <th>Risks of Allowing this Permission</th>
+ * </tr>
+ *
+ * <tr>
+ * <td>virtualMachineManager</td>
+ * <td>Ability to inspect and modify the JDI objects in the
+ * <code>VirtualMachineManager</code>
+ * </td>
+ * <td>This allows an attacker to control the
+ * <code>VirtualMachineManager</code> and cause the system to
+ * misbehave.
+ * </td>
+ * </tr>
+ *
+ * </table>
+ *
+ * <p>
+ * Programmers do not normally create JDIPermission objects directly.
+ * Instead they are created by the security policy code based on reading
+ * the security policy file.
+ *
+ * @author Tim Bell
+ * @since 1.5
+ *
+ * @see com.sun.jdi.Bootstrap
+ * @see java.security.BasicPermission
+ * @see java.security.Permission
+ * @see java.security.Permissions
+ * @see java.security.PermissionCollection
+ * @see java.lang.SecurityManager
+ *
+ */
+
+@jdk.Exported
+public final class JDIPermission extends java.security.BasicPermission {
+ private static final long serialVersionUID = -6988461416938786271L;
+ /**
+ * The <code>JDIPermission</code> class represents access rights to the
+ * <code>VirtualMachineManager</code>
+ * @param name Permission name. Must be "virtualMachineManager".
+ * @throws IllegalArgumentException if the name argument is invalid.
+ */
+ public JDIPermission(String name) {
+ super(name);
+ if (!name.equals("virtualMachineManager")) {
+ throw new IllegalArgumentException("name: " + name);
+ }
+ }
+
+ /**
+ * Constructs a new JDIPermission object.
+ *
+ * @param name Permission name. Must be "virtualMachineManager".
+ * @param actions Must be either null or the empty string.
+ * @throws IllegalArgumentException if arguments are invalid.
+ */
+ public JDIPermission(String name, String actions)
+ throws IllegalArgumentException {
+ super(name);
+ if (!name.equals("virtualMachineManager")) {
+ throw new IllegalArgumentException("name: " + name);
+ }
+ if (actions != null && actions.length() > 0) {
+ throw new IllegalArgumentException("actions: " + actions);
+ }
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/LocalVariable.java b/src/share/classes/com/sun/jdi/LocalVariable.java
new file mode 100644
index 0000000..4b15d91
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/LocalVariable.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * A local variable in the target VM. Each variable declared within a
+ * {@link Method} has its own LocalVariable object. Variables of the same
+ * name declared in different scopes have different LocalVariable objects.
+ * LocalVariables can be used alone to retrieve static information
+ * about their declaration, or can be used in conjunction with a
+ * {@link StackFrame} to set and get values.
+ *
+ * @see StackFrame
+ * @see Method
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+
+@jdk.Exported
+public interface LocalVariable extends Mirror, Comparable<LocalVariable> {
+
+ /**
+ * Gets the name of the local variable.
+ *
+ * @return a string containing the name.
+ */
+ String name();
+
+ /**
+ * Returns a text representation of the type
+ * of this variable.
+ * Where the type is the type specified in the declaration
+ * of this local variable.
+ * <P>
+ * This type name is always available even if
+ * the type has not yet been created or loaded.
+ *
+ * @return a String representing the
+ * type of this local variable.
+
+ */
+ String typeName();
+
+ /**
+ * Returns the type of this variable.
+ * Where the type is the type specified in the declaration
+ * of this local variable.
+ * <P>
+ * Note: if the type of this variable is a reference type (class,
+ * interface, or array) and it has not been created or loaded
+ * by the class loader of the enclosing class,
+ * then ClassNotLoadedException will be thrown.
+ * Also, a reference type may have been loaded but not yet prepared,
+ * in which case the type will be returned
+ * but attempts to perform some operations on the returned type
+ * (e.g. {@link ReferenceType#fields() fields()}) will throw
+ * a {@link ClassNotPreparedException}.
+ * Use {@link ReferenceType#isPrepared()} to determine if
+ * a reference type is prepared.
+ *
+ * @see Type
+ * @see Field#type() Field.type() - for usage examples
+ * @return the {@link Type} of this local variable.
+ * @throws ClassNotLoadedException if the type has not yet been loaded
+ * through the appropriate class loader.
+ */
+ Type type() throws ClassNotLoadedException;
+
+ /**
+ * Gets the JNI signature of the local variable.
+ *
+ * @see <a href="doc-files/signature.html">Type Signatures</a>
+ * @return a string containing the signature.
+ */
+ String signature();
+
+ /**
+ * Gets the generic signature for this variable if there is one.
+ * Generic signatures are described in the
+ * <cite>The Java™ Virtual Machine Specification</cite>.
+ *
+ * @return a string containing the generic signature, or <code>null</code>
+ * if there is no generic signature.
+ *
+ * @since 1.5
+ */
+ String genericSignature();
+
+ /**
+ * Determines whether this variable can be accessed from the given
+ * {@link StackFrame}.
+ *
+ * See {@link StackFrame#visibleVariables} for a complete description
+ * variable visibility in this interface.
+ *
+ * @param frame the StackFrame querying visibility
+ * @return <code>true</code> if this variable is visible;
+ * <code>false</code> otherwise.
+ * @throws IllegalArgumentException if the stack frame's method
+ * does not match this variable's method.
+ */
+ boolean isVisible(StackFrame frame);
+
+ /**
+ * Determines if this variable is an argument to its method.
+ *
+ * @return <code>true</code> if this variable is an argument;
+ * <code>false</code> otherwise.
+ */
+ boolean isArgument();
+
+ /**
+ * Compares the specified Object with this LocalVariable for equality.
+ *
+ * @return true if the Object is a LocalVariable, if both LocalVariables
+ * are contained in the same method (as determined by
+ * {@link Method#equals}), and if both LocalVariables mirror
+ * the same declaration within that method
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns the hash code value for this LocalVariable.
+ *
+ * @return the integer hash code
+ */
+ int hashCode();
+}
diff --git a/src/share/classes/com/sun/jdi/Locatable.java b/src/share/classes/com/sun/jdi/Locatable.java
new file mode 100644
index 0000000..4dae014
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/Locatable.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * A mirror that has a {@link Location}.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface Locatable {
+ /**
+ * Returns the {@link Location} of this mirror, if there
+ * is executable code associated with it. Note that both
+ * Java<SUP><FONT SIZE="-2">TM</FONT></SUP> programming
+ * language methods and native methods have executable code.
+ * Returns null for abstract methods, since abstract methods
+ * have no executable code.
+ *
+ * @return the {@link Location} of this mirror, or null if
+ * there is no executable code associated with it.
+ */
+ Location location();
+}
diff --git a/src/share/classes/com/sun/jdi/Location.java b/src/share/classes/com/sun/jdi/Location.java
new file mode 100644
index 0000000..e508781
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/Location.java
@@ -0,0 +1,262 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+import java.util.List;
+
+/**
+ * A point within the executing code of the target VM.
+ * Locations are used to identify the current position of
+ * a suspended thread (analogous to an instruction pointer or
+ * program counter register in native programs). They are also used
+ * to identify the position at which to set a breakpoint.
+ * <p>
+ * The availability of a line number for a location will
+ * depend on the level of debugging information available from the
+ * target VM.
+ * <p>
+ * Several mirror interfaces have locations. Each such mirror
+ * extends a {@link Locatable} interface.
+ * <p>
+ * <a name="strata"><b>Strata</b></a>
+ * <p>
+ * The source information for a Location is dependent on the
+ * <i>stratum</i> which is used. A stratum is a source code
+ * level within a sequence of translations. For example,
+ * say the baz program is written in the programming language
+ * "Foo" then translated to the language "Bar" and finally
+ * translated into the Java programming language. The
+ * Java programming language stratum is named
+ * <code>"Java"</code>, let's say the other strata are named
+ * "Foo" and "Bar". A given location (as viewed by the
+ * {@link #sourceName()} and {@link #lineNumber()} methods)
+ * might be at line 14 of "baz.foo" in the <code>"Foo"</code>
+ * stratum, line 23 of "baz.bar" in the <code>"Bar"</code>
+ * stratum and line 71 of the <code>"Java"</code> stratum.
+ * Note that while the Java programming language may have
+ * only one source file for a reference type, this restriction
+ * does not apply to other strata - thus each Location should
+ * be consulted to determine its source path.
+ * Queries which do not specify a stratum
+ * ({@link #sourceName()}, {@link #sourcePath()} and
+ * {@link #lineNumber()}) use the VM's default stratum
+ * ({@link VirtualMachine#getDefaultStratum()}).
+ * If the specified stratum (whether explicitly specified
+ * by a method parameter or implicitly as the VM's default)
+ * is <code>null</code> or is not available in the declaring
+ * type, the declaring type's default stratum is used
+ * ({@link #declaringType()}.{@link ReferenceType#defaultStratum()
+ * defaultStratum()}). Note that in the normal case, of code
+ * that originates as Java programming language source, there
+ * will be only one stratum (<code>"Java"</code>) and it will be
+ * returned as the default. To determine the available strata
+ * use {@link ReferenceType#availableStrata()}.
+ *
+ * @see com.sun.jdi.request.EventRequestManager
+ * @see StackFrame
+ * @see com.sun.jdi.event.BreakpointEvent
+ * @see com.sun.jdi.event.ExceptionEvent
+ * @see Locatable
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface Location extends Mirror, Comparable<Location> {
+
+ /**
+ * Gets the type to which this Location belongs. Normally
+ * the declaring type is a {@link ClassType}, but executable
+ * locations also may exist within the static initializer of an
+ * {@link InterfaceType}.
+ *
+ * @return the {@link ReferenceType} containing this Location.
+ */
+ ReferenceType declaringType();
+
+ /**
+ * Gets the method containing this Location.
+ *
+ * @return the location's {@link Method}.
+ */
+ Method method();
+
+ /**
+ * Gets the code position within this location's method.
+ *
+ * @return the long representing the position within the method
+ * or -1 if location is within a native method.
+ */
+ long codeIndex();
+
+ /**
+ * Gets an identifing name for the source corresponding to
+ * this location.
+ * <P>
+ * This method is equivalent to
+ * <code>sourceName(vm.getDefaultStratum())</code> -
+ * see {@link #sourceName(String)}
+ * for more information.
+ *
+ * @return a string specifying the source
+ * @throws AbsentInformationException if the source name is not
+ * known
+ */
+ String sourceName() throws AbsentInformationException;
+
+
+ /**
+ * Gets an identifing name for the source corresponding to
+ * this location. Interpretation of this string is the
+ * responsibility of the source repository mechanism.
+ * <P>
+ * Returned name is for the specified <i>stratum</i>
+ * (see the {@link Location class comment} for a
+ * description of strata).
+ * <P>
+ * The returned string is the unqualified name of the source
+ * file for this Location. For example,
+ * <CODE>java.lang.Thread</CODE> would return
+ * <CODE>"Thread.java"</CODE>.
+ *
+ * @param stratum The stratum to retrieve information from
+ * or <code>null</code> for the declaring type's
+ * default stratum.
+ *
+ * @return a string specifying the source
+ *
+ * @throws AbsentInformationException if the source name is not
+ * known
+ *
+ * @since 1.4
+ */
+ String sourceName(String stratum)
+ throws AbsentInformationException;
+
+ /**
+ * Gets the path to the source corresponding to this
+ * location.
+ * <P>
+ * This method is equivalent to
+ * <code>sourcePath(vm.getDefaultStratum())</code> -
+ * see {@link #sourcePath(String)}
+ * for more information.
+ *
+ * @return a string specifying the source
+ *
+ * @throws AbsentInformationException if the source name is not
+ * known
+ */
+ String sourcePath() throws AbsentInformationException;
+
+
+ /**
+ * Gets the path to the source corresponding to this
+ * location. Interpretation of this string is the
+ * responsibility of the source repository mechanism.
+ * <P>
+ * Returned path is for the specified <i>stratum</i>
+ * (see the {@link Location class comment} for a
+ * description of strata).
+ * <P>
+ * In the reference implementation, for strata which
+ * do not explicitly specify source path (the Java
+ * programming language stratum never does), the returned
+ * string is the package name of {@link #declaringType()}
+ * converted to a platform dependent path followed by the
+ * unqualified name of the source file for this Location
+ * ({@link #sourceName sourceName(stratum)}).
+ * For example, on a
+ * Windows platform, <CODE>java.lang.Thread</CODE>
+ * would return
+ * <CODE>"java\lang\Thread.java"</CODE>.
+ *
+ * @param stratum The stratum to retrieve information from
+ * or <code>null</code> for the declaring type's
+ * default stratum.
+ *
+ * @return a string specifying the source
+ *
+ * @throws AbsentInformationException if the source name is not
+ * known
+ *
+ * @since 1.4
+ */
+ String sourcePath(String stratum)
+ throws AbsentInformationException;
+
+ /**
+ * Gets the line number of this Location.
+ * <P>
+ * This method is equivalent to
+ * <code>lineNumber(vm.getDefaultStratum())</code> -
+ * see {@link #lineNumber(String)}
+ * for more information.
+ *
+ * @return an int specifying the line in the source, returns
+ * -1 if the information is not available; specifically, always
+ * returns -1 for native methods.
+ */
+ int lineNumber();
+
+ /**
+ * The line number of this Location. The line number is
+ * relative to the source specified by
+ * {@link #sourceName(String) sourceName(stratum)}.
+ * <P>
+ * Returned line number is for the specified <i>stratum</i>
+ * (see the {@link Location class comment} for a
+ * description of strata).
+ *
+ * @param stratum The stratum to retrieve information from
+ * or <code>null</code> for the declaring type's
+ * default stratum.
+ *
+ * @return an int specifying the line in the source, returns
+ * -1 if the information is not available; specifically, always
+ * returns -1 for native methods.
+ *
+ * @since 1.4
+ */
+ int lineNumber(String stratum);
+
+ /**
+ * Compares the specified Object with this Location for equality.
+ *
+ * @return true if the Object is a Location and if it refers to
+ * the same point in the same VM as this Location.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns the hash code value for this Location.
+ *
+ * @return the integer hash code
+ */
+ int hashCode();
+}
diff --git a/src/share/classes/com/sun/jdi/LongType.java b/src/share/classes/com/sun/jdi/LongType.java
new file mode 100644
index 0000000..f3cc736
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/LongType.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * The type of all primitive <code>long</code> values
+ * accessed in the target VM. Calls to {@link Value#type} will return an
+ * implementor of this interface.
+ *
+ * @see LongValue
+ *
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface LongType extends PrimitiveType {
+}
diff --git a/src/share/classes/com/sun/jdi/LongValue.java b/src/share/classes/com/sun/jdi/LongValue.java
new file mode 100644
index 0000000..98e25c2
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/LongValue.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Provides access to a primitive <code>long</code> value in
+ * the target VM.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface LongValue extends PrimitiveValue, Comparable<LongValue> {
+
+ /**
+ * Returns this LongValue as a long.
+ *
+ * @return the <code>long</code> mirrored by this object.
+ */
+ long value();
+
+ /**
+ * Compares the specified Object with this LongValue for equality.
+ *
+ * @return true if the Object is a LongValue and if applying "=="
+ * to the two mirrored primitives would evaluate to true; false
+ * otherwise.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns the hash code value for this LongValue.
+ *
+ * @return the integer hash code
+ */
+ int hashCode();
+}
diff --git a/src/share/classes/com/sun/jdi/Method.java b/src/share/classes/com/sun/jdi/Method.java
new file mode 100644
index 0000000..eb81b05
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/Method.java
@@ -0,0 +1,442 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+import java.util.List;
+
+/**
+ * A static or instance method in the target VM. See {@link TypeComponent}
+ * for general information about Field and Method mirrors.
+ *
+ * @see ObjectReference
+ * @see ReferenceType
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface Method extends TypeComponent, Locatable, Comparable<Method> {
+
+ /**
+ * Returns a text representation of the return type,
+ * as specified in the declaration of this method.
+ * <P>
+ * This type name is always available even if
+ * the type has not yet been created or loaded.
+ *
+ * @return a String containing the return type name.
+ */
+ String returnTypeName();
+
+ /**
+ * Returns the return type,
+ * as specified in the declaration of this method.
+ * <P>
+ * Note: if the return type of this method is a reference type (class,
+ * interface, or array) and it has not been created or loaded
+ * by the declaring type's class loader - that is,
+ * {@link TypeComponent#declaringType <CODE>declaringType()</CODE>}
+ * <CODE>.classLoader()</CODE>,
+ * then ClassNotLoadedException will be thrown.
+ * Also, a reference type may have been loaded but not yet prepared,
+ * in which case the type will be returned
+ * but attempts to perform some operations on the returned type
+ * (e.g. {@link ReferenceType#fields() fields()}) will throw
+ * a {@link ClassNotPreparedException}.
+ * Use {@link ReferenceType#isPrepared()} to determine if
+ * a reference type is prepared.
+ *
+ * @see Type
+ * @see Field#type() Field.type() - for usage examples
+ * @return the return {@link Type} of this method.
+ * @throws ClassNotLoadedException if the type has not yet been
+ * created or loaded
+ * through the appropriate class loader.
+ */
+ Type returnType() throws ClassNotLoadedException;
+
+ /**
+ * Returns a list containing a text representation of the type
+ * of each formal parameter of this method.
+ * <P>
+ * This list is always available even if
+ * the types have not yet been created or loaded.
+ *
+ * @return a {@link java.util.List List} of {@link String},
+ * one List element for each parameter of this method.
+ * Each element represents the type of a formal parameter
+ * as specified at compile-time.
+ * If the formal parameter was declared with an ellipsis, then
+ * it is represented as an array of the type before the ellipsis.
+ *
+ */
+ List<String> argumentTypeNames();
+
+ /**
+ * Returns a list containing the type
+ * of each formal parameter of this method.
+ * <P>
+ * Note: if there is any parameter whose type
+ * is a reference type (class, interface, or array)
+ * and it has not been created or loaded
+ * by the declaring type's class loader - that is,
+ * {@link TypeComponent#declaringType <CODE>declaringType()</CODE>}
+ * <CODE>.classLoader()</CODE>,
+ * then ClassNotLoadedException will be thrown.
+ * Also, a reference type may have been loaded but not yet prepared,
+ * in which case the list will be returned
+ * but attempts to perform some operations on the type
+ * (e.g. {@link ReferenceType#fields() fields()}) will throw
+ * a {@link ClassNotPreparedException}.
+ * Use {@link ReferenceType#isPrepared()} to determine if
+ * a reference type is prepared.
+ *
+ * @see Type
+ * @return return a {@link java.util.List List} of {@link Type},
+ * one List element for each parameter of this method.
+ * Each element represents the type of a formal parameter
+ * as specified at compile-time.
+ * If the formal parameter was declared with an ellipsis, then
+ * it is represented as an array of the type before the ellipsis.
+ *
+ * @throws ClassNotLoadedException if the type has not yet been loaded
+ * through the appropriate class loader.
+ */
+ List<Type> argumentTypes() throws ClassNotLoadedException;
+
+ /**
+ * Determine if this method is abstract.
+ *
+ * @return <code>true</code> if the method is declared abstract;
+ * false otherwise.
+ */
+ boolean isAbstract();
+
+ /**
+ * Determine if this method is a default method
+ *
+ * @return <code>true</code> if the method is declared default;
+ * false otherwise
+ *
+ * @since 1.8
+ */
+ default boolean isDefault() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Determine if this method is synchronized.
+ *
+ * @return <code>true</code> if the method is declared synchronized;
+ * false otherwise.
+ */
+ boolean isSynchronized();
+
+ /**
+ * Determine if this method is native.
+ *
+ * @return <code>true</code> if the method is declared native;
+ * false otherwise.
+ */
+ boolean isNative();
+
+ /**
+ * Determine if this method accepts a variable number of arguments.
+ *
+ * @return <code>true</code> if the method accepts a variable number
+ * of arguments, false otherwise.
+ *
+ * @since 1.5
+ */
+ boolean isVarArgs();
+
+ /**
+ * Determine if this method is a bridge method. Bridge
+ * methods are defined in
+ * <cite>The Java™ Language Specification</cite>.
+ *
+ * @return <code>true</code> if the method is a bridge method,
+ * false otherwise.
+ *
+ * @since 1.5
+ */
+ boolean isBridge();
+
+ /**
+ * Determine if this method is a constructor.
+ *
+ * @return <code>true</code> if the method is a constructor;
+ * false otherwise.
+ */
+ boolean isConstructor();
+
+ /**
+ * Determine if this method is a static initializer.
+ *
+ * @return <code>true</code> if the method is a static initializer;
+ * false otherwise.
+ */
+ boolean isStaticInitializer();
+
+ /**
+ * Determine if this method is obsolete.
+ *
+ * @return <code>true</code> if this method has been made obsolete by a
+ * {@link VirtualMachine#redefineClasses} operation.
+ *
+ * @since 1.4
+ */
+ boolean isObsolete();
+
+ /**
+ * Returns a list containing a {@link Location} object for
+ * each executable source line in this method.
+ * <P>
+ * This method is equivalent to
+ * <code>allLineLocations(vm.getDefaultStratum(),null)</code> -
+ * see {@link #allLineLocations(String,String)}
+ * for more information.
+ *
+ * @return a List of all source line {@link Location} objects.
+ *
+ * @throws AbsentInformationException if there is no line
+ * number information for this (non-native, non-abstract)
+ * method.
+ */
+ List<Location> allLineLocations() throws AbsentInformationException;
+
+ /**
+ * Returns a list containing a {@link Location} object for
+ * each executable source line in this method.
+ * <P>
+ * Each location maps a source line to a range of code
+ * indices.
+ * The beginning of the range can be determined through
+ * {@link Location#codeIndex}.
+ * The returned list is ordered by code index
+ * (from low to high).
+ * <P>
+ * The returned list may contain multiple locations for a
+ * particular line number, if the compiler and/or VM has
+ * mapped that line to two or more disjoint code index ranges.
+ * <P>
+ * If the method is native or abstract, an empty list is
+ * returned.
+ * <P>
+ * Returned list is for the specified <i>stratum</i>
+ * (see {@link Location} for a description of strata).
+ *
+ * @param stratum The stratum to retrieve information from
+ * or <code>null</code> for the {@link ReferenceType#defaultStratum()}
+ *
+ * @param sourceName Return locations only within this
+ * source file or <code>null</code> to return locations.
+ *
+ * @return a List of all source line {@link Location} objects.
+ *
+ * @throws AbsentInformationException if there is no line
+ * number information for this (non-native, non-abstract)
+ * method. Or if <i>sourceName</i> is non-<code>null</code>
+ * and source name information is not present.
+ *
+ * @since 1.4
+ */
+ List<Location> allLineLocations(String stratum, String sourceName)
+ throws AbsentInformationException;
+
+ /**
+ * Returns a List containing all {@link Location} objects
+ * that map to the given line number.
+ * <P>
+ * This method is equivalent to
+ * <code>locationsOfLine(vm.getDefaultStratum(), null,
+ * lineNumber)</code> -
+ * see {@link
+ * #locationsOfLine(java.lang.String,java.lang.String,int)}
+ * for more information.
+ *
+ * @param lineNumber the line number
+ *
+ * @return a List of {@link Location} objects that map to
+ * the given line number.
+ *
+ * @throws AbsentInformationException if there is no line
+ * number information for this method.
+ */
+ List<Location> locationsOfLine(int lineNumber) throws AbsentInformationException;
+
+ /**
+ * Returns a List containing all {@link Location} objects
+ * that map to the given line number and source name.
+ * <P>
+ * Returns a list containing each {@link Location} that maps
+ * to the given line. The returned list will contain a
+ * location for each disjoint range of code indices that have
+ * been assigned to the given line by the compiler and/or
+ * VM. Each returned location corresponds to the beginning of
+ * this range. An empty list will be returned if there is no
+ * executable code at the specified line number; specifically,
+ * native and abstract methods will always return an empty
+ * list.
+ * <p>
+ * Returned list is for the specified <i>stratum</i>
+ * (see {@link Location} for a description of strata).
+ *
+ * @param stratum the stratum to use for comparing line number
+ * and source name, or null to use the default
+ * stratum
+ * @param sourceName the source name containing the
+ * line number, or null to match all
+ * source names
+ * @param lineNumber the line number
+ *
+ * @return a List of {@link Location} objects that map to
+ * the given line number.
+ *
+ * @throws AbsentInformationException if there is no line
+ * number information for this method.
+ * Or if <i>sourceName</i> is non-<code>null</code>
+ * and source name information is not present.
+ *
+ * @since 1.4
+ */
+ List<Location> locationsOfLine(String stratum, String sourceName,
+ int lineNumber)
+ throws AbsentInformationException;
+
+ /**
+ * Returns a {@link Location} for the given code index.
+ *
+ * @return the {@link Location} corresponding to the
+ * given code index or null if the specified code index is not a
+ * valid code index for this method (native and abstract methods
+ * will always return null).
+ */
+ Location locationOfCodeIndex(long codeIndex);
+
+ /**
+ * Returns a list containing each {@link LocalVariable} declared
+ * in this method. The list includes any variable declared in any
+ * scope within the method. It may contain multiple variables of the
+ * same name declared within disjoint scopes. Arguments are considered
+ * local variables and will be present in the returned list.
+ *
+ * If local variable information is not available, values of
+ * actual arguments to method invocations can be obtained
+ * by using the method {@link StackFrame#getArgumentValues()}
+ *
+ * @return the list of {@link LocalVariable} objects which mirror
+ * local variables declared in this method in the target VM.
+ * If there are no local variables, a zero-length list is returned.
+ * @throws AbsentInformationException if there is no variable
+ * information for this method.
+ * Generally, local variable information is not available for
+ * native or abstract methods (that is, their argument name
+ * information is not available), thus they will throw this exception.
+ */
+ List<LocalVariable> variables() throws AbsentInformationException;
+
+ /**
+ * Returns a list containing each {@link LocalVariable} of a
+ * given name in this method.
+ * Multiple variables can be returned
+ * if the same variable name is used in disjoint
+ * scopes within the method.
+ *
+ * @return the list of {@link LocalVariable} objects of the given
+ * name.
+ * If there are no matching local variables, a zero-length list
+ * is returned.
+ * @throws AbsentInformationException if there is no variable
+ * information for this method.
+ * Generally, local variable information is not available for
+ * native or abstract methods (that is, their argument name
+ * information is not available), thus they will throw this exception.
+ */
+ List<LocalVariable> variablesByName(String name)
+ throws AbsentInformationException;
+
+ /**
+ * Returns a list containing each {@link LocalVariable} that is
+ * declared as an argument of this method.
+ *
+ * If local variable information is not available, values of
+ * actual arguments to method invocations can be obtained
+ * by using the method {@link StackFrame#getArgumentValues()}
+ *
+ * @return the list of {@link LocalVariable} arguments.
+ * If there are no arguments, a zero-length list is returned.
+ * @throws AbsentInformationException if there is no variable
+ * information for this method.
+ * Generally, local variable information is not available for
+ * native or abstract methods (that is, their argument name
+ * information is not available), thus they will throw this exception.
+ */
+ List<LocalVariable> arguments() throws AbsentInformationException;
+
+ /**
+ * Returns an array containing the bytecodes for this method.
+ * <P>
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canGetBytecodes()}
+ * to determine if the operation is supported.
+ *
+ * @return the array of bytecodes; abstract and native methods
+ * will return a zero-length array.
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support
+ * the retrieval of bytecodes.
+ */
+ byte[] bytecodes();
+
+ /**
+ * Returns the {@link Location} of this method, if there
+ * is executable code associated with it.
+ *
+ * @return the {@link Location} of this mirror, or null if
+ * this is an abstract method; native methods will return a
+ * Location object whose codeIndex is -1.
+ */
+ Location location();
+
+ /**
+ * Compares the specified Object with this method for equality.
+ *
+ * @return true if the Object is a method and if both
+ * mirror the same method (declared in the same class or interface, in
+ * the same VM).
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns the hash code value for this Method.
+ *
+ * @return the integer hash code
+ */
+ int hashCode();
+}
diff --git a/src/share/classes/com/sun/jdi/Mirror.java b/src/share/classes/com/sun/jdi/Mirror.java
new file mode 100644
index 0000000..eb01abf
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/Mirror.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * A proxy used by a debugger to examine or manipulate some entity
+ * in another virtual machine. Mirror is the root of the
+ * interface hierarchy for this package. Mirrors can be proxies for objects
+ * in the target VM ({@link ObjectReference}), primitive values
+ * (for example, {@link IntegerValue}), types (for example,
+ * {@link ReferenceType}), dynamic application state (for example,
+ * {@link StackFrame}), and even debugger-specific constructs (for example,
+ * {@link com.sun.jdi.request.BreakpointRequest}).
+ * The {@link VirtualMachine} itself is also
+ * considered a mirror, representing the composite state of the
+ * target VM.
+ * <P>
+ * There is no guarantee that a particular entity in the target VM will map
+ * to a single instance of Mirror. Implementors are free to decide
+ * whether a single mirror will be used for some or all mirrors. Clients
+ * of this interface should always use <code>equals</code> to compare
+ * two mirrors for equality.
+ * <p>
+ * Any method on a {@link com.sun.jdi.Mirror} that takes a <code>Mirror</code> as an
+ * parameter directly or indirectly (e.g., as a element in a <code>List</code>) will
+ * throw {@link com.sun.jdi.VMMismatchException} if the mirrors are from different
+ * virtual machines.
+ *
+ * @see VirtualMachine
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface Mirror {
+
+ /**
+ * Gets the VirtualMachine to which this
+ * Mirror belongs. A Mirror must be associated
+ * with a VirtualMachine to have any meaning.
+ *
+ * @return the {@link VirtualMachine} for which this mirror is a proxy.
+ */
+ VirtualMachine virtualMachine();
+
+ /**
+ * Returns a String describing this mirror
+ *
+ * @return a string describing this mirror.
+ */
+ String toString();
+}
diff --git a/src/share/classes/com/sun/jdi/MonitorInfo.java b/src/share/classes/com/sun/jdi/MonitorInfo.java
new file mode 100644
index 0000000..ef72517
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/MonitorInfo.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2005, 2013, 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.jdi;
+
+/**
+ * Information about a monitor owned by a thread.
+ *
+ * @author Swamy Venkataramanappa
+ * @since 1.6
+ */
+
+@jdk.Exported
+public interface MonitorInfo extends Mirror {
+
+ /**
+ * Returns the {@link ObjectReference} object for the monitor.
+ * @return the {@link ObjectReference} object for the monitor.
+ * @throws InvalidStackFrameException if the associated stack
+ * frame has become invalid. Once the frame's thread is resumed,
+ * the stack frame is no longer valid.
+ * @see ThreadReference#ownedMonitorsAndFrames
+ * @since 1.6
+ */
+ public ObjectReference monitor();
+
+ /**
+ * Returns the stack depth at which this monitor was
+ * acquired by the owning thread. Returns -1 if the
+ * implementation cannot determine the stack depth
+ * (e.g., for monitors acquired by JNI MonitorEnter).
+ * @return the stack depth at which this monitor was
+ * acquired by the owning thread.
+ * @throws InvalidStackFrameException if the associated stack
+ * frame has become invalid. Once the frame's thread is resumed,
+ * the stack frame is no longer valid.
+ * @see ThreadReference#ownedMonitorsAndFrames
+ */
+ public int stackDepth();
+
+ /**
+ * Returns a {@link ThreadReference} object for the thread that
+ * owns the monitor.
+ * @return a {@link ThreadReference} object for the thread that
+ * owns the monitor.
+ * @throws InvalidStackFrameException if the associated stack
+ * frame has become invalid. Once the frame's thread is resumed,
+ * the stack frame is no longer valid.
+ * @see ThreadReference#frame
+ */
+ ThreadReference thread();
+}
diff --git a/src/share/classes/com/sun/jdi/NativeMethodException.java b/src/share/classes/com/sun/jdi/NativeMethodException.java
new file mode 100644
index 0000000..6379701
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/NativeMethodException.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 1999, 2013, 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.jdi;
+
+/**
+ * Thrown to indicate an operation cannot be completed because
+ * it is not valid for a native method.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public class NativeMethodException extends RuntimeException {
+
+ private static final long serialVersionUID = 3924951669039469992L;
+ public NativeMethodException() {
+ super();
+ }
+
+ public NativeMethodException(String message) {
+ super(message);
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/ObjectCollectedException.java b/src/share/classes/com/sun/jdi/ObjectCollectedException.java
new file mode 100644
index 0000000..b88395e
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/ObjectCollectedException.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Thrown to indicate that the requested operation cannot be
+ * completed because the specified object has been garbage collected.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public class ObjectCollectedException extends RuntimeException {
+ private static final long serialVersionUID = -1928428056197269588L;
+ public ObjectCollectedException() {
+ super();
+ }
+
+ public ObjectCollectedException(String s) {
+ super(s);
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/ObjectReference.java b/src/share/classes/com/sun/jdi/ObjectReference.java
new file mode 100644
index 0000000..b6bf5a3
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/ObjectReference.java
@@ -0,0 +1,445 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * An object that currently exists in the target VM. An ObjectReference
+ * mirrors only the object itself and is not specific to any
+ * {@link Field} or {@link LocalVariable} to which it is currently
+ * assigned. An ObjectReference can
+ * have 0 or more references from field(s) and/or variable(s).
+ * <p>
+ * Any method on <code>ObjectReference</code> which directly or
+ * indirectly takes <code>ObjectReference</code> as an parameter may throw
+ * {@link com.sun.jdi.VMDisconnectedException} if the target VM is
+ * disconnected and the {@link com.sun.jdi.event.VMDisconnectEvent} has been or is
+ * available to be read from the {@link com.sun.jdi.event.EventQueue}.
+ * <p>
+ * Any method on <code>ObjectReference</code> which directly or
+ * indirectly takes <code>ObjectReference</code> as an parameter may throw
+ * {@link com.sun.jdi.VMOutOfMemoryException} if the target VM has run out of memory.
+ * <p>
+ * Any method on <code>ObjectReference</code> or which directly or indirectly takes
+ * <code>ObjectReference</code> as parameter may throw
+ * {@link com.sun.jdi.ObjectCollectedException} if the mirrored object has been
+ * garbage collected.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ObjectReference extends Value {
+
+ /**
+ * Gets the {@link ReferenceType} that mirrors the type
+ * of this object. The type may be a subclass or implementor of the
+ * declared type of any field or variable which currently holds it.
+ * For example, right after the following statement.
+ * <p>
+ * <code>Object obj = new String("Hello, world!");</code>
+ * <p>
+ * The ReferenceType of obj will mirror java.lang.String and not
+ * java.lang.Object.
+ * <p>
+ * The type of an object never changes, so this method will
+ * always return the same ReferenceType over the lifetime of the
+ * mirrored object.
+ * <p>
+ * The returned ReferenceType will be a {@link ClassType} or
+ * {@link ArrayType} and never an {@link InterfaceType}.
+ *
+ * @return the {@link ReferenceType} for this object.
+ */
+ ReferenceType referenceType();
+
+ /**
+ * Gets the value of a given instance or static field in this object.
+ * The Field must be valid for this ObjectReference;
+ * that is, it must be from
+ * the mirrored object's class or a superclass of that class.
+ *
+ * @param sig the field containing the requested value
+ * @return the {@link Value} of the instance field.
+ * @throws java.lang.IllegalArgumentException if the field is not valid for
+ * this object's class.
+ */
+ Value getValue(Field sig);
+
+ /**
+ * Gets the value of multiple instance and/or static fields in this object.
+ * The Fields must be valid for this ObjectReference;
+ * that is, they must be from
+ * the mirrored object's class or a superclass of that class.
+ *
+ * @param fields a list of {@link Field} objects containing the
+ * requested values.
+ * @return a Map of the requested {@link Field} objects with
+ * their {@link Value}.
+ * @throws java.lang.IllegalArgumentException if any field is not valid for
+ * this object's class.
+ */
+ Map<Field,Value> getValues(List<? extends Field> fields);
+
+ /**
+ * Sets the value of a given instance or static field in this object.
+ * The {@link Field} must be valid for this ObjectReference; that is,
+ * it must be from the mirrored object's class or a superclass of that class.
+ * If static, the field must not be final.
+ * <p>
+ * Object values must be assignment compatible with the field type
+ * (This implies that the field type must be loaded through the
+ * enclosing class's class loader). Primitive values must be
+ * either assignment compatible with the field type or must be
+ * convertible to the field type without loss of information.
+ * See section 5.2 of
+ * <cite>The Java™ Language Specification</cite>
+ * for more information on assignment
+ * compatibility.
+ *
+ * @param field the field containing the requested value
+ * @param value the new value to assign
+ * @throws java.lang.IllegalArgumentException if the field is not valid for
+ * this object's class.
+ * @throws InvalidTypeException if the value's type does not match
+ * the field's type.
+ * @throws ClassNotLoadedException if 'value' is not null, and the field
+ * type has not yet been loaded through the appropriate class loader.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ */
+ void setValue(Field field, Value value)
+ throws InvalidTypeException, ClassNotLoadedException;
+
+ /** Perform method invocation with only the invoking thread resumed */
+ static final int INVOKE_SINGLE_THREADED = 0x1;
+ /** Perform non-virtual method invocation */
+ static final int INVOKE_NONVIRTUAL = 0x2;
+
+ /**
+ * Invokes the specified {@link Method} on this object in the
+ * target VM. The
+ * specified method can be defined in this object's class,
+ * in a superclass of this object's class, or in an interface
+ * implemented by this object. The method may be a static method
+ * or an instance method, but not a static initializer or constructor.
+ * Use {@link ClassType#newInstance} to create a new object and
+ * run its constructor.
+ * <p>
+ * The method invocation will occur in the specified thread.
+ * Method invocation can occur only if the specified thread
+ * has been suspended by an event which occurred in that thread.
+ * Method invocation is not supported
+ * when the target VM has been suspended through
+ * {@link VirtualMachine#suspend} or when the specified thread
+ * is suspended through {@link ThreadReference#suspend}.
+ * <p>
+ * The specified method is invoked with the arguments in the specified
+ * argument list. The method invocation is synchronous; this method
+ * does not return until the invoked method returns in the target VM.
+ * If the invoked method throws an exception, this method
+ * will throw an {@link InvocationException} which contains
+ * a mirror to the exception object thrown.
+ * <p>
+ * Object arguments must be assignment compatible with the argument type
+ * (This implies that the argument type must be loaded through the
+ * enclosing class's class loader). Primitive arguments must be
+ * either assignment compatible with the argument type or must be
+ * convertible to the argument type without loss of information.
+ * If the method being called accepts a variable number of arguments,
+ * then the last argument type is an array of some component type.
+ * The argument in the matching position can be omitted, or can be null,
+ * an array of the same component type, or an argument of the
+ * component type followed by any number of other arguments of the same
+ * type. If the argument is omitted, then a 0 length array of the
+ * component type is passed. The component type can be a primitive type.
+ * Autoboxing is not supported.
+ *
+ * See section 5.2 of
+ * <cite>The Java™ Language Specification</cite>
+ * for more information on assignment compatibility.
+ * <p>
+ * By default, the method is invoked using dynamic lookup as
+ * documented in section 15.12.4.4 of
+ * <cite>The Java™ Language Specification</cite>
+ * in particular, overriding based on the runtime type of the object
+ * mirrored by this {@link ObjectReference} will occur. This
+ * behavior can be changed by specifying the
+ * {@link #INVOKE_NONVIRTUAL} bit flag in the <code>options</code>
+ * argument. If this flag is set, the specified method is invoked
+ * whether or not it is overridden for this object's runtime type.
+ * The method, in this case, must have an implementation, either in a class
+ * or an interface. This option is useful for performing method invocations
+ * like those done with the <code>super</code> keyword in the Java programming
+ * language.
+ * <p>
+ * By default, all threads in the target VM are resumed while
+ * the method is being invoked if they were previously
+ * suspended by an event or by {@link VirtualMachine#suspend} or
+ * {@link ThreadReference#suspend}. This is done to prevent the deadlocks
+ * that will occur if any of the threads own monitors
+ * that will be needed by the invoked method.
+ * Note, however, that this implicit resume acts exactly like
+ * {@link ThreadReference#resume}, so if the thread's suspend
+ * count is greater than 1, it will remain in a suspended state
+ * during the invocation and thus a deadlock could still occur.
+ * By default, when the invocation completes,
+ * all threads in the target VM are suspended, regardless their state
+ * before the invocation.
+ * It is possible that
+ * breakpoints or other events might occur during the invocation.
+ * This can cause deadlocks as described above. It can also cause a deadlock
+ * if invokeMethod is called from the client's event handler thread. In this
+ * case, this thread will be waiting for the invokeMethod to complete and
+ * won't read the EventSet that comes in for the new event. If this
+ * new EventSet is SUSPEND_ALL, then a deadlock will occur because no
+ * one will resume the EventSet. To avoid this, all EventRequests should
+ * be disabled before doing the invokeMethod, or the invokeMethod should
+ * not be done from the client's event handler thread.
+ * <p>
+ * The resumption of other threads during the invocation can be prevented
+ * by specifying the {@link #INVOKE_SINGLE_THREADED}
+ * bit flag in the <code>options</code> argument; however,
+ * there is no protection against or recovery from the deadlocks
+ * described above, so this option should be used with great caution.
+ * Only the specified thread will be resumed (as described for all
+ * threads above). Upon completion of a single threaded invoke, the invoking thread
+ * will be suspended once again. Note that any threads started during
+ * the single threaded invocation will not be suspended when the
+ * invocation completes.
+ * <p>
+ * If the target VM is disconnected during the invoke (for example, through
+ * {@link VirtualMachine#dispose}) the method invocation continues.
+ *
+ * @param thread the thread in which to invoke.
+ * @param method the {@link Method} to invoke.
+ * @param arguments the list of {@link Value} arguments bound to the
+ * invoked method. Values from the list are assigned to arguments
+ * in the order they appear in the method signature.
+ * @param options the integer bit flag options.
+ * @return a {@link Value} mirror of the invoked method's return value.
+ * @throws java.lang.IllegalArgumentException if the method is not
+ * a member of this object's class, if the size of the argument list
+ * does not match the number of declared arguments for the method,
+ * if the method is a constructor or static intializer, or
+ * if {@link #INVOKE_NONVIRTUAL} is specified and the method is
+ * either abstract or a non-default interface member.
+ * @throws {@link InvalidTypeException} if any argument in the
+ * argument list is not assignable to the corresponding method argument
+ * type.
+ * @throws ClassNotLoadedException if any argument type has not yet been loaded
+ * through the appropriate class loader.
+ * @throws IncompatibleThreadStateException if the specified thread has not
+ * been suspended by an event.
+ * @throws InvocationException if the method invocation resulted in
+ * an exception in the target VM.
+ * @throws InvalidTypeException If the arguments do not meet this requirement --
+ * Object arguments must be assignment compatible with the argument
+ * type. This implies that the argument type must be
+ * loaded through the enclosing class's class loader.
+ * Primitive arguments must be either assignment compatible with the
+ * argument type or must be convertible to the argument type without loss
+ * of information. See JLS section 5.2 for more information on assignment
+ * compatibility.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ */
+ Value invokeMethod(ThreadReference thread, Method method,
+ List<? extends Value> arguments, int options)
+ throws InvalidTypeException,
+ ClassNotLoadedException,
+ IncompatibleThreadStateException,
+ InvocationException;
+
+ /**
+ * Prevents garbage collection for this object. By default all
+ * {@link ObjectReference} values returned by JDI may be collected
+ * at any time the target VM is running. A call to this method
+ * guarantees that the object will not be collected.
+ * {@link #enableCollection} can be used to allow collection once
+ * again.
+ * <p>
+ * Calls to this method are counted. Every call to this method
+ * requires a corresponding call to {@link #enableCollection} before
+ * garbage collection is re-enabled.
+ * <p>
+ * Note that while the target VM is suspended, no garbage collection
+ * will occur because all threads are suspended. The typical
+ * examination of variables, fields, and arrays during the suspension
+ * is safe without explicitly disabling garbage collection.
+ * <p>
+ * This method should be used sparingly, as it alters the
+ * pattern of garbage collection in the target VM and,
+ * consequently, may result in application behavior under the
+ * debugger that differs from its non-debugged behavior.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only
+ * -see {@link VirtualMachine#canBeModified()}.
+ */
+ void disableCollection();
+
+ /**
+ * Permits garbage collection for this object. By default all
+ * {@link ObjectReference} values returned by JDI may be collected
+ * at any time the target VM is running. A call to this method
+ * is necessary only if garbage collection was previously disabled
+ * with {@link #disableCollection}.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only
+ * -see {@link VirtualMachine#canBeModified()}.
+ */
+ void enableCollection();
+
+ /**
+ * Determines if this object has been garbage collected in the target
+ * VM.
+ *
+ * @return <code>true</code> if this {@link ObjectReference} has been collected;
+ * <code>false</code> otherwise.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only
+ * -see {@link VirtualMachine#canBeModified()}.
+ */
+ boolean isCollected();
+
+ /**
+ * Returns a unique identifier for this ObjectReference.
+ * It is guaranteed to be unique among all
+ * ObjectReferences from the same VM that have not yet been disposed.
+ * The guarantee applies as long
+ * as this ObjectReference has not yet been disposed.
+ *
+ * @return a long unique ID
+ */
+ long uniqueID();
+
+ /**
+ * Returns a List containing a {@link ThreadReference} for
+ * each thread currently waiting for this object's monitor.
+ * See {@link ThreadReference#currentContendedMonitor} for
+ * information about when a thread is considered to be waiting
+ * for a monitor.
+ * <p>
+ * Not all target VMs support this operation. See
+ * VirtualMachine#canGetMonitorInfo to determine if the
+ * operation is supported.
+ *
+ * @return a List of {@link ThreadReference} objects. The list
+ * has zero length if no threads are waiting for the monitor.
+ * @throws java.lang.UnsupportedOperationException if the
+ * target VM does not support this operation.
+ * @throws IncompatibleThreadStateException if any
+ * waiting thread is not suspended
+ * in the target VM
+ */
+ List<ThreadReference> waitingThreads()
+ throws IncompatibleThreadStateException;
+
+ /**
+ * Returns an {@link ThreadReference} for the thread, if any,
+ * which currently owns this object's monitor.
+ * See {@link ThreadReference#ownedMonitors} for a definition
+ * of ownership.
+ * <p>
+ * Not all target VMs support this operation. See
+ * VirtualMachine#canGetMonitorInfo to determine if the
+ * operation is supported.
+ *
+ * @return the {@link ThreadReference} which currently owns the
+ * monitor, or null if it is unowned.
+ *
+ * @throws java.lang.UnsupportedOperationException if the
+ * target VM does not support this operation.
+ * @throws IncompatibleThreadStateException if the owning thread is
+ * not suspended in the target VM
+ */
+ ThreadReference owningThread() throws IncompatibleThreadStateException;
+
+ /**
+ * Returns the number times this object's monitor has been
+ * entered by the current owning thread.
+ * See {@link ThreadReference#ownedMonitors} for a definition
+ * of ownership.
+ * <p>
+ * Not all target VMs support this operation. See
+ * VirtualMachine#canGetMonitorInfo to determine if the
+ * operation is supported.
+ *
+ * @see #owningThread
+ * @return the integer count of the number of entries.
+ *
+ * @throws java.lang.UnsupportedOperationException if the
+ * target VM does not support this operation.
+ * @throws IncompatibleThreadStateException if the owning thread is
+ * not suspended in the target VM
+ */
+ int entryCount() throws IncompatibleThreadStateException;
+
+ /**
+ * Returns objects that directly reference this object.
+ * Only objects that are reachable for the purposes of garbage collection
+ * are returned. Note that an object can also be referenced in other ways,
+ * such as from a local variable in a stack frame, or from a JNI global
+ * reference. Such non-object referrers are not returned by this method.
+ * <p>
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canGetInstanceInfo()}
+ * to determine if the operation is supported.
+ *
+ * @see VirtualMachine#instanceCounts(List)
+ * @see ReferenceType#instances(long)
+
+ * @param maxReferrers The maximum number of referring objects to return.
+ * Must be non-negative. If zero, all referring
+ * objects are returned.
+ * @return a of List of {@link ObjectReference} objects. If there are
+ * no objects that reference this object, a zero-length list is returned..
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation - see
+ * {@link VirtualMachine#canGetInstanceInfo() canGetInstanceInfo()}
+ * @throws java.lang.IllegalArgumentException if maxReferrers is less
+ * than zero.
+ * @since 1.6
+ */
+ List<ObjectReference> referringObjects(long maxReferrers);
+
+
+ /**
+ * Compares the specified Object with this ObjectReference for equality.
+ *
+ * @return true if the Object is an ObjectReference, if the
+ * ObjectReferences belong to the same VM, and if applying the
+ * "==" operator on the mirrored objects in that VM evaluates to true.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns the hash code value for this ObjectReference.
+ *
+ * @return the integer hash code
+ */
+ int hashCode();
+}
diff --git a/src/share/classes/com/sun/jdi/PathSearchingVirtualMachine.java b/src/share/classes/com/sun/jdi/PathSearchingVirtualMachine.java
new file mode 100644
index 0000000..7a75fd6
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/PathSearchingVirtualMachine.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 1999, 2013, 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.jdi;
+
+import java.util.List;
+
+/**
+ * A virtual machine which searches for classes through paths
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public interface PathSearchingVirtualMachine extends VirtualMachine {
+ /**
+ * Get the class path for this virtual machine.
+ *
+ * @return {@link List} of components of the classpath,
+ * each represented by a {@link String}.
+ */
+ List<String> classPath();
+
+ /**
+ * Get the boot class path for this virtual machine.
+ *
+ * @return {@link List} of components of the boot class path,
+ * each represented by a {@link String}.
+ */
+ List<String> bootClassPath();
+
+ /**
+ * Get the base directory used for path searching. Relative directories
+ * in the class path and boot class path can be resolved through
+ * this directory name.
+ *
+ * @return the base directory.
+ */
+ String baseDirectory();
+}
diff --git a/src/share/classes/com/sun/jdi/PrimitiveType.java b/src/share/classes/com/sun/jdi/PrimitiveType.java
new file mode 100644
index 0000000..9cc721f
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/PrimitiveType.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * The type associated with non-object values in a target VM.
+ * Instances of one of the sub-interfaces of this interface will be
+ * returned from {@link Value#type} for all {@link PrimitiveValue} objects.
+ *
+ * @see PrimitiveValue
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface PrimitiveType extends Type {
+}
diff --git a/src/share/classes/com/sun/jdi/PrimitiveValue.java b/src/share/classes/com/sun/jdi/PrimitiveValue.java
new file mode 100644
index 0000000..9601488
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/PrimitiveValue.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * The value assigned to a field or variable of primitive type in a
+ * target VM. Each primitive values is accessed through a subinterface
+ * of this interface.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface PrimitiveValue extends Value {
+
+ /**
+ * Converts this value to a BooleanValue and returns the result
+ * as a boolean.
+ *
+ * @return <code>true</code> if this value is non-zero (or
+ * <code>true</code> if already a BooleanValue); false otherwise.
+ */
+ boolean booleanValue();
+
+ /**
+ * Converts this value to a ByteValue and returns the result
+ * as a byte. The value will be narrowed as
+ * necessary, and magnitude or precision information
+ * may be lost (as if the primitive had been cast to a byte).
+ *
+ * @return the value, converted to byte
+ */
+ byte byteValue();
+
+ /**
+ * Converts this value to a CharValue and returns the result
+ * as a char. The value will be narrowed or widened as
+ * necessary, and magnitude or precision information
+ * may be lost (as if the primitive had been cast to a char,
+ * in the narrowing case).
+ *
+ * @return the value, converted to char
+ */
+ char charValue();
+
+ /**
+ * Converts this value to a ShortValue and returns the result
+ * as a short. The value will be narrowed or widened as
+ * necessary, and magnitude or precision information
+ * may be lost (as if the primitive had been cast to a short,
+ * in the narrowing case).
+ *
+ * @return the value, converted to short
+ */
+ short shortValue();
+
+ /**
+ * Converts this value to an IntegerValue and returns the result
+ * as an int. The value will be narrowed or widened as
+ * necessary, and magnitude or precision information
+ * may be lost (as if the primitive had been cast to an int,
+ * in the narrowing case).
+ *
+ * @return the value, converted to int
+ */
+ int intValue();
+
+ /**
+ * Converts this value to a LongValue and returns the result
+ * as a long. The value will be narrowed or widened as
+ * necessary, and magnitude or precision information
+ * may be lost (as if the primitive had been cast to a long,
+ * in the narrowing case).
+ *
+ * @return the value, converted to long
+ */
+ long longValue();
+
+ /**
+ * Converts this value to a FloatValue and returns the result
+ * as a float. The value will be narrowed or widened as
+ * necessary, and magnitude or precision information
+ * may be lost (as if the primitive had been cast to a float,
+ * in the narrowing case).
+ *
+ * @return the value, converted to float
+ */
+ float floatValue();
+
+ /**
+ * Converts this value to a DoubleValue and returns the result
+ * as a double. The value will be widened as
+ * necessary, and precision information
+ * may be lost.
+ *
+ * @return the value, converted to double
+ */
+ double doubleValue();
+}
diff --git a/src/share/classes/com/sun/jdi/ReferenceType.java b/src/share/classes/com/sun/jdi/ReferenceType.java
new file mode 100644
index 0000000..43d1c02
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/ReferenceType.java
@@ -0,0 +1,831 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The type of an object in a target VM. ReferenceType encompasses
+ * classes, interfaces, and array types as defined in
+ * <cite>The Java™ Language Specification</cite>.
+ * All ReferenceType objects belong to one of the following
+ * subinterfaces:
+ * {@link ClassType} for classes,
+ * {@link InterfaceType} for interfaces, and
+ * {@link ArrayType} for arrays.
+ * Note that primitive classes (for example, the
+ * {@link ClassObjectReference#reflectedType() reflected type} of
+ * {@link java.lang.Integer#TYPE Integer.TYPE})
+ * are represented as ClassType.
+ * The VM creates Class objects for all three, so from the VM perspective,
+ * each ReferenceType maps to a distinct Class object.
+ * <p>
+ * ReferenceTypes can
+ * be obtained by querying a particular {@link ObjectReference} for its
+ * type or by getting a list of all reference types from the
+ * {@link VirtualMachine}.
+ * <p>
+ * ReferenceType provides access to static type information such as
+ * methods and fields and provides access to dynamic type
+ * information such as the corresponding Class object and the classloader.
+ * <p>
+ * Any method on <code>ReferenceType</code> which directly or
+ * indirectly takes <code>ReferenceType</code> as an parameter may throw
+ * {@link com.sun.jdi.VMDisconnectedException} if the target VM is
+ * disconnected and the {@link com.sun.jdi.event.VMDisconnectEvent} has been or is
+ * available to be read from the {@link com.sun.jdi.event.EventQueue}.
+ * <p>
+ * Any method on <code>ReferenceType</code> which directly or
+ * indirectly takes <code>ReferenceType</code> as an parameter may throw
+ * {@link com.sun.jdi.VMOutOfMemoryException} if the target VM has run out of memory.
+ * <p>
+ * Any method on <code>ReferenceType</code> or which directly or indirectly takes
+ * <code>ReferenceType</code> as parameter may throw
+ * {@link com.sun.jdi.ObjectCollectedException} if the mirrored type has been unloaded.
+ *
+ * @see ObjectReference
+ * @see ObjectReference#referenceType
+ * @see VirtualMachine
+ * @see VirtualMachine#allClasses
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ReferenceType
+ extends Type, Comparable<ReferenceType>, Accessible
+{
+
+ /**
+ * Gets the fully qualified name of this type. The returned name
+ * is formatted as it might appear in a Java programming langauge
+ * declaration for objects of this type.
+ * <p>
+ * For primitive classes
+ * the returned name is the name of the corresponding primitive
+ * type; for example, "int" is returned as the name of the class
+ * represented by {@link java.lang.Integer#TYPE Integer.TYPE}.
+ * @return a string containing the type name.
+ */
+ String name();
+
+ /**
+ * Gets the generic signature for this type if there is one.
+ * Generic signatures are described in the
+ * <cite>The Java™ Virtual Machine Specification</cite>.
+ *
+ * @return a string containing the generic signature, or <code>null</code>
+ * if there is no generic signature.
+ *
+ * @since 1.5
+ */
+ String genericSignature();
+
+ /**
+ * Gets the classloader object which loaded the class corresponding
+ * to this type.
+ *
+ * @return a {@link ClassLoaderReference} which mirrors the classloader,
+ * or <code>null</code> if the class was loaded through the bootstrap class
+ * loader.
+ */
+ ClassLoaderReference classLoader();
+
+ /**
+ * Gets an identifying name for the source corresponding to the
+ * declaration of this type. Interpretation of this string is
+ * the responsibility of the source repository mechanism.
+ * <P>
+ * The returned name is dependent on VM's default stratum
+ * ({@link VirtualMachine#getDefaultStratum()}).
+ * In the reference implementation, when using the base stratum,
+ * the returned string is the
+ * unqualified name of the source file containing the declaration
+ * of this type. In other strata the returned source name is
+ * the first source name for that stratum. Since other languages
+ * may have more than one source name for a reference type,
+ * the use of {@link Location#sourceName()} or
+ * {@link #sourceNames(String)} is preferred.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes,
+ * AbsentInformationException is always thrown.
+ *
+ * @return the string source file name
+ * @throws AbsentInformationException if the source name is not
+ * known
+ */
+ String sourceName() throws AbsentInformationException;
+
+ /**
+ * Gets the identifying names for all the source corresponding to the
+ * declaration of this type. Interpretation of these names is
+ * the responsibility of the source repository mechanism.
+ * <P>
+ * The returned names are for the specified stratum
+ * (see {@link Location} for a description of strata).
+ * In the reference implementation, when using the Java
+ * programming language stratum,
+ * the returned List contains one element: a String which is the
+ * unqualified name of the source file containing the declaration
+ * of this type. In other strata the returned source names are
+ * all the source names defined for that stratum.
+ *
+ * @param stratum The stratum to retrieve information from
+ * or <code>null</code> for the declaring type's
+ * default stratum.
+ *
+ * @return a List of String objects each representing a source name
+ *
+ * @throws AbsentInformationException if the source names are not
+ * known.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes,
+ * AbsentInformationException is always thrown.
+ *
+ * @since 1.4
+ */
+ List<String> sourceNames(String stratum) throws AbsentInformationException;
+
+ /**
+ * Gets the paths to the source corresponding to the
+ * declaration of this type. Interpretation of these paths is
+ * the responsibility of the source repository mechanism.
+ * <P>
+ * The returned paths are for the specified stratum
+ * (see {@link Location} for a description of strata).
+ * In the reference implementation, for strata which
+ * do not explicitly specify source path (the Java
+ * programming language stratum never does), the returned
+ * strings are the {@link #sourceNames(String)} prefixed by
+ * the package name of this ReferenceType
+ * converted to a platform dependent path.
+ * For example, on a Windows platform,
+ * <CODE>java.lang.Thread</CODE>
+ * would return a List containing one element:
+ * <CODE>"java\lang\Thread.java"</CODE>.
+ *
+ * @param stratum The stratum to retrieve information from
+ * or <code>null</code> for the declaring type's
+ * default stratum.
+ *
+ * @return a List of String objects each representing a source path
+ *
+ * @throws AbsentInformationException if the source names are not
+ * known.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes,
+ * AbsentInformationException is always thrown.
+ *
+ * @since 1.4
+ */
+ List<String> sourcePaths(String stratum) throws AbsentInformationException;
+
+ /**
+ * Get the source debug extension of this type.
+ * <p>
+ * Not all target virtual machines support this operation.
+ * Use
+ * {@link VirtualMachine#canGetSourceDebugExtension() canGetSourceDebugExtension()}
+ * to determine if the operation is supported.
+ * @return as a string the source debug extension attribute
+ * @throws AbsentInformationException if the extension is not
+ * specified
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation - see
+ * {@link VirtualMachine#canGetSourceDebugExtension() canGetSourceDebugExtension()},
+ */
+ String sourceDebugExtension() throws AbsentInformationException;
+
+ /**
+ * Determines if this type was declared static. Only nested types,
+ * can be declared static, so <code>false</code> is returned
+ * for any package-level type, array type, or primitive class.
+ *
+ * @return <code>true</code> if this type is static; false otherwise.
+ */
+ boolean isStatic();
+
+ /**
+ * Determines if this type was declared abstract.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes,
+ * the return value is undefined.
+ *
+ * @return <code>true</code> if this type is abstract; false otherwise.
+ */
+ boolean isAbstract();
+
+ /**
+ * Determines if this type was declared final.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes,
+ * the return value is always true.
+ *
+ * @return <code>true</code> if this type is final; false otherwise.
+ */
+ boolean isFinal();
+
+ /**
+ * Determines if this type has been prepared. See the JVM
+ * specification for a definition of class preparation.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes,
+ * the return value is undefined.
+ *
+ * @return <code>true</code> if this type is prepared; false otherwise.
+ */
+ boolean isPrepared();
+
+ /**
+ * Determines if this type has been verified. See the JVM
+ * specification for a definition of class verification.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes,
+ * the return value is undefined.
+ *
+ * @return <code>true</code> if this type is verified; false otherwise.
+ */
+ boolean isVerified();
+
+ /**
+ * Determines if this type has been initialized. See the JVM
+ * specification for a definition of class verification.
+ * For {@link InterfaceType}, this method always returns the
+ * same value as {@link #isPrepared()}.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes,
+ * the return value is undefined.
+ *
+ * @return <code>true</code> if this type is initialized; false otherwise.
+ */
+ boolean isInitialized();
+
+ /**
+ * Determines if initialization failed for this class. See the JVM
+ * specification for details on class initialization.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes,
+ * the return value is undefined.
+ *
+ * @return <code>true</code> if initialization was attempted and
+ * failed; false otherwise.
+ */
+ boolean failedToInitialize();
+
+ /**
+ * Returns a list containing each {@link Field} declared in this type.
+ * Inherited fields are not included. Any synthetic fields created
+ * by the compiler are included in the list.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes, the returned
+ * list is always empty.
+ *
+ * @return a list {@link Field} objects; the list has length 0
+ * if no fields exist.
+ * @throws ClassNotPreparedException if this class not yet been
+ * prepared.
+ */
+ List<Field> fields();
+
+ /**
+ * Returns a list containing each unhidden and unambiguous {@link Field}
+ * in this type.
+ * Each field that can be accessed from the class
+ * or its instances with its simple name is included. Fields that
+ * are ambiguously multiply inherited or fields that are hidden by
+ * fields with the same name in a more recently inherited class
+ * cannot be accessed
+ * by their simple names and are not included in the returned
+ * list. All other inherited fields are included.
+ * See JLS section 8.3 for details.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes, the returned
+ * list is always empty.
+ *
+ * @return a List of {@link Field} objects; the list has length
+ * 0 if no visible fields exist.
+ * @throws ClassNotPreparedException if this class not yet been
+ * prepared.
+ */
+ List<Field> visibleFields();
+
+ /**
+ * Returns a list containing each {@link Field} declared in this type,
+ * and its superclasses, implemented interfaces, and/or superinterfaces.
+ * All declared and inherited
+ * fields are included, regardless of whether they are hidden or
+ * multiply inherited.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes, the returned
+ * list is always empty.
+ *
+ * @return a List of {@link Field} objects; the list has length
+ * 0 if no fields exist.
+ * @throws ClassNotPreparedException if this class not yet been
+ * prepared.
+ */
+ List<Field> allFields();
+
+ /**
+ * Finds the visible {@link Field} with the given
+ * non-ambiguous name. This method follows the
+ * inheritance rules specified in the JLS (8.3.3) to determine
+ * visibility.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes, the returned
+ * value is always null.
+ *
+ * @param fieldName a String containing the name of desired field.
+ * @return a {@link Field} object which mirrors the found field, or
+ * null if there is no field with the given name or if the given
+ * name is ambiguous.
+ * @throws ClassNotPreparedException if this class not yet been
+ * prepared.
+ */
+ Field fieldByName(String fieldName);
+
+ /**
+ * Returns a list containing each {@link Method} declared
+ * directly in this type.
+ * Inherited methods are not included. Constructors,
+ * the initialization method if any, and any synthetic methods created
+ * by the compiler are included in the list.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes, the returned
+ * list is always empty.
+ *
+ * @return a list {@link Method} objects; the list has length 0
+ * if no methods exist.
+ * @throws ClassNotPreparedException if this class not yet been
+ * prepared.
+ */
+ List<Method> methods();
+
+ /**
+ * Returns a list containing each {@link Method}
+ * declared or inherited by this type. Methods from superclasses
+ * or superinterfaces that that have been hidden or overridden
+ * are not included.
+ * <p>
+ * Note that despite this exclusion, multiple inherited methods
+ * with the same signature can be present in the returned list, but
+ * at most one can be a member of a {@link ClassType}.
+ * See JLS section 8.4.6 for details.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes, the returned
+ * list is always empty.
+ *
+ * @return a List of {@link Method} objects; the list has length
+ * 0 if no visible methods exist.
+ * @throws ClassNotPreparedException if this class not yet been
+ * prepared.
+ */
+ List<Method> visibleMethods();
+
+ /**
+ * Returns a list containing each {@link Method} declared in this type,
+ * and its superclasses, implemented interfaces, and/or superinterfaces.
+ * All declared and inherited
+ * methods are included, regardless of whether they are hidden or
+ * overridden.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes, the returned
+ * list is always empty.
+ *
+ * @return a List of {@link Method} objects; the list has length
+ * 0 if no methods exist.
+ * @throws ClassNotPreparedException if this class not yet been
+ * prepared.
+ */
+ List<Method> allMethods();
+
+ /**
+ * Returns a List containing each visible {@link Method} that
+ * has the given name. This is most commonly used to
+ * find overloaded methods.
+ * <p>
+ * Overridden and hidden methods are not included.
+ * See JLS (8.4.6) for details.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes, the returned
+ * list is always empty.
+ *
+ * @param name the name of the method to find.
+ * @return a List of {@link Method} objects that match the given
+ * name; the list has length 0 if no matching methods are found.
+ * @throws ClassNotPreparedException if this class not yet been
+ * prepared.
+ */
+ List<Method> methodsByName(String name);
+
+ /**
+ * Returns a List containing each visible {@link Method} that
+ * has the given name and signature.
+ * The signature string is the
+ * JNI signature for the target method:
+ * <ul>
+ * <li><code>()V</code>
+ * <li><code>([Ljava/lang/String;)V</code>
+ * <li><code>(IIII)Z</code>
+ * </ul>
+ * This method follows the inheritance rules specified
+ * in the JLS (8.4.6) to determine visibility.
+ * <p>
+ * At most one method in the list is a concrete method and a
+ * component of {@link ClassType}; any other methods in the list
+ * are abstract. Use {@link ClassType#concreteMethodByName} to
+ * retrieve only the matching concrete method.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes, the returned
+ * list is always empty.
+ *
+ * @param name the name of the method to find.
+ * @param signature the signature of the method to find
+ * @return a List of {@link Method} objects that match the given
+ * name and signature; the list has length 0 if no matching methods
+ * are found.
+ * @throws ClassNotPreparedException if this class not yet been
+ * prepared.
+ */
+ List<Method> methodsByName(String name, String signature);
+
+ /**
+ * Returns a List containing {@link ReferenceType} objects that are
+ * declared within this type and are currently loaded into the Virtual
+ * Machine. Both static nested types and non-static nested
+ * types (that is, inner types) are included. Local inner types
+ * (declared within a code block somewhere in this reference type) are
+ * also included in the returned list.
+ * <p>
+ * For arrays ({@link ArrayType}) and primitive classes, the returned
+ * list is always empty.
+ *
+ * @return a List of nested {@link ReferenceType} objects; the list
+ * has 0 length if there are no nested types.
+ */
+ List<ReferenceType> nestedTypes();
+
+ /**
+ * Gets the {@link Value} of a given static {@link Field} in this type.
+ * The Field must be valid for this type;
+ * that is, it must be declared in this type, a superclass, a
+ * superinterface, or an implemented interface.
+ *
+ * @param field the field containing the requested value
+ * @return the {@link Value} of the instance field.
+ * @throws java.lang.IllegalArgumentException if the field is not valid for
+ * this object's class.
+ */
+ Value getValue(Field field);
+
+ /**
+ * Returns a map containing the {@link Value} of each
+ * static {@link Field} in the given list.
+ * The Fields must be valid for this type;
+ * that is, they must be declared in this type, a superclass, a
+ * superinterface, or an implemented interface.
+ *
+ * @param fields a list of {@link Field} objects containing the
+ * requested values.
+ * @return a Map of the requested {@link Field} objects with
+ * their {@link Value}.
+ * @throws java.lang.IllegalArgumentException if any field is not valid for
+ * this object's class.
+ * @throws VMMismatchException if a {@link Mirror} argument and this mirror
+ * do not belong to the same {@link VirtualMachine}.
+ */
+ Map<Field,Value> getValues(List<? extends Field> fields);
+
+ /**
+ * Returns the class object that corresponds to this type in the
+ * target VM. The VM creates class objects for every kind of
+ * ReferenceType: classes, interfaces, and array types.
+ * @return the {@link ClassObjectReference} for this reference type
+ * in the target VM.
+ */
+ ClassObjectReference classObject();
+
+ /**
+ * Returns a list containing a {@link Location} object
+ * for each executable source line in this reference type.
+ * <P>
+ * This method is equivalent to
+ * <code>allLineLocations(vm.getDefaultStratum(),null)</code> -
+ * see {@link #allLineLocations(String,String)}
+ * for more information.
+ *
+ * @throws AbsentInformationException if there is no line
+ * number information for this class and there are non-native,
+ * non-abstract executable members of this class.
+ *
+ * @throws ClassNotPreparedException if this class not yet
+ * been prepared.
+ */
+ List<Location> allLineLocations() throws AbsentInformationException;
+
+ /**
+ * Returns a list containing a {@link Location} object
+ * for each executable source line in this reference type.
+ * Each location maps a source line to a range of code
+ * indices.
+ * The beginning of the range can be determined through
+ * {@link Location#codeIndex}. The returned list may contain
+ * multiple locations for a particular line number, if the
+ * compiler and/or VM has mapped that line to two or more
+ * disjoint code index ranges. Note that it is possible for
+ * the same source line to represent different code index
+ * ranges in <i>different</i> methods.
+ * <P>
+ * For arrays ({@link ArrayType}) and primitive classes, the
+ * returned list is always empty. For interfaces ({@link
+ * InterfaceType}), the returned list will be non-empty only
+ * if the interface has executable code in its class
+ * initialization.
+ * <P>
+ * Returned list is for the specified <i>stratum</i>
+ * (see {@link Location} for a description of strata).
+ *
+ * @param stratum The stratum to retrieve information from
+ * or <code>null</code> for the {@link #defaultStratum()}.
+ *
+ * @param sourceName Return locations only within this
+ * source file or <code>null</code> to return locations.
+ *
+ * @return a List of all source line {@link Location} objects.
+ *
+ * @throws AbsentInformationException if there is no line
+ * number information for this class and there are non-native,
+ * non-abstract executable members of this class.
+ * Or if <i>sourceName</i> is non-<code>null</code>
+ * and source name information is not present.
+ *
+ * @throws ClassNotPreparedException if this class not yet
+ * been prepared.
+ *
+ * @since 1.4
+ */
+ List<Location> allLineLocations(String stratum, String sourceName)
+ throws AbsentInformationException;
+
+ /**
+ * Returns a List containing all {@link Location} objects
+ * that map to the given line number.
+ * <P>
+ * This method is equivalent to
+ * <code>locationsOfLine(vm.getDefaultStratum(), null,
+ * lineNumber)</code> -
+ * see {@link
+ * #locationsOfLine(java.lang.String,java.lang.String,int)}
+ * for more information.
+ *
+ * @param lineNumber the line number
+ *
+ * @return a List of all {@link Location} objects that map to
+ * the given line.
+ *
+ * @throws AbsentInformationException if there is no line
+ * number information for this class.
+ *
+ * @throws ClassNotPreparedException if this class not yet
+ * been prepared.
+ *
+ * @see VirtualMachine#getDefaultStratum()
+ */
+ List<Location> locationsOfLine(int lineNumber)
+ throws AbsentInformationException;
+
+ /**
+ * Returns a List containing all {@link Location} objects
+ * that map to the given line number.
+ * <P>
+ * For arrays ({@link ArrayType}) and primitive classes, the
+ * returned list is always empty.
+ * For interfaces ({@link InterfaceType}), the returned list
+ * will be non-empty only if the interface has executable code
+ * in its class initialization at the specified line number.
+ * An empty list will be returned if there is no executable
+ * code at the specified line number.
+ * <p>
+ * Returned list is for the specified <i>stratum</i>
+ * (see {@link Location} for a description of strata).
+ *
+ * @param stratum the stratum to use for comparing line number
+ * and source name, or <code>null</code> to
+ * use the {@link #defaultStratum()}.
+ *
+ * @param sourceName the source name containing the line
+ * number, or <code>null</code> to match
+ * all source names
+ *
+ * @param lineNumber the line number
+ *
+ * @return a List of all {@link Location} objects that map
+ * to the given line.
+ *
+ * @throws AbsentInformationException if there is no line
+ * number information for this class.
+ * Or if <i>sourceName</i> is non-<code>null</code>
+ * and source name information is not present.
+ *
+ * @throws ClassNotPreparedException if this class not yet
+ * been prepared.
+ *
+ * @since 1.4
+ */
+ List<Location> locationsOfLine(String stratum,
+ String sourceName,
+ int lineNumber)
+ throws AbsentInformationException;
+
+ /**
+ * Return the available strata for this reference type.
+ * <P>
+ * See the {@link Location} for a description of strata.
+ *
+ * @return List of <CODE>java.lang.String</CODE>, each
+ * representing a stratum
+ *
+ * @since 1.4
+ */
+ List<String> availableStrata();
+
+ /**
+ * Returns the default stratum for this reference type.
+ * This value is specified in the class file and cannot
+ * be set by the user. If the class file does not
+ * specify a default stratum the base stratum
+ * (<code>"Java"</code>) will be returned.
+ * <P>
+ * See the {@link Location} for a description of strata.
+ *
+ * @since 1.4
+ */
+ String defaultStratum();
+
+ /**
+ * Returns instances of this ReferenceType.
+ * Only instances that are reachable for the purposes of garbage collection
+ * are returned.
+ * <p>
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canGetInstanceInfo()}
+ * to determine if the operation is supported.
+ *
+ * @see VirtualMachine#instanceCounts(List)
+ * @see ObjectReference#referringObjects(long)
+ *
+ * @param maxInstances the maximum number of instances to return.
+ * Must be non-negative. If zero, all instances are returned.
+ * @return a List of {@link ObjectReference} objects. If there are
+ * no instances of this ReferenceType, a zero-length list is returned.
+ *
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation - see
+ * {@link VirtualMachine#canGetInstanceInfo() canGetInstanceInfo()}
+ * @throws java.lang.IllegalArgumentException if maxInstances is less
+ * than zero.
+ * @since 1.6
+ */
+ List<ObjectReference> instances(long maxInstances);
+
+ /**
+ * Compares the specified Object with this ReferenceType for equality.
+ *
+ * @return true if the Object is a {@link ReferenceType}, if the
+ * ReferenceTypes belong to the same VM, and if they mirror classes
+ * which correspond to the same instance of java.lang.Class in that VM.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns the hash code value for this ObjectReference.
+ *
+ * @return the integer hash code
+ */
+ int hashCode();
+
+ /**
+ * Returns the class major version number, as defined in the class file format
+ * of the Java Virtual Machine Specification.
+ *
+ * For arrays ({@link ArrayType}) and primitive classes,
+ * the returned major version number value is zero.
+ *
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canGetClassFileVersion()}
+ * to determine if the operation is supported.
+ *
+ * @return the major version number of the class.
+ *
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation - see
+ * {@link VirtualMachine#canGetClassFileVersion() canGetClassFileVersion()}
+ *
+ * @since 1.6
+ */
+ int majorVersion();
+
+
+ /**
+ * Returns the class minor version number, as defined in the class file format
+ * of the Java Virtual Machine Specification.
+ *
+ * For arrays ({@link ArrayType}) and primitive classes,
+ * the returned minor version number value is zero.
+ *
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canGetClassFileVersion()}
+ * to determine if the operation is supported.
+ *
+ * @return the minor version number of the class.
+ *
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation - see
+ * {@link VirtualMachine#canGetClassFileVersion() canGetClassFileVersion()}
+ *
+ * @since 1.6
+ */
+ int minorVersion();
+
+ /**
+ * Returns the number of entries in the constant pool plus one.
+ * This corresponds to the constant_pool_count item of the Class File Format
+ * in the Java Virtual Machine Specification.
+ *
+ * For arrays ({@link ArrayType}) and primitive classes,
+ * the returned constant pool count value is zero.
+ *
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canGetConstantPool()}
+ * to determine if the operation is supported.
+ *
+ * @return total number of constant pool entries for a class plus one.
+ *
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation - see
+ * {@link VirtualMachine#canGetConstantPool() canGetConstantPool()}
+ *
+ * @see #constantPool()
+ * @since 1.6
+ */
+ int constantPoolCount();
+
+ /**
+ * Returns the raw bytes of the constant pool in the format of the
+ * constant_pool item of the Class File Format in the Java Virtual
+ * Machine Specification. The format of the constant pool may
+ * differ between versions of the Class File Format, so, the
+ * minor and major class version numbers should be checked for
+ * compatibility.
+ *
+ * For arrays ({@link ArrayType}) and primitive classes,
+ * a zero length byte array is returned.
+ *
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canGetConstantPool()}
+ * to determine if the operation is supported.
+ *
+ * @return the raw bytes of constant pool.
+ *
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation - see
+ * {@link VirtualMachine#canGetConstantPool() canGetConstantPool()}
+ *
+ * @see #constantPoolCount()
+ * @since 1.6
+ */
+ byte[] constantPool();
+
+}
diff --git a/src/share/classes/com/sun/jdi/ShortType.java b/src/share/classes/com/sun/jdi/ShortType.java
new file mode 100644
index 0000000..9e0a2a9
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/ShortType.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * The type of all primitive <code>short</code> values
+ * accessed in the target VM. Calls to {@link Value#type} will return an
+ * implementor of this interface.
+ *
+ * @see LongValue
+ *
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ShortType extends PrimitiveType {
+}
diff --git a/src/share/classes/com/sun/jdi/ShortValue.java b/src/share/classes/com/sun/jdi/ShortValue.java
new file mode 100644
index 0000000..61e54ec
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/ShortValue.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Provides access to a primitive <code>short</code> value in
+ * the target VM.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ShortValue extends PrimitiveValue, Comparable<ShortValue> {
+
+ /**
+ * Returns this ShortValue as a short.
+ *
+ * @return the <code>short</code> mirrored by this object.
+ */
+ short value();
+
+ /**
+ * Compares the specified Object with this ShortValue for equality.
+ *
+ * @return true if the Object is a ShortValue and if applying "=="
+ * to the two mirrored primitives would evaluate to true; false
+ * otherwise.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns the hash code value for this ShortValue.
+ *
+ * @return the integer hash code
+ */
+ int hashCode();
+}
diff --git a/src/share/classes/com/sun/jdi/StackFrame.java b/src/share/classes/com/sun/jdi/StackFrame.java
new file mode 100644
index 0000000..9d51d8a
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/StackFrame.java
@@ -0,0 +1,240 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The state of one method invocation on a thread's call stack.
+ * As a thread executes, stack frames are pushed and popped from
+ * its call stack as methods are invoked and then return. A StackFrame
+ * mirrors one such frame from a target VM at some point in its
+ * thread's execution. The call stack is, then, simply a List of
+ * StackFrame objects. The call stack can be obtained any time a thread
+ * is suspended through a call to {@link ThreadReference#frames}
+ * <p>
+ * StackFrames provide access to a method's local variables and their
+ * current values.
+ * <p>
+ * The lifetime of a StackFrame is very limited. It is available only
+ * for suspended threads and becomes invalid once its thread is resumed.
+ * <p>
+ * Any method on <code>StackFrame</code> which
+ * takes <code>StackFrame</code> as an parameter may throw
+ * {@link com.sun.jdi.VMDisconnectedException} if the target VM is
+ * disconnected and the {@link com.sun.jdi.event.VMDisconnectEvent} has been or is
+ * available to be read from the {@link com.sun.jdi.event.EventQueue}.
+ * <p>
+ * Any method on <code>StackFrame</code> which
+ * takes <code>StackFrame</code> as an parameter may throw
+ * {@link com.sun.jdi.VMOutOfMemoryException} if the target VM has run out of memory.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface StackFrame extends Mirror, Locatable {
+
+ /**
+ * Returns the {@link Location} of the current instruction in the frame.
+ * The method for which this frame was created can also be accessed
+ * through the returned location.
+ * For the top frame in the stack, this location identifies the
+ * next instruction to be executed. For all other frames, this
+ * location identifies the instruction that caused the next frame's
+ * method to be invoked.
+ * If the frame represents a native method invocation, the returned
+ * location indicates the class and method, but the code index will
+ * not be valid (-1).
+ *
+ * @return the {@link Location} of the current instruction.
+ * @throws InvalidStackFrameException if this stack frame has become
+ * invalid. Once the frame's thread is resumed, the stack frame is
+ * no longer valid.
+ */
+ Location location();
+
+ /**
+ * Returns the thread under which this frame's method is running.
+ *
+ * @return a {@link ThreadReference} which mirrors the frame's thread.
+ * @throws InvalidStackFrameException if this stack frame has become
+ * invalid. Once the frame's thread is resumed, the stack frame is
+ * no longer valid.
+ */
+ ThreadReference thread();
+
+ /**
+ * Returns the value of 'this' for the current frame.
+ * The {@link ObjectReference} for 'this' is only available for
+ * non-native instance methods.
+ *
+ * @return an {@link ObjectReference}, or null if the frame represents
+ * a native or static method.
+ * @throws InvalidStackFrameException if this stack frame has become
+ * invalid. Once the frame's thread is resumed, the stack frame is
+ * no longer valid.
+ */
+ ObjectReference thisObject();
+
+ /**
+ * Returns a list containing each {@link LocalVariable}
+ * that can be accessed from this frame's location.
+ * <p>
+ * Visibility is based on the code index of the current instruction of
+ * this StackFrame. Each variable has a range of byte code indices in which
+ * it is accessible.
+ * If this stack frame's method
+ * matches this variable's method and if the code index of this
+ * StackFrame is within the variable's byte code range, the variable is
+ * visible.
+ * <p>
+ * A variable's byte code range is at least as large as the scope of
+ * that variable, but can continue beyond the end of the scope under
+ * certain circumstances:
+ * <ul>
+ * <li>the compiler/VM does not immediately reuse the variable's slot.
+ * <li>the compiler/VM is implemented to report the extended range that
+ * would result from the item above.
+ * </ul>
+ * The advantage of an extended range is that variables from recently
+ * exited scopes may remain available for examination (this is especially
+ * useful for loop indices). If, as a result of the extensions above,
+ * the current frame location is contained within the range
+ * of multiple local variables of the same name, the variable with the
+ * highest-starting range is chosen for the returned list.
+ *
+ * @return the list of {@link LocalVariable} objects currently visible;
+ * the list will be empty if there are no visible variables;
+ * specifically, frames in native methods will always return a
+ * zero-length list.
+ * @throws AbsentInformationException if there is no local variable
+ * information for this method.
+ * @throws InvalidStackFrameException if this stack frame has become
+ * invalid. Once the frame's thread is resumed, the stack frame is
+ * no longer valid.
+ * @throws NativeMethodException if the current method is native.
+ */
+ List<LocalVariable> visibleVariables() throws AbsentInformationException;
+
+ /**
+ * Finds a {@link LocalVariable} that matches the given name and is
+ * visible at the current frame location.
+ * See {@link #visibleVariables} for more information on visibility.
+ *
+ * @param name the variable name to find
+ * @return the matching {@link LocalVariable}, or null if there is no
+ * visible variable with the given name; frames in native methods
+ * will always return null.
+ * @throws AbsentInformationException if there is no local variable
+ * information for this method.
+ * @throws InvalidStackFrameException if this stack frame has become
+ * invalid. Once the frame's thread is resumed, the stack frame is
+ * no longer valid.
+ * @throws NativeMethodException if the current method is native.
+ */
+ LocalVariable visibleVariableByName(String name) throws AbsentInformationException;
+
+ /**
+ * Gets the {@link Value} of a {@link LocalVariable} in this frame.
+ * The variable must be valid for this frame's method and visible
+ * according to the rules described in {@link #visibleVariables}.
+ *
+ * @param variable the {@link LocalVariable} to be accessed
+ * @return the {@link Value} of the instance field.
+ * @throws java.lang.IllegalArgumentException if the variable is
+ * either invalid for this frame's method or not visible.
+ * @throws InvalidStackFrameException if this stack frame has become
+ * invalid. Once the frame's thread is resumed, the stack frame is
+ * no longer valid.
+ */
+ Value getValue(LocalVariable variable);
+
+ /**
+ * Returns the values of multiple local variables in this frame.
+ * Each variable must be valid for this frame's method and visible
+ * according to the rules described in {@link #visibleVariables}.
+ *
+ * @param variables a list of {@link LocalVariable} objects to be accessed
+ * @return a map associating each {@link LocalVariable} with
+ * its {@link Value}
+ * @throws java.lang.IllegalArgumentException if any variable is
+ * either invalid for this frame's method or not visible.
+ * @throws InvalidStackFrameException if this stack frame has become
+ * invalid. Once the frame's thread is resumed, the stack frame is
+ * no longer valid.
+ */
+ Map<LocalVariable,Value> getValues(List<? extends LocalVariable> variables);
+
+ /**
+ * Sets the {@link Value} of a {@link LocalVariable} in this frame.
+ * The variable must be valid for this frame's method and visible
+ * according to the rules described in {@link #visibleVariables}.
+ * <p>
+ * Object values must be assignment compatible with the variable type
+ * (This implies that the variable type must be loaded through the
+ * enclosing class's class loader). Primitive values must be
+ * either assignment compatible with the variable type or must be
+ * convertible to the variable type without loss of information.
+ * See JLS section 5.2 for more information on assignment
+ * compatibility.
+ *
+ * @param variable the field containing the requested value
+ * @param value the new value to assign
+ * @throws java.lang.IllegalArgumentException if the field is not valid for
+ * this object's class.
+ * @throws InvalidTypeException if the value's type does not match
+ * the variable's type.
+ * @throws ClassNotLoadedException if the variable type has not yet been loaded
+ * through the appropriate class loader.
+ * @throws InvalidStackFrameException if this stack frame has become
+ * invalid. Once the frame's thread is resumed, the stack frame is
+ * no longer valid.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ */
+ void setValue(LocalVariable variable, Value value)
+ throws InvalidTypeException, ClassNotLoadedException;
+
+ /**
+ * Returns the values of all arguments in this frame. Values are
+ * returned even if no local variable information is present.
+ *
+ * @return a list containing a {@link Value} object for each argument
+ * to this frame, in the order in which the arguments were
+ * declared. If the method corresponding to this frame has
+ * no arguments, an empty list is returned.
+ *
+ * @throws InvalidStackFrameException if this stack frame has become
+ * invalid. Once the frame's thread is resumed, the stack frame is
+ * no longer valid.
+ * @since 1.6
+ */
+ List<Value> getArgumentValues();
+
+}
diff --git a/src/share/classes/com/sun/jdi/StringReference.java b/src/share/classes/com/sun/jdi/StringReference.java
new file mode 100644
index 0000000..92e7167
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/StringReference.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * A string object from the target VM.
+ * A StringReference is an {@link ObjectReference} with additional
+ * access to string-specific information from the target VM.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface StringReference extends ObjectReference {
+ /**
+ * Returns the StringReference as a String. The returned string
+ * is the equivalent of the mirrored string, but is an entity in the
+ * client VM and can be manipulated like any other string.
+ *
+ * @return the string value.
+ */
+ String value();
+}
diff --git a/src/share/classes/com/sun/jdi/ThreadGroupReference.java b/src/share/classes/com/sun/jdi/ThreadGroupReference.java
new file mode 100644
index 0000000..110504f
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/ThreadGroupReference.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+import java.util.List;
+
+/**
+ * A thread group object from the target VM.
+ * A ThreadGroupReference is an {@link ObjectReference} with additional
+ * access to threadgroup-specific information from the target VM.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ThreadGroupReference extends ObjectReference {
+
+ /**
+ * Returns the name of this thread group.
+ *
+ * @return the string containing the thread group name.
+ */
+ String name();
+
+ /**
+ * Returns the parent of this thread group.
+ *
+ * @return a {@link ThreadGroupReference} mirroring the parent of this
+ * thread group in the target VM, or null if this is a top-level
+ * thread group.
+ */
+ ThreadGroupReference parent();
+
+ /**
+ * Suspends all threads in this thread group. Each thread
+ * in this group and in all of its subgroups will be
+ * suspended as described in {@link ThreadReference#suspend}.
+ * This is not guaranteed to be an atomic
+ * operation; if the target VM is not interrupted at the time
+ * this method is
+ * called, it is possible that new threads will be created
+ * between the time that threads are enumerated and all of them
+ * have been suspended.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ */
+ void suspend();
+
+ /**
+ * Resumes all threads in this thread group. Each thread
+ * in this group and in all of its subgroups will be
+ * resumed as described in {@link ThreadReference#resume}.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ */
+ void resume();
+
+ /**
+ * Returns a List containing a {@link ThreadReference} for each live thread
+ * in this thread group. Only the live threads in this immediate thread group
+ * (and not its subgroups) are returned. A thread is alive if it
+ * has been started and has not yet been stopped.
+ *
+ * @return a List of {@link ThreadReference} objects mirroring the
+ * live threads from this thread group in the target VM.
+ */
+ List<ThreadReference> threads();
+
+ /**
+ * Returns a List containing each active {@link ThreadGroupReference} in this
+ * thread group. Only the active thread groups in this immediate thread group
+ * (and not its subgroups) are returned.
+ * See <a href="{@docRoot}/../../../../api/java/lang/ThreadGroup.html">java.lang.ThreadGroup</a>
+ * for information about 'active' ThreadGroups.
+ * @return a List of {@link ThreadGroupReference} objects mirroring the
+ * active thread groups from this thread group in the target VM.
+ */
+ List<ThreadGroupReference> threadGroups();
+}
diff --git a/src/share/classes/com/sun/jdi/ThreadReference.java b/src/share/classes/com/sun/jdi/ThreadReference.java
new file mode 100644
index 0000000..2e09ec8
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/ThreadReference.java
@@ -0,0 +1,473 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+import java.util.List;
+
+/**
+ * A thread object from the target VM.
+ * A ThreadReference is an {@link ObjectReference} with additional
+ * access to thread-specific information from the target VM.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ThreadReference extends ObjectReference {
+ /** Thread status is unknown */
+ public final int THREAD_STATUS_UNKNOWN =-1;
+ /** Thread has completed execution */
+ public final int THREAD_STATUS_ZOMBIE = 0;
+ /** Thread is runnable */
+ public final int THREAD_STATUS_RUNNING = 1;
+ /** Thread is sleeping - Thread.sleep() or JVM_Sleep() was called */
+ public final int THREAD_STATUS_SLEEPING = 2;
+ /** Thread is waiting on a java monitor */
+ public final int THREAD_STATUS_MONITOR = 3;
+ /** Thread is waiting - Object.wait() or JVM_MonitorWait() was called */
+ public final int THREAD_STATUS_WAIT = 4;
+ /** Thread has not yet been started */
+ public final int THREAD_STATUS_NOT_STARTED = 5;
+
+ /**
+ * Returns the name of this thread.
+ *
+ * @return the string containing the thread name.
+ */
+ String name();
+
+ /**
+ * Suspends this thread. The thread can be resumed through
+ * {@link #resume} or resumed with other threads through
+ * {@link VirtualMachine#resume}.
+ * <p>
+ * Unlike {@link java.lang.Thread#suspend},
+ * suspends of both the virtual machine and individual threads are
+ * counted. Before a thread will run again, it must be resumed
+ * (through {@link #resume} or {@link ThreadReference#resume})
+ * the same number of times it has been suspended.
+ * <p>
+ * Suspending single threads with this method has the same dangers
+ * as {@link java.lang.Thread#suspend()}. If the suspended thread
+ * holds a monitor needed by another running thread, deadlock is
+ * possible in the target VM (at least until the suspended thread
+ * is resumed again).
+ * <p>
+ * The suspended thread is guaranteed to remain suspended until
+ * resumed through one of the JDI resume methods mentioned above;
+ * the application in the target VM cannot resume the suspended thread
+ * through {@link java.lang.Thread#resume}.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ */
+ void suspend();
+
+ /**
+ * Resumes this thread. If this thread was not previously suspended
+ * through {@link #suspend} or through {@link VirtualMachine#suspend},
+ * or because of a SUSPEND_ALL or SUSPEND_EVENT_THREAD event, then
+ * invoking this method has no effect. Otherwise, the count of pending
+ * suspends on this thread is decremented. If it is decremented to 0,
+ * the thread will continue to execute.
+ * Note: the normal way to resume from an event related suspension is
+ * via {@link com.sun.jdi.event.EventSet#resume}.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ */
+ void resume();
+
+ /**
+ * Returns the number of pending suspends for this thread. See
+ * {@link #suspend} for an explanation of counted suspends.
+ * @return pending suspend count as an integer
+ */
+ int suspendCount();
+
+ /**
+ * Stops this thread with an asynchronous exception.
+ * A debugger thread in the target VM will stop this thread
+ * with the given {@link java.lang.Throwable} object.
+ *
+ * @param throwable the asynchronous exception to throw.
+ * @throws InvalidTypeException if <code>throwable</code> is not
+ * an instance of java.lang.Throwable in the target VM.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ * @see java.lang.Thread#stop(Throwable)
+ */
+ void stop(ObjectReference throwable) throws InvalidTypeException;
+
+ /**
+ * Interrupts this thread unless the thread has been suspended by the
+ * debugger.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ *
+ * @see java.lang.Thread#interrupt()
+ */
+ void interrupt();
+
+ /**
+ * Returns the thread's status. If the thread is not suspended the
+ * thread's current status is returned. If the thread is suspended, the
+ * thread's status before the suspension is returned (or
+ * {@link #THREAD_STATUS_UNKNOWN} if this information is not available.
+ * {@link #isSuspended} can be used to determine if the thread has been
+ * suspended.
+ *
+ * @return one of
+ * {@link #THREAD_STATUS_UNKNOWN},
+ * {@link #THREAD_STATUS_ZOMBIE},
+ * {@link #THREAD_STATUS_RUNNING},
+ * {@link #THREAD_STATUS_SLEEPING},
+ * {@link #THREAD_STATUS_MONITOR},
+ * {@link #THREAD_STATUS_WAIT},
+ * {@link #THREAD_STATUS_NOT_STARTED},
+ */
+ int status();
+
+ /**
+ * Determines whether the thread has been suspended by the
+ * the debugger.
+ *
+ * @return <code>true</code> if the thread is currently suspended;
+ * <code>false</code> otherwise.
+ */
+ boolean isSuspended();
+
+ /**
+ * Determines whether the thread is suspended at a breakpoint.
+ *
+ * @return <code>true</code> if the thread is currently stopped at
+ * a breakpoint; <code>false</code> otherwise.
+ */
+ boolean isAtBreakpoint();
+
+ /**
+ * Returns this thread's thread group.
+ * @return a {@link ThreadGroupReference} that mirrors this thread's
+ * thread group in the target VM.
+ */
+ ThreadGroupReference threadGroup();
+
+ /**
+ * Returns the number of stack frames in the thread's current
+ * call stack.
+ * The thread must be suspended (normally through an interruption
+ * to the VM) to get this information, and
+ * it is only valid until the thread is resumed again.
+ *
+ * @return an integer frame count
+ * @throws IncompatibleThreadStateException if the thread is
+ * not suspended in the target VM
+ */
+ int frameCount() throws IncompatibleThreadStateException;
+
+ /**
+ * Returns a List containing each {@link StackFrame} in the
+ * thread's current call stack.
+ * The thread must be suspended (normally through an interruption
+ * to the VM) to get this information, and
+ * it is only valid until the thread is resumed again.
+ *
+ * @return a List of {@link StackFrame} with the current frame first
+ * followed by each caller's frame.
+ * @throws IncompatibleThreadStateException if the thread is
+ * not suspended in the target VM
+ */
+ List<StackFrame> frames() throws IncompatibleThreadStateException;
+
+ /**
+ * Returns the {@link StackFrame} at the given index in the
+ * thread's current call stack. Index 0 retrieves the current
+ * frame; higher indices retrieve caller frames.
+ * The thread must be suspended (normally through an interruption
+ * to the VM) to get this information, and
+ * it is only valid until the thread is resumed again.
+ *
+ * @param index the desired frame
+ * @return the requested {@link StackFrame}
+ * @throws IncompatibleThreadStateException if the thread is
+ * not suspended in the target VM
+ * @throws java.lang.IndexOutOfBoundsException if the index is greater than
+ * or equal to {@link #frameCount} or is negative.
+ */
+ StackFrame frame(int index) throws IncompatibleThreadStateException;
+
+ /**
+ * Returns a List containing a range of {@link StackFrame} mirrors
+ * from the thread's current call stack.
+ * The thread must be suspended (normally through an interruption
+ * to the VM) to get this information, and
+ * it is only valid until the thread is resumed again.
+ *
+ * @param start the index of the first frame to retrieve.
+ * Index 0 represents the current frame.
+ * @param length the number of frames to retrieve
+ * @return a List of {@link StackFrame} with the current frame first
+ * followed by each caller's frame.
+ * @throws IncompatibleThreadStateException if the thread is
+ * not suspended in the target VM
+ * @throws IndexOutOfBoundsException if the specified range is not
+ * within the range of stack frame indicies.
+ * That is, the exception is thrown if any of the following are true:
+ * <pre> start < 0
+ * start >= {@link #frameCount}
+ * length < 0
+ * (start+length) > {@link #frameCount}</pre>
+ */
+ List<StackFrame> frames(int start, int length)
+ throws IncompatibleThreadStateException;
+
+ /**
+ * Returns a List containing an {@link ObjectReference} for
+ * each monitor owned by the thread.
+ * A monitor is owned by a thread if it has been entered
+ * (via the synchronized statement or entry into a synchronized
+ * method) and has not been relinquished through {@link Object#wait}.
+ * <p>
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canGetOwnedMonitorInfo()}
+ * to determine if the operation is supported.
+ *
+ * @return a List of {@link ObjectReference} objects. The list
+ * has zero length if no monitors are owned by this thread.
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation.
+ * @throws IncompatibleThreadStateException if the thread is
+ * not suspended in the target VM
+ */
+ List<ObjectReference> ownedMonitors()
+ throws IncompatibleThreadStateException;
+
+ /**
+ * Returns a List containing a {@link MonitorInfo} object for
+ * each monitor owned by the thread.
+ * A monitor is owned by a thread if it has been entered
+ * (via the synchronized statement or entry into a synchronized
+ * method) and has not been relinquished through {@link Object#wait}.
+ * <p>
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canGetMonitorFrameInfo()}
+ * to determine if the operation is supported.
+ *
+ * @return a List of {@link MonitorInfo} objects. The list
+ * has zero length if no monitors are owned by this thread.
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation.
+ * @throws IncompatibleThreadStateException if the thread is
+ * not suspended in the target VM
+ *
+ * @since 1.6
+ */
+ List<MonitorInfo> ownedMonitorsAndFrames()
+ throws IncompatibleThreadStateException;
+
+ /**
+ * Returns an {@link ObjectReference} for the monitor, if any,
+ * for which this thread is currently waiting.
+ * The thread can be waiting for a monitor through entry into a
+ * synchronized method, the synchronized statement, or
+ * {@link Object#wait}. The {@link #status} method can be used
+ * to differentiate between the first two cases and the third.
+ * <p>
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canGetCurrentContendedMonitor()}
+ * to determine if the operation is supported.
+ *
+ * @return the {@link ObjectReference} corresponding to the
+ * contended monitor, or null if it is not waiting for a monitor.
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation.
+ * @throws IncompatibleThreadStateException if the thread is
+ * not suspended in the target VM
+ */
+ ObjectReference currentContendedMonitor() throws IncompatibleThreadStateException;
+
+ /**
+ * Pop stack frames.
+ * <P>
+ * All frames up to and including the <CODE>frame</CODE> are
+ * popped off the stack.
+ * The frame previous to the parameter <CODE>frame</CODE>
+ * will become the current frame.
+ * <P>
+ * After this operation, this thread will be
+ * suspended at the invoke instruction of the target method
+ * that created <CODE>frame</CODE>.
+ * The <CODE>frame</CODE>'s method can be reentered with a step into
+ * the instruction.
+ * <P>
+ * The operand stack is restored, however, any changes
+ * to the arguments that occurred in the called method, remain.
+ * For example, if the method <CODE>foo</CODE>:
+ * <PRE>
+ * void foo(int x) {
+ * System.out.println("Foo: " + x);
+ * x = 4;
+ * System.out.println("pop here");
+ * }
+ * </PRE>
+ * was called with <CODE>foo(7)</CODE> and <CODE>foo</CODE>
+ * is popped at the second <CODE>println</CODE> and resumed,
+ * it will print: <CODE>Foo: 4</CODE>.
+ * <P>
+ * Locks acquired by a popped frame are released when it
+ * is popped. This applies to synchronized methods that
+ * are popped, and to any synchronized blocks within them.
+ * <P>
+ * Finally blocks are not executed.
+ * <P>
+ * No aspect of state, other than this thread's execution point and
+ * locks, is affected by this call. Specifically, the values of
+ * fields are unchanged, as are external resources such as
+ * I/O streams. Additionally, the target program might be
+ * placed in a state that is impossible with normal program flow;
+ * for example, order of lock acquisition might be perturbed.
+ * Thus the target program may
+ * proceed differently than the user would expect.
+ * <P>
+ * The specified thread must be suspended.
+ * <P>
+ * All <code>StackFrame</code> objects for this thread are
+ * invalidated.
+ * <P>
+ * No events are generated by this method.
+ * <P>
+ * None of the frames through and including the frame for the caller
+ * of <i>frame</i> may be native.
+ * <P>
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canPopFrames() VirtualMachine.canPopFrames()}
+ * to determine if the operation is supported.
+ *
+ * @param frame Stack frame to pop. <CODE>frame</CODE> is on this
+ * thread's call stack.
+ *
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation - see
+ * {@link VirtualMachine#canPopFrames() VirtualMachine.canPopFrames()}.
+ *
+ * @throws IncompatibleThreadStateException if this
+ * thread is not suspended.
+ *
+ * @throws java.lang.IllegalArgumentException if <CODE>frame</CODE>
+ * is not on this thread's call stack.
+ *
+ * @throws NativeMethodException if one of the frames that would be
+ * popped is that of a native method or if the frame previous to
+ * <i>frame</i> is native.
+ *
+ * @throws InvalidStackFrameException if <CODE>frame</CODE> has become
+ * invalid. Once this thread is resumed, the stack frame is
+ * no longer valid. This exception is also thrown if there are no
+ * more frames.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ *
+ * @since 1.4 */
+ void popFrames(StackFrame frame) throws IncompatibleThreadStateException;
+
+
+ /**
+ * Force a method to return before it reaches a return
+ * statement.
+ * <p>
+ * The method which will return early is referred to as the
+ * called method. The called method is the current method (as
+ * defined by the Frames section in the Java Virtual Machine
+ * Specification) for the specified thread at the time this
+ * method is called.
+ * <p>
+ * The thread must be suspended.
+ * The return occurs when execution of Java programming
+ * language code is resumed on this thread. Between the call to
+ * this method and resumption of thread execution, the
+ * state of the stack is undefined.
+ * <p>
+ * No further instructions are executed in the called
+ * method. Specifically, finally blocks are not executed. Note:
+ * this can cause inconsistent states in the application.
+ * <p>
+ * A lock acquired by calling the called method (if it is a
+ * synchronized method) and locks acquired by entering
+ * synchronized blocks within the called method are
+ * released. Note: this does not apply to native locks or
+ * java.util.concurrent.locks locks.
+ * <p>
+ * Events, such as MethodExit, are generated as they would be in
+ * a normal return.
+ * <p>
+ * The called method must be a non-native Java programming
+ * language method. Forcing return on a thread with only one
+ * frame on the stack causes the thread to exit when resumed.
+ * <p>
+ * The <code>value</code> argument is the value that the
+ * method is to return.
+ * If the return type of the method is void, then value must
+ * be a {@link VoidValue VoidValue}.
+ * Object values must be assignment compatible with the method return type
+ * (This implies that the method return type must be loaded through the
+ * enclosing class's class loader). Primitive values must be
+ * either assignment compatible with the method return type or must be
+ * convertible to the variable type without loss of information.
+ * See JLS section 5.2 for more information on assignment
+ * compatibility.
+ * <p>
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canForceEarlyReturn()}
+ * to determine if the operation is supported.
+ *
+ * @param value the value the method is to return.
+ *
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation - see
+ * {@link VirtualMachine#canGetInstanceInfo() canForceEarlyReturn()}
+ *
+ * @throws IncompatibleThreadStateException if this
+ * thread is not suspended.
+ *
+ * @throws NativeMethodException if the frame to be returned from
+ * is that of a native method.
+ *
+ * @throws InvalidStackFrameException if there are no frames.
+ *
+ * @throws InvalidTypeException if the value's type does not match
+ * the method's return type.
+ *
+ * @throws ClassNotLoadedException if the method's return type has not yet
+ * been loaded through the appropriate class loader.
+ *
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ *
+ * @since 1.6
+ */
+ void forceEarlyReturn(Value value) throws InvalidTypeException,
+ ClassNotLoadedException,
+ IncompatibleThreadStateException;
+
+}
diff --git a/src/share/classes/com/sun/jdi/Type.java b/src/share/classes/com/sun/jdi/Type.java
new file mode 100644
index 0000000..852d714
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/Type.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * The mirror for a type in the target VM.
+ * This interface is the root of a type hierarchy encompassing primitive
+ * types and reference types.
+ * <P>
+ * A Type may be used to represent a run-time type:
+ * <BLOCKQUOTE>
+ * {@link Value}.type()
+ * </BLOCKQUOTE>
+ * or a compile-time type:
+ * <BLOCKQUOTE>
+ * {@link Field#type()} <BR>
+ * {@link Method#returnType()} <BR>
+ * {@link Method#argumentTypes()} <BR>
+ * {@link LocalVariable#type()} <BR>
+ * {@link ArrayType#componentType()}
+ * </BLOCKQUOTE>
+ * <P>
+ * The following table illustrates which subinterfaces of Type
+ * are used to mirror types in the target VM --
+ * <TABLE BORDER=1 SUMMARY="Maps each type declared in target to a mirrored
+ * instance of a subinterface of PrimitiveType or ReferenceType">
+ * <TR BGCOLOR="#EEEEFF">
+ * <TH id="primtype" colspan=3>Subinterfaces of {@link PrimitiveType}</TH>
+ * <TR BGCOLOR="#EEEEFF">
+ * <TH id="declared" align="left" colspan=2>Type declared in target as</TH>
+ * <TH id="mirrored" align="left">Is mirrored as an instance of</TH>
+ * <TR>
+ * <TD headers="primtype declared" colspan=2><CODE>boolean</CODE></TD>
+ * <TD headers="primtype mirrored"> {@link BooleanType}</TD>
+ * <TR>
+ * <TD headers="primtype declared" colspan=2><CODE>byte</CODE></TD>
+ * <TD headers="primtype mirrored">{@link ByteType}</TD>
+ * <TR>
+ * <TD headers="primtype declared" colspan=2><CODE>char</CODE></TD>
+ * <TD headers="primtype mirrored">{@link CharType}</TD>
+ * <TR>
+ * <TD headers="primtype declared" colspan=2><CODE>double</CODE></TD>
+ * <TD headers="primtype mirrored">{@link DoubleType}</TD>
+ * <TR>
+ * <TD headers="primtype declared" colspan=2><CODE>float</CODE></TD>
+ * <TD headers="primtype mirrored">{@link FloatType}</TD>
+ * <TR>
+ * <TD headers="primtype declared" colspan=2><CODE>int</CODE></TD>
+ * <TD headers="primtype mirrored">{@link IntegerType}</TD>
+ * <TR>
+ * <TD headers="primtype declared" colspan=2><CODE>long</CODE></TD>
+ * <TD headers="primtype mirrored">{@link LongType}</TD>
+ * <TR>
+ * <TD headers="primtype declared" colspan=2><CODE>short</CODE></TD>
+ * <TD headers="primtype mirrored">{@link ShortType}</TD>
+ * <TR>
+ * <TD headers="primtype declared" colspan=2><CODE>void</CODE></TD>
+ * <TD headers="primtype mirrored">{@link VoidType}</TD>
+ * <TR BGCOLOR="#EEEEFF">
+ * <TH id="reftype" colspan=3>Subinterfaces of {@link ReferenceType}</TH>
+ * <TR BGCOLOR="#EEEEFF">
+ * <TH id="declared2" align="left">Type declared in target as</TH>
+ * <TH id="example2" align="left">For example</TH>
+ * <TH id="mirrored2" align="left">Is mirrored as an instance of</TH>
+ * <TR>
+ * <TD headers="reftype declared2"><I>a class</I></TD>
+ * <TD headers="reftype example2"><CODE>Date</CODE></TD>
+ * <TD headers="reftype mirrored2">{@link ClassType}</TD>
+ * <TR>
+ * <TD headers="reftype declared2"><I>an interface</I></TD>
+ * <TD headers="reftype example2"><CODE>Runnable</CODE></TD>
+ * <TD headers="reftype mirrored2">{@link InterfaceType}</TD>
+ * <TR>
+ * <TD headers="reftype declared2"><I>an array</I></TD>
+ * <TD headers="reftype example2"> </TD>
+ * <TD headers="reftype mirrored2">{@link ArrayType}</TD>
+ * <TR>
+ * <TD headers="reftype declared2"><I>an array</I></TD>
+ * <TD headers="reftype example2"><CODE>int[]</CODE></TD>
+ * <TD headers="reftype mirrored2">{@link ArrayType} whose
+ * {@link ArrayType#componentType() componentType()} is
+ * {@link IntegerType}</TD>
+ * <TR>
+ * <TD headers="reftype declared2"><I>an array</I></TD>
+ * <TD headers="reftype example2"><CODE>Date[]</CODE></TD>
+ * <TD headers="reftype mirrored2">{@link ArrayType} whose
+ * {@link ArrayType#componentType() componentType()} is
+ * {@link ClassType}</TD>
+ * <TR>
+ * <TD headers="reftype declared2"><I>an array</I></TD>
+ * <TD headers="reftype example2"><CODE>Runnable[]</CODE></TD>
+ * <TD headers="reftype mirrored2">{@link ArrayType} whose
+ * {@link ArrayType#componentType() componentType()} is
+ * {@link InterfaceType}</TD>
+ * </TABLE>
+ *
+ * @see PrimitiveType Subinterface PrimitiveType
+ * @see ReferenceType Subinterface ReferenceType
+ * @see Value Value - for relationship between Type and Value
+ * @see Field#type() Field.type() - for usage examples
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface Type extends Mirror {
+
+ /**
+ * Returns the JNI-style signature for this type.
+ * <p>
+ * For primitive classes
+ * the returned signature is the signature of the corresponding primitive
+ * type; for example, "I" is returned as the signature of the class
+ * represented by {@link java.lang.Integer#TYPE}.
+ *
+ * @see <a href="doc-files/signature.html">Type Signatures</a>
+ * @return the string containing the type signature.
+ */
+ String signature();
+
+ /**
+ * @return a text representation of this type.
+ */
+ String name();
+}
diff --git a/src/share/classes/com/sun/jdi/TypeComponent.java b/src/share/classes/com/sun/jdi/TypeComponent.java
new file mode 100644
index 0000000..fa36d7b
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/TypeComponent.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * An entity declared within a user defined
+ * type (class or interface).
+ * This interface is the root of the type
+ * component hierarchy which
+ * includes {@link Field} and {@link Method}.
+ * Type components of the same name declared in different classes
+ * (including those related by inheritance) have different
+ * TypeComponent objects.
+ * TypeComponents can be used alone to retrieve static information
+ * about their declaration, or can be used in conjunction with a
+ * {@link ReferenceType} or {@link ObjectReference} to access values
+ * or invoke, as applicable.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface TypeComponent extends Mirror, Accessible {
+
+ /**
+ * Gets the name of this type component.
+ * <P>
+ * Note: for fields, this is the field name; for methods,
+ * this is the method name; for constructors, this is <init>;
+ * for static initializers, this is <clinit>.
+ *
+ * @return a string containing the name.
+ */
+ String name();
+
+ /**
+ * Gets the JNI-style signature for this type component. The
+ * signature is encoded type information as defined
+ * in the JNI documentation. It is a convenient, compact format for
+ * for manipulating type information internally, not necessarily
+ * for display to an end user. See {@link Field#typeName} and
+ * {@link Method#returnTypeName} for ways to help get a more readable
+ * representation of the type.
+ *
+ * @see <a href="doc-files/signature.html">Type Signatures</a>
+ * @return a string containing the signature
+ */
+ String signature();
+
+ /**
+ * Gets the generic signature for this TypeComponent if there is one.
+ * Generic signatures are described in the
+ * <cite>The Java™ Virtual Machine Specification</cite>.
+ *
+ * @return a string containing the generic signature, or <code>null</code>
+ * if there is no generic signature.
+ *
+ * @since 1.5
+ */
+ String genericSignature();
+
+ /**
+ * Returns the type in which this component was declared. The
+ * returned {@link ReferenceType} mirrors either a class or an
+ * interface in the target VM.
+ *
+ * @return a {@link ReferenceType} for the type that declared
+ * this type component.
+ */
+ ReferenceType declaringType();
+
+ /**
+ * Determines if this TypeComponent is static.
+ * Return value is undefined for constructors and static initializers.
+ *
+ * @return <code>true</code> if this type component was declared
+ * static; false otherwise.
+ */
+ boolean isStatic();
+
+ /**
+ * Determines if this TypeComponent is final.
+ * Return value is undefined for constructors and static initializers.
+ *
+ * @return <code>true</code> if this type component was declared
+ * final; false otherwise.
+ */
+ boolean isFinal();
+
+ /**
+ * Determines if this TypeComponent is synthetic. Synthetic members
+ * are generated by the compiler and are not present in the source
+ * code for the containing class.
+ * <p>
+ * Not all target VMs support this query. See
+ * {@link VirtualMachine#canGetSyntheticAttribute} to determine if the
+ * operation is supported.
+ *
+ * @return <code>true</code> if this type component is synthetic;
+ * <code>false</code> otherwise.
+ * @throws java.lang.UnsupportedOperationException if the target
+ * VM cannot provide information on synthetic attributes.
+ */
+ boolean isSynthetic();
+}
diff --git a/src/share/classes/com/sun/jdi/VMCannotBeModifiedException.java b/src/share/classes/com/sun/jdi/VMCannotBeModifiedException.java
new file mode 100644
index 0000000..49f1c88
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/VMCannotBeModifiedException.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2003, 2013, 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.jdi;
+
+/**
+ * Thrown to indicate that the operation is invalid because it would
+ * modify the VM and the VM is read-only. See {@link VirtualMachine#canBeModified()}.
+ *
+ * @author Jim Holmlund
+ * @since 1.5
+ */
+@jdk.Exported
+public class VMCannotBeModifiedException extends UnsupportedOperationException {
+ private static final long serialVersionUID = -4063879815130164009L;
+ public VMCannotBeModifiedException() {
+ super();
+ }
+
+ public VMCannotBeModifiedException(String s) {
+ super(s);
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/VMDisconnectedException.java b/src/share/classes/com/sun/jdi/VMDisconnectedException.java
new file mode 100644
index 0000000..faeab60
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/VMDisconnectedException.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Unchecked exception thrown to indicate that the
+ * requested operation cannot be
+ * completed because there is no longer a connection to the target VM.
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public class VMDisconnectedException extends RuntimeException {
+
+ private static final long serialVersionUID = 2892975269768351637L;
+ public VMDisconnectedException() {
+ super();
+ }
+ public VMDisconnectedException(String message) {
+ super(message);
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/VMMismatchException.java b/src/share/classes/com/sun/jdi/VMMismatchException.java
new file mode 100644
index 0000000..b05a9aa
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/VMMismatchException.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 1999, 2013, 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.jdi;
+
+/**
+ * Thrown to indicate that the requested operation cannot be
+ * completed because the a mirror from one target VM is being
+ * combined with a mirror from another target VM.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public class VMMismatchException extends RuntimeException {
+ private static final long serialVersionUID = 289169358790459564L;
+ public VMMismatchException() {
+ super();
+ }
+
+ public VMMismatchException(String s) {
+ super(s);
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/VMOutOfMemoryException.java b/src/share/classes/com/sun/jdi/VMOutOfMemoryException.java
new file mode 100644
index 0000000..cc64d92
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/VMOutOfMemoryException.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 1999, 2013, 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.jdi;
+
+/**
+ * Thrown to indicate that the requested operation cannot be
+ * completed because the target VM has run out of memory.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public class VMOutOfMemoryException extends RuntimeException {
+ private static final long serialVersionUID = 71504228548910686L;
+ public VMOutOfMemoryException() {
+ super();
+ }
+
+ public VMOutOfMemoryException(String s) {
+ super(s);
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/Value.java b/src/share/classes/com/sun/jdi/Value.java
new file mode 100644
index 0000000..4957b02
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/Value.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * The mirror for a value in the target VM.
+ * This interface is the root of a
+ * value hierarchy encompassing primitive values and object values.
+ * <P>
+ * Some examples of where values may be accessed:
+ * <BLOCKQUOTE><TABLE SUMMARY="layout">
+ * <TR>
+ * <TD>{@link ObjectReference#getValue(com.sun.jdi.Field)
+ * ObjectReference.getValue(Field)}
+ * <TD>- value of a field
+ * <TR>
+ * <TD>{@link StackFrame#getValue(com.sun.jdi.LocalVariable)
+ * StackFrame.getValue(LocalVariable)}
+ * <TD>- value of a variable
+ * <TR>
+ * <TD>{@link VirtualMachine#mirrorOf(double)
+ * VirtualMachine.mirrorOf(double)}
+ * <TD>- created in the target VM by the JDI client
+ * <TR>
+ * <TD>{@link com.sun.jdi.event.ModificationWatchpointEvent#valueToBe()
+ * ModificationWatchpointEvent.valueToBe()}
+ * <TD>- returned with an event
+ * </TABLE></BLOCKQUOTE>
+ * <P>
+ * The following table illustrates which subinterfaces of Value
+ * are used to mirror values in the target VM --
+ * <TABLE BORDER=1 SUMMARY="Maps each kind of value to a mirrored
+ * instance of a subinterface of Value">
+ * <TR BGCOLOR="#EEEEFF">
+ * <TH id="primval" colspan=4>Subinterfaces of {@link PrimitiveValue}</TH>
+ * <TR BGCOLOR="#EEEEFF">
+ * <TH id="kind" align="left">Kind of value</TH>
+ * <TH id="example" align="left">For example -<br>expression in target</TH>
+ * <TH id="mirrored" align="left">Is mirrored as an<br>instance of</TH>
+ * <TH id="type" align="left">{@link Type} of value<br>{@link #type() Value.type()}</TH>
+ * <TR>
+ * <TD headers="primval kind"> a boolean</TD>
+ * <TD headers="primval example"> <CODE>true</CODE></TD>
+ * <TD headers="primval mirrored"> {@link BooleanValue}</TD>
+ * <TD headers="primval type"> {@link BooleanType}</TD>
+ * <TR>
+ * <TD headers="primval kind"> a byte</TD>
+ * <TD headers="primval example"> <CODE>(byte)4</CODE></TD>
+ * <TD headers="primval mirrored"> {@link ByteValue}</TD>
+ * <TD headers="primval type"> {@link ByteType}</TD>
+ * <TR>
+ * <TD headers="primval kind"> a char</TD>
+ * <TD headers="primval example"> <CODE>'a'</CODE></TD>
+ * <TD headers="primval mirrored"> {@link CharValue}</TD>
+ * <TD headers="primval type"> {@link CharType}</TD>
+ * <TR>
+ * <TD headers="primval kind"> a double</TD>
+ * <TD headers="primval example"> <CODE>3.1415926</CODE></TD>
+ * <TD headers="primval mirrored"> {@link DoubleValue}</TD>
+ * <TD headers="primval type"> {@link DoubleType}</TD>
+ * <TR>
+ * <TD headers="primval kind"> a float</TD>
+ * <TD headers="primval example"> <CODE>2.5f</CODE></TD>
+ * <TD headers="primval mirrored"> {@link FloatValue}</TD>
+ * <TD headers="primval type"> {@link FloatType}</TD>
+ * <TR>
+ * <TD headers="primval kind"> an int</TD>
+ * <TD headers="primval example"> <CODE>22</CODE></TD>
+ * <TD headers="primval mirrored"> {@link IntegerValue}</TD>
+ * <TD headers="primval type"> {@link IntegerType}</TD>
+ * <TR>
+ * <TD headers="primval kind"> a long</TD>
+ * <TD headers="primval example"> <CODE>1024L</CODE></TD>
+ * <TD headers="primval mirrored"> {@link LongValue}</TD>
+ * <TD headers="primval type"> {@link LongType}</TD>
+ * <TR>
+ * <TD headers="primval kind"> a short</TD>
+ * <TD headers="primval example"> <CODE>(short)12</CODE></TD>
+ * <TD headers="primval mirrored"> {@link ShortValue}</TD>
+ * <TD headers="primval type"> {@link ShortType}</TD>
+ * <TR>
+ * <TD headers="primval kind"> a void</TD>
+ * <TD headers="primval example"> <CODE> </CODE></TD>
+ * <TD headers="primval mirrored"> {@link VoidValue}</TD>
+ * <TD headers="primval type"> {@link VoidType}</TD>
+ * <TR BGCOLOR="#EEEEFF">
+ * <TH id="objref" colspan=4>Subinterfaces of {@link ObjectReference}</TH>
+ * <TR BGCOLOR="#EEEEFF">
+ * <TH id="kind2" align="left">Kind of value</TH>
+ * <TH id="example2" align="left">For example -<br>expression in target</TH>
+ * <TH id="mirrored2" align="left">Is mirrored as an<br>instance of</TH>
+ * <TH id="type2" align="left">{@link Type} of value<br>{@link #type() Value.type()}</TH>
+ * <TR>
+ * <TD headers="objref kind2"> a class instance</TD>
+ * <TD headers="objref example2"> <CODE>this</CODE></TD>
+ * <TD headers="objref mirrored2"> {@link ObjectReference}</TD>
+ * <TD headers="objref type2"> {@link ClassType}</TD>
+ * <TR>
+ * <TD headers="objref kind2"> an array</TD>
+ * <TD headers="objref example2"> <CODE>new int[5]</CODE></TD>
+ * <TD headers="objref mirrored2"> {@link ArrayReference}</TD>
+ * <TD headers="objref type2"> {@link ArrayType}</TD>
+ * <TR>
+ * <TD headers="objref kind2"> a string</TD>
+ * <TD headers="objref example2"> <CODE>"hello"</CODE></TD>
+ * <TD headers="objref mirrored2"> {@link StringReference}</TD>
+ * <TD headers="objref type2"> {@link ClassType}</TD>
+ * <TR>
+ * <TD headers="objref kind2"> a thread</TD>
+ * <TD headers="objref example2"> <CODE>Thread.currentThread()</CODE></TD>
+ * <TD headers="objref mirrored2"> {@link ThreadReference}</TD>
+ * <TD headers="objref type2"> {@link ClassType}</TD>
+ * <TR>
+ * <TD headers="objref kind2"> a thread group</TD>
+ * <TD headers="objref example2"> <CODE>Thread.currentThread()<br> .getThreadGroup()</CODE></TD>
+ * <TD headers="objref mirrored2"> {@link ThreadGroupReference}</TD>
+ * <TD headers="objref type2"> {@link ClassType}</TD>
+ * <TR>
+ * <TD headers="objref kind2"> a <CODE>java.lang.Class</CODE><br>instance</TD>
+ * <TD headers="objref example2"> <CODE>this.getClass()</CODE></TD>
+ * <TD headers="objref mirrored2"> {@link ClassObjectReference}</TD>
+ * <TD headers="objref type2"> {@link ClassType}</TD>
+ * <TR>
+ * <TD headers="objref kind2"> a class loader</TD>
+ * <TD headers="objref example2"> <CODE>this.getClass()<br> .getClassLoader() </CODE></TD>
+ * <TD headers="objref mirrored2"> {@link ClassLoaderReference}</TD>
+ * <TD headers="objref type2"> {@link ClassType}</TD>
+ * <TR BGCOLOR="#EEEEFF">
+ * <TH id="other" colspan=4>Other</TH>
+ * <TR BGCOLOR="#EEEEFF">
+ * <TH id="kind3" align="left">Kind of value</TD>
+ * <TH id="example3" align="left">For example -<br>expression in target</TD>
+ * <TH id="mirrored3" align="left">Is mirrored as</TD>
+ * <TH id="type3" align="left">{@link Type} of value</TD>
+ * <TR>
+ * <TD headers="other kind3"> null</TD>
+ * <TD headers="other example3"> <CODE>null</CODE></TD>
+ * <TD headers="other mirrored3"> <CODE>null</CODE></TD>
+ * <TD headers="other type3"> n/a</TD>
+ * </TABLE>
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+
+@jdk.Exported
+public interface Value extends Mirror {
+ /**
+ * Returns the run-time type of this value.
+ *
+ * @see Type
+ * @return a {@link Type} which mirrors the value's type in the
+ * target VM.
+ */
+ Type type();
+}
diff --git a/src/share/classes/com/sun/jdi/VirtualMachine.java b/src/share/classes/com/sun/jdi/VirtualMachine.java
new file mode 100644
index 0000000..0571a27
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/VirtualMachine.java
@@ -0,0 +1,864 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+import com.sun.jdi.event.EventQueue;
+import com.sun.jdi.request.EventRequestManager;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A virtual machine targeted for debugging.
+ * More precisely, a {@link Mirror mirror} representing the
+ * composite state of the target VM.
+ * All other mirrors are associated with an instance of this
+ * interface. Access to all other mirrors is achieved
+ * directly or indirectly through an instance of this
+ * interface.
+ * Access to global VM properties and control of VM execution
+ * are supported directly by this interface.
+ * <P>
+ * Instances of this interface are created by instances of
+ * {@link com.sun.jdi.connect.Connector}. For example,
+ * an {@link com.sun.jdi.connect.AttachingConnector AttachingConnector}
+ * attaches to a target VM and returns its virtual machine mirror.
+ * A Connector will typically create a VirtualMachine by invoking
+ * the VirtualMachineManager's {@link
+ * com.sun.jdi.VirtualMachineManager#createVirtualMachine(Connection)}
+ * createVirtualMachine(Connection) method.
+ * <p>
+ * Note that a target VM launched by a launching connector is not
+ * guaranteed to be stable until after the {@link com.sun.jdi.event.VMStartEvent} has been
+ * received.
+ * <p>
+ * Any method on <code>VirtualMachine</code> which
+ * takes <code>VirtualMachine</code> as an parameter may throw
+ * {@link com.sun.jdi.VMDisconnectedException} if the target VM is
+ * disconnected and the {@link com.sun.jdi.event.VMDisconnectEvent} has been or is
+ * available to be read from the {@link com.sun.jdi.event.EventQueue}.
+ * <p>
+ * Any method on <code>VirtualMachine</code> which
+ * takes <code>VirtualMachine</code> as an parameter may throw
+ * {@link com.sun.jdi.VMOutOfMemoryException} if the target VM has run out of memory.
+ *
+ * @author Robert Field
+ * @author Gordon Hirsch
+ * @author James McIlree
+ * @since 1.3
+ */
+@jdk.Exported
+public interface VirtualMachine extends Mirror {
+
+ /**
+ * Returns the loaded reference types that
+ * match a given name. The name must be fully qualified
+ * (for example, java.lang.String). The returned list
+ * will contain a {@link ReferenceType} for each class
+ * or interface found with the given name. The search
+ * is confined to loaded classes only; no attempt is made
+ * to load a class of the given name.
+ * <P>
+ * The returned list will include reference types
+ * loaded at least to the point of preparation and
+ * types (like array) for which preparation is
+ * not defined.
+ *
+ * @param className the class/interface name to search for
+ * @return a list of {@link ReferenceType} objects, each
+ * mirroring a type in the target VM with the given name.
+ */
+ List<ReferenceType> classesByName(String className);
+
+ /**
+ * Returns all loaded types. For each loaded type in the target
+ * VM a {@link ReferenceType} will be placed in the returned list.
+ * The list will include ReferenceTypes which mirror classes,
+ * interfaces, and array types.
+ * <P>
+ * The returned list will include reference types
+ * loaded at least to the point of preparation and
+ * types (like array) for which preparation is
+ * not defined.
+ *
+ * @return a list of {@link ReferenceType} objects, each mirroring
+ * a loaded type in the target VM.
+ */
+ List<ReferenceType> allClasses();
+
+ /**
+ * All classes given are redefined according to the
+ * definitions supplied. A method in a redefined class
+ * is called 'equivalent' (to the old version of the
+ * method) if
+ * <UL>
+ * <LI>their bytecodes are the same except for indicies into
+ * the constant pool, and
+ * <LI>the referenced constants are equal.
+ * </UL>
+ * Otherwise, the new method is called 'non-equivalent'.
+ * If a redefined method has active stack frames, those active
+ * frames continue to run the bytecodes of the previous version of the
+ * method. If the new version of such a method is non-equivalent,
+ * then a method from one of these active frames is called 'obsolete' and
+ * {@link Method#isObsolete Method.isObsolete()}
+ * will return true when called on one of these methods.
+ * If resetting such a frame is desired, use
+ * {@link ThreadReference#popFrames ThreadReference.popFrames(StackFrame)}
+ * to pop the old obsolete method execution from the stack.
+ * New invocations of redefined methods will always invoke the new versions.
+ * <p>
+ * This function does not cause any initialization except
+ * that which would occur under the customary JVM semantics.
+ * In other words, redefining a class does not cause
+ * its initializers to be run. The values of preexisting
+ * static variables will remain as they were prior to the
+ * call. However, completely uninitialized (new) static
+ * variables will be assigned their default value.
+ * <p>
+ * If a redefined class has instances then all those
+ * instances will have the fields defined by the redefined
+ * class at the completion of the call. Preexisting fields
+ * will retain their previous values. Any new fields will
+ * have their default values; no instance initializers or
+ * constructors are run.
+ * <p>
+ * Threads need not be suspended.
+ * <p>
+ * No events are generated by this function.
+ * <p>
+ * All breakpoints in the redefined classes are deleted.
+ * <p>
+ * Not all target virtual machines support this operation.
+ * Use {@link #canRedefineClasses() canRedefineClasses()}
+ * to determine if the operation is supported.
+ * Use {@link #canAddMethod() canAddMethod()}
+ * to determine if the redefinition can add methods.
+ * Use {@link #canUnrestrictedlyRedefineClasses() canUnrestrictedlyRedefineClasses()}
+ * to determine if the redefinition can change the schema,
+ * delete methods, change the class hierarchy, etc.
+ *
+ * @param classToBytes A map from {@link ReferenceType}
+ * to array of byte.
+ * The bytes represent the new class definition and
+ * are in Java Virtual Machine class file format.
+ *
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation.
+ * <UL>
+ * <LI>If {@link #canRedefineClasses() canRedefineClasses()}
+ * is false any call of this method will throw this exception.
+ * <LI>If {@link #canAddMethod() canAddMethod()} is false
+ * attempting to add a method will throw this exception.
+ * <LI>If {@link #canUnrestrictedlyRedefineClasses()
+ * canUnrestrictedlyRedefineClasses()}
+ * is false, attempting any of the following will throw
+ * this exception
+ * <UL>
+ * <LI>changing the schema (the fields)
+ * <LI>changing the hierarchy (subclasses, interfaces)
+ * <LI>deleting a method
+ * <LI>changing class modifiers
+ * <LI>changing method modifiers
+ * </UL>
+ * </UL>
+ *
+ * @throws java.lang.NoClassDefFoundError if the bytes
+ * don't correspond to the reference type (the names
+ * don't match).
+ *
+ * @throws java.lang.VerifyError if a "verifier" detects
+ * that a class, though well formed, contains an internal
+ * inconsistency or security problem.
+ *
+ * @throws java.lang.ClassFormatError if the bytes
+ * do not represent a valid class.
+ *
+ * @throws java.lang.ClassCircularityError if a
+ * circularity has been detected while initializing a class.
+ *
+ * @throws java.lang.UnsupportedClassVersionError if the
+ * major and minor version numbers in bytes
+ * are not supported by the VM.
+ *
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ *
+ * @see Method#isObsolete
+ * @see ThreadReference#popFrames
+ * @see #canRedefineClasses
+ * @see #canAddMethod
+ * @see #canUnrestrictedlyRedefineClasses
+ *
+ * @since 1.4
+ */
+ void redefineClasses(Map<? extends ReferenceType,byte[]> classToBytes);
+
+ /**
+ * Returns a list of the currently running threads. For each
+ * running thread in the target VM, a {@link ThreadReference}
+ * that mirrors it is placed in the list.
+ * The returned list contains threads created through
+ * java.lang.Thread, all native threads attached to
+ * the target VM through JNI, and system threads created
+ * by the target VM. Thread objects that have
+ * not yet been started
+ * (see {@link java.lang.Thread#start Thread.start()})
+ * and thread objects that have
+ * completed their execution are not included in the returned list.
+ *
+ * @return a list of {@link ThreadReference} objects, one for each
+ * running thread in the mirrored VM.
+ */
+ List<ThreadReference> allThreads();
+
+ /**
+ * Suspends the execution of the application running in this
+ * virtual machine. All threads currently running will be suspended.
+ * <p>
+ * Unlike {@link java.lang.Thread#suspend Thread.suspend()},
+ * suspends of both the virtual machine and individual threads are
+ * counted. Before a thread will run again, it must be resumed
+ * (through {@link #resume} or {@link ThreadReference#resume})
+ * the same number of times it has been suspended.
+ *
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ */
+ void suspend();
+
+ /**
+ * Continues the execution of the application running in this
+ * virtual machine. All threads are resumed as documented in
+ * {@link ThreadReference#resume}.
+ *
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ *
+ * @see #suspend
+ */
+ void resume();
+
+ /**
+ * Returns each thread group which does not have a parent. For each
+ * top level thread group a {@link ThreadGroupReference} is placed in the
+ * returned list.
+ * <p>
+ * This command may be used as the first step in building a tree
+ * (or trees) of the existing thread groups.
+ *
+ * @return a list of {@link ThreadGroupReference} objects, one for each
+ * top level thread group.
+ */
+ List<ThreadGroupReference> topLevelThreadGroups();
+
+ /**
+ * Returns the event queue for this virtual machine.
+ * A virtual machine has only one {@link EventQueue} object, this
+ * method will return the same instance each time it
+ * is invoked.
+ *
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ *
+ * @return the {@link EventQueue} for this virtual machine.
+ */
+ EventQueue eventQueue();
+
+ /**
+ * Returns the event request manager for this virtual machine.
+ * The {@link EventRequestManager} controls user settable events
+ * such as breakpoints.
+ * A virtual machine has only one {@link EventRequestManager} object,
+ * this method will return the same instance each time it
+ * is invoked.
+ *
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ *
+ * @return the {@link EventRequestManager} for this virtual machine.
+ */
+ EventRequestManager eventRequestManager();
+
+ /**
+ * Creates a {@link BooleanValue} for the given value. This value
+ * can be used for setting and comparing against a value retrieved
+ * from a variable or field in this virtual machine.
+ *
+ * @param value a boolean for which to create the value
+ * @return the {@link BooleanValue} for the given boolean.
+ */
+ BooleanValue mirrorOf(boolean value);
+
+ /**
+ * Creates a {@link ByteValue} for the given value. This value
+ * can be used for setting and comparing against a value retrieved
+ * from a variable or field in this virtual machine.
+ *
+ * @param value a byte for which to create the value
+ * @return the {@link ByteValue} for the given byte.
+ */
+ ByteValue mirrorOf(byte value);
+
+ /**
+ * Creates a {@link CharValue} for the given value. This value
+ * can be used for setting and comparing against a value retrieved
+ * from a variable or field in this virtual machine.
+ *
+ * @param value a char for which to create the value
+ * @return the {@link CharValue} for the given char.
+ */
+ CharValue mirrorOf(char value);
+
+ /**
+ * Creates a {@link ShortValue} for the given value. This value
+ * can be used for setting and comparing against a value retrieved
+ * from a variable or field in this virtual machine.
+ *
+ * @param value a short for which to create the value
+ * @return the {@link ShortValue} for the given short.
+ */
+ ShortValue mirrorOf(short value);
+
+ /**
+ * Creates an {@link IntegerValue} for the given value. This value
+ * can be used for setting and comparing against a value retrieved
+ * from a variable or field in this virtual machine.
+ *
+ * @param value an int for which to create the value
+ * @return the {@link IntegerValue} for the given int.
+ */
+ IntegerValue mirrorOf(int value);
+
+ /**
+ * Creates a {@link LongValue} for the given value. This value
+ * can be used for setting and comparing against a value retrieved
+ * from a variable or field in this virtual machine.
+ *
+ * @param value a long for which to create the value
+ * @return the {@link LongValue} for the given long.
+ */
+ LongValue mirrorOf(long value);
+
+ /**
+ * Creates a {@link FloatValue} for the given value. This value
+ * can be used for setting and comparing against a value retrieved
+ * from a variable or field in this virtual machine.
+ *
+ * @param value a float for which to create the value
+ * @return the {@link FloatValue} for the given float.
+ */
+ FloatValue mirrorOf(float value);
+
+ /**
+ * Creates a {@link DoubleValue} for the given value. This value
+ * can be used for setting and comparing against a value retrieved
+ * from a variable or field in this virtual machine.
+ *
+ * @param value a double for which to create the value
+ * @return the {@link DoubleValue} for the given double.
+ */
+ DoubleValue mirrorOf(double value);
+
+ /**
+ * Creates a string in this virtual machine.
+ * The created string can be used for setting and comparing against
+ * a string value retrieved from a variable or field in this
+ * virtual machine.
+ *
+ * @param value the string to be created
+ * @return a {@link StringReference} that mirrors the newly created
+ * string in the target VM.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only
+ * -see {@link VirtualMachine#canBeModified()}.
+ */
+ StringReference mirrorOf(String value);
+
+
+ /**
+ * Creates a {@link VoidValue}. This value
+ * can be passed to {@link ThreadReference#forceEarlyReturn}
+ * when a void method is to be exited.
+ *
+ * @return the {@link VoidValue}.
+ */
+ VoidValue mirrorOfVoid();
+
+ /**
+ * Returns the {@link java.lang.Process} object for this
+ * virtual machine if launched
+ * by a {@link com.sun.jdi.connect.LaunchingConnector}
+ *
+ * @return the {@link java.lang.Process} object for this virtual
+ * machine, or null if it was not launched by a
+ * {@link com.sun.jdi.connect.LaunchingConnector}.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only
+ * -see {@link VirtualMachine#canBeModified()}.
+ */
+ Process process();
+
+ /**
+ * Invalidates this virtual machine mirror.
+ * The communication channel to the target VM is closed, and
+ * the target VM prepares to accept another subsequent connection
+ * from this debugger or another debugger, including the
+ * following tasks:
+ * <ul>
+ * <li>All event requests are cancelled.
+ * <li>All threads suspended by {@link #suspend} or by
+ * {@link ThreadReference#suspend} are resumed as many
+ * times as necessary for them to run.
+ * <li>Garbage collection is re-enabled in all cases where it was
+ * disabled through {@link ObjectReference#disableCollection}.
+ * </ul>
+ * Any current method invocations executing in the target VM
+ * are continued after the disconnection. Upon completion of any such
+ * method invocation, the invoking thread continues from the
+ * location where it was originally stopped.
+ * <p>
+ * Resources originating in
+ * this VirtualMachine (ObjectReferences, ReferenceTypes, etc.)
+ * will become invalid.
+ */
+ void dispose();
+
+ /**
+ * Causes the mirrored VM to terminate with the given error code.
+ * All resources associated with this VirtualMachine are freed.
+ * If the mirrored VM is remote, the communication channel
+ * to it will be closed. Resources originating in
+ * this VirtualMachine (ObjectReferences, ReferenceTypes, etc.)
+ * will become invalid.
+ * <p>
+ * Threads running in the mirrored VM are abruptly terminated.
+ * A thread death exception is not thrown and
+ * finally blocks are not run.
+ *
+ * @param exitCode the exit code for the target VM. On some platforms,
+ * the exit code might be truncated, for example, to the lower order 8 bits.
+ *
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ */
+ void exit(int exitCode);
+
+ /**
+ * Determines if the target VM supports watchpoints
+ * for field modification.
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ */
+ boolean canWatchFieldModification();
+
+ /**
+ * Determines if the target VM supports watchpoints
+ * for field access.
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ */
+ boolean canWatchFieldAccess();
+
+ /**
+ * Determines if the target VM supports the retrieval
+ * of a method's bytecodes.
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ */
+ boolean canGetBytecodes();
+
+ /**
+ * Determines if the target VM supports the query
+ * of the synthetic attribute of a method or field.
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ */
+ boolean canGetSyntheticAttribute();
+
+ /**
+ * Determines if the target VM supports the retrieval
+ * of the monitors owned by a thread.
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ */
+ boolean canGetOwnedMonitorInfo();
+
+ /**
+ * Determines if the target VM supports the retrieval
+ * of the monitor for which a thread is currently waiting.
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ */
+ boolean canGetCurrentContendedMonitor();
+
+ /**
+ * Determines if the target VM supports the retrieval
+ * of the monitor information for an object.
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ */
+ boolean canGetMonitorInfo();
+
+ /**
+ * Determines if the target VM supports filtering
+ * events by specific instance object. For example,
+ * see {@link com.sun.jdi.request.BreakpointRequest#addInstanceFilter}.
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ */
+ boolean canUseInstanceFilters();
+
+ /**
+ * Determines if the target VM supports any level
+ * of class redefinition.
+ * @see #redefineClasses
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ *
+ * @since 1.4
+ */
+ boolean canRedefineClasses();
+
+ /**
+ * Determines if the target VM supports the addition
+ * of methods when performing class redefinition.
+ * @see #redefineClasses
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ *
+ * @since 1.4
+ */
+ boolean canAddMethod();
+
+ /**
+ * Determines if the target VM supports unrestricted
+ * changes when performing class redefinition.
+ * @see #redefineClasses
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ *
+ * @since 1.4
+ */
+ boolean canUnrestrictedlyRedefineClasses();
+
+ /**
+ * Determines if the target VM supports popping
+ * frames of a threads stack.
+ * @see ThreadReference#popFrames
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ *
+ * @since 1.4
+ */
+ boolean canPopFrames();
+
+ /**
+ * Determines if the target VM supports getting
+ * the source debug extension.
+ * @see ReferenceType#sourceDebugExtension
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ *
+ * @since 1.4
+ */
+ boolean canGetSourceDebugExtension();
+
+ /**
+ * Determines if the target VM supports the creation of
+ * {@link com.sun.jdi.request.VMDeathRequest}s.
+ * @see com.sun.jdi.request.EventRequestManager#createVMDeathRequest
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ *
+ * @since 1.4
+ */
+ boolean canRequestVMDeathEvent();
+
+ /**
+ * Determines if the target VM supports the inclusion of return values
+ * in
+ * {@link com.sun.jdi.event.MethodExitEvent}s.
+ * @see com.sun.jdi.request.EventRequestManager#createMethodExitRequest
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ *
+ * @since 1.6
+ */
+ boolean canGetMethodReturnValues();
+
+ /**
+ * Determines if the target VM supports the accessing of class instances,
+ * instance counts, and referring objects.
+ *
+ * @see #instanceCounts
+ * @see ReferenceType#instances(long)
+ * @see ObjectReference#referringObjects(long)
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ *
+ * @since 1.6
+ */
+ boolean canGetInstanceInfo();
+
+
+ /**
+ * Determines if the target VM supports the filtering of
+ * class prepare events by source name.
+ *
+ * see {@link com.sun.jdi.request.ClassPrepareRequest#addSourceNameFilter}.
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ *
+ * @since 1.6
+ */
+ boolean canUseSourceNameFilters();
+
+ /**
+ * Determines if the target VM supports the forcing of a method to
+ * return early.
+ *
+ * @see ThreadReference#forceEarlyReturn(Value)
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ *
+ * @since 1.6
+ */
+ boolean canForceEarlyReturn();
+
+ /**
+ * Determines if the target VM is a read-only VM. If a method which
+ * would modify the state of the VM is called on a read-only VM,
+ * then {@link VMCannotBeModifiedException} is thrown.
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ *
+ * @since 1.5
+ */
+
+ boolean canBeModified();
+
+ /**
+ * Determines if the target VM supports the creation of
+ * {@link com.sun.jdi.request.MonitorContendedEnterRequest}s.
+ * {@link com.sun.jdi.request.MonitorContendedEnteredRequest}s.
+ * {@link com.sun.jdi.request.MonitorWaitRequest}s.
+ * {@link com.sun.jdi.request.MonitorWaitedRequest}s.
+ * @see com.sun.jdi.request.EventRequestManager#createMonitorContendedEnterRequest
+ * @see com.sun.jdi.request.EventRequestManager#createMonitorContendedEnteredRequest
+ * @see com.sun.jdi.request.EventRequestManager#createMonitorWaitRequest
+ * @see com.sun.jdi.request.EventRequestManager#createMonitorWaitedRequest
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ *
+ * @since 1.6
+ */
+
+ boolean canRequestMonitorEvents();
+
+ /**
+ * Determines if the target VM supports getting which
+ * frame has acquired a monitor.
+ * @see com.sun.jdi.ThreadReference#ownedMonitorsAndFrames
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ *
+ * @since 1.6
+ */
+
+ boolean canGetMonitorFrameInfo();
+
+
+ /**
+ * Determines if the target VM supports reading class file
+ * major and minor versions.
+ *
+ * @see ReferenceType#majorVersion()
+ * @see ReferenceType#minorVersion()
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ *
+ * @since 1.6
+ */
+ boolean canGetClassFileVersion();
+
+ /**
+ * Determines if the target VM supports getting constant pool
+ * information of a class.
+ *
+ * @see ReferenceType#constantPoolCount()
+ * @see ReferenceType#constantPool()
+ *
+ * @return <code>true</code> if the feature is supported,
+ * <code>false</code> otherwise.
+ *
+ * @since 1.6
+ */
+ boolean canGetConstantPool();
+
+ /**
+ * Set this VM's default stratum (see {@link Location} for a
+ * discussion of strata). Overrides the per-class default set
+ * in the class file.
+ * <P>
+ * Affects location queries (such as,
+ * {@link Location#sourceName()})
+ * and the line boundaries used in
+ * single stepping.
+ *
+ * @param stratum the stratum to set as VM default,
+ * or null to use per-class defaults.
+ *
+ * @throws java.lang.UnsupportedOperationException if the
+ * target virtual machine does not support this operation.
+ *
+ * @since 1.4
+ */
+ void setDefaultStratum(String stratum);
+
+ /**
+ * Return this VM's default stratum.
+ *
+ * @see #setDefaultStratum(String)
+ * @see ReferenceType#defaultStratum()
+ * @return <code>null</code> (meaning that the per-class
+ * default - {@link ReferenceType#defaultStratum()} -
+ * should be used) unless the default stratum has been
+ * set with
+ * {@link #setDefaultStratum(String)}.
+ *
+ * @since 1.4
+ */
+ String getDefaultStratum();
+
+ /**
+ * Returns the number of instances of each ReferenceType in the 'refTypes'
+ * list.
+ * Only instances that are reachable for the purposes of garbage collection
+ * are counted.
+ * <p>
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canGetInstanceInfo()}
+ * to determine if the operation is supported.
+ *
+ * @see ReferenceType#instances(long)
+ * @see ObjectReference#referringObjects(long)
+ * @param refTypes the list of {@link ReferenceType} objects for which counts
+ * are to be obtained.
+ *
+ * @return an array of <code>long</code> containing one element for each
+ * element in the 'refTypes' list. Element i of the array contains
+ * the number of instances in the target VM of the ReferenceType at
+ * position i in the 'refTypes' list.
+ * If the 'refTypes' list is empty, a zero-length array is returned.
+ * If a ReferenceType in refTypes has been garbage collected, zero
+ * is returned for its instance count.
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation - see
+ * {@link VirtualMachine#canGetInstanceInfo() canGetInstanceInfo()}
+ * @throws NullPointerException if the 'refTypes' list is null.
+ * @since 1.6
+ */
+ long[] instanceCounts(List<? extends ReferenceType> refTypes);
+
+ /**
+ * Returns text information on the target VM and the
+ * debugger support that mirrors it. No specific format
+ * for this information is guaranteed.
+ * Typically, this string contains version information for the
+ * target VM and debugger interfaces.
+ * More precise information
+ * on VM and JDI versions is available through
+ * {@link #version}, {@link VirtualMachineManager#majorInterfaceVersion},
+ * and {@link VirtualMachineManager#minorInterfaceVersion}
+ *
+ * @return the description.
+ */
+ String description();
+
+ /**
+ * Returns the version of the Java Runtime Environment in the target
+ * VM as reported by the property <code>java.version</code>.
+ * For obtaining the JDI interface version, use
+ * {@link VirtualMachineManager#majorInterfaceVersion}
+ * and {@link VirtualMachineManager#minorInterfaceVersion}
+ *
+ * @return the target VM version.
+ */
+ String version();
+
+ /**
+ * Returns the name of the target VM as reported by the
+ * property <code>java.vm.name</code>.
+ *
+ * @return the target VM name.
+ */
+ String name();
+
+ /** All tracing is disabled. */
+ int TRACE_NONE = 0x00000000;
+ /** Tracing enabled for JDWP packets sent to target VM. */
+ int TRACE_SENDS = 0x00000001;
+ /** Tracing enabled for JDWP packets received from target VM. */
+ int TRACE_RECEIVES = 0x00000002;
+ /** Tracing enabled for internal event handling. */
+ int TRACE_EVENTS = 0x00000004;
+ /** Tracing enabled for internal managment of reference types. */
+ int TRACE_REFTYPES = 0x00000008;
+ /** Tracing enabled for internal management of object references. */
+ int TRACE_OBJREFS = 0x00000010;
+ /** All tracing is enabled. */
+ int TRACE_ALL = 0x00ffffff;
+
+ /**
+ * Traces the activities performed by the com.sun.jdi implementation.
+ * All trace information is output to System.err. The given trace
+ * flags are used to limit the output to only the information
+ * desired. The given flags are in effect and the corresponding
+ * trace will continue until the next call to
+ * this method.
+ * <p>
+ * Output is implementation dependent and trace mode may be ignored.
+ *
+ * @param traceFlags identifies which kinds of tracing to enable.
+ */
+ void setDebugTraceMode(int traceFlags);
+}
diff --git a/src/share/classes/com/sun/jdi/VirtualMachineManager.java b/src/share/classes/com/sun/jdi/VirtualMachineManager.java
new file mode 100644
index 0000000..5b59db5
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/VirtualMachineManager.java
@@ -0,0 +1,431 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+import com.sun.jdi.connect.*;
+import com.sun.jdi.connect.spi.Connection;
+import java.util.List;
+import java.io.IOException;
+
+/**
+ * A manager of connections to target virtual machines. The
+ * VirtualMachineManager allows one application to debug
+ * multiple target VMs. (Note that the converse is not
+ * supported; a target VM can be debugged by only one
+ * debugger application.) This interface
+ * contains methods to manage connections
+ * to remote target VMs and to obtain the {@link VirtualMachine}
+ * mirror for available target VMs.
+ * <p>
+ * Connections can be made using one of several different
+ * {@link com.sun.jdi.connect.Connector} objects. Each connector encapsulates
+ * a different way of connecting the debugger with a target VM.
+ * <p>
+ * The VirtualMachineManager supports many different scenarios for
+ * connecting a debugger to a virtual machine. Four examples
+ * are presented in the table below. The
+ * examples use the command line syntax in Sun's implementation.
+ * Some {@link com.sun.jdi.connect.Connector} implementations may require slightly
+ * different handling than presented below.
+ * <p>
+ * <TABLE BORDER WIDTH="75%" SUMMARY="Four scenarios for connecting a debugger
+ * to a virtual machine">
+ * <TR>
+ * <TH scope=col>Scenario</TH>
+ * <TH scope=col>Description</TH>
+ * <TR>
+ * <TD>Debugger launches target VM (simplest, most-common scenario)</TD>
+ *
+ * <TD>Debugger calls the
+ * {@link com.sun.jdi.connect.LaunchingConnector#launch(java.util.Map)}
+ * method of the default connector, obtained with {@link #defaultConnector}. The
+ * target VM is launched, and a connection between that VM and the
+ * debugger is established. A {@link VirtualMachine} mirror is returned.
+ * <P>Or, for more control
+ * <UL>
+ * <LI>
+ * Debugger selects a connector from the list returned by
+ * {@link #launchingConnectors} with desired characteristics
+ * (for example, transport type, etc.).
+ * <LI>
+ * Debugger calls the
+ * {@link com.sun.jdi.connect.LaunchingConnector#launch(java.util.Map)}
+ * method of the selected connector. The
+ * target VM is launched, and a connection between that VM and the
+ * debugger is established. A {@link VirtualMachine} mirror is returned.
+ * </UL>
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD>Debugger attaches to previously-running VM</TD>
+ * <TD>
+ * <UL>
+ * <LI>
+ * Target VM is launched using the options
+ * <code>-agentlib:jdwp=transport=xxx,server=y</code>
+ * </LI>
+ * <LI>
+ * Target VM generates and outputs the tranport-specific address at which it will
+ * listen for a connection.</LI>
+ * <LI>
+ * Debugger is launched. Debugger selects a connector in the list
+ * returned by {@link #attachingConnectors} matching the transport with
+ * the name "xxx".
+ * <LI>
+ * Debugger presents the default connector parameters (obtained through
+ * {@link com.sun.jdi.connect.Connector#defaultArguments()}) to the end user,
+ * allowing the user to
+ * fill in the transport-specific address generated by the target VM.
+ * <LI>
+ * Debugger calls the {@link com.sun.jdi.connect.AttachingConnector#attach(java.util.Map)} method
+ * of the selected to attach to the target VM. A {@link VirtualMachine}
+ * mirror is returned.
+ * </UL>
+ * </TD>
+ * </TR>
+ *
+ * <TR>
+ * <TD>Target VM attaches to previously-running debugger</TD>
+ * <TD>
+ * <LI>
+ * At startup, debugger selects one or more connectors from
+ * the list returned by {@link #listeningConnectors} for one or more
+ * transports.</LI>
+ * <LI>
+ * Debugger calls the {@link com.sun.jdi.connect.ListeningConnector#startListening(java.util.Map)} method for each selected
+ * connector. For each call, a transport-specific address string is
+ * generated and returned. The debugger makes the transport names and
+ * corresponding address strings available to the end user.
+ * <LI>
+ * Debugger calls
+ * {@link com.sun.jdi.connect.ListeningConnector#accept(java.util.Map)}
+ * for each selected connector to wait for
+ * a target VM to connect.</LI>
+ * <LI>
+ * Later, target VM is launched by end user with the options
+ * <code>-agentlib:jdwp=transport=xxx,address=yyy</code>
+ * where "xxx" the transport for one of the connectors selected by the
+ * the debugger and "yyy"
+ * is the address generated by
+ * {@link com.sun.jdi.connect.ListeningConnector#accept(java.util.Map)} for that
+ * transport.</LI>
+ * <LI>
+ * Debugger's call to {@link com.sun.jdi.connect.ListeningConnector#accept(java.util.Map)} returns
+ * a {@link VirtualMachine} mirror.</LI>
+ * </TD>
+ * </TR>
+ *
+ * <TR>
+ * <TD>Target VM launches debugger (sometimes called "Just-In-Time" debugging)</TD>
+ * <TD>
+ * <LI>
+ * Target VM is launched with the options
+ * <code>-agentlib:jdwp=launch=cmdline,onuncaught=y,transport=xxx,server=y</code>
+ * </LI>
+ * <LI>
+ * Later, an uncaught exception is thrown in the target VM. The target
+ * VM generates the tranport-specific address at which it will
+ * listen for a connection.
+ * <LI>Target VM launches the debugger with the following items concatenated
+ * together (separated by spaces) to form the command line:
+ * <UL>
+ * <LI> The launch= value
+ * <LI> The transport= value
+ * <LI> The generated transport-specific address at which VM is listening for
+ * debugger connection.
+ * </UL>
+ * <LI>
+ * Upon launch, debugger selects a connector in the list
+ * returned by {@link #attachingConnectors} matching the transport with
+ * the name "xxx".
+ * <LI>
+ * Debugger changes the default connector parameters (obtained through
+ * {@link com.sun.jdi.connect.Connector#defaultArguments()}) to specify
+ * the transport specific address at which the VM is listenig. Optionally,
+ * other connector arguments can be presented to the user.
+ * <LI>
+ * Debugger calls the
+ * {@link com.sun.jdi.connect.AttachingConnector#attach(java.util.Map)} method
+ * of the selected to attach to the target VM. A {@link VirtualMachine}
+ * mirror is returned.
+ * </TD>
+ * </TR>
+ * </TABLE>
+ *
+ * <p> Connectors are created at start-up time. That is, they
+ * are created the first time that {@link
+ * com.sun.jdi.Bootstrap#virtualMachineManager()} is invoked.
+ * The list of all Connectors created at start-up time can be
+ * obtained from the VirtualMachineManager by invoking the
+ * {@link #allConnectors allConnectors} method.
+ *
+ * <p> Connectors are created at start-up time if they are
+ * installed on the platform. In addition, Connectors are created
+ * automatically by the VirtualMachineManager to encapsulate any
+ * {@link com.sun.jdi.connect.spi.TransportService} implementations
+ * that are installed on the platform. These two mechanisms for
+ * creating Connectors are described here.
+ *
+ * <p> A Connector is installed on the platform if it is installed
+ * in a jar file that is visible to the defining class loader of
+ * the {@link com.sun.jdi.connect.Connector} type,
+ * and that jar file contains a provider configuration file named
+ * <tt>com.sun.jdi.connect.Connector</tt> in the resource directory
+ * <tt>META-INF/services</tt>, and the provider configuration file
+ * lists the full-qualified class name of the Connector
+ * implementation. A Connector is a class that implements the
+ * {@link com.sun.jdi.connect.Connector Connector} interface. More
+ * appropriately the class implements one of the specific Connector
+ * types, namely {@link com.sun.jdi.connect.AttachingConnector
+ * AttachingConnector}, {@link com.sun.jdi.connect.ListeningConnector
+ * ListeningConnector}, or {@link com.sun.jdi.connect.LaunchingConnector
+ * LaunchingConnector}. The format of the provider configuration file
+ * is one fully-qualified class name per line. Space and tab characters
+ * surrounding each class, as well as blank lines are ignored. The
+ * comment character is <tt>'#'</tt> (<tt>0x23</tt>), and on each
+ * line all characters following the first comment character are
+ * ignored. The file must be encoded in UTF-8.
+ *
+ * <p> At start-up time the VirtualMachineManager attempts to load
+ * and instantiate (using the no-arg constructor) each class listed
+ * in the provider configuration file. Exceptions thrown when loading
+ * or creating the Connector are caught and ignored. In other words,
+ * the start-up process continues despite of errors.
+ *
+ * <p> In addition to Connectors installed on the platform the
+ * VirtualMachineManager will also create Connectors to encapsulate
+ * any {@link com.sun.jdi.connect.spi.TransportService} implementations
+ * that are installed on the platform. A TransportService is
+ * installed on the platform if it installed in a jar file that is
+ * visible to the defining class loader for the
+ * {@link com.sun.jdi.connect.spi.TransportService} type, and that jar
+ * file contains a provider configuration file named
+ * <tt>com.sun.jdi.connect.spi.TransportService</tt> in the resource
+ * directory <tt>META-INF/services</tt>, and the provider
+ * configuration file lists the the full-qualified class name of the
+ * TransportService implementation. A TransportService is a concrete
+ * sub-class of {@link com.sun.jdi.connect.spi.TransportService
+ * TransportService}. The format of the provider configuration file
+ * is the same as the provider configuration file for Connectors
+ * except that each class listed must be the fully-qualified class
+ * name of a class that implements the TransportService interface.
+ *
+ * <p> For each TransportService installed on the platform, the
+ * VirtualMachineManager creates a corresponding
+ * {@link com.sun.jdi.connect.AttachingConnector} and
+ * {@link com.sun.jdi.connect.ListeningConnector}. These
+ * Connectors are created to encapsulate a {@link
+ * com.sun.jdi.connect.Transport Transport} that in turn
+ * encapsulates the TransportService.
+ * The AttachingConnector will be named based on the name of the
+ * transport service concatenated with the string <tt>Attach</tt>.
+ * For example, if the transport service {@link
+ * com.sun.jdi.connect.spi.TransportService#name() name()} method
+ * returns <tt>telepathic</tt> then the AttachingConnector will
+ * be named <tt>telepathicAttach</tt>. Similiarly the ListeningConnector
+ * will be named with the string <tt>Listen</tt> tagged onto the
+ * name of the transport service. The {@link
+ * com.sun.jdi.connect.Connector#description() description()} method
+ * of both the AttachingConnector, and the ListeningConnector, will
+ * delegate to the {@link com.sun.jdi.connect.spi.TransportService#description()
+ * description()} method of the underlying transport service. Both
+ * the AttachingConnector and the ListeningConnector will have two
+ * Connector {@link com.sun.jdi.connect.Connector$Argument Arguments}.
+ * A {@link com.sun.jdi.connect.Connector$StringArgument StringArgument}
+ * named <tt>address</tt> is the connector argument to specify the
+ * address to attach too, or to listen on. A
+ * {@link com.sun.jdi.connect.Connector$IntegerArgument IntegerArgument}
+ * named <tt>timeout</tt> is the connector argument to specify the
+ * timeout when attaching, or accepting. The timeout connector may be
+ * ignored depending on if the transport service supports an attach
+ * timeout or accept timeout.
+ *
+ * <p> Initialization of the virtual machine manager will fail, that is
+ * {@link com.sun.jdi.Bootstrap#virtualMachineManager()} will throw an
+ * error if the virtual machine manager is unable to create any
+ * connectors.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public interface VirtualMachineManager {
+
+ /**
+ * Identifies the default connector. This connector should
+ * be used as the launching connector when selection of a
+ * connector with specific characteristics is unnecessary.
+ *
+ * @return the default {@link com.sun.jdi.connect.LaunchingConnector}
+ */
+ LaunchingConnector defaultConnector();
+
+ /**
+ * Returns the list of known {@link com.sun.jdi.connect.LaunchingConnector} objects.
+ * Any of the returned objects can be used to launch a new target
+ * VM and immediately create a {@link VirtualMachine} mirror for it.
+ *
+ * Note that a target VM launched by a launching connector is not
+ * guaranteed to be stable until after the {@link com.sun.jdi.event.VMStartEvent} has been
+ * received.
+ * @return a list of {@link com.sun.jdi.connect.LaunchingConnector} objects.
+ */
+ List<LaunchingConnector> launchingConnectors();
+
+ /**
+ * Returns the list of known {@link com.sun.jdi.connect.AttachingConnector} objects.
+ * Any of the returned objects can be used to attach to an existing target
+ * VM and create a {@link VirtualMachine} mirror for it.
+ *
+ * @return a list of {@link com.sun.jdi.connect.AttachingConnector} objects.
+ */
+ List<AttachingConnector> attachingConnectors();
+
+ /**
+ * Returns the list of known {@link com.sun.jdi.connect.ListeningConnector} objects.
+ * Any of the returned objects can be used to listen for a
+ * connection initiated by a target VM
+ * and create a {@link VirtualMachine} mirror for it.
+ *
+ * @return a list of {@link com.sun.jdi.connect.ListeningConnector} objects.
+ */
+ List<ListeningConnector> listeningConnectors();
+
+ /**
+ * Returns the list of all known {@link com.sun.jdi.connect.Connector} objects.
+ *
+ * @return a list of {@link com.sun.jdi.connect.Connector} objects.
+ */
+ List<Connector> allConnectors();
+
+ /**
+ * Lists all target VMs which are connected to the debugger.
+ * The list includes {@link VirtualMachine} instances for
+ * any target VMs which initiated a connection
+ * and any
+ * target VMs to which this manager has initiated a connection.
+ * A target VM will remain in this list
+ * until the VM is disconnected.
+ * {@link com.sun.jdi.event.VMDisconnectEvent} is placed in the event queue
+ * after the VM is removed from the list.
+ *
+ * @return a list of {@link VirtualMachine} objects, each mirroring
+ * a target VM.
+ */
+ List<VirtualMachine> connectedVirtualMachines();
+
+ /**
+ * Returns the major version number of the JDI interface.
+ * See {@link VirtualMachine#version} target VM version and
+ * information and
+ * {@link VirtualMachine#description} more version information.
+ *
+ * @return the integer major version number.
+ */
+ int majorInterfaceVersion();
+
+ /**
+ * Returns the minor version number of the JDI interface.
+ * See {@link VirtualMachine#version} target VM version and
+ * information and
+ * {@link VirtualMachine#description} more version information.
+ *
+ * @return the integer minor version number
+ */
+ int minorInterfaceVersion();
+
+ /**
+ * Create a virtual machine mirror for a target VM.
+ *
+ * <p> Creates a virtual machine mirror for a target VM
+ * for which a {@link com.sun.jdi.connect.spi.Connection Connection}
+ * already exists. A Connection is created when a {@link
+ * com.sun.jdi.connect.Connector Connector} establishes
+ * a connection and successfully handshakes with a target VM.
+ * A Connector can then use this method to create a virtual machine
+ * mirror to represent the composite state of the target VM.
+ *
+ * <p> The <tt>process</tt> argument specifies the
+ * {@link java.lang.Process} object for the taget VM. It may be
+ * specified as <tt>null</tt>. If the target VM is launched
+ * by a {@link com.sun.jdi.connect.LaunchingConnector
+ * LaunchingConnector} the <tt>process</tt> argument should be
+ * specified, otherwise calling {@link com.sun.jdi.VirtualMachine#process()}
+ * on the created virtual machine will return <tt>null</tt>.
+ *
+ * <p> This method exists so that Connectors may create
+ * a virtual machine mirror when a connection is established
+ * to a target VM. Only developers creating new Connector
+ * implementations should need to make direct use of this
+ * method. </p>
+ *
+ * @param connection
+ * The open connection to the target VM.
+ *
+ * @param process
+ * If launched, the {@link java.lang.Process} object for
+ * the target VM. <tt>null</tt> if not launched.
+ *
+ * @return new virtual machine representing the target VM.
+ *
+ * @throws IOException
+ * if an I/O error occurs
+ *
+ * @throws IllegalStateException
+ * if the connection is not open
+ *
+ * @see com.sun.jdi.connect.spi.Connection#isOpen()
+ * @see com.sun.jdi.VirtualMachine#process()
+ *
+ * @since 1.5
+ */
+ VirtualMachine createVirtualMachine(Connection connection, Process process) throws IOException;
+
+ /**
+ * Creates a new virtual machine.
+ *
+ * <p> This convenience method works as if by invoking {@link
+ * #createVirtualMachine(Connection, Process)} method and
+ * specifying <tt>null</tt> as the <tt>process</tt> argument.
+ *
+ * <p> This method exists so that Connectors may create
+ * a virtual machine mirror when a connection is established
+ * to a target VM. Only developers creating new Connector
+ * implementations should need to make direct use of this
+ * method. </p>
+ *
+ * @return the new virtual machine
+ *
+ * @throws IOException
+ * if an I/O error occurs
+ *
+ * @throws IllegalStateException
+ * if the connection is not open
+ *
+ * @since 1.5
+ */
+ VirtualMachine createVirtualMachine(Connection connection) throws IOException;
+}
diff --git a/src/share/classes/com/sun/jdi/VoidType.java b/src/share/classes/com/sun/jdi/VoidType.java
new file mode 100644
index 0000000..9a9ee46
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/VoidType.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * The type of all primitive <code>void</code> values
+ * accessed in the target VM. Calls to {@link Value#type} will return an
+ * implementor of this interface.
+ *
+ * @see VoidValue
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface VoidType extends Type {
+}
diff --git a/src/share/classes/com/sun/jdi/VoidValue.java b/src/share/classes/com/sun/jdi/VoidValue.java
new file mode 100644
index 0000000..f3fb87e
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/VoidValue.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi;
+
+/**
+ * Provides access to a primitive <code>void</code> value in
+ * the target VM.
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface VoidValue extends Value {
+
+ /**
+ * Compares the specified Object with this VoidValue for equality.
+ *
+ * @return true if the Object is a VoidValue; false
+ * otherwise.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * Returns the hash code value for this VoidValue.
+ *
+ * @return the hash code
+ */
+ int hashCode();
+}
diff --git a/src/share/classes/com/sun/jdi/connect/AttachingConnector.java b/src/share/classes/com/sun/jdi/connect/AttachingConnector.java
new file mode 100644
index 0000000..80bf5a0
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/connect/AttachingConnector.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.connect;
+
+import com.sun.jdi.VirtualMachine;
+import java.util.Map;
+import java.io.IOException;
+
+/**
+ * A connector which attaches to a previously running target VM.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public interface AttachingConnector extends Connector {
+ /**
+ * Attaches to a running application and and returns a
+ * mirror of its VM.
+ * <p>
+ * The connector uses the given argument map in
+ * attaching the application. These arguments will include addressing
+ * information that identifies the VM.
+ * The argument map associates argument name strings to instances
+ * of {@link Connector.Argument}. The default argument map for a
+ * connector can be obtained through {@link Connector#defaultArguments}.
+ * Argument map values can be changed, but map entries should not be
+ * added or deleted.
+ *
+ * @param arguments the argument map to be used in launching the VM.
+ * @return the {@link VirtualMachine} mirror of the target VM.
+ *
+ * @throws TransportTimeoutException when the Connector encapsulates
+ * a transport that supports a timeout when attaching, a
+ * {@link Connector.Argument} representing a timeout has been set
+ * in the argument map, and a timeout occurs when trying to attach
+ * to the target VM.
+ *
+ * @throws java.io.IOException when unable to attach.
+ * Specific exceptions are dependent on the Connector implementation
+ * in use.
+ * @throws IllegalConnectorArgumentsException when one of the
+ * connector arguments is invalid.
+ */
+ VirtualMachine attach(Map<String,? extends Connector.Argument> arguments)
+ throws IOException, IllegalConnectorArgumentsException;
+}
diff --git a/src/share/classes/com/sun/jdi/connect/Connector.java b/src/share/classes/com/sun/jdi/connect/Connector.java
new file mode 100644
index 0000000..52aebbf
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/connect/Connector.java
@@ -0,0 +1,291 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.connect;
+
+import java.util.Map;
+import java.util.List;
+import java.io.Serializable;
+
+/**
+ * A method of connection between a debugger and a target VM.
+ * A connector encapsulates exactly one {@link Transport}. used
+ * to establish the connection. Each connector has a set of arguments
+ * which controls its operation. The arguments are stored as a
+ * map, keyed by a string. Each implementation defines the string
+ * argument keys it accepts.
+ *
+ * @see LaunchingConnector
+ * @see AttachingConnector
+ * @see ListeningConnector
+ * @see Connector.Argument
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public interface Connector {
+ /**
+ * Returns a short identifier for the connector. Connector implementors
+ * should follow similar naming conventions as are used with packages
+ * to avoid name collisions. For example, the Sun connector
+ * implementations have names prefixed with "com.sun.jdi.".
+ * Not intended for exposure to end-user.
+ *
+ * @return the name of this connector.
+ */
+ String name();
+
+ /**
+ * Returns a human-readable description of this connector
+ * and its purpose.
+ *
+ * @return the description of this connector
+ */
+ String description();
+
+ /**
+ * Returns the transport mechanism used by this connector to establish
+ * connections with a target VM.
+ *
+ * @return the {@link Transport} used by this connector.
+ */
+ Transport transport();
+
+ /**
+ * Returns the arguments accepted by this Connector and their
+ * default values. The keys of the returned map are string argument
+ * names. The values are {@link Connector.Argument} containing
+ * information about the argument and its default value.
+ *
+ * @return the map associating argument names with argument
+ * information and default value.
+ */
+ Map<String,Connector.Argument> defaultArguments();
+
+ /**
+ * Specification for and value of a Connector argument.
+ * Will always implement a subinterface of Argument:
+ * {@link Connector.StringArgument}, {@link Connector.BooleanArgument},
+ * {@link Connector.IntegerArgument},
+ * or {@link Connector.SelectedArgument}.
+ */
+ @jdk.Exported
+ public interface Argument extends Serializable {
+ /**
+ * Returns a short, unique identifier for the argument.
+ * Not intended for exposure to end-user.
+ *
+ * @return the name of this argument.
+ */
+ String name();
+
+ /**
+ * Returns a short human-readable label for this argument.
+ *
+ * @return a label for this argument
+ */
+ String label();
+
+ /**
+ * Returns a human-readable description of this argument
+ * and its purpose.
+ *
+ * @return the description of this argument
+ */
+ String description();
+
+ /**
+ * Returns the current value of the argument. Initially, the
+ * default value is returned. If the value is currently unspecified,
+ * null is returned.
+ *
+ * @return the current value of the argument.
+ */
+ String value();
+
+ /**
+ * Sets the value of the argument.
+ * The value should be checked with {@link #isValid(String)}
+ * before setting it; invalid values will throw an exception
+ * when the connection is established - for example,
+ * on {@link LaunchingConnector#launch}
+ */
+ void setValue(String value);
+
+ /**
+ * Performs basic sanity check of argument.
+ * @return <code>true</code> if the value is valid to be
+ * used in {@link #setValue(String)}
+ */
+ boolean isValid(String value);
+
+ /**
+ * Indicates whether the argument must be specified. If true,
+ * {@link #setValue} must be used to set a non-null value before
+ * using this argument in establishing a connection.
+ *
+ * @return <code>true</code> if the argument must be specified;
+ * <code>false</code> otherwise.
+ */
+ boolean mustSpecify();
+ }
+
+ /**
+ * Specification for and value of a Connector argument,
+ * whose value is Boolean. Boolean values are represented
+ * by the localized versions of the strings "true" and "false".
+ */
+ @jdk.Exported
+ public interface BooleanArgument extends Argument {
+ /**
+ * Sets the value of the argument.
+ */
+ void setValue(boolean value);
+
+ /**
+ * Performs basic sanity check of argument.
+ * @return <code>true</code> if value is a string
+ * representation of a boolean value.
+ * @see #stringValueOf(boolean)
+ */
+ boolean isValid(String value);
+
+ /**
+ * Return the string representation of the <code>value</code>
+ * parameter.
+ * Does not set or examine the current value of <code>this</code>
+ * instance.
+ * @return the localized String representation of the
+ * boolean value.
+ */
+ String stringValueOf(boolean value);
+
+ /**
+ * Return the value of the argument as a boolean. Since
+ * the argument may not have been set or may have an invalid
+ * value {@link #isValid(String)} should be called on
+ * {@link #value()} to check its validity. If it is invalid
+ * the boolean returned by this method is undefined.
+ * @return the value of the argument as a boolean.
+ */
+ boolean booleanValue();
+ }
+
+ /**
+ * Specification for and value of a Connector argument,
+ * whose value is an integer. Integer values are represented
+ * by their corresponding strings.
+ */
+ @jdk.Exported
+ public interface IntegerArgument extends Argument {
+ /**
+ * Sets the value of the argument.
+ * The value should be checked with {@link #isValid(int)}
+ * before setting it; invalid values will throw an exception
+ * when the connection is established - for example,
+ * on {@link LaunchingConnector#launch}
+ */
+ void setValue(int value);
+
+ /**
+ * Performs basic sanity check of argument.
+ * @return <code>true</code> if value represents an int that is
+ * <code>{@link #min()} <= value <= {@link #max()}</code>
+ */
+ boolean isValid(String value);
+
+ /**
+ * Performs basic sanity check of argument.
+ * @return <code>true</code> if
+ * <code>{@link #min()} <= value <= {@link #max()}</code>
+ */
+ boolean isValid(int value);
+
+ /**
+ * Return the string representation of the <code>value</code>
+ * parameter.
+ * Does not set or examine the current value of <code>this</code>
+ * instance.
+ * @return the String representation of the
+ * int value.
+ */
+ String stringValueOf(int value);
+
+ /**
+ * Return the value of the argument as a int. Since
+ * the argument may not have been set or may have an invalid
+ * value {@link #isValid(String)} should be called on
+ * {@link #value()} to check its validity. If it is invalid
+ * the int returned by this method is undefined.
+ * @return the value of the argument as a int.
+ */
+ int intValue();
+
+ /**
+ * The upper bound for the value.
+ * @return the maximum allowed value for this argument.
+ */
+ int max();
+
+ /**
+ * The lower bound for the value.
+ * @return the minimum allowed value for this argument.
+ */
+ int min();
+ }
+
+ /**
+ * Specification for and value of a Connector argument,
+ * whose value is a String.
+ */
+ @jdk.Exported
+ public interface StringArgument extends Argument {
+ /**
+ * Performs basic sanity check of argument.
+ * @return <code>true</code> always
+ */
+ boolean isValid(String value);
+ }
+
+ /**
+ * Specification for and value of a Connector argument,
+ * whose value is a String selected from a list of choices.
+ */
+ @jdk.Exported
+ public interface SelectedArgument extends Argument {
+ /**
+ * Return the possible values for the argument
+ * @return {@link List} of {@link String}
+ */
+ List<String> choices();
+
+ /**
+ * Performs basic sanity check of argument.
+ * @return <code>true</code> if value is one of {@link #choices()}.
+ */
+ boolean isValid(String value);
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/connect/IllegalConnectorArgumentsException.java b/src/share/classes/com/sun/jdi/connect/IllegalConnectorArgumentsException.java
new file mode 100644
index 0000000..b7f57c0
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/connect/IllegalConnectorArgumentsException.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.connect;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
+
+/**
+ * Thrown to indicate an invalid argument or
+ * inconsistent passed to a {@link Connector}.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public class IllegalConnectorArgumentsException extends Exception {
+
+ private static final long serialVersionUID = -3042212603611350941L;
+ List<String> names;
+
+ /**
+ * Construct an <code>IllegalConnectorArgumentsException</code>
+ * with the specified detail message and the name of the argument
+ * which is invalid or inconsistent.
+ * @param s the detailed message.
+ * @param name the name of the invalid or inconsistent argument.
+ */
+ public IllegalConnectorArgumentsException(String s,
+ String name) {
+ super(s);
+ names = new ArrayList<String>(1);
+ names.add(name);
+ }
+
+ /**
+ * Construct an <code>IllegalConnectorArgumentsException</code>
+ * with the specified detail message and a <code>List</code> of
+ * names of arguments which are invalid or inconsistent.
+ * @param s the detailed message.
+ * @param names a <code>List</code> containing the names of the
+ * invalid or inconsistent argument.
+ */
+ public IllegalConnectorArgumentsException(String s, List<String> names) {
+ super(s);
+
+ this.names = new ArrayList<String>(names);
+ }
+
+ /**
+ * Return a <code>List</code> containing the names of the
+ * invalid or inconsistent arguments.
+ * @return a <code>List</code> of argument names.
+ */
+ public List<String> argumentNames() {
+ return Collections.unmodifiableList(names);
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/connect/LaunchingConnector.java b/src/share/classes/com/sun/jdi/connect/LaunchingConnector.java
new file mode 100644
index 0000000..af801e9
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/connect/LaunchingConnector.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.connect;
+
+import com.sun.jdi.VirtualMachine;
+import java.util.Map;
+import java.io.IOException;
+
+/**
+ * A connector which can launch a target VM before connecting to it.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public interface LaunchingConnector extends Connector {
+ /**
+ * Launches an application and connects to its VM. Properties
+ * of the launch (possibly including options,
+ * main class, and arguments) are specified in
+ * <code>arguments</code>.
+ * The argument map associates argument name strings to instances
+ * of {@link Connector.Argument}. The default argument map for a
+ * connector can be obtained through {@link Connector#defaultArguments}.
+ * Argument map values can be changed, but map entries should not be
+ * added or deleted.
+ * <p>A target VM launched by a launching connector is not
+ * guaranteed to be stable until after the {@link com.sun.jdi.event.VMStartEvent} has been
+ * received.
+ * <p>
+ * <b>Important note:</b> If a target VM is launched through this
+ * funcctions, its output and error streams must be read as it
+ * executes. These streams are available through the
+ * {@link java.lang.Process Process} object returned by
+ * {@link com.sun.jdi.VirtualMachine#process}. If the streams are not periodically
+ * read, the target VM will stop executing when the buffers for these
+ * streams are filled.
+ *
+ * @param arguments the argument map to be used in launching the VM.
+ * @return the {@link VirtualMachine} mirror of the target VM.
+ * @throws java.io.IOException when unable to launch.
+ * Specific exceptions are dependent on the Connector implementation
+ * in use.
+ * @throws IllegalConnectorArgumentsException when one of the
+ * connector arguments is invalid.
+ * @throws VMStartException when the VM was successfully launched, but
+ * terminated with an error before a connection could be established.
+ */
+ VirtualMachine launch(Map<String,? extends Connector.Argument> arguments)
+ throws IOException, IllegalConnectorArgumentsException,
+ VMStartException;
+}
diff --git a/src/share/classes/com/sun/jdi/connect/ListeningConnector.java b/src/share/classes/com/sun/jdi/connect/ListeningConnector.java
new file mode 100644
index 0000000..1048201
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/connect/ListeningConnector.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.connect;
+
+import java.util.Map;
+import java.io.IOException;
+import com.sun.jdi.VirtualMachine;
+
+/**
+ * A connector which listens for a connection initiated by a target VM.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ListeningConnector extends Connector {
+ /**
+ * Indicates whether this listening connector supports multiple
+ * connections for a single argument map. If so, a call to
+ * {@link #startListening} may allow
+ * multiple target VM to become connected.
+ *
+ * @return <code>true</code> if multiple connections are supported;
+ * <code>false</code> otherwise.
+ */
+ boolean supportsMultipleConnections();
+
+ /**
+ * Listens for one or more connections initiated by target VMs.
+ * The connector uses the given argument map
+ * in determining the address at which to listen or else it generates
+ * an appropriate listen address. In either case, an address string
+ * is returned from this method which can be used in starting target VMs
+ * to identify this connector. The format of the address string
+ * is connector, transport, and, possibly, platform dependent.
+ * <p>
+ * The argument map associates argument name strings to instances
+ * of {@link Connector.Argument}. The default argument map for a
+ * connector can be obtained through {@link Connector#defaultArguments}.
+ * Argument map values can be changed, but map entries should not be
+ * added or deleted.
+ * <p>
+ * This method does not return a {@link VirtualMachine}, and, normally,
+ * returns before any target VM initiates
+ * a connection. The connected target is obtained through
+ * {@link #accept} (using the same argument map as is passed to this
+ * method).
+ * <p>
+ * If <code>arguments</code> contains addressing information. and
+ * only one connection will be accepted, the {@link #accept accept} method
+ * can be called immediately without calling this method.
+ *
+ * @return the address at which the connector is listening
+ * for a connection.
+ * @throws java.io.IOException when unable to start listening.
+ * Specific exceptions are dependent on the Connector implementation
+ * in use.
+ * @throws IllegalConnectorArgumentsException when one of the
+ * connector arguments is invalid.
+ */
+ String startListening(Map<String,? extends Connector.Argument> arguments)
+ throws IOException, IllegalConnectorArgumentsException;
+
+ /**
+ * Cancels listening for connections. The given argument map should match
+ * the argument map given for a previous {@link #startListening} invocation.
+ *
+ * @throws java.io.IOException when unable to stop listening.
+ * Specific exceptions are dependent on the Connector implementation
+ * in use.
+ * @throws IllegalConnectorArgumentsException when one of the
+ * connector arguments is invalid.
+ */
+ void stopListening(Map<String,? extends Connector.Argument> arguments)
+ throws IOException, IllegalConnectorArgumentsException;
+
+
+ /**
+ * Waits for a target VM to attach to this connector.
+ *
+ * @throws TransportTimeoutException when the Connector encapsulates
+ * a transport that supports a timeout when accepting, a
+ * {@link Connector.Argument} representing a timeout has been set
+ * in the argument map, and a timeout occurs whilst waiting for
+ * the target VM to connect.
+ * @throws java.io.IOException when unable to accept.
+ * Specific exceptions are dependent on the Connector implementation
+ * in use.
+ * @throws IllegalConnectorArgumentsException when one of the
+ * connector arguments is invalid.
+ */
+ VirtualMachine accept(Map<String,? extends Connector.Argument> arguments)
+ throws IOException, IllegalConnectorArgumentsException;
+
+}
diff --git a/src/share/classes/com/sun/jdi/connect/Transport.java b/src/share/classes/com/sun/jdi/connect/Transport.java
new file mode 100644
index 0000000..102d64c
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/connect/Transport.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.connect;
+
+import com.sun.jdi.connect.spi.TransportService; // for javadoc
+
+/**
+ * A method of communication between a debugger and a target VM.
+ *
+ * <p> A Transport represents the transport mechanism used by a
+ * {@link com.sun.jdi.connect.Connector Connector} to establish a
+ * connection with a target VM. It consists of a name which is obtained
+ * by invoking the {@link #name} method. Furthermore, a Transport
+ * encapsulates a {@link com.sun.jdi.connect.spi.TransportService
+ * TransportService} which is the underlying service used
+ * to establish connections and exchange Java Debug Wire Protocol
+ * (JDWP) packets with a target VM.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public interface Transport {
+ /**
+ * Returns a short identifier for the transport.
+ *
+ * @return the name of this transport.
+ */
+ String name();
+}
diff --git a/src/share/classes/com/sun/jdi/connect/TransportTimeoutException.java b/src/share/classes/com/sun/jdi/connect/TransportTimeoutException.java
new file mode 100644
index 0000000..1ede92b
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/connect/TransportTimeoutException.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2003, 2013, 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.jdi.connect;
+
+/**
+ * This exception may be thrown as a result of a timeout
+ * when attaching to a target VM, or waiting to accept a
+ * connection from a target VM.
+ *
+ * <p> When attaching to a target VM, using {@link
+ * AttachingConnector#attach attach} this
+ * exception may be thrown if the connector supports a timeout
+ * {@link Connector.Argument connector argument}. Similiarly,
+ * when waiting to accept a connection from a target VM,
+ * using {@link ListeningConnector#accept accept} this
+ * exception may be thrown if the connector supports a
+ * timeout connector argument when accepting.
+ *
+ * <p> In addition, for developers creating {@link
+ * com.sun.jdi.connect.spi.TransportService TransportService}
+ * implementations this exception is thrown when
+ * {@link com.sun.jdi.connect.spi.TransportService#attach attach}
+ * times out when establishing a connection to a target VM,
+ * or {@link com.sun.jdi.connect.spi.TransportService#accept
+ * accept} times out while waiting for a target VM to connect. </p>
+ *
+ * @see AttachingConnector#attach
+ * @see ListeningConnector#accept
+ * @see com.sun.jdi.connect.spi.TransportService#attach
+ * @see com.sun.jdi.connect.spi.TransportService#accept
+ *
+ * @since 1.5
+ */
+@jdk.Exported
+public class TransportTimeoutException extends java.io.IOException {
+ private static final long serialVersionUID = 4107035242623365074L;
+ /**
+ * Constructs a <tt>TransportTimeoutException</tt> with no detail
+ * message.
+ */
+ public TransportTimeoutException() {
+ }
+
+
+ /**
+ * Constructs a <tt>TransportTimeoutException</tt> with the
+ * specified detail message.
+ *
+ * @param message the detail message pertaining to this exception.
+ */
+ public TransportTimeoutException(String message) {
+ super(message);
+ }
+
+}
diff --git a/src/share/classes/com/sun/jdi/connect/VMStartException.java b/src/share/classes/com/sun/jdi/connect/VMStartException.java
new file mode 100644
index 0000000..04c0629
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/connect/VMStartException.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.connect;
+
+/**
+ * A target VM was successfully launched, but terminated with an
+ * error before a connection could be established. This exception
+ * provides the {@link java.lang.Process} object for the launched
+ * target to help in diagnosing the problem.
+ *
+ * @author Gordon Hirsch
+ * @since 1.3
+ */
+@jdk.Exported
+public class VMStartException extends Exception {
+
+ private static final long serialVersionUID = 6408644824640801020L;
+ Process process;
+
+ public VMStartException(Process process) {
+ super();
+ this.process = process;
+ }
+
+ public VMStartException(String message,
+ Process process) {
+ super(message);
+ this.process = process;
+ }
+
+ public Process process() {
+ return process;
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/connect/package-info.java b/src/share/classes/com/sun/jdi/connect/package-info.java
new file mode 100644
index 0000000..c444b75
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/connect/package-info.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 1998, 2013, 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.
+ */
+
+/**
+ * This package defines connections between the virtual machine
+ * using the JDI and the target virtual machine.
+ * In concert with {@link com.sun.jdi.VirtualMachineManager}
+ * it is the mechanism for launching, attaching, etc to
+ * target virtual machines.
+ * <p>
+ * Methods may be added to the interfaces in the JDI packages in future
+ * releases. Existing packages may be renamed if the JDI becomes a standard
+ * extension.
+ */
+
+@jdk.Exported
+package com.sun.jdi.connect;
diff --git a/src/share/classes/com/sun/jdi/connect/spi/ClosedConnectionException.java b/src/share/classes/com/sun/jdi/connect/spi/ClosedConnectionException.java
new file mode 100644
index 0000000..a324bc3
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/connect/spi/ClosedConnectionException.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2003, 2013, 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.jdi.connect.spi;
+
+/**
+ * This exception may be thrown as a result of an asynchronous
+ * close of a {@link Connection} while an I/O operation is
+ * in progress.
+ *
+ * <p> When a thread is blocked in {@link Connection#readPacket
+ * readPacket} waiting for packet from a target VM the
+ * {@link Connection} may be closed asynchronous by another
+ * thread invokving the {@link Connection#close close} method.
+ * When this arises the thread in readPacket will throw this
+ * exception. Similiarly when a thread is blocked in
+ * {@link Connection#writePacket} the Connection may be closed.
+ * When this occurs the thread in writePacket will throw
+ * this exception.
+ *
+ * @see Connection#readPacket
+ * @see Connection#writePacket
+ *
+ * @since 1.5
+ */
+@jdk.Exported
+public class ClosedConnectionException extends java.io.IOException {
+ private static final long serialVersionUID = 3877032124297204774L;
+ /**
+ * Constructs a <tt>ClosedConnectionException</tt> with no detail
+ * message.
+ */
+ public ClosedConnectionException() {
+ }
+
+ /**
+ * Constructs a <tt>ClosedConnectionException</tt> with the
+ * specified detail message.
+ *
+ * @param message the detail message pertaining to this exception.
+ */
+ public ClosedConnectionException(String message) {
+ super(message);
+ }
+
+}
diff --git a/src/share/classes/com/sun/jdi/connect/spi/Connection.java b/src/share/classes/com/sun/jdi/connect/spi/Connection.java
new file mode 100644
index 0000000..36df964
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/connect/spi/Connection.java
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 2003, 2013, 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.jdi.connect.spi;
+
+import java.io.IOException;
+
+/**
+ * A connection between a debugger and a target VM which it debugs.
+ *
+ * <p> A Connection represents a bi-directional communication channel
+ * between a debugger and a target VM. A Connection is created when
+ * {@link com.sun.jdi.connect.spi.TransportService TransportService}
+ * establishes a connection and successfully handshakes with a target
+ * VM. A TransportService implementation provides a reliable
+ * JDWP packet transportation service and consequently a Connection
+ * provides a reliable flow of JDWP packets between the debugger
+ * and the target VM. A Connection is stream oriented, that is, the
+ * JDWP packets written to a connection are read by the target VM
+ * in the order in which they were written. Similiarly packets written
+ * to a Connection by the target VM are read by the debugger in the
+ * order in which they were written.
+ *
+ * <p> A connection is either open or closed. It is open upon creation,
+ * and remains open until it is closed. Once closed, it remains closed,
+ * and any attempt to invoke an I/O operation upon it will cause a
+ * {@link ClosedConnectionException} to be thrown. A connection can
+ * be tested by invoking the {@link #isOpen isOpen} method.
+ *
+ * <p> A Connection is safe for access by multiple concurrent threads,
+ * although at most one thread may be reading and at most one thread may
+ * be writing at any given time. </p>
+ *
+ * @since 1.5
+ */
+
+@jdk.Exported
+public abstract class Connection {
+
+ /**
+ * Reads a packet from the target VM.
+ *
+ * <p> Attempts to read a JDWP packet from the target VM.
+ * A read operation may block indefinitely and only returns
+ * when it reads all bytes of a packet, or in the case of a
+ * transport service that is based on a stream-oriented
+ * communication protocol, the end of stream is encountered.
+ *
+ * <p> Reading a packet does not do any integrity checking on
+ * the packet aside from a check that the length of the packet
+ * (as indicated by the value of the <tt>length</tt> field, the
+ * first four bytes of the packet) is 11 or more bytes.
+ * If the value of the <tt>length</tt> value is less then 11
+ * then an <tt>IOException</tt> is thrown.
+ *
+ * <p> Returns a byte array of a length equal to the length
+ * of the received packet, or a byte array of length 0 when an
+ * end of stream is encountered. If end of stream is encountered
+ * after some, but not all bytes of a packet, are read then it
+ * is considered an I/O error and an <tt>IOException</tt> is
+ * thrown. The first byte of the packet is stored in element
+ * <tt>0</tt> of the byte array, the second in element <tt>1</tt>,
+ * and so on. The bytes in the byte array are laid out as per the
+ * <a href="../../../../../../../../../technotes/guides/jpda/jdwp-spec.html">
+ * JDWP specification</a>. That is, all fields in the packet
+ * are in big endian order as per the JDWP specification.
+ *
+ * <p> This method may be invoked at any time. If another thread has
+ * already initiated a {@link #readPacket readPacket} on this
+ * connection then the invocation of this method will block until the
+ * first operation is complete. </p>
+ *
+ * @return the packet read from the target VM
+ *
+ * @throws ClosedConnectionException
+ * If the connection is closed, or another thread closes
+ * the connection while the readPacket is in progress.
+ *
+ * @throws java.io.IOException
+ * If the length of the packet (as indictaed by the first
+ * 4 bytes) is less than 11 bytes, or an I/O error occurs.
+ *
+ *
+ */
+ public abstract byte[] readPacket() throws IOException;
+
+ /**
+ * Writes a packet to the target VM.
+ *
+ * <p> Attempts to write, or send, a JDWP packet to the target VM.
+ * A write operation only returns after writing the entire packet
+ * to the target VM. Writing the entire packet does not mean
+ * the entire packet has been transmitted to the target VM
+ * but rather that all bytes have been written to the
+ * transport service. A transport service based on a TCP/IP connection
+ * may, for example, buffer some or all of the packet before
+ * transmission on the network.
+ *
+ * <p> The byte array provided to this method should be laid out
+ * as per the <a
+ * href="../../../../../../../../../technotes/guides/jpda/jdwp-spec.html">
+ * JDWP specification</a>. That is, all fields in the packet
+ * are in big endian order. The first byte, that is element
+ * <tt>pkt[0]</tt>, is the first byte of the <tt>length</tt> field.
+ * <tt>pkt[1]</tt> is the second byte of the <tt>length</tt> field,
+ * and so on.
+ *
+ * <p> Writing a packet does not do any integrity checking on
+ * the packet aside from checking the packet length. Checking
+ * the packet length requires checking that the value of the
+ * <tt>length</tt> field (as indicated by the first four bytes
+ * of the packet) is 11 or greater. Consequently the length of
+ * the byte array provided to this method, that is
+ * <tt>pkt.length</tt>, must be 11 or more, and must be equal
+ * or greater than the value of the <tt>length</tt> field. If the
+ * length of the byte array is greater than the value of
+ * the <tt>length</tt> field then all bytes from element
+ * <tt>pkt[length]</tt> onwards are ignored. In other words,
+ * any additional bytes that follow the packet in the byte
+ * array are ignored and will not be transmitted to the target
+ * VM.
+ *
+ * <p> A write operation may block or may complete immediately.
+ * The exact circumstances when an operation blocks depends on
+ * the transport service. In the case of a TCP/IP connection to
+ * the target VM, the writePacket method may block if there is
+ * network congestion or there is insufficient space to buffer
+ * the packet in the underlying network system.
+ *
+ * <p> This method may be invoked at any time. If another thread has
+ * already initiated a write operation upon this Connection then
+ * a subsequent invocation of this method will block until the first
+ * operation is complete. </p>
+ *
+ * @param pkt
+ * The packet to write to the target VM.
+ *
+ * @throws ClosedConnectionException
+ * If the connection is closed, or another thread closes
+ * the connection while the write operation is in progress.
+ *
+ * @throws java.io.IOException
+ * If an I/O error occurs.
+ *
+ * @throws IllegalArgumentException
+ * If the value of the <tt>length</tt> field is invalid,
+ * or the byte array is of insufficient length.
+ */
+ public abstract void writePacket(byte pkt[]) throws IOException;
+
+ /**
+ * Closes this connection.
+ *
+ * <p> If the connection is already closed then invoking this method
+ * has no effect. After a connection is closed, any further attempt
+ * calls to {@link #readPacket readPacket} or {@link #writePacket
+ * writePacket} will throw a {@link ClosedConnectionException}.
+ *
+ * <p> Any thread currently blocked in an I/O operation ({@link
+ * #readPacket readPacket} or {@link #writePacket writePacket})
+ * will throw a {@link ClosedConnectionException}).
+ *
+ * <p> This method may be invoked at any time. If some other thread has
+ * already invoked it, however, then another invocation will block until
+ * the first invocation is complete, after which it will return without
+ * effect. </p>
+ *
+ * @throws java.io.IOException
+ * If an I/O error occurs
+ */
+ public abstract void close() throws IOException;
+
+ /**
+ * Tells whether or not this connection is open. </p>
+ *
+ * @return <tt>true</tt> if, and only if, this connection is open
+ */
+ public abstract boolean isOpen();
+}
diff --git a/src/share/classes/com/sun/jdi/connect/spi/TransportService.java b/src/share/classes/com/sun/jdi/connect/spi/TransportService.java
new file mode 100644
index 0000000..f589424
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/connect/spi/TransportService.java
@@ -0,0 +1,380 @@
+/*
+ * Copyright (c) 2003, 2013, 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.jdi.connect.spi;
+
+import java.io.IOException;
+import com.sun.jdi.connect.TransportTimeoutException;
+
+/**
+ * A transport service for connections between a debugger and
+ * a target VM.
+ *
+ * <p> A transport service is a concrete subclass of this class
+ * that has a zero-argument constructor and implements the abstract
+ * methods specified below. It is the underlying service
+ * used by a {@link com.sun.jdi.connect.Transport} for
+ * connections between a debugger and a target VM.
+ *
+ * <p> A transport service is used to establish a connection
+ * between a debugger and a target VM, and to transport Java
+ * Debug Wire Protocol (JDWP) packets over an underlying
+ * communication protocol. In essence a transport service
+ * implementation binds JDWP (as specified in the
+ * <a href="../../../../../../../../../technotes/guides/jpda/jdwp-spec.html">
+ * JDWP specification</a>) to an underlying communication
+ * protocol. A transport service implementation provides
+ * a reliable JDWP packet transportation service. JDWP
+ * packets are sent to and from the target VM without duplication
+ * or data loss. A transport service implementation may be
+ * based on an underlying communication protocol that is
+ * reliable or unreliable. If the underlying communication
+ * protocol is reliable then the transport service implementation
+ * may be relatively simple and may only need to transport JDWP
+ * packets as payloads of the underlying communication
+ * protocol. In the case of an unreliable communication
+ * protocol the transport service implementation may include
+ * additional protocol support in order to ensure that packets
+ * are not duplicated and that there is no data loss. The
+ * details of such protocols are specific to the implementation
+ * but may involve techniques such as the <i>positive
+ * acknowledgment with retransmission</i> technique used in
+ * protocols such as the Transmission Control Protocol (TCP)
+ * (see <a href="http://www.ietf.org/rfc/rfc0793.txt"> RFC 793
+ * </a>).
+ *
+ * <p> A transport service can be used to initiate a connection
+ * to a target VM. This is done by invoking the {@link #attach}
+ * method. Alternatively, a transport service can listen and
+ * accept connections initiated by a target VM. This is done
+ * by invoking the {@link #startListening(String)} method to
+ * put the transport into listen mode. Then the {@link #accept}
+ * method is used to accept a connection initiated by a
+ * target VM.
+ *
+ * @since 1.5
+ */
+
+@jdk.Exported
+public abstract class TransportService {
+
+ /**
+ * Returns a name to identify the transport service.
+ *
+ * @return The name of the transport service
+ */
+ public abstract String name();
+
+ /**
+ * Returns a description of the transport service.
+ *
+ * @return The description of the transport service
+ */
+ public abstract String description();
+
+ /**
+ * The transport service capabilities.
+ */
+ @jdk.Exported
+ public static abstract class Capabilities {
+
+ /**
+ * Tells whether or not this transport service can support
+ * multiple concurrent connections to a single address that
+ * it is listening on.
+ *
+ * @return <tt>true</tt> if, and only if, this transport
+ * service supports multiple connections.
+ */
+ public abstract boolean supportsMultipleConnections();
+
+
+ /**
+ * Tell whether or not this transport service supports a timeout
+ * when attaching to a target VM.
+ *
+ * @return <tt>true</tt> if, and only if, this transport
+ * service supports attaching with a timeout.
+ *
+ * @see #attach(String,long,long)
+ */
+ public abstract boolean supportsAttachTimeout();
+
+ /**
+ * Tell whether or not this transport service supports a
+ * timeout while waiting for a target VM to connect.
+ *
+ * @return <tt>true</tt> if, and only if, this transport
+ * service supports timeout while waiting for
+ * a target VM to connect.
+ *
+ * @see #accept(TransportService.ListenKey,long,long)
+ */
+ public abstract boolean supportsAcceptTimeout();
+
+ /**
+ * Tells whether or not this transport service supports a
+ * timeout when handshaking with the target VM.
+ *
+ * @return <tt>true</tt> if, and only if, this transport
+ * service supports a timeout while handshaking
+ * with the target VM.
+ *
+ * @see #attach(String,long,long)
+ * @see #accept(TransportService.ListenKey,long,long)
+ */
+ public abstract boolean supportsHandshakeTimeout();
+
+ }
+
+ /**
+ * Returns the capabilities of the transport service.
+ *
+ * @return the transport service capabilities
+ */
+ public abstract Capabilities capabilities();
+
+ /**
+ * Attaches to the specified address.
+ *
+ * <p> Attaches to the specified address and returns a connection
+ * representing the bi-directional communication channel to the
+ * target VM.
+ *
+ * <p> Attaching to the target VM involves two steps:
+ * First, a connection is established to specified address. This
+ * is followed by a handshake to ensure that the connection is
+ * to a target VM. The handshake involves the exchange
+ * of a string <i>JDWP-Handshake</i> as specified in the <a
+ * href="../../../../../../../../../technotes/guides/jpda/jdwp-spec.html">
+ * Java Debug Wire Protocol</a> specification.
+ *
+ * @param address
+ * The address of the target VM.
+ *
+ * @param attachTimeout
+ * If this transport service supports an attach timeout,
+ * and if <tt>attachTimeout</tt> is positive, then it specifies
+ * the timeout, in milliseconds (more or less), to use
+ * when attaching to the target VM. If the transport service
+ * does not support an attach timeout, or if <tt>attachTimeout</tt>
+ * is specified as zero then attach without any timeout.
+ *
+ * @param handshakeTimeout
+ * If this transport service supports a handshake timeout,
+ * and if <tt>handshakeTimeout</tt> is positive, then it
+ * specifies the timeout, in milliseconds (more or less), to
+ * use when handshaking with the target VM. The exact
+ * usage of the timeout are specific to the transport service.
+ * A transport service may, for example, use the handshake
+ * timeout as the inter-character timeout while waiting for
+ * the <i>JDWP-Handshake</i> message from the target VM.
+ * Alternatively, a transport service may, for example,
+ * use the handshakeTimeout as a timeout for the duration of the
+ * handshake exchange.
+ * If the transport service does not support a handshake
+ * timeout, or if <tt>handshakeTimeout</tt> is specified
+ * as zero then the handshake does not timeout if there
+ * isn't a response from the target VM.
+ *
+ * @return The Connection representing the bi-directional
+ * communication channel to the target VM.
+ *
+ * @throws TransportTimeoutException
+ * If a timeout occurs while establishing the connection.
+ *
+ * @throws IOException
+ * If an I/O error occurs (including a timeout when
+ * handshaking).
+ *
+ * @throws IllegalArgumentException
+ * If the address is invalid or the value of the
+ * attach timeout or handshake timeout is negative.
+ *
+ * @see TransportService.Capabilities#supportsAttachTimeout()
+ */
+ public abstract Connection attach(String address, long attachTimeout,
+ long handshakeTimeout) throws IOException;
+
+ /**
+ * A <i>listen key</i>.
+ *
+ * <p> A <tt>TransportService</tt> may listen on multiple, yet
+ * different, addresses at the same time. To uniquely identify
+ * each <tt>listener</tt> a listen key is created each time that
+ * {@link #startListening startListening} is called. The listen
+ * key is used in calls to the {@link #accept accept} method
+ * to accept inbound connections to that listener. A listen
+ * key is valid until it is used as an argument to {@link
+ * #stopListening stopListening} to stop the transport
+ * service from listening on an address.
+ */
+ @jdk.Exported
+ public static abstract class ListenKey {
+
+ /**
+ * Returns a string representation of the listen key.
+ */
+ public abstract String address();
+ }
+
+ /**
+ * Listens on the specified address for inbound connections.
+ *
+ * <p> This method starts the transport service listening on
+ * the specified address so that it can subsequently accept
+ * an inbound connection. It does not wait until an inbound
+ * connection is established.
+ *
+ * @param address
+ * The address to start listening for connections,
+ * or <tt>null</tt> to listen on an address chosen
+ * by the transport service.
+ *
+ * @return a listen key to be used in subsequent calls to be
+ * {@link #accept accept} or {@link #stopListening
+ * stopListening} methods.
+ *
+ * @throws IOException
+ * If an I/O error occurs.
+ *
+ * @throws IllegalArgumentException
+ * If the specific address is invalid
+ */
+ public abstract ListenKey startListening(String address) throws IOException;
+
+ /**
+ * Listens on an address chosen by the transport service.
+ *
+ * <p> This convenience method works as if by invoking {@link
+ * #startListening(String) startListening(<tt>null</tt>)}. </p>
+ *
+ * @return a listen key to be used in subsequent calls to be
+ * {@link #accept accept} or {@link #stopListening
+ * stopListening} methods.
+ *
+ * @throws IOException
+ * If an I/O error occurs.
+ */
+ public abstract ListenKey startListening() throws IOException;
+
+ /**
+ * Stop listening for inbound connections.
+ *
+ * <p> Invoking this method while another thread is blocked
+ * in {@link #accept accept}, with the same listen key,
+ * waiting to accept a connection will cause that thread to
+ * throw an IOException. If the thread blocked in accept
+ * has already accepted a connection from a target VM and
+ * is in the process of handshaking with the target VM then
+ * invoking this method will not cause the thread to throw
+ * an exception.
+ *
+ * @param listenKey
+ * The listen key obtained from a previous call to {@link
+ * #startListening(String)} or {@link #startListening()}.
+ *
+ * @throws IllegalArgumentException
+ * If the listen key is invalid
+ *
+ * @throws IOException
+ * If an I/O error occurs.
+ */
+ public abstract void stopListening(ListenKey listenKey) throws IOException;
+
+ /**
+ * Accept a connection from a target VM.
+ *
+ * <p> Waits (indefinitely or with timeout) to accept a connection
+ * from a target VM. Returns a connection representing the
+ * bi-directional communication channel to the target VM.
+ *
+ * <p> Accepting a connection from a target VM involves two
+ * steps. First, the transport service waits to accept
+ * the connection from the target VM. Once the connection is
+ * established a handshake is performed to ensure that the
+ * connection is indeed to a target VM. The handshake involves
+ * the exchange of a string <i>JDWP-Handshake</i> as specified
+ * in the <a
+ * href="../../../../../../../../../technotes/guides/jpda/jdwp-spec.html">
+ * Java Debug Wire Protocol</a> specification.
+ *
+ * @param listenKey
+ * A listen key obtained from a previous call to {@link
+ * #startListening(String)} or {@link #startListening()}.
+ *
+ * @param acceptTimeout
+ * if this transport service supports an accept timeout, and
+ * if <tt>acceptTimeout</tt> is positive then block for up to
+ * <tt>acceptTimeout</tt> milliseconds, more or less, while waiting
+ * for the target VM to connect.
+ * If the transport service does not support an accept timeout
+ * or if <tt>acceptTimeout</tt> is zero then block indefinitely
+ * for a target VM to connect.
+ *
+ * @param handshakeTimeout
+ * If this transport service supports a handshake timeout,
+ * and if <tt>handshakeTimeout</tt> is positive, then it
+ * specifies the timeout, in milliseconds (more or less), to
+ * use when handshaking with the target VM. The exact
+ * usage of the timeout is specific to the transport service.
+ * A transport service may, for example, use the handshake
+ * timeout as the inter-character timeout while waiting for
+ * the <i>JDWP-Handshake</i> message from the target VM.
+ * Alternatively, a transport service may, for example,
+ * use the timeout as a timeout for the duration of the
+ * handshake exchange.
+ * If the transport service does not support a handshake
+ * timeout, of if <tt>handshakeTimeout</tt> is specified
+ * as zero then the handshake does not timeout if there
+ * isn't a response from the target VM.
+ *
+ * @return The Connection representing the bi-directional
+ * communication channel to the target VM.
+ *
+ * @throws TransportTimeoutException
+ * If a timeout occurs while waiting for a target VM
+ * to connect.
+ *
+ * @throws IOException
+ * If an I/O error occurs (including a timeout when
+ * handshaking).
+ *
+ * @throws IllegalArgumentException
+ * If the value of the acceptTimeout argument, or
+ * handshakeTimeout is negative, or an invalid listen key
+ * is provided.
+ *
+ * @throws IllegalStateException
+ * If {@link #stopListening stopListening} has already been
+ * called with this listen key and the transport service
+ * is no longer listening for inbound connections.
+ *
+ * @see TransportService.Capabilities#supportsAcceptTimeout()
+ */
+ public abstract Connection accept(ListenKey listenKey, long acceptTimeout,
+ long handshakeTimeout) throws IOException;
+
+}
diff --git a/src/share/classes/com/sun/jdi/connect/spi/package-info.java b/src/share/classes/com/sun/jdi/connect/spi/package-info.java
new file mode 100644
index 0000000..956e28d
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/connect/spi/package-info.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2003, 2013, 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.
+ */
+
+/**
+ * This package comprises the interfaces and classes used to
+ * develop new {@link com.sun.jdi.connect.spi.TransportService}
+ * implementations.
+ */
+
+@jdk.Exported
+package com.sun.jdi.connect.spi;
diff --git a/src/share/classes/com/sun/jdi/doc-files/signature.html b/src/share/classes/com/sun/jdi/doc-files/signature.html
new file mode 100644
index 0000000..f7bdd8d
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/doc-files/signature.html
@@ -0,0 +1,39 @@
+<HTML>
+<HEAD>
+<TITLE>
+JDI Type Signatures
+</TITLE>
+</HEAD>
+<BODY BGCOLOR="white">
+<dl><dd>
+<Table Border="0">
+<caption><h2>JDI Type Signatures</h2></caption>
+<tr><th>Type Signature
+<th>Java Type
+<tr><td>Z<td>boolean
+<tr><td>B<td>byte
+<tr><td>C<td>char
+<tr><td>S<td>short
+<tr><td>I<td>int
+<tr><td>J<td>long
+<tr><td>F<td>float
+<tr><td>D<td>double
+<tr><td><strong>L</strong> <em>fully-qualified-class</em>
+<strong>;</strong>
+<td>fully-qualified-class
+<tr><td><strong>[</strong> <em>type
+</em>
+<td><em>type</em>[]
+<tr><td>
+<strong>(</strong> <em>arg-types </em><strong>)</strong> <em>ret-type
+</em>
+<td>method type (including constructors)
+</Table>
+</dd></dl>
+<p>For example, the Java method:
+<p><pre> long f (int n, String s, int[] arr);
+</pre>has the following type signature:
+<p><pre> (ILjava/lang/String;[I)J
+</pre>
+</BODY>
+</HTML>
diff --git a/src/share/classes/com/sun/jdi/event/AccessWatchpointEvent.java b/src/share/classes/com/sun/jdi/event/AccessWatchpointEvent.java
new file mode 100644
index 0000000..b04d4f7
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/AccessWatchpointEvent.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ * Notification of a field access in the target VM. Field modifications
+ * are not considered field accesses.
+ *
+ * @see EventQueue
+ * @see VirtualMachine
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface AccessWatchpointEvent extends WatchpointEvent {
+}
diff --git a/src/share/classes/com/sun/jdi/event/BreakpointEvent.java b/src/share/classes/com/sun/jdi/event/BreakpointEvent.java
new file mode 100644
index 0000000..565f4f0
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/BreakpointEvent.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+import java.util.List;
+
+/**
+ * Notification of a breakpoint in the target VM.
+ * The breakpoint event
+ * is generated before the code at its location is executed.
+ * When a location
+ * is reached which satisfies a currently enabled
+ * {@link com.sun.jdi.request.BreakpointRequest breakpoint request},
+ * an {@link EventSet event set}
+ * containing an instance of this class will be added
+ * to the VM's event queue.
+ *
+ * @see EventQueue
+ * @see VirtualMachine
+ * @see com.sun.jdi.request.BreakpointRequest
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface BreakpointEvent extends LocatableEvent {
+}
diff --git a/src/share/classes/com/sun/jdi/event/ClassPrepareEvent.java b/src/share/classes/com/sun/jdi/event/ClassPrepareEvent.java
new file mode 100644
index 0000000..2f0bf5a
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/ClassPrepareEvent.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ * Notification of a class prepare in the target VM. See the JVM
+ * specification for a definition of class preparation. Class prepare
+ * events are not generated for primtiive classes (for example,
+ * java.lang.Integer.TYPE).
+ *
+ * @see EventQueue
+ * @see VirtualMachine
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ClassPrepareEvent extends Event {
+ /**
+ * Returns the thread in which this event has occurred.
+ * <p>
+ * In rare cases, this event may occur in a debugger system
+ * thread within the target VM. Debugger threads take precautions
+ * to prevent these events, but they cannot be avoided under some
+ * conditions, especially for some subclasses of
+ * {@link java.lang.Error}.
+ * If the event was generated by a debugger system thread, the
+ * value returned by this method is null, and if the requested
+ * suspend policy for the event was
+ * {@link com.sun.jdi.request.EventRequest#SUSPEND_EVENT_THREAD},
+ * all threads will be suspended instead, and the
+ * {@link EventSet#suspendPolicy} will reflect this change.
+ * <p>
+ * Note that the discussion above does not apply to system threads
+ * created by the target VM during its normal (non-debug) operation.
+ *
+ * @return a {@link ThreadReference} which mirrors the event's thread in
+ * the target VM, or null in the rare cases described above.
+ */
+ public ThreadReference thread();
+
+ /**
+ * Returns the reference type for which this event was generated.
+ *
+ * @return a {@link ReferenceType} which mirrors the class, interface, or
+ * array which has been linked.
+ */
+ public ReferenceType referenceType();
+}
diff --git a/src/share/classes/com/sun/jdi/event/ClassUnloadEvent.java b/src/share/classes/com/sun/jdi/event/ClassUnloadEvent.java
new file mode 100644
index 0000000..b900e6a
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/ClassUnloadEvent.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ * Notification of a class unload in the target VM.
+ * <p>
+ * There are severe constraints on the debugger back-end during
+ * garbage collection, so unload information is greatly limited.
+ *
+ * @see EventQueue
+ * @see VirtualMachine
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ClassUnloadEvent extends Event {
+ /**
+ * Returns the name of the class that has been unloaded.
+ */
+ public String className();
+
+ /**
+ * Returns the JNI-style signature of the class that has been unloaded.
+ */
+ public String classSignature();
+}
diff --git a/src/share/classes/com/sun/jdi/event/Event.java b/src/share/classes/com/sun/jdi/event/Event.java
new file mode 100644
index 0000000..8e8185c
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/Event.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.EventRequest;
+
+/**
+ * An occurrence in a target VM that is of interest to a debugger. Event is
+ * the common superinterface for all events (examples include
+ * {@link BreakpointEvent}, {@link ExceptionEvent},
+ * {@link ClassPrepareEvent}).
+ * When an event occurs, an instance of Event as a component of
+ * an {@link EventSet} is enqueued in the
+ * {@link VirtualMachine}'s {@link EventQueue}.
+ *
+ * @see EventSet
+ * @see EventQueue
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface Event extends Mirror {
+
+ /**
+ * @return The {@link EventRequest} that requested this event.
+ * Some events (eg. {@link VMDeathEvent}) may not have
+ * a cooresponding request and thus will return null.
+ */
+ EventRequest request();
+}
diff --git a/src/share/classes/com/sun/jdi/event/EventIterator.java b/src/share/classes/com/sun/jdi/event/EventIterator.java
new file mode 100644
index 0000000..e16ccc5
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/EventIterator.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+import java.util.Iterator;
+
+/**
+ * EventIterators are unmodifiable.
+ *
+ * @see Event
+ * @see EventSet
+ * @see EventSet#iterator
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+
+@jdk.Exported
+public interface EventIterator extends Iterator<Event> {
+
+ /**
+ * @return The next {@link Event} in an {@link EventSet}.
+ */
+ Event nextEvent();
+}
diff --git a/src/share/classes/com/sun/jdi/event/EventQueue.java b/src/share/classes/com/sun/jdi/event/EventQueue.java
new file mode 100644
index 0000000..e7912ba
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/EventQueue.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ * Manager of incoming debugger events for a target VM.
+ * Events are always grouped in {@link EventSet}s.
+ * EventSets generated by the debugger back end can be read
+ * here. There is one instance of EventQueue assigned to a particular
+ * {@link com.sun.jdi.VirtualMachine VirtualMachine}.
+ * <P>
+ * Some events cause the suspension of the target VM - event requests
+ * ({@link com.sun.jdi.request}) with a
+ * {@link com.sun.jdi.request.EventRequest#suspendPolicy() suspend policy}
+ * of {@link com.sun.jdi.request.EventRequest#SUSPEND_ALL SUSPEND_ALL}
+ * or {@link com.sun.jdi.request.EventRequest#SUSPEND_EVENT_THREAD
+ * SUSPEND_EVENT_THREAD} and sometimes
+ * {@link VMStartEvent}.
+ * If these suspensions are not resumed the target VM will hang.
+ * Thus, it is always good policy to
+ * {@link #remove() remove()} every EventSet from the
+ * event queue until an EventSet containing a
+ * {@link VMDisconnectEvent} is read.
+ * Unless {@link com.sun.jdi.VirtualMachine#resume() resume} is
+ * being handled in another way, each EventSet should invoke
+ * {@link EventSet#resume()}.
+ *
+ * @see EventSet
+ * @see VirtualMachine
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+
+@jdk.Exported
+public interface EventQueue extends Mirror {
+
+ /**
+ * Waits forever for the next available event.
+ *
+ * @return the next {@link EventSet}.
+ * @throws InterruptedException if any thread has interrupted
+ * this thread.
+ * @throws com.sun.jdi.VMDisconnectedException if the connection
+ * to the target VM is no longer available. Note this will always
+ * be preceded by a {@link com.sun.jdi.event.VMDisconnectEvent}.
+ */
+ EventSet remove() throws InterruptedException;
+
+ /**
+ * Waits a specified time for the next available event.
+ *
+ * @param timeout Time in milliseconds to wait for the next event
+ * @return the next {@link EventSet}, or null if there is a timeout.
+ * @throws InterruptedException if any thread has interrupted
+ * this thread.
+ * @throws com.sun.jdi.VMDisconnectedException if the connection
+ * to the target VM is no longer available. Note this will always
+ * be preceded by a {@link com.sun.jdi.event.VMDisconnectEvent}.
+ * @throws IllegalArgumentException if the timeout argument
+ * contains an illegal value.
+ */
+ EventSet remove(long timeout) throws InterruptedException;
+}
diff --git a/src/share/classes/com/sun/jdi/event/EventSet.java b/src/share/classes/com/sun/jdi/event/EventSet.java
new file mode 100644
index 0000000..bba0573
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/EventSet.java
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+import java.util.Set;
+
+/**
+ * Several {@link Event} objects may be created at a given time by
+ * the target {@link VirtualMachine}. For example, there may be
+ * more than one {@link com.sun.jdi.request.BreakpointRequest}
+ * for a given {@link Location}
+ * or you might single step to the same location as a
+ * BreakpointRequest. These {@link Event} objects are delivered
+ * together as an EventSet. For uniformity, an EventSet is always used
+ * to deliver {@link Event} objects. EventSets are delivered by
+ * the {@link EventQueue}.
+ * EventSets are unmodifiable.
+ * <P>
+ * Associated with the issuance of an event set, suspensions may
+ * have occurred in the target VM. These suspensions correspond
+ * with the {@link #suspendPolicy() suspend policy}.
+ * To assure matching resumes occur, it is recommended,
+ * where possible,
+ * to complete the processing of an event set with
+ * {@link #resume() EventSet.resume()}.
+ * <P>
+ * The events that are grouped in an EventSet are restricted in the
+ * following ways:
+ * <P>
+ * <UL>
+ * <LI>Always singleton sets:
+ * <UL>
+ * <LI>{@link VMStartEvent}
+ * <LI>{@link VMDisconnectEvent}
+ * </UL>
+ * <LI>Only with other VMDeathEvents:
+ * <UL>
+ * <LI>{@link VMDeathEvent}
+ * </UL>
+ * <LI>Only with other ThreadStartEvents for the same thread:
+ * <UL>
+ * <LI>{@link ThreadStartEvent}
+ * </UL>
+ * <LI>Only with other ThreadDeathEvents for the same thread:
+ * <UL>
+ * <LI>{@link ThreadDeathEvent}
+ * </UL>
+ * <LI>Only with other ClassPrepareEvents for the same class:
+ * <UL>
+ * <LI>{@link ClassPrepareEvent}
+ * </UL>
+ * <LI>Only with other ClassUnloadEvents for the same class:
+ * <UL>
+ * <LI>{@link ClassUnloadEvent}
+ * </UL>
+ * <LI>Only with other AccessWatchpointEvents for the same field access:
+ * <UL>
+ * <LI>{@link AccessWatchpointEvent}
+ * </UL>
+ * <LI>Only with other ModificationWatchpointEvents for the same field
+ * modification:
+ * <UL>
+ * <LI>{@link ModificationWatchpointEvent}
+ * </UL>
+ * <LI>Only with other ExceptionEvents for the same exception occurrance:
+ * <UL>
+ * <LI>{@link ExceptionEvent}
+ * </UL>
+ * <LI>Only with other MethodExitEvents for the same method exit:
+ * <UL>
+ * <LI>{@link MethodExitEvent}
+ * </UL>
+ * <LI>Only with other Monitor contended enter events for the same monitor object:
+ * <UL>
+ * <LI>Monitor Contended Enter Event
+ * </UL>
+ * <LI>Only with other Monitor contended entered events for the same monitor object:
+ * <UL>
+ * <LI>Monitor Contended Entered Event
+ * </UL>
+ * <LI>Only with other Monitor wait events for the same monitor object:
+ * <UL>
+ * <LI>Monitor Wait Event
+ * </UL>
+ * <LI>Only with other Monitor waited events for the same monitor object:
+ * <UL>
+ * <LI>Monitor Waited Event
+ * </UL>
+ * <LI>Only with other members of this group, at the same location
+ * and in the same thread:
+ * <UL>
+ * <LI>{@link BreakpointEvent}
+ * <LI>{@link StepEvent}
+ * <LI>{@link MethodEntryEvent}
+ * </UL>
+ * </UL>
+ *
+ * @see Event
+ * @see EventQueue
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+
+@jdk.Exported
+public interface EventSet extends Mirror, Set<Event> {
+
+ /**
+ * Returns the policy used to suspend threads in the target VM
+ * for this event set. This policy is selected from the suspend
+ * policies for each event's request; the target VM chooses the
+ * policy which suspends the most threads. The target VM
+ * suspends threads according to that policy
+ * and that policy is returned here. See
+ * {@link com.sun.jdi.request.EventRequest} for the possible
+ * policy values.
+ * <p>
+ * In rare cases, the suspend policy may differ from the requested
+ * value if a {@link ClassPrepareEvent} has occurred in a
+ * debugger system thread. See {@link ClassPrepareEvent#thread}
+ * for details.
+ *
+ * @return the suspendPolicy which is either
+ * {@link com.sun.jdi.request.EventRequest#SUSPEND_ALL SUSPEND_ALL},
+ * {@link com.sun.jdi.request.EventRequest#SUSPEND_EVENT_THREAD SUSPEND_EVENT_THREAD} or
+ * {@link com.sun.jdi.request.EventRequest#SUSPEND_NONE SUSPEND_NONE}.
+ */
+ int suspendPolicy();
+
+ /**
+ * Return an iterator specific to {@link Event} objects.
+ */
+ EventIterator eventIterator();
+
+ /**
+ * Resumes threads suspended by this event set. If the {@link #suspendPolicy}
+ * is {@link com.sun.jdi.request.EventRequest#SUSPEND_ALL}, a call
+ * to this method is equivalent to
+ * {@link com.sun.jdi.VirtualMachine#resume}. If the
+ * suspend policy is
+ * {@link com.sun.jdi.request.EventRequest#SUSPEND_EVENT_THREAD},
+ * a call to this method is equivalent to
+ * {@link com.sun.jdi.ThreadReference#resume} for the event thread.
+ * Otherwise, a call to this method is a no-op.
+ */
+ void resume();
+}
diff --git a/src/share/classes/com/sun/jdi/event/ExceptionEvent.java b/src/share/classes/com/sun/jdi/event/ExceptionEvent.java
new file mode 100644
index 0000000..91ed8e4
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/ExceptionEvent.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ * Notification of an exception in the target VM. When an exception
+ * is thrown which satisfies a currently enabled
+ * {@link com.sun.jdi.request.ExceptionRequest exception request},
+ * an {@link EventSet event set}
+ * containing an instance of this class will be added
+ * to the VM's event queue.
+ * If the exception is thrown from a non-native method,
+ * the exception event is generated at the location where the
+ * exception is thrown.
+ * If the exception is thrown from a native method, the exception event
+ * is generated at the first non-native location reached after the exception
+ * is thrown.
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ExceptionEvent extends LocatableEvent {
+
+ /**
+ * Gets the thrown exception object. The exception object is
+ * an instance of {@link java.lang.Throwable} or a subclass in the
+ * target VM.
+ *
+ * @return an {@link ObjectReference} which mirrors the thrown object in
+ * the target VM.
+ */
+ public ObjectReference exception();
+
+ /**
+ * Gets the location where the exception will be caught. An exception
+ * is considered to be caught if, at the point of the throw, the
+ * current location is dynamically enclosed in a try statement that
+ * handles the exception. (See the JVM specification for details).
+ * If there is such a try statement, the catch location is the
+ * first code index of the appropriate catch clause.
+ * <p>
+ * If there are native methods in the call stack at the time of the
+ * exception, there are important restrictions to note about the
+ * returned catch location. In such cases,
+ * it is not possible to predict whether an exception will be handled
+ * by some native method on the call stack.
+ * Thus, it is possible that exceptions considered uncaught
+ * here will, in fact, be handled by a native method and not cause
+ * termination of the target VM. Furthermore, it cannot be assumed that the
+ * catch location returned here will ever be reached by the throwing
+ * thread. If there is
+ * a native frame between the current location and the catch location,
+ * the exception might be handled and cleared in that native method
+ * instead.
+ * <p>
+ * Note that the compiler can generate try-catch blocks in some cases
+ * where they are not explicit in the source code; for example,
+ * the code generated for <code>synchronized</code> and
+ * <code>finally</code> blocks can contain implicit try-catch blocks.
+ * If such an implicitly generated try-catch is
+ * present on the call stack at the time of the throw, the exception
+ * will be considered caught even though it appears to be uncaught from
+ * examination of the source code.
+ *
+ * @return the {@link Location} where the exception will be caught or null if
+ * the exception is uncaught.
+ */
+ public Location catchLocation();
+}
diff --git a/src/share/classes/com/sun/jdi/event/LocatableEvent.java b/src/share/classes/com/sun/jdi/event/LocatableEvent.java
new file mode 100644
index 0000000..ab4d7f5
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/LocatableEvent.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 1999, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+import java.util.List;
+
+/**
+ * Abstract superinterface of events which have both location
+ * and thread.
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface LocatableEvent extends Event, Locatable {
+
+ /**
+ * Returns the thread in which this event has occurred.
+ *
+ * @return a {@link ThreadReference} which mirrors the event's thread in
+ * the target VM.
+ */
+ public ThreadReference thread();
+}
diff --git a/src/share/classes/com/sun/jdi/event/MethodEntryEvent.java b/src/share/classes/com/sun/jdi/event/MethodEntryEvent.java
new file mode 100644
index 0000000..29e4df6
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/MethodEntryEvent.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ * Notification of a method invocation in the target VM. This event
+ * occurs after entry into the invoked method and before any
+ * code has executed.
+ * Method entry events are generated for both native and non-native
+ * methods.
+ * <P>
+ * In some VMs method entry events can occur for a particular thread
+ * before its {@link ThreadStartEvent} occurs if methods are called
+ * as part of the thread's initialization.
+ *
+ * @see EventQueue
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface MethodEntryEvent extends LocatableEvent {
+
+ /**
+ * Returns the method that was entered.
+ *
+ * @return a {@link Method} which mirrors the method that was entered.
+ */
+ public Method method();
+}
diff --git a/src/share/classes/com/sun/jdi/event/MethodExitEvent.java b/src/share/classes/com/sun/jdi/event/MethodExitEvent.java
new file mode 100644
index 0000000..6c7ad30
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/MethodExitEvent.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ * Notification of a method return in the target VM. This event
+ * is generated after all code in the method has executed, but the
+ * location of this event is the last executed location in the method.
+ * Method exit events are generated for both native and non-native
+ * methods. Method exit events are not generated if the method terminates
+ * with a thrown exception.
+ *
+ * @see EventQueue
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface MethodExitEvent extends LocatableEvent {
+
+ /**
+ * Returns the method that was exited.
+ *
+ * @return a {@link Method} which mirrors the method that was exited.
+ * @throws ObjectCollectedException may be thrown if class
+ * has been garbage collected.
+ */
+ public Method method();
+
+ /**
+ * Returns the value that the method will return.
+ *
+ * Not all target virtual machines support this operation.
+ * Use
+ * {@link VirtualMachine#canGetMethodReturnValues() canGetMethodReturnValues()}
+ * to determine if this operation is supported.
+ *
+ * @return a {@link Value} which mirrors the value to be returned.
+ *
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation - see
+ * {@link VirtualMachine#canGetMethodReturnValues() canGetMethodReturnValues()}
+ *
+ * @since 1.6
+ */
+
+ public Value returnValue();
+}
diff --git a/src/share/classes/com/sun/jdi/event/ModificationWatchpointEvent.java b/src/share/classes/com/sun/jdi/event/ModificationWatchpointEvent.java
new file mode 100644
index 0000000..965a6cd
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/ModificationWatchpointEvent.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ * Notification of a field modification in the
+ * target VM.
+ *
+ * @see EventQueue
+ * @see VirtualMachine
+ * @see com.sun.jdi.request.ModificationWatchpointRequest
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ModificationWatchpointEvent extends WatchpointEvent {
+
+ /**
+ * Value that will be assigned to the field when the instruction
+ * completes.
+ */
+ Value valueToBe();
+}
diff --git a/src/share/classes/com/sun/jdi/event/MonitorContendedEnterEvent.java b/src/share/classes/com/sun/jdi/event/MonitorContendedEnterEvent.java
new file mode 100644
index 0000000..0890d12
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/MonitorContendedEnterEvent.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2005, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ *
+ * Notification that a thread in the target VM is attempting
+ * to enter a monitor that is already acquired by another thread.
+ * <P>
+ *
+ * @see EventQueue
+ * @see MonitorContendedEnteredEvent
+ *
+ *
+ * @author Swamy Venkataramanappa
+ * @since 1.6
+ */
+@jdk.Exported
+public interface MonitorContendedEnterEvent extends LocatableEvent {
+
+ /**
+ * Returns the thread in which this event has occurred.
+ * <p>
+ *
+ * @return a {@link ThreadReference} which mirrors the event's thread in
+ * the target VM.
+ */
+ public ThreadReference thread();
+
+ /**
+ * Returns the method that was entered.
+ *
+ * @return an {@link ObjectReference} for the monitor.
+ */
+ public ObjectReference monitor();
+}
diff --git a/src/share/classes/com/sun/jdi/event/MonitorContendedEnteredEvent.java b/src/share/classes/com/sun/jdi/event/MonitorContendedEnteredEvent.java
new file mode 100644
index 0000000..f249c18
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/MonitorContendedEnteredEvent.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2005, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ *
+ * Notification that a thread in the target VM is entering a monitor
+ * after waiting for it to be released by another thread.
+ * <P>
+ *
+ * @see EventQueue
+ * @see MonitorContendedEnterEvent
+ *
+ * @author Swamy Venkataramanappa
+ * @since 1.6
+ */
+@jdk.Exported
+public interface MonitorContendedEnteredEvent extends LocatableEvent {
+
+ /**
+ * Returns the thread in which this event has occurred.
+ * <p>
+ *
+ * @return a {@link ThreadReference} which mirrors the event's thread in
+ * the target VM.
+ */
+ public ThreadReference thread();
+
+ /**
+ * Returns the monitor that was entered.
+ *
+ * @return an {@link ObjectReference} for the monitor.
+ */
+ public ObjectReference monitor();
+
+}
diff --git a/src/share/classes/com/sun/jdi/event/MonitorWaitEvent.java b/src/share/classes/com/sun/jdi/event/MonitorWaitEvent.java
new file mode 100644
index 0000000..6cd32a6
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/MonitorWaitEvent.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2005, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ * Notification that a thread in the target VM is about to
+ * wait on a monitor object.
+ * <P>
+ *
+ * @see EventQueue
+ * @see MonitorWaitedEvent
+ *
+ * @author Swamy Venkataramanappa
+ * @since 1.6
+ */
+@jdk.Exported
+public interface MonitorWaitEvent extends LocatableEvent {
+
+ /**
+ * Returns the thread in which monitor wait event has occurred.
+ * <p>
+ *
+ * @return a {@link ThreadReference} which mirrors the event's thread in
+ * the target VM.
+ */
+ public ThreadReference thread();
+
+ /**
+ * Returns the monitor object that the thread about to wait.
+ *
+ * @return an {@link ObjectReference} for the monitor.
+ */
+ public ObjectReference monitor();
+
+ /**
+ * Returns the number of millisecond the thread will wait.
+ *
+ * @return a <code>jlong</code> containing monitor wait time in milliseconds.
+ */
+ public long timeout();
+}
diff --git a/src/share/classes/com/sun/jdi/event/MonitorWaitedEvent.java b/src/share/classes/com/sun/jdi/event/MonitorWaitedEvent.java
new file mode 100644
index 0000000..f79cf03
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/MonitorWaitedEvent.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2005, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ * Notification that a thread in the target VM has finished
+ * waiting on an monitor object.
+ * <P>
+ *
+ * @see EventQueue
+ * @see MonitorWaitEvent
+ *
+ * @author Swamy Venkataramanappa
+ * @since 1.6
+ */
+@jdk.Exported
+public interface MonitorWaitedEvent extends LocatableEvent {
+
+ /**
+ * Returns the thread in which this event has occurred.
+ * <p>
+ *
+ * @return a {@link ThreadReference} which mirrors the event's thread in
+ * the target VM.
+ */
+ public ThreadReference thread();
+
+ /**
+ * Returns the monitor object this thread waited on.
+ *
+ * @return an {@link ObjectReference} for the monitor.
+ */
+ public ObjectReference monitor();
+
+ /**
+ * Returns whether the wait has timed out or been interrupted.
+ *
+ * @return <code>true</code> if the wait is timed out.
+ */
+ public boolean timedout();
+
+
+}
diff --git a/src/share/classes/com/sun/jdi/event/StepEvent.java b/src/share/classes/com/sun/jdi/event/StepEvent.java
new file mode 100644
index 0000000..2790787
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/StepEvent.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ * Notification of step completion in the target VM.
+ * The step event
+ * is generated immediately before the code at its location is executed;
+ * thus, if the step is entering a new method (as might occur with
+ * {@link com.sun.jdi.request.StepRequest#STEP_INTO StepRequest.STEP_INTO})
+ * the location of the event is the first instruction of the method.
+ * When a step leaves a method, the location of the event will be the
+ * first instruction after the call in the calling method; note that
+ * this location may not be at a line boundary, even if
+ * {@link com.sun.jdi.request.StepRequest#STEP_LINE StepRequest.STEP_LINE}
+ * was used.
+ *
+ * @see com.sun.jdi.request.StepRequest
+ * @see EventQueue
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface StepEvent extends LocatableEvent {
+}
diff --git a/src/share/classes/com/sun/jdi/event/ThreadDeathEvent.java b/src/share/classes/com/sun/jdi/event/ThreadDeathEvent.java
new file mode 100644
index 0000000..cd23380
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/ThreadDeathEvent.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ * Notification of a completed thread in the target VM. The
+ * notification is generated by the dying thread before it terminates.
+ * Because of this timing, it is possible
+ * for {@link VirtualMachine#allThreads} to return this thread
+ * after this event is received.
+ * <p>
+ * Note that this event gives no information
+ * about the lifetime of the thread object. It may or may not be collected
+ * soon depending on what references exist in the target VM.
+ *
+ * @see EventQueue
+ * @see VirtualMachine
+ * @see ThreadReference
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ThreadDeathEvent extends Event {
+ /**
+ * Returns the thread which is terminating.
+ *
+ * @return a {@link ThreadReference} which mirrors the event's thread in
+ * the target VM.
+ */
+ public ThreadReference thread();
+}
diff --git a/src/share/classes/com/sun/jdi/event/ThreadStartEvent.java b/src/share/classes/com/sun/jdi/event/ThreadStartEvent.java
new file mode 100644
index 0000000..01e9e63
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/ThreadStartEvent.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ * Notification of a new running thread in the target VM.
+ * The new thread can be the result of a call to
+ * <code>{@link java.lang.Thread#start}</code> or the result of
+ * attaching a new thread to the VM though JNI. The
+ * notification is generated by the new thread some time before
+ * its execution starts.
+ * Because of this timing, it is possible to receive other events
+ * for the thread before this event is received. (Notably,
+ * {@link MethodEntryEvent}s and {@link MethodExitEvent}s might occur
+ * during thread initialization.)
+ * It is also possible for {@link VirtualMachine#allThreads} to return
+ * a new started thread before this event is received.
+ * <p>
+ * Note that this event gives no information
+ * about the creation of the thread object which may have happened
+ * much earlier, depending on the VM being debugged.
+ *
+ * @see EventQueue
+ * @see VirtualMachine
+ * @see ThreadReference
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ThreadStartEvent extends Event {
+ /**
+ * Returns the thread which has started.
+ *
+ * @return a {@link ThreadReference} which mirrors the event's thread in
+ * the target VM.
+ */
+ public ThreadReference thread();
+}
diff --git a/src/share/classes/com/sun/jdi/event/VMDeathEvent.java b/src/share/classes/com/sun/jdi/event/VMDeathEvent.java
new file mode 100644
index 0000000..c96aa12
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/VMDeathEvent.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ * Notification of target VM termination.
+ * This event occurs if the target VM terminates before the
+ * VM disconnects ({@link VMDisconnectEvent}).
+ * Thus, this event will NOT occur if
+ * external forces terminate the connection (e.g. a crash)
+ * or if the connection is intentionally terminated with
+ * {@link com.sun.jdi.VirtualMachine#dispose()
+ * VirtualMachine.dispose()}
+ * <P>
+ * On VM termination, a single unsolicited VMDeathEvent
+ * will always be sent with a
+ * {@link com.sun.jdi.request.EventRequest#suspendPolicy() suspend policy}
+ * of {@link com.sun.jdi.request.EventRequest#SUSPEND_NONE SUSPEND_NONE}.
+ * Additional VMDeathEvents will be sent in the same event set if they are
+ * requested with a
+ * {@link com.sun.jdi.request.VMDeathRequest VMDeathRequest}.
+ * <P>
+ * The VM is still intact and can be queried at the point this
+ * event was initiated but immediately thereafter it is not
+ * considered intact and cannot be queried.
+ * Note: If the enclosing {@link EventSet} has a
+ * {@link com.sun.jdi.request.EventRequest#suspendPolicy() suspend policy}
+ * other than
+ * {@link com.sun.jdi.request.EventRequest#SUSPEND_ALL SUSPEND_ALL}
+ * the initiating point may be long past.
+ * <P>
+ * All VMDeathEvents will be in a single {@link EventSet},
+ * no other events will be in the event set. A resume
+ * must occur to continue execution after any event set which
+ * performs suspensions - in this case to allow proper shutdown.
+ *
+ * @see VMDisconnectEvent
+ * @see com.sun.jdi.request.EventRequestManager#createVMDeathRequest
+ * @see com.sun.jdi.request.VMDeathRequest
+ * @see EventQueue
+ * @see VirtualMachine
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface VMDeathEvent extends Event {
+}
diff --git a/src/share/classes/com/sun/jdi/event/VMDisconnectEvent.java b/src/share/classes/com/sun/jdi/event/VMDisconnectEvent.java
new file mode 100644
index 0000000..82c49e2
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/VMDisconnectEvent.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ * Notification of disconnection from target VM.
+ * May be caused by normal termination of a VM,
+ * VM termination by uncaught exception or other error,
+ * debugger action (
+ * {@link VirtualMachine#dispose} or
+ * {@link VirtualMachine#exit}) or by external events
+ * (for example, target process termination by the
+ * operating system, transport termination, etc).
+ * <p>
+ * If the target VM terminates before the disconnection, this event
+ * will be preceded by a {@link VMDeathEvent}.
+ * <p>
+ * This event is always sent.
+ * There is no corresponding {@link com.sun.jdi.request.EventRequest}.
+ * The enclosing singleton {@link EventSet} always has a
+ * suspend policy of {@link com.sun.jdi.request.EventRequest#SUSPEND_NONE}.
+ *
+ * @see VMDeathEvent
+ * @see EventQueue
+ * @see VirtualMachine
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface VMDisconnectEvent extends Event {
+}
diff --git a/src/share/classes/com/sun/jdi/event/VMStartEvent.java b/src/share/classes/com/sun/jdi/event/VMStartEvent.java
new file mode 100644
index 0000000..586526a
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/VMStartEvent.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ * Notification of initialization of a target VM. This event is
+ * received before the main thread is started and before any
+ * application code has been executed. Before this event occurs
+ * a significant amount of system code has executed and a number
+ * of system classes have been loaded.
+ * This event is always generated by the target VM, even
+ * if not explicitly requested.
+ *
+ * @see VMDeathEvent
+ * @see EventQueue
+ * @see VirtualMachine
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface VMStartEvent extends Event {
+ /**
+ * Returns the initial thread of the VM which has started.
+ *
+ * @return a {@link ThreadReference} which mirrors the event's thread in
+ * the target VM.
+ */
+ public ThreadReference thread();
+}
diff --git a/src/share/classes/com/sun/jdi/event/WatchpointEvent.java b/src/share/classes/com/sun/jdi/event/WatchpointEvent.java
new file mode 100644
index 0000000..0246bff
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/WatchpointEvent.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.event;
+
+import com.sun.jdi.*;
+
+/**
+ * Notification of a field triggered event encountered by a thread in the
+ * target VM.
+ *
+ * @see EventQueue
+ * @see VirtualMachine
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface WatchpointEvent extends LocatableEvent {
+
+ /**
+ * Returns the field that is about to be accessed/modified.
+ *
+ * @return a {@link Field} which mirrors the field
+ * in the target VM.
+ * @throws ObjectCollectedException may be thrown if class
+ * has been garbage collected.
+ */
+ Field field();
+
+ /**
+ * Returns the object whose field is about to be accessed/modified.
+ * Return null is the access is to a static field.
+ *
+ * @return a {@link ObjectReference} which mirrors the event's
+ * object in the target VM.
+ */
+ ObjectReference object();
+
+ /**
+ * Current value of the field.
+ * @throws ObjectCollectedException if object or class have been
+ * garbage collected.
+ */
+ Value valueCurrent();
+}
diff --git a/src/share/classes/com/sun/jdi/event/package-info.java b/src/share/classes/com/sun/jdi/event/package-info.java
new file mode 100644
index 0000000..fa9afe3
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/event/package-info.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 1998, 2013, 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.
+ */
+
+/**
+ * This package defines JDI events and event processing.
+ * An {@link com.sun.jdi.event.Event} is always a member of an
+ * {@link com.sun.jdi.event.EventSet}, which
+ * is retrieved from the {@link com.sun.jdi.event.EventQueue}.
+ * Examples of Events include
+ * {@link com.sun.jdi.event.BreakpointEvent "breakpoints events"},
+ * {@link com.sun.jdi.event.ThreadStartEvent "thread creation events"} and
+ * {@link com.sun.jdi.event.VMDeathEvent "virtual machine death event"}.
+ * With the exception
+ * of termination events, all events received must be requested with an
+ * {@link com.sun.jdi.request.EventRequest "EventRequest"}. The
+ * {@link com.sun.jdi.request} package defines event requests and event
+ * request management.
+ * <p>
+ * Methods may be added to the interfaces in the JDI packages in future
+ * releases. Existing packages may be renamed if the JDI becomes a standard
+ * extension.
+ */
+
+@jdk.Exported
+package com.sun.jdi.event;
diff --git a/src/share/classes/com/sun/jdi/package-info.java b/src/share/classes/com/sun/jdi/package-info.java
new file mode 100644
index 0000000..00f422f
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/package-info.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 1998, 2013, 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.
+ */
+
+/**
+ * This is the core package of the Java Debug
+ * Interface (JDI), it defines mirrors for values, types, and the target
+ * VirtualMachine itself - as well bootstrapping facilities.
+ * {@link com.sun.jdi.VirtualMachine} mirrors the target virtual machine and
+ * is the origin of all information provided by the JDI. A VirtualMachine
+ * is typically created by using the
+ * {@link com.sun.jdi.VirtualMachineManager} to create
+ * a connection to the target virtual machine (see the
+ * {@link com.sun.jdi.connect} package). In turn the
+ * {@link com.sun.jdi.VirtualMachineManager} is typically created by calling
+ * {@link com.sun.jdi.Bootstrap#virtualMachineManager()}.
+ * <p>
+ * Most of the methods within this package can throw the unchecked exception
+ * {@link com.sun.jdi.VMDisconnectedException}.
+ * <p>
+ * Methods may be added to the interfaces in the JDI packages in future
+ * releases. Existing packages may be renamed if the JDI becomes a standard
+ * extension.
+ */
+
+@jdk.Exported
+package com.sun.jdi;
diff --git a/src/share/classes/com/sun/jdi/request/AccessWatchpointRequest.java b/src/share/classes/com/sun/jdi/request/AccessWatchpointRequest.java
new file mode 100644
index 0000000..03d64f9
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/AccessWatchpointRequest.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+/**
+ * Request for notification when the contents of a field are accessed
+ * in the target VM.
+ * This event will be triggered when the specified field is accessed
+ * by Java<SUP><FONT SIZE="-2">TM</FONT></SUP> programming
+ * language code or by a
+ * Java Native Interface (JNI) get function (<code>Get<Type>Field,
+ * GetStatic<Type>Field</code>).
+ * Access by JDI does not trigger this event.
+ * When an enabled AccessWatchpointRequest is satisfied, an
+ * {@link com.sun.jdi.event.EventSet event set} containing an
+ * {@link com.sun.jdi.event.AccessWatchpointEvent AccessWatchpointEvent} will be placed
+ * on the {@link com.sun.jdi.event.EventQueue EventQueue}.
+ * The collection of existing ExceptionRequests is
+ * managed by the {@link EventRequestManager}
+ * The collection of existing
+ * watchpoints is
+ * managed by the {@link EventRequestManager}.
+ * <p>
+ * Note that the modification
+ * of a Field is not considered an access.
+ *
+ * @see ModificationWatchpointRequest
+ * @see com.sun.jdi.event.EventQueue
+ * @see EventRequestManager
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface AccessWatchpointRequest extends WatchpointRequest {
+}
diff --git a/src/share/classes/com/sun/jdi/request/BreakpointRequest.java b/src/share/classes/com/sun/jdi/request/BreakpointRequest.java
new file mode 100644
index 0000000..c6d937e
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/BreakpointRequest.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+/**
+ * Identifies a {@link Location} in the target VM at which
+ * execution should be stopped. When an enabled BreakpointRequest is
+ * satisfied, an
+ * {@link com.sun.jdi.event.EventSet event set} containing an
+ * {@link com.sun.jdi.event.BreakpointEvent BreakpointEvent}
+ * will be placed on the
+ * {@link com.sun.jdi.event.EventQueue EventQueue} and
+ * the application is interrupted. The collection of existing breakpoints is
+ * managed by the {@link EventRequestManager}
+ *
+ * @see Location
+ * @see com.sun.jdi.event.BreakpointEvent
+ * @see com.sun.jdi.event.EventQueue
+ * @see EventRequestManager
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface BreakpointRequest extends EventRequest, Locatable {
+
+ /**
+ * Returns the location of the requested breakpoint.
+ *
+ * @return the {@link Location} where this breakpoint has been set.
+ */
+ Location location();
+
+ /**
+ * Restricts the events generated by this request to those in
+ * the given thread.
+ * @param thread the thread to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addThreadFilter(ThreadReference thread);
+
+ /**
+ * Restricts the events generated by this request to those in
+ * which the currently executing instance is the object
+ * specified.
+ * <P>
+ * Not all targets support this operation.
+ * Use {@link VirtualMachine#canUseInstanceFilters()}
+ * to determine if the operation is supported.
+ * @since 1.4
+ * @param instance the object which must be the current instance
+ * in order to pass this filter.
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addInstanceFilter(ObjectReference instance);
+}
diff --git a/src/share/classes/com/sun/jdi/request/ClassPrepareRequest.java b/src/share/classes/com/sun/jdi/request/ClassPrepareRequest.java
new file mode 100644
index 0000000..4bd1b78
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/ClassPrepareRequest.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+/**
+ * Request for notification when a class is prepared in the target VM.
+ * When an enabled ClassPrepareRequest is satisfied, an
+ * {@link com.sun.jdi.event.EventSet event set} containing a
+ * {@link com.sun.jdi.event.ClassPrepareEvent ClassPrepareEvent}
+ * will be placed on the
+ * {@link com.sun.jdi.event.EventQueue EventQueue}.
+ * The collection of existing ClassPrepareRequests is
+ * managed by the {@link EventRequestManager}
+ * <p>
+ * Class preparation is defined in the Java Virtual Machine
+ * Specification.
+ *
+ * @see com.sun.jdi.event.ClassPrepareEvent
+ * @see com.sun.jdi.event.EventQueue
+ * @see EventRequestManager
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ClassPrepareRequest extends EventRequest {
+
+ /**
+ * Restricts the events generated by this request to be the
+ * preparation of the given reference type and any subtypes.
+ * An event will be generated for any prepared reference type that can
+ * be safely cast to the given reference type.
+ *
+ * @param refType the reference type to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(ReferenceType refType);
+
+ /**
+ * Restricts the events generated by this request to the
+ * preparation of reference types whose name matches this restricted
+ * regular expression. Regular expressions are limited
+ * to exact matches and patterns that begin with '*' or end with '*';
+ * for example, "*.Foo" or "java.*".
+ *
+ * @param classPattern the pattern String to filter for.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to the
+ * preparation of reference types whose name does <b>not</b> match
+ * this restricted regular expression. Regular expressions are limited
+ * to exact matches and patterns that begin with '*' or end with '*';
+ * for example, "*.Foo" or "java.*".
+ *
+ * @param classPattern the pattern String to filter against.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassExclusionFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to the
+ * preparation of reference types for which the restricted regular
+ * expression 'sourceNamePattern' matches one of the 'sourceNames' for
+ * the reference type being prepared.
+ * That is, if refType is the ReferenceType being prepared,
+ * then there exists at least one stratum, call it 'someStratum'
+ * on the list returned by
+ * refType.availableStrata();
+ *
+ * such that a name on the list returned by
+ * refType.sourceNames(someStratam)
+ *
+ * matches 'sourceNamePattern'.
+ * Regular expressions are limited
+ * to exact matches and patterns that begin with '*' or end with '*';
+ * for example, "*.Foo" or "java.*".
+ * <P>
+ * Not all targets support this operation.
+ * Use {@link VirtualMachine#canUseSourceNameFilters()}
+ * to determine if the operation is supported.
+ * @since 1.6
+ * @param sourceNamePattern the pattern string to filter for.
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addSourceNameFilter(String sourceNamePattern);
+}
diff --git a/src/share/classes/com/sun/jdi/request/ClassUnloadRequest.java b/src/share/classes/com/sun/jdi/request/ClassUnloadRequest.java
new file mode 100644
index 0000000..4335c03
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/ClassUnloadRequest.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+/**
+ * Request for notification when a class is unloaded in the target VM.
+ * When an enabled ClassUnloadRequest is satisfied, a
+ * {@link com.sun.jdi.event.EventSet event set} containing an
+ * {@link com.sun.jdi.event.ClassUnloadEvent ClassUnloadEvent} will
+ * be placed on the {@link com.sun.jdi.event.EventQueue EventQueue}.
+ * The collection of existing ClassUnloadRequests is
+ * managed by the {@link EventRequestManager}
+ * <p>
+ * Refer to the Java Virtual Machine Specification for more information
+ * on class unloading.
+ *
+ * @see com.sun.jdi.event.ClassUnloadEvent
+ * @see com.sun.jdi.event.EventQueue
+ * @see EventRequestManager
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ClassUnloadRequest extends EventRequest {
+
+ /**
+ * Restricts the events generated by this request to the
+ * unloading of reference types whose name matches a restricted
+ * regular expression. Regular expressions are limited to exact
+ * matches and patterns that begin with '*' or end with '*'; for
+ * example, "*.Foo" or "java.*".
+ * @param classPattern the pattern String to filter for.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to the
+ * unloading of reference types whose name does <b>not</b> match
+ * a restricted regular expression. Regular expressions are limited
+ * to exact matches and patterns that begin with '*' or end with '*';
+ * for example, "*.Foo" or "java.*".
+ * @param classPattern the pattern String to filter against.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassExclusionFilter(String classPattern);
+}
diff --git a/src/share/classes/com/sun/jdi/request/DuplicateRequestException.java b/src/share/classes/com/sun/jdi/request/DuplicateRequestException.java
new file mode 100644
index 0000000..3412f23
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/DuplicateRequestException.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.request;
+
+/**
+ * Thrown to indicate a duplicate event request.
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public class DuplicateRequestException extends RuntimeException {
+ private static final long serialVersionUID = -3719784920313411060L;
+
+ public DuplicateRequestException() {
+ super();
+ }
+
+ public DuplicateRequestException(String s) {
+ super(s);
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/request/EventRequest.java b/src/share/classes/com/sun/jdi/request/EventRequest.java
new file mode 100644
index 0000000..b1e59e7
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/EventRequest.java
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+/**
+ * Represents a request for notification of an event. Examples include
+ * {@link BreakpointRequest} and {@link ExceptionRequest}.
+ * When an event occurs for which an enabled request is present,
+ * an {@link com.sun.jdi.event.EventSet EventSet} will
+ * be placed on the {@link com.sun.jdi.event.EventQueue EventQueue}.
+ * The collection of existing event requests is
+ * managed by the {@link EventRequestManager}.
+ * <p>
+ * The number of events generated for an event request can be controlled
+ * through filters. Filters provide additional constraints that an event
+ * must satisfy before it is placed on the event queue. Multiple filters can
+ * be used by making multiple calls to filter addition methods such as
+ * {@link ExceptionRequest#addClassFilter(java.lang.String classPattern)}.
+ * Filters are added to an event one at a time only while the event is
+ * disabled. Multiple filters are applied with CUT-OFF AND, in the order
+ * it was added to the request. Only events that satisfy all filters are
+ * placed in the event queue.
+ * <p>
+ * The set of available filters is dependent on the event request,
+ * some examples of filters are:
+ * <ul>
+ * <li>Thread filters allow control over the thread for which events are
+ * generated.
+ * <li>Class filters allow control over the class in which the event
+ * occurs.
+ * <li>Instance filters allow control over the instance in which
+ * the event occurs.
+ * <li>Count filters allow control over the number of times an event
+ * is reported.
+ * </ul>
+ * Filters can dramatically improve debugger performance by reducing the
+ * amount of event traffic sent from the target VM to the debugger VM.
+ * <p>
+ * Any method on <code>EventRequest</code> which
+ * takes <code>EventRequest</code> as an parameter may throw
+ * {@link com.sun.jdi.VMDisconnectedException} if the target VM is
+ * disconnected and the {@link com.sun.jdi.event.VMDisconnectEvent} has been or is
+ * available to be read from the {@link com.sun.jdi.event.EventQueue}.
+ * <p>
+ * Any method on <code>EventRequest</code> which
+ * takes <code>EventRequest</code> as an parameter may throw
+ * {@link com.sun.jdi.VMOutOfMemoryException} if the target VM has run out of memory.
+ *
+ * @see com.sun.jdi.event.BreakpointEvent
+ * @see com.sun.jdi.event.EventQueue
+ * @see EventRequestManager
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface EventRequest extends Mirror {
+
+ /**
+ * Determines if this event request is currently enabled.
+ *
+ * @return <code>true</code> if enabled;
+ * <code>false</code> otherwise.
+ */
+ boolean isEnabled();
+
+ /**
+ * Enables or disables this event request. While this event request is
+ * disabled, the event request will be ignored and the target VM
+ * will not be stopped if any of its threads reaches the
+ * event request. Disabled event requests still exist,
+ * and are included in event request lists such as
+ * {@link EventRequestManager#breakpointRequests()}.
+ *
+ * @param val <code>true</code> if the event request is to be enabled;
+ * <code>false</code> otherwise.
+ * @throws InvalidRequestStateException if this request
+ * has been deleted.
+ * @throws IllegalThreadStateException if this is a StepRequest,
+ * <code>val</code> is <code>true</code>, and the
+ * thread named in the request has died.
+ */
+ void setEnabled(boolean val);
+
+ /**
+ * Same as {@link #setEnabled <CODE>setEnabled(true)</CODE>}.
+ * @throws InvalidRequestStateException if this request
+ * has been deleted.
+ * @throws IllegalThreadStateException if this is a StepRequest
+ * and the thread named in the request has died.
+ */
+ void enable();
+
+ /**
+ * Same as {@link #setEnabled <CODE>setEnabled(false)</CODE>}.
+ * @throws InvalidRequestStateException if this request
+ * has been deleted.
+ */
+ void disable();
+
+ /**
+ * Limit the requested event to be reported at most once after a
+ * given number of occurrences. The event is not reported
+ * the first <code>count - 1</code> times this filter is reached.
+ * To request a one-off event, call this method with a count of 1.
+ * <p>
+ * Once the count reaches 0, any subsequent filters in this request
+ * are applied. If none of those filters cause the event to be
+ * suppressed, the event is reported. Otherwise, the event is not
+ * reported. In either case subsequent events are never reported for
+ * this request.
+ *
+ * @param count the number of ocurrences before generating an event.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ * @throws IllegalArgumentException if <CODE>count</CODE>
+ * is less than one.
+ */
+ void addCountFilter(int count);
+
+ /** Suspend no threads when the event occurs */
+ int SUSPEND_NONE = 0;
+ /** Suspend only the thread which generated the event when the event occurs */
+ int SUSPEND_EVENT_THREAD = 1;
+ /** Suspend all threads when the event occurs */
+ int SUSPEND_ALL = 2;
+
+ /**
+ * Determines the threads to suspend when the requested event occurs
+ * in the target VM. Use {@link #SUSPEND_ALL} to suspend all
+ * threads in the target VM (the default). Use {@link #SUSPEND_EVENT_THREAD}
+ * to suspend only the thread which generated the event. Use
+ * {@link #SUSPEND_NONE} to suspend no threads.
+ * <p>
+ * Thread suspensions through events have the same functionality
+ * as explicitly requested suspensions. See
+ * {@link com.sun.jdi.ThreadReference#suspend} and
+ * {@link com.sun.jdi.VirtualMachine#suspend} for details.
+ *
+ * @param policy the selected suspend policy.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Suspend policy may only be set in disabled requests.
+ * @throws IllegalArgumentException if the policy argument
+ * contains an illegal value.
+ */
+ void setSuspendPolicy(int policy);
+
+ /**
+ * Returns a value which describes the threads to suspend when the
+ * requested event occurs in the target VM.
+ * The returned value is {@link #SUSPEND_ALL},
+ * {@link #SUSPEND_EVENT_THREAD}, or {@link #SUSPEND_NONE}.
+ *
+ * @return the current suspend mode for this request
+ */
+ int suspendPolicy();
+
+ /**
+ * Add an arbitrary key/value "property" to this request.
+ * The property can be used by a client of the JDI to
+ * associate application information with the request;
+ * These client-set properties are not used internally
+ * by the JDI.
+ * <p>
+ * The <code>get/putProperty</code> methods provide access to
+ * a small per-instance map. This is <b>not</b> to be confused
+ * with {@link java.util.Properties}.
+ * <p>
+ * If value is null this method will remove the property.
+ *
+ * @see #getProperty
+ */
+ void putProperty(Object key, Object value);
+
+ /**
+ * Returns the value of the property with the specified key. Only
+ * properties added with {@link #putProperty} will return
+ * a non-null value.
+ *
+ * @return the value of this property or null
+ * @see #putProperty
+ */
+ Object getProperty(Object key);
+}
diff --git a/src/share/classes/com/sun/jdi/request/EventRequestManager.java b/src/share/classes/com/sun/jdi/request/EventRequestManager.java
new file mode 100644
index 0000000..3664c84
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/EventRequestManager.java
@@ -0,0 +1,545 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+import java.util.List;
+
+/**
+ * Manages the creation and deletion of {@link EventRequest}s. A single
+ * implementor of this interface exists in a particuar VM and
+ * is accessed through {@link VirtualMachine#eventRequestManager()}
+ *
+ * @see EventRequest
+ * @see com.sun.jdi.event.Event
+ * @see BreakpointRequest
+ * @see com.sun.jdi.event.BreakpointEvent
+ * @see VirtualMachine
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+
+@jdk.Exported
+public interface EventRequestManager extends Mirror {
+
+ /**
+ * Creates a new disabled {@link ClassPrepareRequest}.
+ * The new event request is added to the list managed by this
+ * EventRequestManager. Use {@link EventRequest#enable()} to
+ * activate this event request.
+ *
+ * @return the created {@link ClassPrepareRequest}
+ */
+ ClassPrepareRequest createClassPrepareRequest();
+
+ /**
+ * Creates a new disabled {@link ClassUnloadRequest}.
+ * The new event request is added to the list managed by this
+ * EventRequestManager. Use {@link EventRequest#enable()} to
+ * activate this event request.
+ *
+ * @return the created {@link ClassUnloadRequest}
+ */
+ ClassUnloadRequest createClassUnloadRequest();
+
+ /**
+ * Creates a new disabled {@link ThreadStartRequest}.
+ * The new event request is added to the list managed by this
+ * EventRequestManager. Use {@link EventRequest#enable()} to
+ * activate this event request.
+ *
+ * @return the created {@link ThreadStartRequest}
+ */
+ ThreadStartRequest createThreadStartRequest();
+
+ /**
+ * Creates a new disabled {@link ThreadDeathRequest}.
+ * The new event request is added to the list managed by this
+ * EventRequestManager. Use {@link EventRequest#enable()} to
+ * activate this event request.
+ *
+ * @return the created {@link ThreadDeathRequest}
+ */
+ ThreadDeathRequest createThreadDeathRequest();
+
+ /**
+ * Creates a new disabled {@link ExceptionRequest}.
+ * The new event request is added to the list managed by this
+ * EventRequestManager. Use {@link EventRequest#enable()} to
+ * activate this event request.
+ * <P>
+ * A specific exception type and its subclasses can be selected
+ * for exception events. Caught exceptions, uncaught exceptions,
+ * or both can be selected. Note, however, that
+ * at the time an exception is thrown, it is not always
+ * possible to determine whether it is truly caught. See
+ * {@link com.sun.jdi.event.ExceptionEvent#catchLocation} for
+ * details.
+ * @param refType If non-null, specifies that exceptions which are
+ * instances of refType will be reported. Note: this
+ * will include instances of sub-types. If null,
+ * all instances will be reported
+ * @param notifyCaught If true, caught exceptions will be reported.
+ * @param notifyUncaught If true, uncaught exceptions will be reported.
+ *
+ * @return the created {@link ExceptionRequest}
+ */
+ ExceptionRequest createExceptionRequest(ReferenceType refType,
+ boolean notifyCaught,
+ boolean notifyUncaught);
+
+ /**
+ * Creates a new disabled {@link MethodEntryRequest}.
+ * The new event request is added to the list managed by this
+ * EventRequestManager. Use {@link EventRequest#enable()} to
+ * activate this event request.
+ *
+ * @return the created {@link MethodEntryRequest}
+ */
+ MethodEntryRequest createMethodEntryRequest();
+
+ /**
+ * Creates a new disabled {@link MethodExitRequest}.
+ * The new event request is added to the list managed by this
+ * EventRequestManager. Use {@link EventRequest#enable()} to
+ * activate this event request.
+ *
+ * @return the created {@link MethodExitRequest}
+ */
+ MethodExitRequest createMethodExitRequest();
+
+ /**
+ * Creates a new disabled {@link MonitorContendedEnterRequest}.
+ * The new event request is added to the list managed by this
+ * EventRequestManager. Use {@link EventRequest#enable()} to
+ * activate this event request.
+ *
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canRequestMonitorEvents()}
+ * to determine if the operation is supported.
+ *
+ * @return the created {@link MonitorContendedEnterRequest}
+ * @throws java.lang.UnsupportedOperationException if
+ * the target VM does not support this
+ * operation.
+ *
+ * @since 1.6
+ */
+ MonitorContendedEnterRequest createMonitorContendedEnterRequest();
+
+ /**
+ * Creates a new disabled {@link MonitorContendedEnteredRequest}.
+ * The new event request is added to the list managed by this
+ * EventRequestManager. Use {@link EventRequest#enable()} to
+ * activate this event request.
+ *
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canRequestMonitorEvents()}
+ * to determine if the operation is supported.
+ *
+ * @return the created {@link MonitorContendedEnteredRequest}
+ * @throws java.lang.UnsupportedOperationException if
+ * the target VM does not support this
+ * operation.
+ *
+ * @since 1.6
+ */
+
+ MonitorContendedEnteredRequest createMonitorContendedEnteredRequest();
+
+ /**
+ * Creates a new disabled {@link MonitorWaitRequest}.
+ * The new event request is added to the list managed by this
+ * EventRequestManager. Use {@link EventRequest#enable()} to
+ * activate this event request.
+ *
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canRequestMonitorEvents()}
+ * to determine if the operation is supported.
+ *
+ * @return the created {@link MonitorWaitRequest}
+ * @throws java.lang.UnsupportedOperationException if
+ * the target VM does not support this
+ * operation.
+ *
+ * @since 1.6
+ */
+ MonitorWaitRequest createMonitorWaitRequest();
+
+ /**
+ * Creates a new disabled {@link MonitorWaitedRequest}.
+ * The new event request is added to the list managed by this
+ * EventRequestManager. Use {@link EventRequest#enable()} to
+ * activate this event request.
+ *
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canRequestMonitorEvents()}
+ * to determine if the operation is supported.
+ *
+ * @return the created {@link MonitorWaitedRequest}
+ * @throws java.lang.UnsupportedOperationException if
+ * the target VM does not support this
+ * operation.
+ *
+ * @since 1.6
+ */
+ MonitorWaitedRequest createMonitorWaitedRequest();
+
+ /**
+ * Creates a new disabled {@link StepRequest}.
+ * The new event request is added to the list managed by this
+ * EventRequestManager. Use {@link EventRequest#enable()} to
+ * activate this event request.
+ * <p>
+ * The returned request will control stepping only in the specified
+ * <code>thread</code>; all other threads will be unaffected.
+ * A <code>size</code>value of {@link com.sun.jdi.request.StepRequest#STEP_MIN} will generate a
+ * step event each time the code index changes. It represents the
+ * smallest step size available and often maps to the instruction
+ * level.
+ * A <code>size</code> value of {@link com.sun.jdi.request.StepRequest#STEP_LINE} will generate a
+ * step event each time the source line changes unless line number information is not available,
+ * in which case a STEP_MIN will be done instead. For example, no line number information is
+ * available during the execution of a method that has been rendered obsolete by
+ * by a {@link com.sun.jdi.VirtualMachine#redefineClasses} operation.
+ * A <code>depth</code> value of {@link com.sun.jdi.request.StepRequest#STEP_INTO} will generate
+ * step events in any called methods. A <code>depth</code> value
+ * of {@link com.sun.jdi.request.StepRequest#STEP_OVER} restricts step events to the current frame
+ * or caller frames. A <code>depth</code> value of {@link com.sun.jdi.request.StepRequest#STEP_OUT}
+ * restricts step events to caller frames only. All depth
+ * restrictions are relative to the call stack immediately before the
+ * step takes place.
+ * <p>
+ * Only one pending step request is allowed per thread.
+ * <p>
+ * Note that a typical debugger will want to cancel stepping
+ * after the first step is detected. Thus a next line method
+ * would do the following:
+ * <code>
+ * <pre>
+ * EventRequestManager mgr = myVM.{@link VirtualMachine#eventRequestManager eventRequestManager}();
+ * StepRequest request = mgr.createStepRequest(myThread,
+ * StepRequest.{@link StepRequest#STEP_LINE STEP_LINE},
+ * StepRequest.{@link StepRequest#STEP_OVER STEP_OVER});
+ * request.{@link EventRequest#addCountFilter addCountFilter}(1); // next step only
+ * request.enable();
+ * myVM.{@link VirtualMachine#resume resume}();
+ * </pre>
+ * </code>
+ *
+ * @param thread the thread in which to step
+ * @param depth the step depth
+ * @param size the step size
+ * @return the created {@link StepRequest}
+ * @throws DuplicateRequestException if there is already a pending
+ * step request for the specified thread.
+ * @throws IllegalArgumentException if the size or depth arguments
+ * contain illegal values.
+ */
+ StepRequest createStepRequest(ThreadReference thread,
+ int size,
+ int depth);
+
+ /**
+ * Creates a new disabled {@link BreakpointRequest}.
+ * The given {@link Location} must have a valid
+ * (that is, non-negative) code index. The new
+ * breakpoint is added to the list managed by this
+ * EventRequestManager. Multiple breakpoints at the
+ * same location are permitted. Use {@link EventRequest#enable()} to
+ * activate this event request.
+ *
+ * @param location the location of the new breakpoint.
+ * @return the created {@link BreakpointRequest}
+ * @throws NativeMethodException if location is within a native method.
+ */
+ BreakpointRequest createBreakpointRequest(Location location);
+
+ /**
+ * Creates a new disabled watchpoint which watches accesses to the
+ * specified field. The new
+ * watchpoint is added to the list managed by this
+ * EventRequestManager. Multiple watchpoints on the
+ * same field are permitted.
+ * Use {@link EventRequest#enable()} to
+ * activate this event request.
+ * <P>
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canWatchFieldAccess()}
+ * to determine if the operation is supported.
+ *
+ * @param field the field to watch
+ * @return the created watchpoint
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation.
+ */
+ AccessWatchpointRequest createAccessWatchpointRequest(Field field);
+
+ /**
+ * Creates a new disabled watchpoint which watches accesses to the
+ * specified field. The new
+ * watchpoint is added to the list managed by this
+ * EventRequestManager. Multiple watchpoints on the
+ * same field are permitted.
+ * Use {@link EventRequest#enable()} to
+ * activate this event request.
+ * <P>
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canWatchFieldModification()}
+ * to determine if the operation is supported.
+ *
+ * @param field the field to watch
+ * @return the created watchpoint
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation.
+ */
+ ModificationWatchpointRequest createModificationWatchpointRequest(Field field);
+
+ /**
+ * Creates a new disabled {@link VMDeathRequest}.
+ * The new request is added to the list managed by this
+ * EventRequestManager.
+ * Use {@link EventRequest#enable()} to
+ * activate this event request.
+ * <P>
+ * This request (if enabled) will cause a
+ * {@link com.sun.jdi.event.VMDeathEvent}
+ * to be sent on termination of the target VM.
+ * <P>
+ * A VMDeathRequest with a suspend policy of
+ * {@link EventRequest#SUSPEND_ALL SUSPEND_ALL}
+ * can be used to assure processing of incoming
+ * {@link EventRequest#SUSPEND_NONE SUSPEND_NONE} or
+ * {@link EventRequest#SUSPEND_EVENT_THREAD SUSPEND_EVENT_THREAD}
+ * events before VM death. If all event processing is being
+ * done in the same thread as event sets are being read,
+ * enabling the request is all that is needed since the VM
+ * will be suspended until the {@link com.sun.jdi.event.EventSet}
+ * containing the {@link com.sun.jdi.event.VMDeathEvent}
+ * is resumed.
+ * <P>
+ * Not all target virtual machines support this operation.
+ * Use {@link VirtualMachine#canRequestVMDeathEvent()}
+ * to determine if the operation is supported.
+ *
+ * @return the created request
+ * @throws java.lang.UnsupportedOperationException if
+ * the target VM does not support this
+ * operation.
+ *
+ * @since 1.4
+ */
+ VMDeathRequest createVMDeathRequest();
+
+ /**
+ * Removes an eventRequest. The eventRequest is disabled and
+ * the removed from the requests managed by this
+ * EventRequestManager. Once the eventRequest is deleted, no
+ * operations (for example, {@link EventRequest#setEnabled})
+ * are permitted - attempts to do so will generally cause an
+ * {@link InvalidRequestStateException}.
+ * No other eventRequests are effected.
+ * <P>
+ * Because this method changes the underlying lists of event
+ * requests, attempting to directly delete from a list returned
+ * by a request accessor (e.g. below):
+ * <PRE>
+ * Iterator iter = requestManager.stepRequests().iterator();
+ * while (iter.hasNext()) {
+ * requestManager.deleteEventRequest(iter.next());
+ * }
+ * </PRE>
+ * may cause a {@link java.util.ConcurrentModificationException}.
+ * Instead use
+ * {@link #deleteEventRequests(List) deleteEventRequests(List)}
+ * or copy the list before iterating.
+ *
+ * @param eventRequest the eventRequest to remove
+ */
+ void deleteEventRequest(EventRequest eventRequest);
+
+ /**
+ * Removes a list of {@link EventRequest}s.
+ *
+ * @see #deleteEventRequest(EventRequest)
+ *
+ * @param eventRequests the list of eventRequests to remove
+ */
+ void deleteEventRequests(List<? extends EventRequest> eventRequests);
+
+ /**
+ * Remove all breakpoints managed by this EventRequestManager.
+ *
+ * @see #deleteEventRequest(EventRequest)
+ */
+ void deleteAllBreakpoints();
+
+ /**
+ * Return an unmodifiable list of the enabled and disabled step requests.
+ * This list is a live view of these requests and thus changes as requests
+ * are added and deleted.
+ * @return the all {@link StepRequest} objects.
+ */
+ List<StepRequest> stepRequests();
+
+ /**
+ * Return an unmodifiable list of the enabled and disabled class prepare requests.
+ * This list is a live view of these requests and thus changes as requests
+ * are added and deleted.
+ * @return the all {@link ClassPrepareRequest} objects.
+ */
+ List<ClassPrepareRequest> classPrepareRequests();
+
+ /**
+ * Return an unmodifiable list of the enabled and disabled class unload requests.
+ * This list is a live view of these requests and thus changes as requests
+ * are added and deleted.
+ * @return the all {@link ClassUnloadRequest} objects.
+ */
+ List<ClassUnloadRequest> classUnloadRequests();
+
+ /**
+ * Return an unmodifiable list of the enabled and disabled thread start requests.
+ * This list is a live view of these requests and thus changes as requests
+ * are added and deleted.
+ * @return the all {@link ThreadStartRequest} objects.
+ */
+ List<ThreadStartRequest> threadStartRequests();
+
+ /**
+ * Return an unmodifiable list of the enabled and disabled thread death requests.
+ * This list is a live view of these requests and thus changes as requests
+ * are added and deleted.
+ * @return the all {@link ThreadDeathRequest} objects.
+ */
+ List<ThreadDeathRequest> threadDeathRequests();
+
+ /**
+ * Return an unmodifiable list of the enabled and disabled exception requests.
+ * This list is a live view of these requests and thus changes as requests
+ * are added and deleted.
+ * @return the all {@link ExceptionRequest} objects.
+ */
+ List<ExceptionRequest> exceptionRequests();
+
+ /**
+ * Return an unmodifiable list of the enabled and disabled breakpoint requests.
+ * This list is a live view of these requests and thus changes as requests
+ * are added and deleted.
+ * @return the list of all {@link BreakpointRequest} objects.
+ */
+ List<BreakpointRequest> breakpointRequests();
+
+ /**
+ * Return an unmodifiable list of the enabled and disabled access
+ * watchpoint requests.
+ * This list is a live view of these requests and thus changes as requests
+ * are added and deleted.
+ * @return the all {@link AccessWatchpointRequest} objects.
+ */
+ List<AccessWatchpointRequest> accessWatchpointRequests();
+
+ /**
+ * Return an unmodifiable list of the enabled and disabled modification
+ * watchpoint requests.
+ * This list is a live view of these requests and thus changes as requests
+ * are added and deleted.
+ * @return the all {@link ModificationWatchpointRequest} objects.
+ */
+ List<ModificationWatchpointRequest> modificationWatchpointRequests();
+
+ /**
+ * Return an unmodifiable list of the enabled and disabled method entry requests.
+ * This list is a live view of these requests and thus changes as requests
+ * are added and deleted.
+ * @return the list of all {@link MethodEntryRequest} objects.
+ */
+ List<MethodEntryRequest> methodEntryRequests();
+
+ /**
+ * Return an unmodifiable list of the enabled and disabled method exit requests.
+ * This list is a live view of these requests and thus changes as requests
+ * are added and deleted.
+ * @return the list of all {@link MethodExitRequest} objects.
+ */
+ List<MethodExitRequest> methodExitRequests();
+
+ /**
+ * Return an unmodifiable list of the enabled and disabled monitor contended enter requests.
+ * This list is a live view of these requests and thus changes as requests
+ * are added and deleted.
+ * @return the list of all {@link MonitorContendedEnterRequest} objects.
+ *
+ * @since 1.6
+ */
+ List<MonitorContendedEnterRequest> monitorContendedEnterRequests();
+
+ /**
+ * Return an unmodifiable list of the enabled and disabled monitor contended entered requests.
+ * This list is a live view of these requests and thus changes as requests
+ * are added and deleted.
+ * @return the list of all {@link MonitorContendedEnteredRequest} objects.
+ *
+ * @since 1.6
+ */
+ List<MonitorContendedEnteredRequest> monitorContendedEnteredRequests();
+
+ /**
+ * Return an unmodifiable list of the enabled and disabled monitor wait requests.
+ * This list is a live view of these requests and thus changes as requests
+ * are added and deleted.
+ * @return the list of all {@link MonitorWaitRequest} objects.
+ *
+ * @since 1.6
+ */
+ List<MonitorWaitRequest> monitorWaitRequests();
+
+ /**
+ * Return an unmodifiable list of the enabled and disabled monitor waited requests.
+ * This list is a live view of these requests and thus changes as requests
+ * are added and deleted.
+ * @return the list of all {@link MonitorWaitedRequest} objects.
+ *
+ * @since 1.6
+ */
+ List<MonitorWaitedRequest> monitorWaitedRequests();
+
+ /**
+ * Return an unmodifiable list of the enabled and disabled VM death requests.
+ * This list is a live view of these requests and thus changes as requests
+ * are added and deleted.
+ * Note: the unsolicited VMDeathEvent does not have a
+ * corresponding request.
+ * @return the list of all {@link VMDeathRequest} objects.
+ *
+ * @since 1.4
+ */
+ List<VMDeathRequest> vmDeathRequests();
+}
diff --git a/src/share/classes/com/sun/jdi/request/ExceptionRequest.java b/src/share/classes/com/sun/jdi/request/ExceptionRequest.java
new file mode 100644
index 0000000..8de652f
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/ExceptionRequest.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+/**
+ * Request for notification when an exception occurs in the target VM.
+ * When an enabled ExceptionRequest is satisfied, an
+ * {@link com.sun.jdi.event.EventSet event set} containing an
+ * {@link com.sun.jdi.event.ExceptionEvent ExceptionEvent} will be placed
+ * on the {@link com.sun.jdi.event.EventQueue EventQueue}.
+ * The collection of existing ExceptionRequests is
+ * managed by the {@link EventRequestManager}
+ *
+ * @see com.sun.jdi.event.ExceptionEvent
+ * @see com.sun.jdi.event.EventQueue
+ * @see EventRequestManager
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ExceptionRequest extends EventRequest {
+
+ /**
+ * Returns exception type for which exception events are requested.
+ * @return
+ * The exception (and its subclasses) requested
+ * with {@link EventRequestManager#createExceptionRequest}, or
+ * null if, as by default, all exceptions are requested.
+ */
+ ReferenceType exception();
+
+ /**
+ * Returns whether caught exceptions of the requested type
+ * will generate events when they are thrown.
+ * <p>
+ * Note that at the time an exception is thrown, it is not always
+ * possible to determine whether it is truly caught. See
+ * {@link com.sun.jdi.event.ExceptionEvent#catchLocation} for
+ * details.
+ * @return
+ * boolean true if caught exceptions will be reported, false
+ * otherwise.
+ */
+ boolean notifyCaught();
+
+ /**
+ * Returns whether uncaught exceptions of the requested type
+ * will generate events when they are thrown.
+ * <p>
+ * Note that at the time an exception is thrown, it is not always
+ * possible to determine whether it is truly uncaught. See
+ * {@link com.sun.jdi.event.ExceptionEvent#catchLocation} for
+ * details.
+ * @return
+ * boolean true if caught exceptions will be reported, false
+ * otherwise.
+ */
+ boolean notifyUncaught();
+
+ /**
+ * Restricts the events generated by this request to those in
+ * the given thread.
+ * @param thread the thread to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addThreadFilter(ThreadReference thread);
+
+ /**
+ * Restricts the events generated by this request to those whose
+ * location is in the given reference type or any of its subtypes.
+ * An event will be generated for any location in a reference type
+ * that can be safely cast to the given reference type.
+ *
+ * @param refType the reference type to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(ReferenceType refType);
+
+ /**
+ * Restricts the events generated by this request to those
+ * whose location is in a class whose name matches a restricted
+ * regular expression. Regular expressions are limited
+ * to exact matches and patterns that begin with '*' or end with '*';
+ * for example, "*.Foo" or "java.*".
+ *
+ * @param classPattern the pattern String to filter for.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to those
+ * whose location is in a class whose name does <b>not</b> match a
+ * restricted regular expression. Regular expressions are limited
+ * to exact matches and patterns that begin with '*' or end with '*';
+ * for example, "*.Foo" or "java.*".
+ *
+ * @param classPattern the pattern String to filter against.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassExclusionFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to those in
+ * which the currently executing instance ("this") is the object
+ * specified.
+ * <P>
+ * Not all targets support this operation.
+ * Use {@link VirtualMachine#canUseInstanceFilters()}
+ * to determine if the operation is supported.
+ * @since 1.4
+ * @param instance the object which must be the current instance
+ * in order to pass this filter.
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addInstanceFilter(ObjectReference instance);
+}
diff --git a/src/share/classes/com/sun/jdi/request/InvalidRequestStateException.java b/src/share/classes/com/sun/jdi/request/InvalidRequestStateException.java
new file mode 100644
index 0000000..6faab81
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/InvalidRequestStateException.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 1999, 2013, 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.jdi.request;
+
+/**
+ * Thrown to indicate that the requested event cannot be modified
+ * because it is enabled. Filters can be added only to disabled
+ * event requests.
+ * Also thrown if an operation is attempted on a deleted request.
+ * See {@link EventRequestManager#deleteEventRequest(EventRequest)}
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public class InvalidRequestStateException extends RuntimeException {
+ private static final long serialVersionUID = -3774632428543322148L;
+ public InvalidRequestStateException()
+ {
+ super();
+ }
+
+ public InvalidRequestStateException(String s)
+ {
+ super(s);
+ }
+}
diff --git a/src/share/classes/com/sun/jdi/request/MethodEntryRequest.java b/src/share/classes/com/sun/jdi/request/MethodEntryRequest.java
new file mode 100644
index 0000000..c31a1e7
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/MethodEntryRequest.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+/**
+ * Request for notification when a method is invoked in the target VM.
+ * When an enabled MethodEntryRequest is satisfied, an
+ * {@link com.sun.jdi.event.EventSet event set} containing a
+ * {@link com.sun.jdi.event.MethodEntryEvent MethodEntryEvent}
+ * will be placed on the
+ * {@link com.sun.jdi.event.EventQueue EventQueue}.
+ * The collection of existing MethodEntryRequests is
+ * managed by the {@link EventRequestManager}
+ *
+ * @see com.sun.jdi.event.MethodEntryEvent
+ * @see com.sun.jdi.event.EventQueue
+ * @see EventRequestManager
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface MethodEntryRequest extends EventRequest {
+
+ /**
+ * Restricts the events generated by this request to those in
+ * the given thread.
+ * @param thread the thread to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addThreadFilter(ThreadReference thread);
+
+ /**
+ * Restricts the events generated by this request to those whose
+ * method is in the given reference type or any of its subtypes.
+ * An event will be generated for any location in a reference type
+ * that can be safely cast to the given reference type.
+ *
+ * @param refType the reference type to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(ReferenceType refType);
+
+ /**
+ * Restricts the events generated by this request to those
+ * whose method is in a class whose name matches this restricted
+ * regular expression. Regular expressions are limited
+ * to exact matches and patterns that begin with '*' or end with '*';
+ * for example, "*.Foo" or "java.*".
+ *
+ * @param classPattern the pattern String to filter for.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to those
+ * whose method is in a class whose name does <b>not</b> match this restricted
+ * regular expression, e.g. "java.*" or "*.Foo".
+ * @param classPattern the pattern String to filter against.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassExclusionFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to those in
+ * which the currently executing instance ("this") is the object
+ * specified.
+ * <P>
+ * Not all targets support this operation.
+ * Use {@link VirtualMachine#canUseInstanceFilters()}
+ * to determine if the operation is supported.
+ * @since 1.4
+ * @param instance the object which must be the current instance
+ * in order to pass this filter.
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addInstanceFilter(ObjectReference instance);
+}
diff --git a/src/share/classes/com/sun/jdi/request/MethodExitRequest.java b/src/share/classes/com/sun/jdi/request/MethodExitRequest.java
new file mode 100644
index 0000000..8c64b9f
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/MethodExitRequest.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+/**
+ * Request for notification when a method returns in the target VM.
+ * When an enabled MethodExitRequest is hit, an
+ * {@link com.sun.jdi.event.EventSet event set} containing a
+ * {@link com.sun.jdi.event.MethodExitEvent MethodExitEvent}
+ * will be placed on the
+ * {@link com.sun.jdi.event.EventQueue EventQueue}.
+ * The collection of existing MethodExitRequests is
+ * managed by the {@link EventRequestManager}
+ *
+ * @see com.sun.jdi.event.MethodExitEvent
+ * @see com.sun.jdi.event.EventQueue
+ * @see EventRequestManager
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface MethodExitRequest extends EventRequest {
+
+ /**
+ * Restricts the events generated by this request to those in
+ * the given thread.
+ * @param thread the thread to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addThreadFilter(ThreadReference thread);
+
+ /**
+ * Restricts the events generated by this request to those whose
+ * method is in the given reference type or any of its subtypes.
+ * An event will be generated for any location in a reference type
+ * that can be safely cast to the given reference type.
+ *
+ * @param refType the reference type to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(ReferenceType refType);
+
+ /**
+ * Restricts the events generated by this request to those
+ * whose method is in a class whose name matches a restricted
+ * regular expression. Regular expressions are limited
+ * to exact matches and patterns that begin with '*' or end with '*';
+ * for example, "*.Foo" or "java.*".
+ *
+ * @param classPattern the pattern String to filter for.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to those
+ * whose method is in a class whose name does <b>not</b> match this
+ * restricted regular expression. Regular expressions are limited
+ * to exact matches and patterns that begin with '*' or end with '*';
+ * for example, "*.Foo" or "java.*".
+ *
+ * @param classPattern the pattern String to filter against.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassExclusionFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to those in
+ * which the currently executing instance ("this") is the object
+ * specified.
+ * <P>
+ * Not all targets support this operation.
+ * Use {@link VirtualMachine#canUseInstanceFilters()}
+ * to determine if the operation is supported.
+ * @since 1.4
+ * @param instance the object which must be the current instance
+ * in order to pass this filter.
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addInstanceFilter(ObjectReference instance);
+}
diff --git a/src/share/classes/com/sun/jdi/request/ModificationWatchpointRequest.java b/src/share/classes/com/sun/jdi/request/ModificationWatchpointRequest.java
new file mode 100644
index 0000000..d28ae73
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/ModificationWatchpointRequest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+/**
+ * Request for notification when a field is set.
+ * This event will be triggered when a value is assigned to the specified
+ * field with a Java<SUP><FONT SIZE="-2">TM</FONT></SUP> programming
+ * language statement (assignment, increment, etc) or by a
+ * Java Native Interface (JNI) set function (<code>Set<Type>Field,
+ * SetStatic<Type>Field</code>).
+ * Setting a field to a value which is the same as the previous value
+ * still triggers this event.
+ * Modification by JDI does not trigger this event.
+ * When an enabled
+ * ModificationWatchpointRequest is satisfied, an
+ * {@link com.sun.jdi.event.EventSet event set} containing a
+ * {@link com.sun.jdi.event.ModificationWatchpointEvent ModificationWatchpointEvent}
+ * will be placed on
+ * the {@link com.sun.jdi.event.EventQueue EventQueue}.
+ * The collection of existing
+ * watchpoints is
+ * managed by the {@link EventRequestManager}.
+ *
+ * @see com.sun.jdi.event.ModificationWatchpointEvent
+ * @see AccessWatchpointRequest
+ * @see com.sun.jdi.event.EventQueue
+ * @see EventRequestManager
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ModificationWatchpointRequest extends WatchpointRequest {
+}
diff --git a/src/share/classes/com/sun/jdi/request/MonitorContendedEnterRequest.java b/src/share/classes/com/sun/jdi/request/MonitorContendedEnterRequest.java
new file mode 100644
index 0000000..56c4625
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/MonitorContendedEnterRequest.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2005, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+/**
+ * Request for notification of a thread in the target VM
+ * attempting to enter a monitor already acquired by another thread.
+ * When an enabled MonitorContededEnterRequest is satisfied, an
+ * {@link com.sun.jdi.event.EventSet event set} containing a
+ * {@link com.sun.jdi.event.MonitorContendedEnterEvent MonitorContendedEnterEvent}
+ * will be placed on the
+ * {@link com.sun.jdi.event.EventQueue EventQueue}.
+ * The collection of existing MonitorContendedEnterEvents is
+ * managed by the {@link EventRequestManager}
+ *
+ * @see com.sun.jdi.event.MonitorContendedEnterEvent
+ * @see com.sun.jdi.event.EventQueue
+ * @see EventRequestManager
+ *
+ * @author Swamy Venkataramanappa
+ * @since 1.6
+ */
+@jdk.Exported
+public interface MonitorContendedEnterRequest extends EventRequest {
+
+ /**
+ * Restricts the events generated by this request to those in
+ * the given thread.
+ * @param thread the thread to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addThreadFilter(ThreadReference thread);
+
+ /**
+ * Restricts the events generated by this request to those whose
+ * method is in the given reference type or any of its subtypes.
+ * An event will be generated for any location in a reference type
+ * that can be safely cast to the given reference type.
+ *
+ * @param refType the reference type to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(ReferenceType refType);
+
+ /**
+ * Restricts the events generated by this request to those
+ * whose method is in a class whose name matches this restricted
+ * regular expression. Regular expressions are limited
+ * to exact matches and patterns that begin with '*' or end with '*';
+ * for example, "*.Foo" or "java.*".
+ *
+ * @param classPattern the pattern String to filter for.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to those
+ * whose method is in a class whose name does <b>not</b> match this restricted
+ * regular expression, e.g. "java.*" or "*.Foo".
+ * @param classPattern the pattern String to filter against.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassExclusionFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to those in
+ * which the currently executing instance ("this") is the object
+ * specified.
+ * <P>
+ * Not all targets support this operation.
+ * Use {@link VirtualMachine#canUseInstanceFilters()}
+ * to determine if the operation is supported.
+ * @param instance the object which must be the current instance
+ * in order to pass this filter.
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addInstanceFilter(ObjectReference instance);
+}
diff --git a/src/share/classes/com/sun/jdi/request/MonitorContendedEnteredRequest.java b/src/share/classes/com/sun/jdi/request/MonitorContendedEnteredRequest.java
new file mode 100644
index 0000000..cc36ea2
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/MonitorContendedEnteredRequest.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2005, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+/**
+ * Request for notification of a thread in the target VM entering a monitor
+ * after waiting for it to be released by another thread.
+ * When an enabled MonitorContededEnteredRequest is satisfied, an
+ * {@link com.sun.jdi.event.EventSet event set} containing a
+ * {@link com.sun.jdi.event.MonitorContendedEnteredEvent MonitorContendedEnteredEvent}
+ * will be placed on the
+ * {@link com.sun.jdi.event.EventQueue EventQueue}.
+ * The collection of existing MonitorContendedEnteredEvents is
+ * managed by the {@link EventRequestManager}
+ *
+ * @see com.sun.jdi.event.MonitorContendedEnteredEvent
+ * @see com.sun.jdi.event.EventQueue
+ * @see EventRequestManager
+ *
+ * @author Swamy Venkataramanappa
+ * @since 1.6
+ */
+@jdk.Exported
+public interface MonitorContendedEnteredRequest extends EventRequest {
+
+ /**
+ * Restricts the events generated by this request to those in
+ * the given thread.
+ * @param thread the thread to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addThreadFilter(ThreadReference thread);
+
+ /**
+ * Restricts the events generated by this request to those whose
+ * method is in the given reference type or any of its subtypes.
+ * An event will be generated for any location in a reference type
+ * that can be safely cast to the given reference type.
+ *
+ * @param refType the reference type to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(ReferenceType refType);
+
+ /**
+ * Restricts the events generated by this request to those
+ * whose method is in a class whose name matches this restricted
+ * regular expression. Regular expressions are limited
+ * to exact matches and patterns that begin with '*' or end with '*';
+ * for example, "*.Foo" or "java.*".
+ *
+ * @param classPattern the pattern String to filter for.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to those
+ * whose method is in a class whose name does <b>not</b> match this restricted
+ * regular expression, e.g. "java.*" or "*.Foo".
+ * @param classPattern the pattern String to filter against.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassExclusionFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to those in
+ * which the currently executing instance ("this") is the object
+ * specified.
+ * <P>
+ * Not all targets support this operation.
+ * Use {@link VirtualMachine#canUseInstanceFilters()}
+ * to determine if the operation is supported.
+ * @param instance the object which must be the current instance
+ * in order to pass this filter.
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addInstanceFilter(ObjectReference instance);
+}
diff --git a/src/share/classes/com/sun/jdi/request/MonitorWaitRequest.java b/src/share/classes/com/sun/jdi/request/MonitorWaitRequest.java
new file mode 100644
index 0000000..9cb162b
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/MonitorWaitRequest.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2005, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+/**
+ * Request for notification when a thread in the target VM is about to
+ * wait on a monitor object. That is, a thread is entering Object.wait().
+ * When an enabled MonitorWaitRequest is satisfied, an
+ * {@link com.sun.jdi.event.EventSet event set} containing a
+ * {@link com.sun.jdi.event.MonitorWaitEvent MonitorWaitEvent}
+ * will be placed on the
+ * {@link com.sun.jdi.event.EventQueue EventQueue}.
+ * The collection of existing MonitorWaitEvents is
+ * managed by the {@link EventRequestManager}
+ *
+ * @see com.sun.jdi.event.MonitorWaitEvent
+ * @see com.sun.jdi.event.EventQueue
+ * @see EventRequestManager
+ *
+ * @author Swamy Venkataramanappa
+ * @since 1.6
+ */
+@jdk.Exported
+public interface MonitorWaitRequest extends EventRequest {
+
+ /**
+ * Restricts the events generated by this request to those in
+ * the given thread.
+ * @param thread the thread to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addThreadFilter(ThreadReference thread);
+
+ /**
+ * Restricts the events generated by this request to those whose
+ * monitor object is of the given reference type or any of
+ * its subtypes.
+ *
+ * @param refType the reference type to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(ReferenceType refType);
+
+ /**
+ * Restricts the events generated by this request to those
+ * in which the name of the class of the monitor object matches this restricted
+ * regular expression. Regular expressions are limited
+ * to exact matches and patterns that begin with '*' or end with '*';
+ * for example, "*.Foo" or "java.*".
+ *
+ * @param classPattern the pattern String to filter for.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to those
+ * in which the name of the class of the monitor object does <b>not</b>match this restricted
+ * regular expression, e.g. "java.*" or "*.Foo".
+ * @param classPattern the pattern String to filter against.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassExclusionFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to those in
+ * which the currently executing instance ("this") is the object
+ * specified.
+ * <P>
+ * Not all targets support this operation.
+ * Use {@link VirtualMachine#canUseInstanceFilters()}
+ * to determine if the operation is supported.
+ * @param instance the object which must be the current instance
+ * in order to pass this filter.
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addInstanceFilter(ObjectReference instance);
+}
diff --git a/src/share/classes/com/sun/jdi/request/MonitorWaitedRequest.java b/src/share/classes/com/sun/jdi/request/MonitorWaitedRequest.java
new file mode 100644
index 0000000..6cc41fb
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/MonitorWaitedRequest.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2005, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+/**
+ * Request for notification when a thread in the target VM has finished waiting on
+ * a monitor object. That is, a thread is leaving Object.wait(). "
+ * When an enabled MonitorWaitedRequest is satisfied, an
+ * {@link com.sun.jdi.event.EventSet event set} containing a
+ * {@link com.sun.jdi.event.MonitorWaitedEvent MonitorWaitedEvent}
+ * will be placed on the
+ * {@link com.sun.jdi.event.EventQueue EventQueue}.
+ * The collection of existing MonitorWaitedEvents is
+ * managed by the {@link EventRequestManager}
+ *
+ * @see com.sun.jdi.event.MonitorWaitedEvent
+ * @see com.sun.jdi.event.EventQueue
+ * @see EventRequestManager
+ *
+ * @author Swamy Venkataramanappa
+ * @since 1.6
+ */
+@jdk.Exported
+public interface MonitorWaitedRequest extends EventRequest {
+
+ /**
+ * Restricts the events generated by this request to those in
+ * the given thread.
+ * @param thread the thread to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addThreadFilter(ThreadReference thread);
+
+ /**
+ * Restricts the events generated by this request to those whose
+ * monitor object is of the given reference type or any of
+ * its subtypes.
+ *
+ * @param refType the reference type to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(ReferenceType refType);
+
+ /**
+ * Restricts the events generated by this request to those
+ * in which the name of the class of the monitor object matches this restricted
+ * regular expression. Regular expressions are limited
+ * to exact matches and patterns that begin with '*' or end with '*';
+ * for example, "*.Foo" or "java.*".
+ *
+ * @param classPattern the pattern String to filter for.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to those
+ * in which the name of the class of the monitor object does <b>not</b>match this restricted
+ * regular expression, e.g. "java.*" or "*.Foo".
+ * @param classPattern the pattern String to filter against.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassExclusionFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to those in
+ * which the currently executing instance ("this") is the object
+ * specified.
+ * <P>
+ * Not all targets support this operation.
+ * Use {@link VirtualMachine#canUseInstanceFilters()}
+ * to determine if the operation is supported.
+ * @param instance the object which must be the current instance
+ * in order to pass this filter.
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addInstanceFilter(ObjectReference instance);
+}
diff --git a/src/share/classes/com/sun/jdi/request/StepRequest.java b/src/share/classes/com/sun/jdi/request/StepRequest.java
new file mode 100644
index 0000000..abcb249
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/StepRequest.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+/**
+ * Request for notification when a step occurs in the target VM.
+ * When an enabled StepRequest is satisfied, an
+ * {@link com.sun.jdi.event.EventSet event set} containing a
+ * {@link com.sun.jdi.event.StepEvent StepEvent} will be placed on the
+ * {@link com.sun.jdi.event.EventQueue EventQueue}.
+ * The collection of existing StepRequests is
+ * managed by the {@link EventRequestManager}
+ *
+ * @see com.sun.jdi.event.StepEvent
+ * @see com.sun.jdi.event.EventQueue
+ * @see EventRequestManager
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface StepRequest extends EventRequest {
+
+ /** Step into any newly pushed frames */
+ int STEP_INTO = 1;
+ /** Step over any newly pushed frames */
+ int STEP_OVER = 2;
+ /** Step out of the current frame */
+ int STEP_OUT = 3;
+
+ /** Step to the next available location */
+ int STEP_MIN = -1;
+ /** Step to the next location on a different line */
+ int STEP_LINE = -2;
+
+ /**
+ * @return the thread on which the step event is being requested.
+ */
+ ThreadReference thread();
+
+ /**
+ * @return the step size
+ */
+ int size();
+
+ /**
+ * @return the step depth
+ */
+ int depth();
+
+ /**
+ * Restricts the events generated by this request to those whose
+ * location is in the given reference type or any of its subtypes.
+ * An event will be generated for any location in a reference type
+ * that can be safely cast to the given reference type.
+ *
+ * @param refType the reference type to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(ReferenceType refType);
+
+ /**
+ * Restricts the events generated by this request to those
+ * whose location is in a class whose name matches a restricted
+ * regular expression. Regular expressions are limited
+ * to exact matches and patterns that begin with '*' or end with '*';
+ * for example, "*.Foo" or "java.*".
+ *
+ * @param classPattern the pattern String to filter for.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to those
+ * whose location is in a class whose name does <b>not</b> match a
+ * restricted regular expression. Regular expressions are limited
+ * to exact matches and patterns that begin with '*' or end with '*';
+ * for example, "*.Foo" or "java.*".
+ *
+ * @param classPattern the pattern String to filter against.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassExclusionFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to those in
+ * which the currently executing instance ("this") is the object
+ * specified.
+ * <P>
+ * Not all targets support this operation.
+ * Use {@link VirtualMachine#canUseInstanceFilters()}
+ * to determine if the operation is supported.
+ * @since 1.4
+ * @param instance the object which must be the current instance
+ * in order to pass this filter.
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addInstanceFilter(ObjectReference instance);
+}
diff --git a/src/share/classes/com/sun/jdi/request/ThreadDeathRequest.java b/src/share/classes/com/sun/jdi/request/ThreadDeathRequest.java
new file mode 100644
index 0000000..916fff4
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/ThreadDeathRequest.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+/**
+ * Request for notification when a thread terminates in the target VM.
+ * When an enabled ThreadDeathRequest is satisfied, an
+ * {@link com.sun.jdi.event.EventSet event set} containing a
+ * {@link com.sun.jdi.event.ThreadDeathEvent ThreadDeathEvent}
+ * will be placed on the
+ * {@link com.sun.jdi.event.EventQueue EventQueue}.
+ * The collection of existing ThreadDeathRequests is
+ * managed by the {@link EventRequestManager}
+ *
+ * @see com.sun.jdi.event.ThreadDeathEvent
+ * @see com.sun.jdi.event.EventQueue
+ * @see EventRequestManager
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ThreadDeathRequest extends EventRequest {
+
+ /**
+ * Restricts the events generated by this request to those in
+ * the given thread.
+ * @param thread the thread to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addThreadFilter(ThreadReference thread);
+}
diff --git a/src/share/classes/com/sun/jdi/request/ThreadStartRequest.java b/src/share/classes/com/sun/jdi/request/ThreadStartRequest.java
new file mode 100644
index 0000000..c34d171
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/ThreadStartRequest.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+/**
+ * Request for notification when a thread starts execution in the target VM.
+ * When an enabled ThreadStartRequest is hit, an
+ * {@link com.sun.jdi.event.EventSet event set} containing a
+ * {@link com.sun.jdi.event.ThreadStartEvent ThreadStartEvent}
+ * will be placed on the
+ * {@link com.sun.jdi.event.EventQueue EventQueue}.
+ * The collection of existing ThreadStartRequests is
+ * managed by the {@link EventRequestManager}
+ *
+ * @see com.sun.jdi.event.ThreadStartEvent
+ * @see com.sun.jdi.event.EventQueue
+ * @see EventRequestManager
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface ThreadStartRequest extends EventRequest {
+
+ /**
+ * Restricts the events generated by this request to those in
+ * the given thread.
+ * @param thread the thread to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addThreadFilter(ThreadReference thread);
+}
diff --git a/src/share/classes/com/sun/jdi/request/VMDeathRequest.java b/src/share/classes/com/sun/jdi/request/VMDeathRequest.java
new file mode 100644
index 0000000..69a767f
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/VMDeathRequest.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2001, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+/**
+ * Request for notification when the target VM terminates.
+ * When an enabled VMDeathRequest is satisfied, an
+ * {@link com.sun.jdi.event.EventSet event set} containing a
+ * {@link com.sun.jdi.event.VMDeathEvent VMDeathEvent}
+ * will be placed on the
+ * {@link com.sun.jdi.event.EventQueue EventQueue}.
+ * The collection of existing VMDeathRequests is
+ * managed by the {@link EventRequestManager}
+ * <P>
+ * Even without creating a VMDeathRequest, a single
+ * unsolicited VMDeathEvent will be sent with a
+ * {@link EventRequest#suspendPolicy() suspend policy}
+ * of {@link EventRequest#SUSPEND_NONE SUSPEND_NONE}.
+ * This request would typically be created so that a
+ * VMDeathEvent with a suspend policy of
+ * {@link EventRequest#SUSPEND_ALL SUSPEND_ALL}
+ * will be sent. This event can be used to assure
+ * completion of any processing which requires the VM
+ * to be alive (e.g. event processing). Note: the
+ * unsolicited VMDeathEvent will still be sent.
+ *
+ * @see com.sun.jdi.event.VMDeathEvent
+ * @see com.sun.jdi.event.EventQueue
+ * @see EventRequestManager
+ *
+ * @author Robert Field
+ * @since 1.4
+ */
+@jdk.Exported
+public interface VMDeathRequest extends EventRequest {
+
+}
diff --git a/src/share/classes/com/sun/jdi/request/WatchpointRequest.java b/src/share/classes/com/sun/jdi/request/WatchpointRequest.java
new file mode 100644
index 0000000..0b0de7e
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/WatchpointRequest.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 1998, 2013, 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.jdi.request;
+
+import com.sun.jdi.*;
+
+/**
+ * Identifies a {@link Field} in the target VM being watched.
+ *
+ * @see AccessWatchpointRequest
+ * @see ModificationWatchpointRequest
+ * @see com.sun.jdi.event.EventQueue
+ * @see EventRequestManager
+ *
+ * @author Robert Field
+ * @since 1.3
+ */
+@jdk.Exported
+public interface WatchpointRequest extends EventRequest {
+
+ /**
+ * Gets the Field being watched by this WatchpointRequest.
+ *
+ * @return the {@link Field} this Watchpoint is monitoring.
+ */
+ Field field();
+
+ /**
+ * Restricts the events generated by this request to those in
+ * the given thread.
+ * @param thread the thread to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addThreadFilter(ThreadReference thread);
+
+ /**
+ * Restricts the events generated by this request to those whose
+ * location is in the given reference type or any of its subtypes.
+ * An event will be generated for any location in a reference type
+ * that can be safely cast to the given reference type.
+ *
+ * @param refType the reference type to filter on.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(ReferenceType refType);
+
+ /**
+ * Restricts the events generated by this request to those
+ * whose location is in a class whose name matches a restricted
+ * regular expression. Regular expressions are limited
+ * to exact matches and patterns that begin with '*' or end with '*';
+ * for example, "*.Foo" or "java.*".
+ *
+ * @param classPattern the pattern String to filter for.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to those
+ * whose location is in a class whose name does <b>not</b> match this
+ * restricted regular expression. Regular expressions are limited
+ * to exact matches and patterns that begin with '*' or end with '*';
+ * for example, "*.Foo" or "java.*".
+ *
+ * @param classPattern the pattern String to filter against.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addClassExclusionFilter(String classPattern);
+
+ /**
+ * Restricts the events generated by this request to those in
+ * which the currently executing instance ("this") is the object
+ * specified.
+ * <P>
+ * Not all targets support this operation.
+ * Use {@link VirtualMachine#canUseInstanceFilters()}
+ * to determine if the operation is supported.
+ * @since 1.4
+ * @param instance the object which must be the current instance
+ * in order to pass this filter.
+ * @throws java.lang.UnsupportedOperationException if
+ * the target virtual machine does not support this
+ * operation.
+ * @throws InvalidRequestStateException if this request is currently
+ * enabled or has been deleted.
+ * Filters may be added only to disabled requests.
+ */
+ void addInstanceFilter(ObjectReference instance);
+}
diff --git a/src/share/classes/com/sun/jdi/request/package-info.java b/src/share/classes/com/sun/jdi/request/package-info.java
new file mode 100644
index 0000000..add151d
--- /dev/null
+++ b/src/share/classes/com/sun/jdi/request/package-info.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 1998, 2013, 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.
+ */
+
+/**
+ * This package is used to request that a JDI
+ * event be sent under specified conditions.
+ * With the exception of termination events, which are
+ * always sent, there is one kind of
+ * {@link com.sun.jdi.request.EventRequest} for each kind of
+ * {@link com.sun.jdi.event.Event Event} - for example,
+ * {@link com.sun.jdi.request.BreakpointRequest} is used to request a
+ * {@link com.sun.jdi.event.BreakpointEvent BreakpointEvent}.
+ * Event requests are created by the
+ * {@link com.sun.jdi.request.EventRequestManager}.
+ * Events and event processing are defined in the
+ * {@link com.sun.jdi.event} package.
+ * <p>
+ * Methods may be added to the interfaces in the JDI packages in future
+ * releases. Existing packages may be renamed if the JDI becomes a standard
+ * extension.
+ */
+
+@jdk.Exported
+package com.sun.jdi.request;
diff --git a/src/share/classes/com/sun/tools/jdi/AbstractLauncher.java b/src/share/classes/com/sun/tools/jdi/AbstractLauncher.java
new file mode 100644
index 0000000..75d5d0a
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/AbstractLauncher.java
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 1999, 2013, 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.tools.jdi;
+
+import com.sun.tools.jdi.*;
+import com.sun.jdi.connect.*;
+import com.sun.jdi.connect.spi.*;
+import com.sun.jdi.*;
+
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.List;
+import java.util.ArrayList;
+import java.io.IOException;
+import java.io.InterruptedIOException;
+
+abstract class AbstractLauncher extends ConnectorImpl implements LaunchingConnector {
+
+ abstract public VirtualMachine
+ launch(Map<String,? extends Connector.Argument> arguments)
+ throws IOException,
+ IllegalConnectorArgumentsException,
+ VMStartException;
+ abstract public String name();
+ abstract public String description();
+
+ ThreadGroup grp;
+
+ AbstractLauncher() {
+ super();
+
+ grp = Thread.currentThread().getThreadGroup();
+ ThreadGroup parent = null;
+ while ((parent = grp.getParent()) != null) {
+ grp = parent;
+ }
+ }
+
+ String[] tokenizeCommand(String command, char quote) {
+ String quoteStr = String.valueOf(quote); // easier to deal with
+
+ /*
+ * Tokenize the command, respecting the given quote character.
+ */
+ StringTokenizer tokenizer = new StringTokenizer(command,
+ quote + " \t\r\n\f",
+ true);
+ String quoted = null;
+ String pending = null;
+ List<String> tokenList = new ArrayList<String>();
+ while (tokenizer.hasMoreTokens()) {
+ String token = tokenizer.nextToken();
+ if (quoted != null) {
+ if (token.equals(quoteStr)) {
+ tokenList.add(quoted);
+ quoted = null;
+ } else {
+ quoted += token;
+ }
+ } else if (pending != null) {
+ if (token.equals(quoteStr)) {
+ quoted = pending;
+ } else if ((token.length() == 1) &&
+ Character.isWhitespace(token.charAt(0))) {
+ tokenList.add(pending);
+ } else {
+ throw new InternalException("Unexpected token: " + token);
+ }
+ pending = null;
+ } else {
+ if (token.equals(quoteStr)) {
+ quoted = "";
+ } else if ((token.length() == 1) &&
+ Character.isWhitespace(token.charAt(0))) {
+ // continue
+ } else {
+ pending = token;
+ }
+ }
+ }
+
+ /*
+ * Add final token.
+ */
+ if (pending != null) {
+ tokenList.add(pending);
+ }
+
+ /*
+ * An unclosed quote at the end of the command. Do an
+ * implicit end quote.
+ */
+ if (quoted != null) {
+ tokenList.add(quoted);
+ }
+
+ String[] tokenArray = new String[tokenList.size()];
+ for (int i = 0; i < tokenList.size(); i++) {
+ tokenArray[i] = tokenList.get(i);
+ }
+ return tokenArray;
+ }
+
+ protected VirtualMachine launch(String[] commandArray, String address,
+ TransportService.ListenKey listenKey,
+ TransportService ts)
+ throws IOException, VMStartException {
+ Helper helper = new Helper(commandArray, address, listenKey, ts);
+ helper.launchAndAccept();
+
+ VirtualMachineManager manager =
+ Bootstrap.virtualMachineManager();
+
+ return manager.createVirtualMachine(helper.connection(),
+ helper.process());
+ }
+
+ /**
+ * This class simply provides a context for a single launch and
+ * accept. It provides instance fields that can be used by
+ * all threads involved. This stuff can't be in the Connector proper
+ * because the connector is a singleton and is not specific to any
+ * one launch.
+ */
+ private class Helper {
+ private final String address;
+ private TransportService.ListenKey listenKey;
+ private TransportService ts;
+ private final String[] commandArray;
+ private Process process = null;
+ private Connection connection = null;
+ private IOException acceptException = null;
+ private boolean exited = false;
+
+ Helper(String[] commandArray, String address, TransportService.ListenKey listenKey,
+ TransportService ts) {
+ this.commandArray = commandArray;
+ this.address = address;
+ this.listenKey = listenKey;
+ this.ts = ts;
+ }
+
+ String commandString() {
+ String str = "";
+ for (int i = 0; i < commandArray.length; i++) {
+ if (i > 0) {
+ str += " ";
+ }
+ str += commandArray[i];
+ }
+ return str;
+ }
+
+ synchronized void launchAndAccept() throws
+ IOException, VMStartException {
+
+ process = Runtime.getRuntime().exec(commandArray);
+
+ Thread acceptingThread = acceptConnection();
+ Thread monitoringThread = monitorTarget();
+ try {
+ while ((connection == null) &&
+ (acceptException == null) &&
+ !exited) {
+ wait();
+ }
+
+ if (exited) {
+ throw new VMStartException(
+ "VM initialization failed for: " + commandString(), process);
+ }
+ if (acceptException != null) {
+ // Rethrow the exception in this thread
+ throw acceptException;
+ }
+ } catch (InterruptedException e) {
+ throw new InterruptedIOException("Interrupted during accept");
+ } finally {
+ acceptingThread.interrupt();
+ monitoringThread.interrupt();
+ }
+ }
+
+ Process process() {
+ return process;
+ }
+
+ Connection connection() {
+ return connection;
+ }
+
+ synchronized void notifyOfExit() {
+ exited = true;
+ notify();
+ }
+
+ synchronized void notifyOfConnection(Connection connection) {
+ this.connection = connection;
+ notify();
+ }
+
+ synchronized void notifyOfAcceptException(IOException acceptException) {
+ this.acceptException = acceptException;
+ notify();
+ }
+
+ Thread monitorTarget() {
+ Thread thread = new Thread(grp,
+ "launched target monitor") {
+ public void run() {
+ try {
+ process.waitFor();
+ /*
+ * Notify waiting thread of VM error termination
+ */
+ notifyOfExit();
+ } catch (InterruptedException e) {
+ // Connection has been established, stop monitoring
+ }
+ }
+ };
+ thread.setDaemon(true);
+ thread.start();
+ return thread;
+ }
+
+ Thread acceptConnection() {
+ Thread thread = new Thread(grp,
+ "connection acceptor") {
+ public void run() {
+ try {
+ Connection connection = ts.accept(listenKey, 0, 0);
+ /*
+ * Notify waiting thread of connection
+ */
+ notifyOfConnection(connection);
+ } catch (InterruptedIOException e) {
+ // VM terminated, stop accepting
+ } catch (IOException e) {
+ // Report any other exception to waiting thread
+ notifyOfAcceptException(e);
+ }
+ }
+ };
+ thread.setDaemon(true);
+ thread.start();
+ return thread;
+ }
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ArrayReferenceImpl.java b/src/share/classes/com/sun/tools/jdi/ArrayReferenceImpl.java
new file mode 100644
index 0000000..88d26e7
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ArrayReferenceImpl.java
@@ -0,0 +1,283 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+
+public class ArrayReferenceImpl extends ObjectReferenceImpl
+ implements ArrayReference
+{
+ int length = -1;
+
+ ArrayReferenceImpl(VirtualMachine aVm,long aRef) {
+ super(aVm,aRef);
+ }
+
+ protected ClassTypeImpl invokableReferenceType(Method method) {
+ // The method has to be a method on Object since
+ // arrays don't have methods nor any other 'superclasses'
+ // So, use the ClassTypeImpl for Object instead of
+ // the ArrayTypeImpl for the array itself.
+ return (ClassTypeImpl)method.declaringType();
+ }
+
+ ArrayTypeImpl arrayType() {
+ return (ArrayTypeImpl)type();
+ }
+
+ /**
+ * Return array length.
+ * Need not be synchronized since it cannot be provably stale.
+ */
+ public int length() {
+ if(length == -1) {
+ try {
+ length = JDWP.ArrayReference.Length.
+ process(vm, this).arrayLength;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+ return length;
+ }
+
+ public Value getValue(int index) {
+ List<Value> list = getValues(index, 1);
+ return list.get(0);
+ }
+
+ public List<Value> getValues() {
+ return getValues(0, -1);
+ }
+
+ /**
+ * Validate that the range to set/get is valid.
+ * length of -1 (meaning rest of array) has been converted
+ * before entry.
+ */
+ private void validateArrayAccess(int index, int length) {
+ // because length can be computed from index,
+ // index must be tested first for correct error message
+ if ((index < 0) || (index > length())) {
+ throw new IndexOutOfBoundsException(
+ "Invalid array index: " + index);
+ }
+ if (length < 0) {
+ throw new IndexOutOfBoundsException(
+ "Invalid array range length: " + length);
+ }
+ if (index + length > length()) {
+ throw new IndexOutOfBoundsException(
+ "Invalid array range: " +
+ index + " to " + (index + length - 1));
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private static <T> T cast(Object x) {
+ return (T)x;
+ }
+
+ public List<Value> getValues(int index, int length) {
+ if (length == -1) { // -1 means the rest of the array
+ length = length() - index;
+ }
+ validateArrayAccess(index, length);
+ if (length == 0) {
+ return new ArrayList<Value>();
+ }
+
+ List<Value> vals;
+ try {
+ vals = cast(JDWP.ArrayReference.GetValues.process(vm, this, index, length).values);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+
+ return vals;
+ }
+
+ public void setValue(int index, Value value)
+ throws InvalidTypeException,
+ ClassNotLoadedException {
+ List<Value> list = new ArrayList<Value>(1);
+ list.add(value);
+ setValues(index, list, 0, 1);
+ }
+
+ public void setValues(List<? extends Value> values)
+ throws InvalidTypeException,
+ ClassNotLoadedException {
+ setValues(0, values, 0, -1);
+ }
+
+ public void setValues(int index, List<? extends Value> values,
+ int srcIndex, int length)
+ throws InvalidTypeException,
+ ClassNotLoadedException {
+
+ if (length == -1) { // -1 means the rest of the array
+ // shorter of, the rest of the array and rest of
+ // the source values
+ length = Math.min(length() - index,
+ values.size() - srcIndex);
+ }
+ validateMirrorsOrNulls(values);
+ validateArrayAccess(index, length);
+
+ if ((srcIndex < 0) || (srcIndex > values.size())) {
+ throw new IndexOutOfBoundsException(
+ "Invalid source index: " + srcIndex);
+ }
+ if (srcIndex + length > values.size()) {
+ throw new IndexOutOfBoundsException(
+ "Invalid source range: " +
+ srcIndex + " to " +
+ (srcIndex + length - 1));
+ }
+
+ boolean somethingToSet = false;;
+ ValueImpl[] setValues = new ValueImpl[length];
+
+ for (int i = 0; i < length; i++) {
+ ValueImpl value = (ValueImpl)values.get(srcIndex + i);
+
+ try {
+ // Validate and convert if necessary
+ setValues[i] =
+ ValueImpl.prepareForAssignment(value,
+ new Component());
+ somethingToSet = true;
+ } catch (ClassNotLoadedException e) {
+ /*
+ * Since we got this exception,
+ * the component must be a reference type.
+ * This means the class has not yet been loaded
+ * through the defining class's class loader.
+ * If the value we're trying to set is null,
+ * then setting to null is essentially a
+ * no-op, and we should allow it without an
+ * exception.
+ */
+ if (value != null) {
+ throw e;
+ }
+ }
+ }
+ if (somethingToSet) {
+ try {
+ JDWP.ArrayReference.SetValues.
+ process(vm, this, index, setValues);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+ }
+
+ public String toString() {
+ return "instance of " + arrayType().componentTypeName() +
+ "[" + length() + "] (id=" + uniqueID() + ")";
+ }
+
+ byte typeValueKey() {
+ return JDWP.Tag.ARRAY;
+ }
+
+ void validateAssignment(ValueContainer destination)
+ throws InvalidTypeException, ClassNotLoadedException {
+ try {
+ super.validateAssignment(destination);
+ } catch (ClassNotLoadedException e) {
+ /*
+ * An array can be used extensively without the
+ * enclosing loader being recorded by the VM as an
+ * initiating loader of the array type. In addition, the
+ * load of an array class is fairly harmless as long as
+ * the component class is already loaded. So we relax the
+ * rules a bit and allow the assignment as long as the
+ * ultimate component types are assignable.
+ */
+ boolean valid = false;
+ JNITypeParser destParser = new JNITypeParser(
+ destination.signature());
+ JNITypeParser srcParser = new JNITypeParser(
+ arrayType().signature());
+ int destDims = destParser.dimensionCount();
+ if (destDims <= srcParser.dimensionCount()) {
+ /*
+ * Remove all dimensions from the destination. Remove
+ * the same number of dimensions from the source.
+ * Get types for both and check to see if they are
+ * compatible.
+ */
+ String destComponentSignature =
+ destParser.componentSignature(destDims);
+ Type destComponentType =
+ destination.findType(destComponentSignature);
+ String srcComponentSignature =
+ srcParser.componentSignature(destDims);
+ Type srcComponentType =
+ arrayType().findComponentType(srcComponentSignature);
+ valid = ArrayTypeImpl.isComponentAssignable(destComponentType,
+ srcComponentType);
+ }
+
+ if (!valid) {
+ throw new InvalidTypeException("Cannot assign " +
+ arrayType().name() +
+ " to " +
+ destination.typeName());
+ }
+ }
+ }
+
+ /*
+ * Represents an array component to other internal parts of this
+ * implementation. This is not exposed at the JDI level. Currently,
+ * this class is needed only for type checking so it does not even
+ * reference a particular component - just a generic component
+ * of this array. In the future we may need to expand its use.
+ */
+ class Component implements ValueContainer {
+ public Type type() throws ClassNotLoadedException {
+ return arrayType().componentType();
+ }
+ public String typeName() {
+ return arrayType().componentTypeName();
+ }
+ public String signature() {
+ return arrayType().componentSignature();
+ }
+ public Type findType(String signature) throws ClassNotLoadedException {
+ return arrayType().findComponentType(signature);
+ }
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ArrayTypeImpl.java b/src/share/classes/com/sun/tools/jdi/ArrayTypeImpl.java
new file mode 100644
index 0000000..3449a45
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ArrayTypeImpl.java
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+public class ArrayTypeImpl extends ReferenceTypeImpl
+ implements ArrayType
+{
+ protected ArrayTypeImpl(VirtualMachine aVm, long aRef) {
+ super(aVm, aRef);
+ }
+
+ public ArrayReference newInstance(int length) {
+ try {
+ return (ArrayReference)JDWP.ArrayType.NewInstance.
+ process(vm, this, length).newArray;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+
+ public String componentSignature() {
+ return signature().substring(1); // Just skip the leading '['
+ }
+
+ public String componentTypeName() {
+ JNITypeParser parser = new JNITypeParser(componentSignature());
+ return parser.typeName();
+ }
+
+ Type type() throws ClassNotLoadedException {
+ return findType(componentSignature());
+ }
+
+ @Override
+ void addVisibleMethods(Map<String, Method> map, Set<InterfaceType> seenInterfaces) {
+ // arrays don't have methods
+ }
+
+ public List<Method> allMethods() {
+ return new ArrayList<Method>(0); // arrays don't have methods
+ }
+
+ /*
+ * Find the type object, if any, of a component type of this array.
+ * The component type does not have to be immediate; e.g. this method
+ * can be used to find the component Foo of Foo[][]. This method takes
+ * advantage of the property that an array and its component must have
+ * the same class loader. Since array set operations don't have an
+ * implicit enclosing type like field and variable set operations,
+ * this method is sometimes needed for proper type checking.
+ */
+ Type findComponentType(String signature) throws ClassNotLoadedException {
+ byte tag = (byte)signature.charAt(0);
+ if (PacketStream.isObjectTag(tag)) {
+ // It's a reference type
+ JNITypeParser parser = new JNITypeParser(componentSignature());
+ List<ReferenceType> list = vm.classesByName(parser.typeName());
+ Iterator<ReferenceType> iter = list.iterator();
+ while (iter.hasNext()) {
+ ReferenceType type = iter.next();
+ ClassLoaderReference cl = type.classLoader();
+ if ((cl == null)?
+ (classLoader() == null) :
+ (cl.equals(classLoader()))) {
+ return type;
+ }
+ }
+ // Component class has not yet been loaded
+ throw new ClassNotLoadedException(componentTypeName());
+ } else {
+ // It's a primitive type
+ return vm.primitiveTypeMirror(tag);
+ }
+ }
+
+ public Type componentType() throws ClassNotLoadedException {
+ return findComponentType(componentSignature());
+ }
+
+ static boolean isComponentAssignable(Type destination, Type source) {
+ if (source instanceof PrimitiveType) {
+ // Assignment of primitive arrays requires identical
+ // component types.
+ return source.equals(destination);
+ } else {
+ if (destination instanceof PrimitiveType) {
+ return false;
+ }
+
+ ReferenceTypeImpl refSource = (ReferenceTypeImpl)source;
+ ReferenceTypeImpl refDestination = (ReferenceTypeImpl)destination;
+ // Assignment of object arrays requires availability
+ // of widening conversion of component types
+ return refSource.isAssignableTo(refDestination);
+ }
+ }
+
+ /*
+ * Return true if an instance of the given reference type
+ * can be assigned to a variable of this type
+ */
+ boolean isAssignableTo(ReferenceType destType) {
+ if (destType instanceof ArrayType) {
+ try {
+ Type destComponentType = ((ArrayType)destType).componentType();
+ return isComponentAssignable(destComponentType, componentType());
+ } catch (ClassNotLoadedException e) {
+ // One or both component types has not yet been
+ // loaded => can't assign
+ return false;
+ }
+ } else if (destType instanceof InterfaceType) {
+ // Only valid InterfaceType assignee is Cloneable
+ return destType.name().equals("java.lang.Cloneable");
+ } else {
+ // Only valid ClassType assignee is Object
+ return destType.name().equals("java.lang.Object");
+ }
+ }
+
+ List<ReferenceType> inheritedTypes() {
+ return new ArrayList<ReferenceType>(0);
+ }
+
+ void getModifiers() {
+ if (modifiers != -1) {
+ return;
+ }
+ /*
+ * For object arrays, the return values for Interface
+ * Accessible.isPrivate(), Accessible.isProtected(),
+ * etc... are the same as would be returned for the
+ * component type. Fetch the modifier bits from the
+ * component type and use those.
+ *
+ * For primitive arrays, the modifiers are always
+ * VMModifiers.FINAL | VMModifiers.PUBLIC
+ *
+ * Reference com.sun.jdi.Accessible.java.
+ */
+ try {
+ Type t = componentType();
+ if (t instanceof PrimitiveType) {
+ modifiers = VMModifiers.FINAL | VMModifiers.PUBLIC;
+ } else {
+ ReferenceType rt = (ReferenceType)t;
+ modifiers = rt.modifiers();
+ }
+ } catch (ClassNotLoadedException cnle) {
+ cnle.printStackTrace();
+ }
+ }
+
+ public String toString() {
+ return "array class " + name() + " (" + loaderString() + ")";
+ }
+
+ /*
+ * Save a pointless trip over the wire for these methods
+ * which have undefined results for arrays.
+ */
+ public boolean isPrepared() { return true; }
+ public boolean isVerified() { return true; }
+ public boolean isInitialized() { return true; }
+ public boolean failedToInitialize() { return false; }
+ public boolean isAbstract() { return false; }
+
+ /*
+ * Defined always to be true for arrays
+ */
+ public boolean isFinal() { return true; }
+
+ /*
+ * Defined always to be false for arrays
+ */
+ public boolean isStatic() { return false; }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/BaseLineInfo.java b/src/share/classes/com/sun/tools/jdi/BaseLineInfo.java
new file mode 100644
index 0000000..872af85
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/BaseLineInfo.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2001, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+class BaseLineInfo implements LineInfo {
+ private final int lineNumber;
+ private final ReferenceTypeImpl declaringType;
+
+ BaseLineInfo(int lineNumber,
+ ReferenceTypeImpl declaringType) {
+ this.lineNumber = lineNumber;
+ this.declaringType = declaringType;
+ }
+
+ public String liStratum() {
+ return SDE.BASE_STRATUM_NAME;
+ }
+
+ public int liLineNumber() {
+ return lineNumber;
+ }
+
+ public String liSourceName()
+ throws AbsentInformationException {
+ return declaringType.baseSourceName();
+ }
+
+ public String liSourcePath()
+ throws AbsentInformationException {
+ return declaringType.baseSourcePath();
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/BooleanTypeImpl.java b/src/share/classes/com/sun/tools/jdi/BooleanTypeImpl.java
new file mode 100644
index 0000000..31f560f
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/BooleanTypeImpl.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 1998, 1999, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class BooleanTypeImpl extends PrimitiveTypeImpl implements BooleanType {
+ BooleanTypeImpl(VirtualMachine vm) {
+ super(vm);
+ }
+
+ public String signature() {
+ return String.valueOf((char)JDWP.Tag.BOOLEAN);
+ }
+
+ PrimitiveValue convert(PrimitiveValue value) throws InvalidTypeException {
+ return vm.mirrorOf(((PrimitiveValueImpl)value).checkedBooleanValue());
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/BooleanValueImpl.java b/src/share/classes/com/sun/tools/jdi/BooleanValueImpl.java
new file mode 100644
index 0000000..17144bb
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/BooleanValueImpl.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class BooleanValueImpl extends PrimitiveValueImpl
+ implements BooleanValue {
+ private boolean value;
+
+ BooleanValueImpl(VirtualMachine aVm,boolean aValue) {
+ super(aVm);
+
+ value = aValue;
+ }
+
+ public boolean equals(Object obj) {
+ if ((obj != null) && (obj instanceof BooleanValue)) {
+ return (value == ((BooleanValue)obj).value())
+ && super.equals(obj);
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ /*
+ * TO DO: Better hash code
+ */
+ return intValue();
+ }
+
+ public Type type() {
+ return vm.theBooleanType();
+ }
+
+ public boolean value() {
+ return value;
+ }
+
+ public boolean booleanValue() {
+ return value;
+ }
+
+ public byte byteValue() {
+ return(byte)((value)?1:0);
+ }
+
+ public char charValue() {
+ return(char)((value)?1:0);
+ }
+
+ public short shortValue() {
+ return(short)((value)?1:0);
+ }
+
+ public int intValue() {
+ return (value)?1:0;
+ }
+
+ public long longValue() {
+ return(long)((value)?1:0);
+ }
+
+ public float floatValue() {
+ return(float)((value)?1.0:0.0);
+ }
+
+ public double doubleValue() {
+ return (value)?1.0:0.0;
+ }
+
+ public String toString() {
+ return "" + value;
+ }
+
+ byte typeValueKey() {
+ return JDWP.Tag.BOOLEAN;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ByteTypeImpl.java b/src/share/classes/com/sun/tools/jdi/ByteTypeImpl.java
new file mode 100644
index 0000000..1e3b053
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ByteTypeImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 1998, 1999, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class ByteTypeImpl extends PrimitiveTypeImpl implements ByteType {
+ ByteTypeImpl(VirtualMachine vm) {
+ super(vm);
+ }
+
+
+ public String signature() {
+ return String.valueOf((char)JDWP.Tag.BYTE);
+ }
+
+ PrimitiveValue convert(PrimitiveValue value) throws InvalidTypeException {
+ return vm.mirrorOf(((PrimitiveValueImpl)value).checkedByteValue());
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ByteValueImpl.java b/src/share/classes/com/sun/tools/jdi/ByteValueImpl.java
new file mode 100644
index 0000000..effb240
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ByteValueImpl.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 1998, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class ByteValueImpl extends PrimitiveValueImpl
+ implements ByteValue {
+ private byte value;
+
+ ByteValueImpl(VirtualMachine aVm,byte aValue) {
+ super(aVm);
+
+ value = aValue;
+ }
+
+ public boolean equals(Object obj) {
+ if ((obj != null) && (obj instanceof ByteValue)) {
+ return (value == ((ByteValue)obj).value())
+ && super.equals(obj);
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ /*
+ * TO DO: Better hash code
+ */
+ return intValue();
+ }
+
+ public int compareTo(ByteValue obj) {
+ byte other = obj.value();
+ return value() - other;
+ }
+
+
+ public Type type() {
+ return vm.theByteType();
+ }
+
+ public byte value() {
+ return value;
+ }
+
+ public boolean booleanValue() {
+ return(value == 0)?false:true;
+ }
+
+ public byte byteValue() {
+ return value;
+ }
+
+ public char charValue() {
+ return(char)value;
+ }
+
+ public short shortValue() {
+ return(short)value;
+ }
+
+ public int intValue() {
+ return(int)value;
+ }
+
+ public long longValue() {
+ return(long)value;
+ }
+
+ public float floatValue() {
+ return(float)value;
+ }
+
+ public double doubleValue() {
+ return(double)value;
+ }
+
+ char checkedCharValue() throws InvalidTypeException {
+ if ((value > Character.MAX_VALUE) || (value < Character.MIN_VALUE)) {
+ throw new InvalidTypeException("Can't convert " + value + " to char");
+ } else {
+ return super.checkedCharValue();
+ }
+ }
+
+ public String toString() {
+ return "" + value;
+ }
+
+ byte typeValueKey() {
+ return JDWP.Tag.BYTE;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/CharTypeImpl.java b/src/share/classes/com/sun/tools/jdi/CharTypeImpl.java
new file mode 100644
index 0000000..6dd150a
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/CharTypeImpl.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1998, 1999, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class CharTypeImpl extends PrimitiveTypeImpl implements CharType {
+ CharTypeImpl(VirtualMachine vm) {
+ super(vm);
+ }
+
+
+ public String signature() {
+ return String.valueOf((char)JDWP.Tag.CHAR);
+ }
+
+ PrimitiveValue convert(PrimitiveValue value) throws InvalidTypeException {
+ return vm.mirrorOf(((PrimitiveValueImpl)value).checkedCharValue());
+ }
+
+}
diff --git a/src/share/classes/com/sun/tools/jdi/CharValueImpl.java b/src/share/classes/com/sun/tools/jdi/CharValueImpl.java
new file mode 100644
index 0000000..f367968
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/CharValueImpl.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class CharValueImpl extends PrimitiveValueImpl
+ implements CharValue {
+ private char value;
+
+ CharValueImpl(VirtualMachine aVm,char aValue) {
+ super(aVm);
+
+ value = aValue;
+ }
+
+ public boolean equals(Object obj) {
+ if ((obj != null) && (obj instanceof CharValue)) {
+ return (value == ((CharValue)obj).value()) &&
+ super.equals(obj);
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ /*
+ * TO DO: Better hash code
+ */
+ return intValue();
+ }
+
+ public int compareTo(CharValue obj) {
+ char other = obj.value();
+ return value() - other;
+ }
+
+ public Type type() {
+ return vm.theCharType();
+ }
+
+ public char value() {
+ return value;
+ }
+
+ public boolean booleanValue() {
+ return(value == 0)?false:true;
+ }
+
+ public byte byteValue() {
+ return(byte)value;
+ }
+
+ public char charValue() {
+ return value;
+ }
+
+ public short shortValue() {
+ return(short)value;
+ }
+
+ public int intValue() {
+ return(int)value;
+ }
+
+ public long longValue() {
+ return(long)value;
+ }
+
+ public float floatValue() {
+ return(float)value;
+ }
+
+ public double doubleValue() {
+ return(double)value;
+ }
+
+ public String toString() {
+ return "" + value;
+ }
+
+ byte checkedByteValue() throws InvalidTypeException {
+ // Note: since char is unsigned, don't check against MIN_VALUE
+ if (value > Byte.MAX_VALUE) {
+ throw new InvalidTypeException("Can't convert " + value + " to byte");
+ } else {
+ return super.checkedByteValue();
+ }
+ }
+
+ short checkedShortValue() throws InvalidTypeException {
+ // Note: since char is unsigned, don't check against MIN_VALUE
+ if (value > Short.MAX_VALUE) {
+ throw new InvalidTypeException("Can't convert " + value + " to short");
+ } else {
+ return super.checkedShortValue();
+ }
+ }
+
+ byte typeValueKey() {
+ return JDWP.Tag.CHAR;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ClassLoaderReferenceImpl.java b/src/share/classes/com/sun/tools/jdi/ClassLoaderReferenceImpl.java
new file mode 100644
index 0000000..4b29acd
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ClassLoaderReferenceImpl.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+import java.util.*;
+
+public class ClassLoaderReferenceImpl extends ObjectReferenceImpl
+ implements ClassLoaderReference, VMListener {
+
+ // This is cached only while the VM is suspended
+ private static class Cache extends ObjectReferenceImpl.Cache {
+ List<ReferenceType> visibleClasses = null;
+ }
+
+ protected ObjectReferenceImpl.Cache newCache() {
+ return new Cache();
+ }
+
+ ClassLoaderReferenceImpl(VirtualMachine aVm, long ref) {
+ super(aVm, ref);
+ vm.state().addListener(this);
+ }
+
+ protected String description() {
+ return "ClassLoaderReference " + uniqueID();
+ }
+
+ public List<ReferenceType> definedClasses() {
+ ArrayList<ReferenceType> definedClasses = new ArrayList<ReferenceType>();
+ for (ReferenceType type : vm.allClasses()) {
+ if (type.isPrepared() &&
+ equals(type.classLoader())) {
+ definedClasses.add(type);
+ }
+ }
+ return definedClasses;
+ }
+
+ public List<ReferenceType> visibleClasses() {
+ List<ReferenceType> classes = null;
+ try {
+ Cache local = (Cache)getCache();
+
+ if (local != null) {
+ classes = local.visibleClasses;
+ }
+ if (classes == null) {
+ JDWP.ClassLoaderReference.VisibleClasses.ClassInfo[]
+ jdwpClasses = JDWP.ClassLoaderReference.VisibleClasses.
+ process(vm, this).classes;
+ classes = new ArrayList<ReferenceType>(jdwpClasses.length);
+ for (int i = 0; i < jdwpClasses.length; ++i) {
+ classes.add(vm.referenceType(jdwpClasses[i].typeID,
+ jdwpClasses[i].refTypeTag));
+ }
+ classes = Collections.unmodifiableList(classes);
+ if (local != null) {
+ local.visibleClasses = classes;
+ if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) {
+ vm.printTrace(description() +
+ " temporarily caching visible classes (count = " +
+ classes.size() + ")");
+ }
+ }
+ }
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ return classes;
+ }
+
+ Type findType(String signature) throws ClassNotLoadedException {
+ List<ReferenceType> types = visibleClasses();
+ Iterator<ReferenceType> iter = types.iterator();
+ while (iter.hasNext()) {
+ ReferenceType type = iter.next();
+ if (type.signature().equals(signature)) {
+ return type;
+ }
+ }
+ JNITypeParser parser = new JNITypeParser(signature);
+ throw new ClassNotLoadedException(parser.typeName(),
+ "Class " + parser.typeName() + " not loaded");
+ }
+
+ byte typeValueKey() {
+ return JDWP.Tag.CLASS_LOADER;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ClassObjectReferenceImpl.java b/src/share/classes/com/sun/tools/jdi/ClassObjectReferenceImpl.java
new file mode 100644
index 0000000..3cbbf34
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ClassObjectReferenceImpl.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 1999, 2000, 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.tools.jdi;
+
+import com.sun.jdi.*;
+import java.util.*;
+
+public class ClassObjectReferenceImpl extends ObjectReferenceImpl
+ implements ClassObjectReference {
+ private ReferenceType reflectedType;
+
+ ClassObjectReferenceImpl(VirtualMachine vm, long ref) {
+ super(vm, ref);
+ }
+
+ public ReferenceType reflectedType() {
+ if (reflectedType == null) {
+ try {
+ JDWP.ClassObjectReference.ReflectedType reply =
+ JDWP.ClassObjectReference.ReflectedType.process(vm, this);
+ reflectedType = vm.referenceType(reply.typeID,
+ reply.refTypeTag);
+
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+ return reflectedType;
+ }
+
+ byte typeValueKey() {
+ return JDWP.Tag.CLASS_OBJECT;
+ }
+
+ public String toString() {
+ return "instance of " + referenceType().name() +
+ "(reflected class=" + reflectedType().name() + ", " + "id=" + uniqueID() + ")";
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java b/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java
new file mode 100644
index 0000000..b815d1a
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java
@@ -0,0 +1,296 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+import java.util.*;
+
+final public class ClassTypeImpl extends InvokableTypeImpl
+ implements ClassType
+{
+ private static class IResult implements InvocationResult {
+ final private JDWP.ClassType.InvokeMethod rslt;
+
+ public IResult(JDWP.ClassType.InvokeMethod rslt) {
+ this.rslt = rslt;
+ }
+
+ @Override
+ public ObjectReferenceImpl getException() {
+ return rslt.exception;
+ }
+
+ @Override
+ public ValueImpl getResult() {
+ return rslt.returnValue;
+ }
+ }
+
+ private boolean cachedSuperclass = false;
+ private ClassType superclass = null;
+ private int lastLine = -1;
+ private List<InterfaceType> interfaces = null;
+
+ protected ClassTypeImpl(VirtualMachine aVm,long aRef) {
+ super(aVm, aRef);
+ }
+
+ public ClassType superclass() {
+ if(!cachedSuperclass) {
+ ClassTypeImpl sup = null;
+ try {
+ sup = JDWP.ClassType.Superclass.
+ process(vm, this).superclass;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+
+ /*
+ * If there is a superclass, cache its
+ * ClassType here. Otherwise,
+ * leave the cache reference null.
+ */
+ if (sup != null) {
+ superclass = sup;
+ }
+ cachedSuperclass = true;
+ }
+
+ return superclass;
+ }
+
+ @Override
+ public List<InterfaceType> interfaces() {
+ if (interfaces == null) {
+ interfaces = getInterfaces();
+ }
+ return interfaces;
+ }
+
+ @Override
+ public List<InterfaceType> allInterfaces() {
+ return getAllInterfaces();
+ }
+
+ public List<ClassType> subclasses() {
+ List<ClassType> subs = new ArrayList<ClassType>();
+ for (ReferenceType refType : vm.allClasses()) {
+ if (refType instanceof ClassType) {
+ ClassType clazz = (ClassType)refType;
+ ClassType superclass = clazz.superclass();
+ if ((superclass != null) && superclass.equals(this)) {
+ subs.add((ClassType)refType);
+ }
+ }
+ }
+
+ return subs;
+ }
+
+ public boolean isEnum() {
+ ClassType superclass = superclass();
+ if (superclass != null &&
+ superclass.name().equals("java.lang.Enum")) {
+ return true;
+ }
+ return false;
+ }
+
+ public void setValue(Field field, Value value)
+ throws InvalidTypeException, ClassNotLoadedException {
+
+ validateMirror(field);
+ validateMirrorOrNull(value);
+ validateFieldSet(field);
+
+ // More validation specific to setting from a ClassType
+ if(!field.isStatic()) {
+ throw new IllegalArgumentException(
+ "Must set non-static field through an instance");
+ }
+
+ try {
+ JDWP.ClassType.SetValues.FieldValue[] values =
+ new JDWP.ClassType.SetValues.FieldValue[1];
+ values[0] = new JDWP.ClassType.SetValues.FieldValue(
+ ((FieldImpl)field).ref(),
+ // validate and convert if necessary
+ ValueImpl.prepareForAssignment(value, (FieldImpl)field));
+
+ try {
+ JDWP.ClassType.SetValues.process(vm, this, values);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ } catch (ClassNotLoadedException e) {
+ /*
+ * Since we got this exception,
+ * the field type must be a reference type. The value
+ * we're trying to set is null, but if the field's
+ * class has not yet been loaded through the enclosing
+ * class loader, then setting to null is essentially a
+ * no-op, and we should allow it without an exception.
+ */
+ if (value != null) {
+ throw e;
+ }
+ }
+ }
+
+ PacketStream sendNewInstanceCommand(final ThreadReferenceImpl thread,
+ final MethodImpl method,
+ final ValueImpl[] args,
+ final int options) {
+ CommandSender sender =
+ new CommandSender() {
+ public PacketStream send() {
+ return JDWP.ClassType.NewInstance.enqueueCommand(
+ vm, ClassTypeImpl.this, thread,
+ method.ref(), args, options);
+ }
+ };
+
+ PacketStream stream;
+ if ((options & INVOKE_SINGLE_THREADED) != 0) {
+ stream = thread.sendResumingCommand(sender);
+ } else {
+ stream = vm.sendResumingCommand(sender);
+ }
+ return stream;
+ }
+
+ public ObjectReference newInstance(ThreadReference threadIntf,
+ Method methodIntf,
+ List<? extends Value> origArguments,
+ int options)
+ throws InvalidTypeException,
+ ClassNotLoadedException,
+ IncompatibleThreadStateException,
+ InvocationException {
+ validateMirror(threadIntf);
+ validateMirror(methodIntf);
+ validateMirrorsOrNulls(origArguments);
+
+ MethodImpl method = (MethodImpl)methodIntf;
+ ThreadReferenceImpl thread = (ThreadReferenceImpl)threadIntf;
+
+ validateConstructorInvocation(method);
+
+ List<Value> arguments = method.validateAndPrepareArgumentsForInvoke(
+ origArguments);
+ ValueImpl[] args = arguments.toArray(new ValueImpl[0]);
+ JDWP.ClassType.NewInstance ret = null;
+ try {
+ PacketStream stream =
+ sendNewInstanceCommand(thread, method, args, options);
+ ret = JDWP.ClassType.NewInstance.waitForReply(vm, stream);
+ } catch (JDWPException exc) {
+ if (exc.errorCode() == JDWP.Error.INVALID_THREAD) {
+ throw new IncompatibleThreadStateException();
+ } else {
+ throw exc.toJDIException();
+ }
+ }
+
+ /*
+ * There is an implict VM-wide suspend at the conclusion
+ * of a normal (non-single-threaded) method invoke
+ */
+ if ((options & INVOKE_SINGLE_THREADED) == 0) {
+ vm.notifySuspend();
+ }
+
+ if (ret.exception != null) {
+ throw new InvocationException(ret.exception);
+ } else {
+ return ret.newObject;
+ }
+ }
+
+ public Method concreteMethodByName(String name, String signature) {
+ Method method = null;
+ for (Method candidate : visibleMethods()) {
+ if (candidate.name().equals(name) &&
+ candidate.signature().equals(signature) &&
+ !candidate.isAbstract()) {
+
+ method = candidate;
+ break;
+ }
+ }
+ return method;
+ }
+
+ void validateConstructorInvocation(Method method)
+ throws InvalidTypeException,
+ InvocationException {
+ /*
+ * Method must be in this class.
+ */
+ ReferenceTypeImpl declType = (ReferenceTypeImpl)method.declaringType();
+ if (!declType.equals(this)) {
+ throw new IllegalArgumentException("Invalid constructor");
+ }
+
+ /*
+ * Method must be a constructor
+ */
+ if (!method.isConstructor()) {
+ throw new IllegalArgumentException("Cannot create instance with non-constructor");
+ }
+ }
+
+
+ public String toString() {
+ return "class " + name() + " (" + loaderString() + ")";
+ }
+
+ @Override
+ CommandSender getInvokeMethodSender(ThreadReferenceImpl thread,
+ MethodImpl method,
+ ValueImpl[] args,
+ int options) {
+ return () ->
+ JDWP.ClassType.InvokeMethod.enqueueCommand(vm,
+ ClassTypeImpl.this,
+ thread,
+ method.ref(),
+ args,
+ options);
+ }
+
+ @Override
+ InvocationResult waitForReply(PacketStream stream) throws JDWPException {
+ return new IResult(JDWP.ClassType.InvokeMethod.waitForReply(vm, stream));
+ }
+
+ @Override
+ boolean canInvoke(Method method) {
+ // Method must be in this class or a superclass.
+ return ((ReferenceTypeImpl)method.declaringType()).isAssignableFrom(this);
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/CommandSender.java b/src/share/classes/com/sun/tools/jdi/CommandSender.java
new file mode 100644
index 0000000..d7916c7
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/CommandSender.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 1999, 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.tools.jdi;
+
+import com.sun.jdi.*;
+import java.util.EventListener;
+
+interface CommandSender {
+ PacketStream send();
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ConcreteMethodImpl.java b/src/share/classes/com/sun/tools/jdi/ConcreteMethodImpl.java
new file mode 100644
index 0000000..a485f31
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ConcreteMethodImpl.java
@@ -0,0 +1,545 @@
+/*
+ * Copyright (c) 2000, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.ListIterator;
+import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.lang.ref.SoftReference;
+
+/**
+ * Represents methods with method bodies.
+ * That is, non-native non-abstract methods.
+ * Private to MethodImpl.
+ */
+public class ConcreteMethodImpl extends MethodImpl {
+
+ /*
+ * A subset of the line number info that is softly cached
+ */
+ static private class SoftLocationXRefs {
+ final String stratumID; // The stratum of this information
+ final Map<Integer, List<Location>> lineMapper; // Maps line number to location(s)
+ final List<Location> lineLocations; // List of locations ordered by code index
+
+ /*
+ * Note: these do not necessarily correspond to
+ * the line numbers of the first and last elements
+ * in the lineLocations list. Use these only for bounds
+ * checking and with lineMapper.
+ */
+ final int lowestLine;
+ final int highestLine;
+
+ SoftLocationXRefs(String stratumID, Map<Integer, List<Location>> lineMapper, List<Location> lineLocations,
+ int lowestLine, int highestLine) {
+ this.stratumID = stratumID;
+ this.lineMapper = Collections.unmodifiableMap(lineMapper);
+ this.lineLocations =
+ Collections.unmodifiableList(lineLocations);
+ this.lowestLine = lowestLine;
+ this.highestLine = highestLine;
+ }
+ }
+
+ private Location location = null;
+ private SoftReference<SoftLocationXRefs> softBaseLocationXRefsRef;
+ private SoftReference<SoftLocationXRefs> softOtherLocationXRefsRef;
+ private SoftReference<List<LocalVariable>> variablesRef = null;
+ private boolean absentVariableInformation = false;
+ private long firstIndex = -1;
+ private long lastIndex = -1;
+ private SoftReference<byte[]> bytecodesRef = null;
+ private int argSlotCount = -1;
+
+ ConcreteMethodImpl(VirtualMachine vm, ReferenceTypeImpl declaringType,
+ long ref,
+ String name, String signature,
+ String genericSignature, int modifiers) {
+
+ // The generic signature is set when this is created
+ super(vm, declaringType, ref, name, signature,
+ genericSignature, modifiers);
+ }
+
+ public Location location() {
+ if (location == null) {
+ getBaseLocations();
+ }
+ return location;
+ }
+
+ List<Location> sourceNameFilter(List<Location> list,
+ SDE.Stratum stratum,
+ String sourceName)
+ throws AbsentInformationException {
+ if (sourceName == null) {
+ return list;
+ } else {
+ /* needs sourceName filteration */
+ List<Location> locs = new ArrayList<Location>();
+ for (Location loc : list) {
+ if (((LocationImpl)loc).sourceName(stratum).equals(sourceName)) {
+ locs.add(loc);
+ }
+ }
+ return locs;
+ }
+ }
+
+ List<Location> allLineLocations(SDE.Stratum stratum,
+ String sourceName)
+ throws AbsentInformationException {
+ List<Location> lineLocations = getLocations(stratum).lineLocations;
+
+ if (lineLocations.size() == 0) {
+ throw new AbsentInformationException();
+ }
+
+ return Collections.unmodifiableList(
+ sourceNameFilter(lineLocations, stratum, sourceName));
+ }
+
+ List<Location> locationsOfLine(SDE.Stratum stratum,
+ String sourceName,
+ int lineNumber)
+ throws AbsentInformationException {
+ SoftLocationXRefs info = getLocations(stratum);
+
+ if (info.lineLocations.size() == 0) {
+ throw new AbsentInformationException();
+ }
+
+ /*
+ * Find the locations which match the line number
+ * passed in.
+ */
+ List<Location> list = info.lineMapper.get(new Integer(lineNumber));
+
+ if (list == null) {
+ list = new ArrayList<Location>(0);
+ }
+ return Collections.unmodifiableList(
+ sourceNameFilter(list, stratum, sourceName));
+ }
+
+
+ public Location locationOfCodeIndex(long codeIndex) {
+ if (firstIndex == -1) {
+ getBaseLocations();
+ }
+
+ /*
+ * Check for invalid code index.
+ */
+ if (codeIndex < firstIndex || codeIndex > lastIndex) {
+ return null;
+ }
+
+ return new LocationImpl(virtualMachine(), this, codeIndex);
+ }
+
+
+ LineInfo codeIndexToLineInfo(SDE.Stratum stratum,
+ long codeIndex) {
+ if (firstIndex == -1) {
+ getBaseLocations();
+ }
+
+ /*
+ * Check for invalid code index.
+ */
+ if (codeIndex < firstIndex || codeIndex > lastIndex) {
+ throw new InternalError(
+ "Location with invalid code index");
+ }
+
+ List<Location> lineLocations = getLocations(stratum).lineLocations;
+
+ /*
+ * Check for absent line numbers.
+ */
+ if (lineLocations.size() == 0) {
+ return super.codeIndexToLineInfo(stratum, codeIndex);
+ }
+
+ Iterator<Location> iter = lineLocations.iterator();
+ /*
+ * Treat code before the beginning of the first line table
+ * entry as part of the first line. javac will generate
+ * code like this for some local classes. This "prolog"
+ * code contains assignments from locals in the enclosing
+ * scope to synthetic fields in the local class. Same for
+ * other language prolog code.
+ */
+ LocationImpl bestMatch = (LocationImpl)iter.next();
+ while (iter.hasNext()) {
+ LocationImpl current = (LocationImpl)iter.next();
+ if (current.codeIndex() > codeIndex) {
+ break;
+ }
+ bestMatch = current;
+ }
+ return bestMatch.getLineInfo(stratum);
+ }
+
+
+ public List<LocalVariable> variables() throws AbsentInformationException {
+ return getVariables();
+ }
+
+ public List<LocalVariable> variablesByName(String name) throws AbsentInformationException {
+ List<LocalVariable> variables = getVariables();
+
+ List<LocalVariable> retList = new ArrayList<LocalVariable>(2);
+ Iterator<LocalVariable> iter = variables.iterator();
+ while(iter.hasNext()) {
+ LocalVariable variable = iter.next();
+ if (variable.name().equals(name)) {
+ retList.add(variable);
+ }
+ }
+ return retList;
+ }
+
+ public List<LocalVariable> arguments() throws AbsentInformationException {
+ List<LocalVariable> variables = getVariables();
+
+ List<LocalVariable> retList = new ArrayList<LocalVariable>(variables.size());
+ Iterator<LocalVariable> iter = variables.iterator();
+ while(iter.hasNext()) {
+ LocalVariable variable = iter.next();
+ if (variable.isArgument()) {
+ retList.add(variable);
+ }
+ }
+ return retList;
+ }
+
+ public byte[] bytecodes() {
+ byte[] bytecodes = (bytecodesRef == null) ? null :
+ bytecodesRef.get();
+ if (bytecodes == null) {
+ try {
+ bytecodes = JDWP.Method.Bytecodes.
+ process(vm, declaringType, ref).bytes;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ bytecodesRef = new SoftReference<byte[]>(bytecodes);
+ }
+ /*
+ * Arrays are always modifiable, so it is a little unsafe
+ * to return the cached bytecodes directly; instead, we
+ * make a clone at the cost of using more memory.
+ */
+ return bytecodes.clone();
+ }
+
+ int argSlotCount() throws AbsentInformationException {
+ if (argSlotCount == -1) {
+ getVariables();
+ }
+ return argSlotCount;
+ }
+
+ private SoftLocationXRefs getLocations(SDE.Stratum stratum) {
+ if (stratum.isJava()) {
+ return getBaseLocations();
+ }
+ String stratumID = stratum.id();
+ SoftLocationXRefs info =
+ (softOtherLocationXRefsRef == null) ? null :
+ softOtherLocationXRefsRef.get();
+ if (info != null && info.stratumID.equals(stratumID)) {
+ return info;
+ }
+
+ List<Location> lineLocations = new ArrayList<Location>();
+ Map<Integer, List<Location>> lineMapper = new HashMap<Integer, List<Location>>();
+ int lowestLine = -1;
+ int highestLine = -1;
+ SDE.LineStratum lastLineStratum = null;
+ SDE.Stratum baseStratum =
+ declaringType.stratum(SDE.BASE_STRATUM_NAME);
+ Iterator<Location> it = getBaseLocations().lineLocations.iterator();
+ while(it.hasNext()) {
+ LocationImpl loc = (LocationImpl)it.next();
+ int baseLineNumber = loc.lineNumber(baseStratum);
+ SDE.LineStratum lineStratum =
+ stratum.lineStratum(declaringType,
+ baseLineNumber);
+
+ if (lineStratum == null) {
+ // location not mapped in this stratum
+ continue;
+ }
+
+ int lineNumber = lineStratum.lineNumber();
+
+ // remove unmapped and dup lines
+ if ((lineNumber != -1) &&
+ (!lineStratum.equals(lastLineStratum))) {
+ lastLineStratum = lineStratum;
+
+ // Remember the largest/smallest line number
+ if (lineNumber > highestLine) {
+ highestLine = lineNumber;
+ }
+ if ((lineNumber < lowestLine) || (lowestLine == -1)) {
+ lowestLine = lineNumber;
+ }
+
+ loc.addStratumLineInfo(
+ new StratumLineInfo(stratumID,
+ lineNumber,
+ lineStratum.sourceName(),
+ lineStratum.sourcePath()));
+
+ // Add to the location list
+ lineLocations.add(loc);
+
+ // Add to the line -> locations map
+ Integer key = new Integer(lineNumber);
+ List<Location> mappedLocs = lineMapper.get(key);
+ if (mappedLocs == null) {
+ mappedLocs = new ArrayList<Location>(1);
+ lineMapper.put(key, mappedLocs);
+ }
+ mappedLocs.add(loc);
+ }
+ }
+
+ info = new SoftLocationXRefs(stratumID,
+ lineMapper, lineLocations,
+ lowestLine, highestLine);
+ softOtherLocationXRefsRef = new SoftReference<SoftLocationXRefs>(info);
+ return info;
+ }
+
+ private SoftLocationXRefs getBaseLocations() {
+ SoftLocationXRefs info = (softBaseLocationXRefsRef == null) ? null :
+ softBaseLocationXRefsRef.get();
+ if (info != null) {
+ return info;
+ }
+
+ JDWP.Method.LineTable lntab = null;
+ try {
+ lntab = JDWP.Method.LineTable.process(vm, declaringType, ref);
+ } catch (JDWPException exc) {
+ /*
+ * Note: the absent info error shouldn't happen here
+ * because the first and last index are always available.
+ */
+ throw exc.toJDIException();
+ }
+
+ int count = lntab.lines.length;
+
+ List<Location> lineLocations = new ArrayList<Location>(count);
+ Map<Integer, List<Location>>lineMapper = new HashMap<Integer, List<Location>>();
+ int lowestLine = -1;
+ int highestLine = -1;
+ for (int i = 0; i < count; i++) {
+ long bci = lntab.lines[i].lineCodeIndex;
+ int lineNumber = lntab.lines[i].lineNumber;
+
+ /*
+ * Some compilers will point multiple consecutive
+ * lines at the same location. We need to choose
+ * one of them so that we can consistently map back
+ * and forth between line and location. So we choose
+ * to record only the last line entry at a particular
+ * location.
+ */
+ if ((i + 1 == count) || (bci != lntab.lines[i+1].lineCodeIndex)) {
+ // Remember the largest/smallest line number
+ if (lineNumber > highestLine) {
+ highestLine = lineNumber;
+ }
+ if ((lineNumber < lowestLine) || (lowestLine == -1)) {
+ lowestLine = lineNumber;
+ }
+ LocationImpl loc =
+ new LocationImpl(virtualMachine(), this, bci);
+ loc.addBaseLineInfo(
+ new BaseLineInfo(lineNumber, declaringType));
+
+ // Add to the location list
+ lineLocations.add(loc);
+
+ // Add to the line -> locations map
+ Integer key = new Integer(lineNumber);
+ List<Location> mappedLocs = lineMapper.get(key);
+ if (mappedLocs == null) {
+ mappedLocs = new ArrayList<Location>(1);
+ lineMapper.put(key, mappedLocs);
+ }
+ mappedLocs.add(loc);
+ }
+ }
+
+ /*
+ * firstIndex, lastIndex, and startLocation need to be
+ * retrieved only once since they are strongly referenced.
+ */
+ if (location == null) {
+ firstIndex = lntab.start;
+ lastIndex = lntab.end;
+ /*
+ * The startLocation is the first one in the
+ * location list if we have one;
+ * otherwise, we construct a location for a
+ * method start with no line info
+ */
+ if (count > 0) {
+ location = lineLocations.get(0);
+ } else {
+ location = new LocationImpl(virtualMachine(), this,
+ firstIndex);
+ }
+ }
+
+ info = new SoftLocationXRefs(SDE.BASE_STRATUM_NAME,
+ lineMapper, lineLocations,
+ lowestLine, highestLine);
+ softBaseLocationXRefsRef = new SoftReference<SoftLocationXRefs>(info);
+ return info;
+ }
+
+ private List<LocalVariable> getVariables1_4() throws AbsentInformationException {
+ JDWP.Method.VariableTable vartab = null;
+ try {
+ vartab = JDWP.Method.VariableTable.
+ process(vm, declaringType, ref);
+ } catch (JDWPException exc) {
+ if (exc.errorCode() == JDWP.Error.ABSENT_INFORMATION) {
+ absentVariableInformation = true;
+ throw new AbsentInformationException();
+ } else {
+ throw exc.toJDIException();
+ }
+ }
+
+ // Get the number of slots used by argument variables
+ argSlotCount = vartab.argCnt;
+ int count = vartab.slots.length;
+ List<LocalVariable> variables = new ArrayList<LocalVariable>(count);
+ for (int i=0; i<count; i++) {
+ JDWP.Method.VariableTable.SlotInfo si = vartab.slots[i];
+
+ /*
+ * Skip "this*" entries because they are never real
+ * variables from the JLS perspective.
+ */
+ if (!si.name.startsWith("this$") && !si.name.equals("this")) {
+ Location scopeStart = new LocationImpl(virtualMachine(),
+ this, si.codeIndex);
+ Location scopeEnd =
+ new LocationImpl(virtualMachine(), this,
+ si.codeIndex + si.length - 1);
+ LocalVariable variable =
+ new LocalVariableImpl(virtualMachine(), this,
+ si.slot, scopeStart, scopeEnd,
+ si.name, si.signature, null);
+ // Add to the variable list
+ variables.add(variable);
+ }
+ }
+ return variables;
+ }
+
+ private List<LocalVariable> getVariables1() throws AbsentInformationException {
+
+ if (!vm.canGet1_5LanguageFeatures()) {
+ return getVariables1_4();
+ }
+
+ JDWP.Method.VariableTableWithGeneric vartab = null;
+ try {
+ vartab = JDWP.Method.VariableTableWithGeneric.
+ process(vm, declaringType, ref);
+ } catch (JDWPException exc) {
+ if (exc.errorCode() == JDWP.Error.ABSENT_INFORMATION) {
+ absentVariableInformation = true;
+ throw new AbsentInformationException();
+ } else {
+ throw exc.toJDIException();
+ }
+ }
+
+ // Get the number of slots used by argument variables
+ argSlotCount = vartab.argCnt;
+ int count = vartab.slots.length;
+ List<LocalVariable> variables = new ArrayList<LocalVariable>(count);
+ for (int i=0; i<count; i++) {
+ JDWP.Method.VariableTableWithGeneric.SlotInfo si = vartab.slots[i];
+
+ /*
+ * Skip "this*" entries because they are never real
+ * variables from the JLS perspective.
+ */
+ if (!si.name.startsWith("this$") && !si.name.equals("this")) {
+ Location scopeStart = new LocationImpl(virtualMachine(),
+ this, si.codeIndex);
+ Location scopeEnd =
+ new LocationImpl(virtualMachine(), this,
+ si.codeIndex + si.length - 1);
+ LocalVariable variable =
+ new LocalVariableImpl(virtualMachine(), this,
+ si.slot, scopeStart, scopeEnd,
+ si.name, si.signature,
+ si.genericSignature);
+ // Add to the variable list
+ variables.add(variable);
+ }
+ }
+ return variables;
+ }
+
+ private List<LocalVariable> getVariables() throws AbsentInformationException {
+ if (absentVariableInformation) {
+ throw new AbsentInformationException();
+ }
+
+ List<LocalVariable> variables = (variablesRef == null) ? null :
+ variablesRef.get();
+ if (variables != null) {
+ return variables;
+ }
+ variables = getVariables1();
+ variables = Collections.unmodifiableList(variables);
+ variablesRef = new SoftReference<List<LocalVariable>>(variables);
+ return variables;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ConnectorImpl.java b/src/share/classes/com/sun/tools/jdi/ConnectorImpl.java
new file mode 100644
index 0000000..d6b1e95
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ConnectorImpl.java
@@ -0,0 +1,425 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+
+import com.sun.tools.jdi.*;
+import com.sun.jdi.*;
+import com.sun.jdi.connect.*;
+import com.sun.jdi.InternalException;
+import java.util.Collections;
+import java.util.Collection;
+import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.ResourceBundle;
+import java.io.Serializable;
+
+abstract class ConnectorImpl implements Connector {
+ Map<String,Argument> defaultArguments = new java.util.LinkedHashMap<String,Argument>();
+
+ // Used by BooleanArgument
+ static String trueString = null;
+ static String falseString;
+
+ public Map<String,Argument> defaultArguments() {
+ Map<String,Argument> defaults = new java.util.LinkedHashMap<String,Argument>();
+ Collection<Argument> values = defaultArguments.values();
+
+ Iterator<Argument> iter = values.iterator();
+ while (iter.hasNext()) {
+ ArgumentImpl argument = (ArgumentImpl)iter.next();
+ defaults.put(argument.name(), (Argument)argument.clone());
+ }
+ return defaults;
+ }
+
+ void addStringArgument(String name, String label, String description,
+ String defaultValue, boolean mustSpecify) {
+ defaultArguments.put(name,
+ new StringArgumentImpl(name, label,
+ description,
+ defaultValue,
+ mustSpecify));
+ }
+
+ void addBooleanArgument(String name, String label, String description,
+ boolean defaultValue, boolean mustSpecify) {
+ defaultArguments.put(name,
+ new BooleanArgumentImpl(name, label,
+ description,
+ defaultValue,
+ mustSpecify));
+ }
+
+ void addIntegerArgument(String name, String label, String description,
+ String defaultValue, boolean mustSpecify,
+ int min, int max) {
+ defaultArguments.put(name,
+ new IntegerArgumentImpl(name, label,
+ description,
+ defaultValue,
+ mustSpecify,
+ min, max));
+ }
+
+ void addSelectedArgument(String name, String label, String description,
+ String defaultValue, boolean mustSpecify,
+ List<String> list) {
+ defaultArguments.put(name,
+ new SelectedArgumentImpl(name, label,
+ description,
+ defaultValue,
+ mustSpecify, list));
+ }
+
+ ArgumentImpl argument(String name, Map<String, ? extends Argument> arguments)
+ throws IllegalConnectorArgumentsException {
+
+ ArgumentImpl argument = (ArgumentImpl)arguments.get(name);
+ if (argument == null) {
+ throw new IllegalConnectorArgumentsException(
+ "Argument missing", name);
+ }
+ String value = argument.value();
+ if (value == null || value.length() == 0) {
+ if (argument.mustSpecify()) {
+ throw new IllegalConnectorArgumentsException(
+ "Argument unspecified", name);
+ }
+ } else if(!argument.isValid(value)) {
+ throw new IllegalConnectorArgumentsException(
+ "Argument invalid", name);
+ }
+
+ return argument;
+ }
+
+
+ private ResourceBundle messages = null;
+
+ String getString(String key) {
+ if (messages == null) {
+ messages = ResourceBundle.getBundle("com.sun.tools.jdi.resources.jdi");
+ }
+ return messages.getString(key);
+ }
+
+ public String toString() {
+ String string = name() + " (defaults: ";
+ Iterator<Argument> iter = defaultArguments().values().iterator();
+ boolean first = true;
+ while (iter.hasNext()) {
+ ArgumentImpl argument = (ArgumentImpl)iter.next();
+ if (!first) {
+ string += ", ";
+ }
+ string += argument.toString();
+ first = false;
+ }
+ string += ")";
+ return string;
+ }
+
+ abstract class ArgumentImpl implements Connector.Argument, Cloneable, Serializable {
+ private String name;
+ private String label;
+ private String description;
+ private String value;
+ private boolean mustSpecify;
+
+ ArgumentImpl(String name, String label, String description,
+ String value,
+ boolean mustSpecify) {
+ this.name = name;
+ this.label = label;
+ this.description = description;
+ this.value = value;
+ this.mustSpecify = mustSpecify;
+ }
+
+ public abstract boolean isValid(String value);
+
+ public String name() {
+ return name;
+ }
+
+ public String label() {
+ return label;
+ }
+
+ public String description() {
+ return description;
+ }
+
+ public String value() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ if (value == null) {
+ throw new NullPointerException("Can't set null value");
+ }
+ this.value = value;
+ }
+
+ public boolean mustSpecify() {
+ return mustSpecify;
+ }
+
+ public boolean equals(Object obj) {
+ if ((obj != null) && (obj instanceof Connector.Argument)) {
+ Connector.Argument other = (Connector.Argument)obj;
+ return (name().equals(other.name())) &&
+ (description().equals(other.description())) &&
+ (mustSpecify() == other.mustSpecify()) &&
+ (value().equals(other.value()));
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ return description().hashCode();
+ }
+
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ // Object should always support clone
+ throw new InternalException();
+ }
+ }
+
+ public String toString() {
+ return name() + "=" + value();
+ }
+ }
+
+ class BooleanArgumentImpl extends ConnectorImpl.ArgumentImpl
+ implements Connector.BooleanArgument {
+ private static final long serialVersionUID = 1624542968639361316L;
+ BooleanArgumentImpl(String name, String label, String description,
+ boolean value,
+ boolean mustSpecify) {
+ super(name, label, description, null, mustSpecify);
+ if(trueString == null) {
+ trueString = getString("true");
+ falseString = getString("false");
+ }
+ setValue(value);
+ }
+
+ /**
+ * Sets the value of the argument.
+ */
+ public void setValue(boolean value) {
+ setValue(stringValueOf(value));
+ }
+
+ /**
+ * Performs basic sanity check of argument.
+ * @return <code>true</code> if value is a string
+ * representation of a boolean value.
+ * @see #stringValueOf(boolean)
+ */
+ public boolean isValid(String value) {
+ return value.equals(trueString) || value.equals(falseString);
+ }
+
+ /**
+ * Return the string representation of the <code>value</code>
+ * parameter.
+ * Does not set or examine the value or the argument.
+ * @return the localized String representation of the
+ * boolean value.
+ */
+ public String stringValueOf(boolean value) {
+ return value? trueString : falseString;
+ }
+
+ /**
+ * Return the value of the argument as a boolean. Since
+ * the argument may not have been set or may have an invalid
+ * value {@link #isValid(String)} should be called on
+ * {@link #value()} to check its validity. If it is invalid
+ * the boolean returned by this method is undefined.
+ * @return the value of the argument as a boolean.
+ */
+ public boolean booleanValue() {
+ return value().equals(trueString);
+ }
+ }
+
+ class IntegerArgumentImpl extends ConnectorImpl.ArgumentImpl
+ implements Connector.IntegerArgument {
+ private static final long serialVersionUID = 763286081923797770L;
+ private final int min;
+ private final int max;
+
+ IntegerArgumentImpl(String name, String label, String description,
+ String value,
+ boolean mustSpecify, int min, int max) {
+ super(name, label, description, value, mustSpecify);
+ this.min = min;
+ this.max = max;
+ }
+
+ /**
+ * Sets the value of the argument.
+ * The value should be checked with {@link #isValid(int)}
+ * before setting it; invalid values will throw an exception
+ * when the connection is established - for example,
+ * on {@link LaunchingConnector#launch}
+ */
+ public void setValue(int value) {
+ setValue(stringValueOf(value));
+ }
+
+ /**
+ * Performs basic sanity check of argument.
+ * @return <code>true</code> if value represents an int that is
+ * <code>{@link #min()} <= value <= {@link #max()}</code>
+ */
+ public boolean isValid(String value) {
+ if (value == null) {
+ return false;
+ }
+ try {
+ return isValid(Integer.decode(value).intValue());
+ } catch(NumberFormatException exc) {
+ return false;
+ }
+ }
+
+ /**
+ * Performs basic sanity check of argument.
+ * @return <code>true</code> if
+ * <code>{@link #min()} <= value <= {@link #max()}</code>
+ */
+ public boolean isValid(int value) {
+ return min <= value && value <= max;
+ }
+
+ /**
+ * Return the string representation of the <code>value</code>
+ * parameter.
+ * Does not set or examine the value or the argument.
+ * @return the String representation of the
+ * int value.
+ */
+ public String stringValueOf(int value) {
+ // *** Should this be internationalized????
+ // *** Even Brian Beck was unsure if an Arabic programmer
+ // *** would expect port numbers in Arabic numerals,
+ // *** so punt for now.
+ return ""+value;
+ }
+
+ /**
+ * Return the value of the argument as a int. Since
+ * the argument may not have been set or may have an invalid
+ * value {@link #isValid(String)} should be called on
+ * {@link #value()} to check its validity. If it is invalid
+ * the int returned by this method is undefined.
+ * @return the value of the argument as a int.
+ */
+ public int intValue() {
+ if (value() == null) {
+ return 0;
+ }
+ try {
+ return Integer.decode(value()).intValue();
+ } catch(NumberFormatException exc) {
+ return 0;
+ }
+ }
+
+ /**
+ * The upper bound for the value.
+ * @return the maximum allowed value for this argument.
+ */
+ public int max() {
+ return max;
+ }
+
+ /**
+ * The lower bound for the value.
+ * @return the minimum allowed value for this argument.
+ */
+ public int min() {
+ return min;
+ }
+ }
+
+ class StringArgumentImpl extends ConnectorImpl.ArgumentImpl
+ implements Connector.StringArgument {
+ private static final long serialVersionUID = 7500484902692107464L;
+ StringArgumentImpl(String name, String label, String description,
+ String value,
+ boolean mustSpecify) {
+ super(name, label, description, value, mustSpecify);
+ }
+
+ /**
+ * Performs basic sanity check of argument.
+ * @return <code>true</code> always
+ */
+ public boolean isValid(String value) {
+ return true;
+ }
+ }
+
+ class SelectedArgumentImpl extends ConnectorImpl.ArgumentImpl
+ implements Connector.SelectedArgument {
+ private static final long serialVersionUID = -5689584530908382517L;
+ private final List<String> choices;
+
+ SelectedArgumentImpl(String name, String label, String description,
+ String value,
+ boolean mustSpecify, List<String> choices) {
+ super(name, label, description, value, mustSpecify);
+ this.choices = Collections.unmodifiableList(new ArrayList<String>(choices));
+ }
+
+ /**
+ * Return the possible values for the argument
+ * @return {@link List} of {@link String}
+ */
+ public List<String> choices() {
+ return choices;
+ }
+
+ /**
+ * Performs basic sanity check of argument.
+ * @return <code>true</code> if value is one of {@link #choices()}.
+ */
+ public boolean isValid(String value) {
+ return choices.contains(value);
+ }
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/DoubleTypeImpl.java b/src/share/classes/com/sun/tools/jdi/DoubleTypeImpl.java
new file mode 100644
index 0000000..d075999
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/DoubleTypeImpl.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1998, 1999, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class DoubleTypeImpl extends PrimitiveTypeImpl implements DoubleType {
+ DoubleTypeImpl(VirtualMachine vm) {
+ super(vm);
+ }
+
+
+ public String signature() {
+ return String.valueOf((char)JDWP.Tag.DOUBLE);
+ }
+
+ PrimitiveValue convert(PrimitiveValue value) throws InvalidTypeException {
+ return vm.mirrorOf(((PrimitiveValueImpl)value).checkedDoubleValue());
+ }
+
+}
diff --git a/src/share/classes/com/sun/tools/jdi/DoubleValueImpl.java b/src/share/classes/com/sun/tools/jdi/DoubleValueImpl.java
new file mode 100644
index 0000000..b144368
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/DoubleValueImpl.java
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class DoubleValueImpl extends PrimitiveValueImpl
+ implements DoubleValue {
+ private double value;
+
+ DoubleValueImpl(VirtualMachine aVm,double aValue) {
+ super(aVm);
+
+ value = aValue;
+ }
+
+ public boolean equals(Object obj) {
+ if ((obj != null) && (obj instanceof DoubleValue)) {
+ return (value == ((DoubleValue)obj).value()) &&
+ super.equals(obj);
+ } else {
+ return false;
+ }
+ }
+
+ public int compareTo(DoubleValue obj) {
+ double other = obj.value();
+ if (value() < other) {
+ return -1;
+ } else if (value() == other) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+
+ public int hashCode() {
+ /*
+ * TO DO: Better hash code
+ */
+ return intValue();
+ }
+
+ public Type type() {
+ return vm.theDoubleType();
+ }
+
+ public double value() {
+ return value;
+ }
+
+ public boolean booleanValue() {
+ return(value == 0.0)?false:true;
+ }
+
+ public byte byteValue() {
+ return(byte)value;
+ }
+
+ public char charValue() {
+ return(char)value;
+ }
+
+ public short shortValue() {
+ return(short)value;
+ }
+
+ public int intValue() {
+ return(int)value;
+ }
+
+ public long longValue() {
+ return(long)value;
+ }
+
+ public float floatValue() {
+ return(float)value;
+ }
+
+ public double doubleValue() {
+ return value;
+ }
+
+ byte checkedByteValue() throws InvalidTypeException {
+ if ((value > Byte.MAX_VALUE) || (value < Byte.MIN_VALUE)) {
+ throw new InvalidTypeException("Can't convert " + value + " to byte");
+ } else {
+ return super.checkedByteValue();
+ }
+ }
+
+ char checkedCharValue() throws InvalidTypeException {
+ if ((value > Character.MAX_VALUE) || (value < Character.MIN_VALUE)) {
+ throw new InvalidTypeException("Can't convert " + value + " to char");
+ } else {
+ return super.checkedCharValue();
+ }
+ }
+
+ short checkedShortValue() throws InvalidTypeException {
+ if ((value > Short.MAX_VALUE) || (value < Short.MIN_VALUE)) {
+ throw new InvalidTypeException("Can't convert " + value + " to short");
+ } else {
+ return super.checkedShortValue();
+ }
+ }
+
+ int checkedIntValue() throws InvalidTypeException {
+ if ((value > Integer.MAX_VALUE) || (value < Integer.MIN_VALUE)) {
+ throw new InvalidTypeException("Can't convert " + value + " to int");
+ } else {
+ return super.checkedIntValue();
+ }
+ }
+
+ long checkedLongValue() throws InvalidTypeException {
+ long longValue = (long)value;
+ if (longValue != value) {
+ throw new InvalidTypeException("Can't convert " + value + " to long");
+ } else {
+ return super.checkedLongValue();
+ }
+ }
+
+ float checkedFloatValue() throws InvalidTypeException {
+ float floatValue = (float)value;
+ if (floatValue != value) {
+ throw new InvalidTypeException("Can't convert " + value + " to float");
+ } else {
+ return super.checkedFloatValue();
+ }
+ }
+
+ public String toString() {
+ return "" + value;
+ }
+
+ byte typeValueKey() {
+ return JDWP.Tag.DOUBLE;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/EventQueueImpl.java b/src/share/classes/com/sun/tools/jdi/EventQueueImpl.java
new file mode 100644
index 0000000..ca8e33f
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/EventQueueImpl.java
@@ -0,0 +1,242 @@
+/*
+ * Copyright (c) 1998, 2006, 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.tools.jdi;
+
+import com.sun.jdi.*;
+import com.sun.jdi.event.EventQueue;
+import com.sun.jdi.event.EventSet;
+
+import java.util.*;
+
+public class EventQueueImpl extends MirrorImpl implements EventQueue {
+
+ /*
+ * Note this is not a synchronized list. Iteration/update should be
+ * protected through the 'this' monitor.
+ */
+ LinkedList<EventSet> eventSets = new LinkedList<EventSet>();
+
+ TargetVM target;
+ boolean closed = false;
+
+ EventQueueImpl(VirtualMachine vm, TargetVM target) {
+ super(vm);
+ this.target = target;
+ target.addEventQueue(this);
+ }
+
+ /*
+ * Override superclass back to default equality
+ */
+ public boolean equals(Object obj) {
+ return this == obj;
+ }
+
+ public int hashCode() {
+ return System.identityHashCode(this);
+ }
+
+ synchronized void enqueue(EventSet eventSet) {
+ eventSets.add(eventSet);
+ notifyAll();
+ }
+
+ synchronized int size() {
+ return eventSets.size();
+ }
+
+ synchronized void close() {
+ if (!closed) {
+ closed = true; // OK for this the be first since synchronized
+
+ // place VMDisconnectEvent into queue
+ enqueue(new EventSetImpl(vm,
+ (byte)JDWP.EventKind.VM_DISCONNECTED));
+ }
+ }
+
+ public EventSet remove() throws InterruptedException {
+ return remove(0);
+ }
+
+ /**
+ * Filter out events not for user's eyes.
+ * Then filter out empty sets.
+ */
+ public EventSet remove(long timeout) throws InterruptedException {
+ if (timeout < 0) {
+ throw new IllegalArgumentException("Timeout cannot be negative");
+ }
+
+ EventSet eventSet;
+ while (true) {
+ EventSetImpl fullEventSet = removeUnfiltered(timeout);
+ if (fullEventSet == null) {
+ eventSet = null; // timeout
+ break;
+ }
+ /*
+ * Remove events from the event set for which
+ * there is no corresponding enabled request (
+ * this includes our internally requested events.)
+ * This never returns null
+ */
+ eventSet = fullEventSet.userFilter();
+ if (!eventSet.isEmpty()) {
+ break;
+ }
+ }
+
+ if ((eventSet != null) && (eventSet.suspendPolicy() == JDWP.SuspendPolicy.ALL)) {
+ vm.notifySuspend();
+ }
+
+ return eventSet;
+ }
+
+ EventSet removeInternal() throws InterruptedException {
+ EventSet eventSet;
+ do {
+ // Waiting forever, so removeUnfiltered() is never null
+ eventSet = removeUnfiltered(0).internalFilter();
+ } while (eventSet == null || eventSet.isEmpty());
+
+ /*
+ * Currently, no internal events are requested with a suspend
+ * policy other than none, so we don't check for notifySuspend()
+ * here. If this changes in the future, there is much
+ * infrastructure that needs to be updated.
+ */
+
+ return eventSet;
+ }
+
+ private TimerThread startTimerThread(long timeout) {
+ TimerThread thread = new TimerThread(timeout);
+ thread.setDaemon(true);
+ thread.start();
+ return thread;
+ }
+
+ private boolean shouldWait(TimerThread timerThread) {
+ return !closed && eventSets.isEmpty() &&
+ ((timerThread == null) ? true : !timerThread.timedOut());
+ }
+
+ private EventSetImpl removeUnfiltered(long timeout)
+ throws InterruptedException {
+ EventSetImpl eventSet = null;
+
+ /*
+ * Make sure the VM has completed initialization before
+ * trying to build events.
+ */
+ vm.waitInitCompletion();
+
+ synchronized(this) {
+ if (!eventSets.isEmpty()) {
+ /*
+ * If there's already something there, no need
+ * for anything elaborate.
+ */
+ eventSet = (EventSetImpl)eventSets.removeFirst();
+ } else {
+ /*
+ * If a timeout was specified, create a thread to
+ * notify this one when a timeout
+ * occurs. We can't use the timed version of wait()
+ * because it is possible for multiple enqueue() calls
+ * before we see something in the eventSet queue
+ * (this is possible when multiple threads call
+ * remove() concurrently -- not a great idea, but
+ * it should be supported). Even if enqueue() did a
+ * notify() instead of notifyAll() we are not able to
+ * use a timed wait because there's no way to distinguish
+ * a timeout from a notify. That limitation implies a
+ * possible race condition between a timed out thread
+ * and a notified thread.
+ */
+ TimerThread timerThread = null;
+ try {
+ if (timeout > 0) {
+ timerThread = startTimerThread(timeout);
+ }
+
+ while (shouldWait(timerThread)) {
+ this.wait();
+ }
+ } finally {
+ if ((timerThread != null) && !timerThread.timedOut()) {
+ timerThread.interrupt();
+ }
+ }
+
+ if (eventSets.isEmpty()) {
+ if (closed) {
+ throw new VMDisconnectedException();
+ }
+ } else {
+ eventSet = (EventSetImpl)eventSets.removeFirst();
+ }
+ }
+ }
+
+ // The build is synchronized on the event set, don't hold
+ // the queue lock.
+ if (eventSet != null) {
+ target.notifyDequeueEventSet();
+ eventSet.build();
+ }
+ return eventSet;
+ }
+
+ private class TimerThread extends Thread {
+ private boolean timedOut = false;
+ private long timeout;
+
+ TimerThread(long timeout) {
+ super(vm.threadGroupForJDI(), "JDI Event Queue Timer");
+ this.timeout = timeout;
+ }
+
+ boolean timedOut() {
+ return timedOut;
+ }
+
+ public void run() {
+ try {
+ Thread.sleep(timeout);
+ EventQueueImpl queue = EventQueueImpl.this;
+ synchronized(queue) {
+ timedOut = true;
+ queue.notifyAll();
+ }
+ } catch (InterruptedException e) {
+ // Exit without notifying
+ }
+ }
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java b/src/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java
new file mode 100644
index 0000000..1157216
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java
@@ -0,0 +1,954 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.*;
+import com.sun.tools.jdi.JDWP;
+
+import java.util.*;
+
+/**
+ * This interface is used to create and remove Breakpoints, Watchpoints,
+ * etc.
+ * It include implementations of all the request interfaces..
+ */
+// Warnings from List filters and List[] requestLists is hard to fix.
+// Remove SuppressWarning when we fix the warnings from List filters
+// and List[] requestLists. The generic array is not supported.
+@SuppressWarnings("unchecked")
+class EventRequestManagerImpl extends MirrorImpl
+ implements EventRequestManager
+{
+ List<? extends EventRequest>[] requestLists;
+ private static int methodExitEventCmd = 0;
+
+ static int JDWPtoJDISuspendPolicy(byte jdwpPolicy) {
+ switch(jdwpPolicy) {
+ case JDWP.SuspendPolicy.ALL:
+ return EventRequest.SUSPEND_ALL;
+ case JDWP.SuspendPolicy.EVENT_THREAD:
+ return EventRequest.SUSPEND_EVENT_THREAD;
+ case JDWP.SuspendPolicy.NONE:
+ return EventRequest.SUSPEND_NONE;
+ default:
+ throw new IllegalArgumentException("Illegal policy constant: " + jdwpPolicy);
+ }
+ }
+
+ static byte JDItoJDWPSuspendPolicy(int jdiPolicy) {
+ switch(jdiPolicy) {
+ case EventRequest.SUSPEND_ALL:
+ return JDWP.SuspendPolicy.ALL;
+ case EventRequest.SUSPEND_EVENT_THREAD:
+ return JDWP.SuspendPolicy.EVENT_THREAD;
+ case EventRequest.SUSPEND_NONE:
+ return JDWP.SuspendPolicy.NONE;
+ default:
+ throw new IllegalArgumentException("Illegal policy constant: " + jdiPolicy);
+ }
+ }
+
+ /*
+ * Override superclass back to default equality
+ */
+ public boolean equals(Object obj) {
+ return this == obj;
+ }
+
+ public int hashCode() {
+ return System.identityHashCode(this);
+ }
+
+ abstract class EventRequestImpl extends MirrorImpl implements EventRequest {
+ int id;
+
+ /*
+ * This list is not protected by a synchronized wrapper. All
+ * access/modification should be protected by synchronizing on
+ * the enclosing instance of EventRequestImpl.
+ */
+ List<Object> filters = new ArrayList<>();
+
+ boolean isEnabled = false;
+ boolean deleted = false;
+ byte suspendPolicy = JDWP.SuspendPolicy.ALL;
+ private Map<Object, Object> clientProperties = null;
+
+ EventRequestImpl() {
+ super(EventRequestManagerImpl.this.vm);
+ }
+
+
+ /*
+ * Override superclass back to default equality
+ */
+ public boolean equals(Object obj) {
+ return this == obj;
+ }
+
+ public int hashCode() {
+ return System.identityHashCode(this);
+ }
+
+ abstract int eventCmd();
+
+ InvalidRequestStateException invalidState() {
+ return new InvalidRequestStateException(toString());
+ }
+
+ String state() {
+ return deleted? " (deleted)" :
+ (isEnabled()? " (enabled)" : " (disabled)");
+ }
+
+ /**
+ * @return all the event request of this kind
+ */
+ List requestList() {
+ return EventRequestManagerImpl.this.requestList(eventCmd());
+ }
+
+ /**
+ * delete the event request
+ */
+ void delete() {
+ if (!deleted) {
+ requestList().remove(this);
+ disable(); /* must do BEFORE delete */
+ deleted = true;
+ }
+ }
+
+ public boolean isEnabled() {
+ return isEnabled;
+ }
+
+ public void enable() {
+ setEnabled(true);
+ }
+
+ public void disable() {
+ setEnabled(false);
+ }
+
+ public synchronized void setEnabled(boolean val) {
+ if (deleted) {
+ throw invalidState();
+ } else {
+ if (val != isEnabled) {
+ if (isEnabled) {
+ clear();
+ } else {
+ set();
+ }
+ }
+ }
+ }
+
+ public synchronized void addCountFilter(int count) {
+ if (isEnabled() || deleted) {
+ throw invalidState();
+ }
+ if (count < 1) {
+ throw new IllegalArgumentException("count is less than one");
+ }
+ filters.add(JDWP.EventRequest.Set.Modifier.Count.create(count));
+ }
+
+ public void setSuspendPolicy(int policy) {
+ if (isEnabled() || deleted) {
+ throw invalidState();
+ }
+ suspendPolicy = JDItoJDWPSuspendPolicy(policy);
+ }
+
+ public int suspendPolicy() {
+ return JDWPtoJDISuspendPolicy(suspendPolicy);
+ }
+
+ /**
+ * set (enable) the event request
+ */
+ synchronized void set() {
+ JDWP.EventRequest.Set.Modifier[] mods =
+ filters.toArray(
+ new JDWP.EventRequest.Set.Modifier[filters.size()]);
+ try {
+ id = JDWP.EventRequest.Set.process(vm, (byte)eventCmd(),
+ suspendPolicy, mods).requestID;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ isEnabled = true;
+ }
+
+ synchronized void clear() {
+ try {
+ JDWP.EventRequest.Clear.process(vm, (byte)eventCmd(), id);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ isEnabled = false;
+ }
+
+ /**
+ * @return a small Map
+ * @see #putProperty
+ * @see #getProperty
+ */
+ private Map<Object, Object> getProperties() {
+ if (clientProperties == null) {
+ clientProperties = new HashMap<Object, Object>(2);
+ }
+ return clientProperties;
+ }
+
+ /**
+ * Returns the value of the property with the specified key. Only
+ * properties added with <code>putProperty</code> will return
+ * a non-null value.
+ *
+ * @return the value of this property or null
+ * @see #putProperty
+ */
+ public final Object getProperty(Object key) {
+ if (clientProperties == null) {
+ return null;
+ } else {
+ return getProperties().get(key);
+ }
+ }
+
+ /**
+ * Add an arbitrary key/value "property" to this component.
+ *
+ * @see #getProperty
+ */
+ public final void putProperty(Object key, Object value) {
+ if (value != null) {
+ getProperties().put(key, value);
+ } else {
+ getProperties().remove(key);
+ }
+ }
+ }
+
+ abstract class ThreadVisibleEventRequestImpl extends EventRequestImpl {
+ public synchronized void addThreadFilter(ThreadReference thread) {
+ validateMirror(thread);
+ if (isEnabled() || deleted) {
+ throw invalidState();
+ }
+ filters.add(JDWP.EventRequest.Set.Modifier.ThreadOnly
+ .create((ThreadReferenceImpl)thread));
+ }
+ }
+
+ abstract class ClassVisibleEventRequestImpl
+ extends ThreadVisibleEventRequestImpl {
+ public synchronized void addClassFilter(ReferenceType clazz) {
+ validateMirror(clazz);
+ if (isEnabled() || deleted) {
+ throw invalidState();
+ }
+ filters.add(JDWP.EventRequest.Set.Modifier.ClassOnly
+ .create((ReferenceTypeImpl)clazz));
+ }
+
+ public synchronized void addClassFilter(String classPattern) {
+ if (isEnabled() || deleted) {
+ throw invalidState();
+ }
+ if (classPattern == null) {
+ throw new NullPointerException();
+ }
+ filters.add(JDWP.EventRequest.Set.Modifier.ClassMatch
+ .create(classPattern));
+ }
+
+ public synchronized void addClassExclusionFilter(String classPattern) {
+ if (isEnabled() || deleted) {
+ throw invalidState();
+ }
+ if (classPattern == null) {
+ throw new NullPointerException();
+ }
+ filters.add(JDWP.EventRequest.Set.Modifier.ClassExclude
+ .create(classPattern));
+ }
+
+ public synchronized void addInstanceFilter(ObjectReference instance) {
+ validateMirror(instance);
+ if (isEnabled() || deleted) {
+ throw invalidState();
+ }
+ if (!vm.canUseInstanceFilters()) {
+ throw new UnsupportedOperationException(
+ "target does not support instance filters");
+ }
+ filters.add(JDWP.EventRequest.Set.Modifier.InstanceOnly
+ .create((ObjectReferenceImpl)instance));
+ }
+ }
+
+ class BreakpointRequestImpl extends ClassVisibleEventRequestImpl
+ implements BreakpointRequest {
+ private final Location location;
+
+ BreakpointRequestImpl(Location location) {
+ this.location = location;
+ filters.add(0,JDWP.EventRequest.Set.Modifier.LocationOnly
+ .create(location));
+ requestList().add(this);
+ }
+
+ public Location location() {
+ return location;
+ }
+
+ int eventCmd() {
+ return JDWP.EventKind.BREAKPOINT;
+ }
+
+ public String toString() {
+ return "breakpoint request " + location() + state();
+ }
+ }
+
+ class ClassPrepareRequestImpl extends ClassVisibleEventRequestImpl
+ implements ClassPrepareRequest {
+ ClassPrepareRequestImpl() {
+ requestList().add(this);
+ }
+
+ int eventCmd() {
+ return JDWP.EventKind.CLASS_PREPARE;
+ }
+
+ public synchronized void addSourceNameFilter(String sourceNamePattern) {
+ if (isEnabled() || deleted) {
+ throw invalidState();
+ }
+ if (!vm.canUseSourceNameFilters()) {
+ throw new UnsupportedOperationException(
+ "target does not support source name filters");
+ }
+ if (sourceNamePattern == null) {
+ throw new NullPointerException();
+ }
+
+ filters.add(JDWP.EventRequest.Set.Modifier.SourceNameMatch
+ .create(sourceNamePattern));
+ }
+
+ public String toString() {
+ return "class prepare request " + state();
+ }
+ }
+
+ class ClassUnloadRequestImpl extends ClassVisibleEventRequestImpl
+ implements ClassUnloadRequest {
+ ClassUnloadRequestImpl() {
+ requestList().add(this);
+ }
+
+ int eventCmd() {
+ return JDWP.EventKind.CLASS_UNLOAD;
+ }
+
+ public String toString() {
+ return "class unload request " + state();
+ }
+ }
+
+ class ExceptionRequestImpl extends ClassVisibleEventRequestImpl
+ implements ExceptionRequest {
+ ReferenceType exception = null;
+ boolean caught = true;
+ boolean uncaught = true;
+
+ ExceptionRequestImpl(ReferenceType refType,
+ boolean notifyCaught, boolean notifyUncaught) {
+ exception = refType;
+ caught = notifyCaught;
+ uncaught = notifyUncaught;
+ {
+ ReferenceTypeImpl exc;
+ if (exception == null) {
+ exc = new ClassTypeImpl(vm, 0);
+ } else {
+ exc = (ReferenceTypeImpl)exception;
+ }
+ filters.add(JDWP.EventRequest.Set.Modifier.ExceptionOnly.
+ create(exc, caught, uncaught));
+ }
+ requestList().add(this);
+ }
+
+ public ReferenceType exception() {
+ return exception;
+ }
+
+ public boolean notifyCaught() {
+ return caught;
+ }
+
+ public boolean notifyUncaught() {
+ return uncaught;
+ }
+
+ int eventCmd() {
+ return JDWP.EventKind.EXCEPTION;
+ }
+
+ public String toString() {
+ return "exception request " + exception() + state();
+ }
+ }
+
+ class MethodEntryRequestImpl extends ClassVisibleEventRequestImpl
+ implements MethodEntryRequest {
+ MethodEntryRequestImpl() {
+ requestList().add(this);
+ }
+
+ int eventCmd() {
+ return JDWP.EventKind.METHOD_ENTRY;
+ }
+
+ public String toString() {
+ return "method entry request " + state();
+ }
+ }
+
+ class MethodExitRequestImpl extends ClassVisibleEventRequestImpl
+ implements MethodExitRequest {
+ MethodExitRequestImpl() {
+ if (methodExitEventCmd == 0) {
+ /*
+ * If we can get return values, then we always get them.
+ * Thus, for JDI MethodExitRequests, we always use the
+ * same JDWP EventKind. Here we decide which to use and
+ * save it so that it will be used for all future
+ * MethodExitRequests.
+ *
+ * This call to canGetMethodReturnValues can't
+ * be done in the EventRequestManager ctor because that is too early.
+ */
+ if (vm.canGetMethodReturnValues()) {
+ methodExitEventCmd = JDWP.EventKind.METHOD_EXIT_WITH_RETURN_VALUE;
+ } else {
+ methodExitEventCmd = JDWP.EventKind.METHOD_EXIT;
+ }
+ }
+ requestList().add(this);
+ }
+
+ int eventCmd() {
+ return EventRequestManagerImpl.methodExitEventCmd;
+ }
+
+ public String toString() {
+ return "method exit request " + state();
+ }
+ }
+
+ class MonitorContendedEnterRequestImpl extends ClassVisibleEventRequestImpl
+ implements MonitorContendedEnterRequest {
+ MonitorContendedEnterRequestImpl() {
+ requestList().add(this);
+ }
+
+ int eventCmd() {
+ return JDWP.EventKind.MONITOR_CONTENDED_ENTER;
+ }
+
+ public String toString() {
+ return "monitor contended enter request " + state();
+ }
+ }
+
+ class MonitorContendedEnteredRequestImpl extends ClassVisibleEventRequestImpl
+ implements MonitorContendedEnteredRequest {
+ MonitorContendedEnteredRequestImpl() {
+ requestList().add(this);
+ }
+
+ int eventCmd() {
+ return JDWP.EventKind.MONITOR_CONTENDED_ENTERED;
+ }
+
+ public String toString() {
+ return "monitor contended entered request " + state();
+ }
+ }
+
+ class MonitorWaitRequestImpl extends ClassVisibleEventRequestImpl
+ implements MonitorWaitRequest {
+ MonitorWaitRequestImpl() {
+ requestList().add(this);
+ }
+
+ int eventCmd() {
+ return JDWP.EventKind.MONITOR_WAIT;
+ }
+
+ public String toString() {
+ return "monitor wait request " + state();
+ }
+ }
+
+ class MonitorWaitedRequestImpl extends ClassVisibleEventRequestImpl
+ implements MonitorWaitedRequest {
+ MonitorWaitedRequestImpl() {
+ requestList().add(this);
+ }
+
+ int eventCmd() {
+ return JDWP.EventKind.MONITOR_WAITED;
+ }
+
+ public String toString() {
+ return "monitor waited request " + state();
+ }
+ }
+
+ class StepRequestImpl extends ClassVisibleEventRequestImpl
+ implements StepRequest {
+ ThreadReferenceImpl thread;
+ int size;
+ int depth;
+
+ StepRequestImpl(ThreadReference thread, int size, int depth) {
+ this.thread = (ThreadReferenceImpl)thread;
+ this.size = size;
+ this.depth = depth;
+
+ /*
+ * Translate size and depth to corresponding JDWP values.
+ */
+ int jdwpSize;
+ switch (size) {
+ case STEP_MIN:
+ jdwpSize = JDWP.StepSize.MIN;
+ break;
+ case STEP_LINE:
+ jdwpSize = JDWP.StepSize.LINE;
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid step size");
+ }
+
+ int jdwpDepth;
+ switch (depth) {
+ case STEP_INTO:
+ jdwpDepth = JDWP.StepDepth.INTO;
+ break;
+ case STEP_OVER:
+ jdwpDepth = JDWP.StepDepth.OVER;
+ break;
+ case STEP_OUT:
+ jdwpDepth = JDWP.StepDepth.OUT;
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid step depth");
+ }
+
+ /*
+ * Make sure this isn't a duplicate
+ */
+ List<StepRequest> requests = stepRequests();
+ Iterator<StepRequest> iter = requests.iterator();
+ while (iter.hasNext()) {
+ StepRequest request = iter.next();
+ if ((request != this) &&
+ request.isEnabled() &&
+ request.thread().equals(thread)) {
+ throw new DuplicateRequestException(
+ "Only one step request allowed per thread");
+ }
+ }
+
+ filters.add(JDWP.EventRequest.Set.Modifier.Step.
+ create(this.thread, jdwpSize, jdwpDepth));
+ requestList().add(this);
+
+ }
+ public int depth() {
+ return depth;
+ }
+
+ public int size() {
+ return size;
+ }
+
+ public ThreadReference thread() {
+ return thread;
+ }
+
+ int eventCmd() {
+ return JDWP.EventKind.SINGLE_STEP;
+ }
+
+ public String toString() {
+ return "step request " + thread() + state();
+ }
+ }
+
+ class ThreadDeathRequestImpl extends ThreadVisibleEventRequestImpl
+ implements ThreadDeathRequest {
+ ThreadDeathRequestImpl() {
+ requestList().add(this);
+ }
+
+ int eventCmd() {
+ return JDWP.EventKind.THREAD_DEATH;
+ }
+
+ public String toString() {
+ return "thread death request " + state();
+ }
+ }
+
+ class ThreadStartRequestImpl extends ThreadVisibleEventRequestImpl
+ implements ThreadStartRequest {
+ ThreadStartRequestImpl() {
+ requestList().add(this);
+ }
+
+ int eventCmd() {
+ return JDWP.EventKind.THREAD_START;
+ }
+
+ public String toString() {
+ return "thread start request " + state();
+ }
+ }
+
+ abstract class WatchpointRequestImpl extends ClassVisibleEventRequestImpl
+ implements WatchpointRequest {
+ final Field field;
+
+ WatchpointRequestImpl(Field field) {
+ this.field = field;
+ filters.add(0,
+ JDWP.EventRequest.Set.Modifier.FieldOnly.create(
+ (ReferenceTypeImpl)field.declaringType(),
+ ((FieldImpl)field).ref()));
+ }
+
+ public Field field() {
+ return field;
+ }
+ }
+
+ class AccessWatchpointRequestImpl extends WatchpointRequestImpl
+ implements AccessWatchpointRequest {
+ AccessWatchpointRequestImpl(Field field) {
+ super(field);
+ requestList().add(this);
+ }
+
+ int eventCmd() {
+ return JDWP.EventKind.FIELD_ACCESS;
+ }
+
+ public String toString() {
+ return "access watchpoint request " + field + state();
+ }
+ }
+
+ class ModificationWatchpointRequestImpl extends WatchpointRequestImpl
+ implements ModificationWatchpointRequest {
+ ModificationWatchpointRequestImpl(Field field) {
+ super(field);
+ requestList().add(this);
+ }
+
+ int eventCmd() {
+ return JDWP.EventKind.FIELD_MODIFICATION;
+ }
+
+ public String toString() {
+ return "modification watchpoint request " + field + state();
+ }
+ }
+
+ class VMDeathRequestImpl extends EventRequestImpl
+ implements VMDeathRequest {
+ VMDeathRequestImpl() {
+ requestList().add(this);
+ }
+
+ int eventCmd() {
+ return JDWP.EventKind.VM_DEATH;
+ }
+
+ public String toString() {
+ return "VM death request " + state();
+ }
+ }
+
+ /**
+ * Constructor.
+ */
+ EventRequestManagerImpl(VirtualMachine vm) {
+ super(vm);
+ java.lang.reflect.Field[] ekinds =
+ JDWP.EventKind.class.getDeclaredFields();
+ int highest = 0;
+ for (int i = 0; i < ekinds.length; ++i) {
+ int val;
+ try {
+ val = ekinds[i].getInt(null);
+ } catch (IllegalAccessException exc) {
+ throw new RuntimeException("Got: " + exc);
+ }
+ if (val > highest) {
+ highest = val;
+ }
+ }
+ requestLists = new List[highest+1];
+ for (int i=0; i <= highest; i++) {
+ requestLists[i] = new ArrayList<>();
+ }
+ }
+
+ public ClassPrepareRequest createClassPrepareRequest() {
+ return new ClassPrepareRequestImpl();
+ }
+
+ public ClassUnloadRequest createClassUnloadRequest() {
+ return new ClassUnloadRequestImpl();
+ }
+
+ public ExceptionRequest createExceptionRequest(ReferenceType refType,
+ boolean notifyCaught,
+ boolean notifyUncaught) {
+ validateMirrorOrNull(refType);
+ return new ExceptionRequestImpl(refType, notifyCaught, notifyUncaught);
+ }
+
+ public StepRequest createStepRequest(ThreadReference thread,
+ int size, int depth) {
+ validateMirror(thread);
+ return new StepRequestImpl(thread, size, depth);
+ }
+
+ public ThreadDeathRequest createThreadDeathRequest() {
+ return new ThreadDeathRequestImpl();
+ }
+
+ public ThreadStartRequest createThreadStartRequest() {
+ return new ThreadStartRequestImpl();
+ }
+
+ public MethodEntryRequest createMethodEntryRequest() {
+ return new MethodEntryRequestImpl();
+ }
+
+ public MethodExitRequest createMethodExitRequest() {
+ return new MethodExitRequestImpl();
+ }
+
+ public MonitorContendedEnterRequest createMonitorContendedEnterRequest() {
+ if (!vm.canRequestMonitorEvents()) {
+ throw new UnsupportedOperationException(
+ "target VM does not support requesting Monitor events");
+ }
+ return new MonitorContendedEnterRequestImpl();
+ }
+
+ public MonitorContendedEnteredRequest createMonitorContendedEnteredRequest() {
+ if (!vm.canRequestMonitorEvents()) {
+ throw new UnsupportedOperationException(
+ "target VM does not support requesting Monitor events");
+ }
+ return new MonitorContendedEnteredRequestImpl();
+ }
+
+ public MonitorWaitRequest createMonitorWaitRequest() {
+ if (!vm.canRequestMonitorEvents()) {
+ throw new UnsupportedOperationException(
+ "target VM does not support requesting Monitor events");
+ }
+ return new MonitorWaitRequestImpl();
+ }
+
+ public MonitorWaitedRequest createMonitorWaitedRequest() {
+ if (!vm.canRequestMonitorEvents()) {
+ throw new UnsupportedOperationException(
+ "target VM does not support requesting Monitor events");
+ }
+ return new MonitorWaitedRequestImpl();
+ }
+
+ public BreakpointRequest createBreakpointRequest(Location location) {
+ validateMirror(location);
+ if (location.codeIndex() == -1) {
+ throw new NativeMethodException("Cannot set breakpoints on native methods");
+ }
+ return new BreakpointRequestImpl(location);
+ }
+
+ public AccessWatchpointRequest
+ createAccessWatchpointRequest(Field field) {
+ validateMirror(field);
+ if (!vm.canWatchFieldAccess()) {
+ throw new UnsupportedOperationException(
+ "target VM does not support access watchpoints");
+ }
+ return new AccessWatchpointRequestImpl(field);
+ }
+
+ public ModificationWatchpointRequest
+ createModificationWatchpointRequest(Field field) {
+ validateMirror(field);
+ if (!vm.canWatchFieldModification()) {
+ throw new UnsupportedOperationException(
+ "target VM does not support modification watchpoints");
+ }
+ return new ModificationWatchpointRequestImpl(field);
+ }
+
+ public VMDeathRequest createVMDeathRequest() {
+ if (!vm.canRequestVMDeathEvent()) {
+ throw new UnsupportedOperationException(
+ "target VM does not support requesting VM death events");
+ }
+ return new VMDeathRequestImpl();
+ }
+
+ public void deleteEventRequest(EventRequest eventRequest) {
+ validateMirror(eventRequest);
+ ((EventRequestImpl)eventRequest).delete();
+ }
+
+ public void deleteEventRequests(List<? extends EventRequest> eventRequests) {
+ validateMirrors(eventRequests);
+ // copy the eventRequests to avoid ConcurrentModificationException
+ Iterator<? extends EventRequest> iter = (new ArrayList<>(eventRequests)).iterator();
+ while (iter.hasNext()) {
+ ((EventRequestImpl)iter.next()).delete();
+ }
+ }
+
+ public void deleteAllBreakpoints() {
+ requestList(JDWP.EventKind.BREAKPOINT).clear();
+
+ try {
+ JDWP.EventRequest.ClearAllBreakpoints.process(vm);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+
+ public List<StepRequest> stepRequests() {
+ return (List<StepRequest>)unmodifiableRequestList(JDWP.EventKind.SINGLE_STEP);
+ }
+
+ public List<ClassPrepareRequest> classPrepareRequests() {
+ return (List<ClassPrepareRequest>)unmodifiableRequestList(JDWP.EventKind.CLASS_PREPARE);
+ }
+
+ public List<ClassUnloadRequest> classUnloadRequests() {
+ return (List<ClassUnloadRequest>)unmodifiableRequestList(JDWP.EventKind.CLASS_UNLOAD);
+ }
+
+ public List<ThreadStartRequest> threadStartRequests() {
+ return (List<ThreadStartRequest>)unmodifiableRequestList(JDWP.EventKind.THREAD_START);
+ }
+
+ public List<ThreadDeathRequest> threadDeathRequests() {
+ return (List<ThreadDeathRequest>)unmodifiableRequestList(JDWP.EventKind.THREAD_DEATH);
+ }
+
+ public List<ExceptionRequest> exceptionRequests() {
+ return (List<ExceptionRequest>)unmodifiableRequestList(JDWP.EventKind.EXCEPTION);
+ }
+
+ public List<BreakpointRequest> breakpointRequests() {
+ return (List<BreakpointRequest>)unmodifiableRequestList(JDWP.EventKind.BREAKPOINT);
+ }
+
+ public List<AccessWatchpointRequest> accessWatchpointRequests() {
+ return (List<AccessWatchpointRequest>)unmodifiableRequestList(JDWP.EventKind.FIELD_ACCESS);
+ }
+
+ public List<ModificationWatchpointRequest> modificationWatchpointRequests() {
+ return (List<ModificationWatchpointRequest>)unmodifiableRequestList(JDWP.EventKind.FIELD_MODIFICATION);
+ }
+
+ public List<MethodEntryRequest> methodEntryRequests() {
+ return (List<MethodEntryRequest>)unmodifiableRequestList(JDWP.EventKind.METHOD_ENTRY);
+ }
+
+ public List<MethodExitRequest> methodExitRequests() {
+ return (List<MethodExitRequest>)unmodifiableRequestList(
+ EventRequestManagerImpl.methodExitEventCmd);
+ }
+
+ public List<MonitorContendedEnterRequest> monitorContendedEnterRequests() {
+ return (List<MonitorContendedEnterRequest>)unmodifiableRequestList(JDWP.EventKind.MONITOR_CONTENDED_ENTER);
+ }
+
+ public List<MonitorContendedEnteredRequest> monitorContendedEnteredRequests() {
+ return (List<MonitorContendedEnteredRequest>)unmodifiableRequestList(JDWP.EventKind.MONITOR_CONTENDED_ENTERED);
+ }
+
+ public List<MonitorWaitRequest> monitorWaitRequests() {
+ return (List<MonitorWaitRequest>)unmodifiableRequestList(JDWP.EventKind.MONITOR_WAIT);
+ }
+
+ public List<MonitorWaitedRequest> monitorWaitedRequests() {
+ return (List<MonitorWaitedRequest>)unmodifiableRequestList(JDWP.EventKind.MONITOR_WAITED);
+ }
+
+ public List<VMDeathRequest> vmDeathRequests() {
+ return (List<VMDeathRequest>)unmodifiableRequestList(JDWP.EventKind.VM_DEATH);
+ }
+
+ List<? extends EventRequest> unmodifiableRequestList(int eventCmd) {
+ return Collections.unmodifiableList(requestList(eventCmd));
+ }
+
+ EventRequest request(int eventCmd, int requestId) {
+ List<? extends EventRequest> rl = requestList(eventCmd);
+ for (int i = rl.size() - 1; i >= 0; i--) {
+ EventRequestImpl er = (EventRequestImpl)rl.get(i);
+ if (er.id == requestId) {
+ return er;
+ }
+ }
+ return null;
+ }
+
+ List<? extends EventRequest> requestList(int eventCmd) {
+ return requestLists[eventCmd];
+ }
+
+}
diff --git a/src/share/classes/com/sun/tools/jdi/EventSetImpl.java b/src/share/classes/com/sun/tools/jdi/EventSetImpl.java
new file mode 100644
index 0000000..d907e95
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/EventSetImpl.java
@@ -0,0 +1,879 @@
+/*
+ * Copyright (c) 1998, 2013, 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.tools.jdi;
+
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+import com.sun.jdi.request.*;
+
+import java.util.*;
+enum EventDestination {UNKNOWN_EVENT, INTERNAL_EVENT, CLIENT_EVENT};
+
+/*
+ * An EventSet is normally created by the transport reader thread when
+ * it reads a JDWP Composite command. The constructor doesn't unpack
+ * the events contained in the Composite command and create EventImpls
+ * for them because that process might involve calling back into the back-end
+ * which should not be done by the transport reader thread. Instead,
+ * the raw bytes of the packet are read and stored in the EventSet.
+ * The EventSet is then added to each EventQueue. When an EventSet is
+ * removed from an EventQueue, the EventSetImpl.build() method is called.
+ * This method reads the packet bytes and creates the actual EventImpl objects.
+ * build() also filters out events for our internal handler and puts them in
+ * their own EventSet. This means that the EventImpls that are in the EventSet
+ * that is on the queues are all for client requests.
+ */
+public class EventSetImpl extends ArrayList<Event> implements EventSet {
+ private static final long serialVersionUID = -4857338819787924570L;
+ private VirtualMachineImpl vm; // we implement Mirror
+ private Packet pkt;
+ private byte suspendPolicy;
+ private EventSetImpl internalEventSet;
+
+ public String toString() {
+ String string = "event set, policy:" + suspendPolicy +
+ ", count:" + this.size() + " = {";
+ boolean first = true;
+ for (Event event : this) {
+ if (!first) {
+ string += ", ";
+ }
+ string += event.toString();
+ first = false;
+ }
+ string += "}";
+ return string;
+ }
+
+ abstract class EventImpl extends MirrorImpl implements Event {
+
+ private final byte eventCmd;
+ private final int requestID;
+ // This is set only for client requests, not internal requests.
+ private final EventRequest request;
+
+ /**
+ * Constructor for events.
+ */
+ protected EventImpl(JDWP.Event.Composite.Events.EventsCommon evt,
+ int requestID) {
+ super(EventSetImpl.this.vm);
+ this.eventCmd = evt.eventKind();
+ this.requestID = requestID;
+ EventRequestManagerImpl ermi = EventSetImpl.this.
+ vm.eventRequestManagerImpl();
+ this.request = ermi.request(eventCmd, requestID);
+ }
+
+ /*
+ * Override superclass back to default equality
+ */
+ public boolean equals(Object obj) {
+ return this == obj;
+ }
+
+ public int hashCode() {
+ return System.identityHashCode(this);
+ }
+
+ /**
+ * Constructor for VM disconnected events.
+ */
+ protected EventImpl(byte eventCmd) {
+ super(EventSetImpl.this.vm);
+ this.eventCmd = eventCmd;
+ this.requestID = 0;
+ this.request = null;
+ }
+
+ public EventRequest request() {
+ return request;
+ }
+
+ int requestID() {
+ return requestID;
+ }
+
+ EventDestination destination() {
+ /*
+ * We need to decide if this event is for
+ * 1. an internal request
+ * 2. a client request that is no longer available, ie
+ * it has been deleted, or disabled and re-enabled
+ * which gives it a new ID.
+ * 3. a current client request that is disabled
+ * 4. a current enabled client request.
+ *
+ * We will filter this set into a set
+ * that contains only 1s for our internal queue
+ * and a set that contains only 4s for our client queue.
+ * If we get an EventSet that contains only 2 and 3
+ * then we have to resume it if it is not SUSPEND_NONE
+ * because no one else will.
+ */
+ if (requestID == 0) {
+ /* An unsolicited event. These have traditionally
+ * been treated as client events.
+ */
+ return EventDestination.CLIENT_EVENT;
+ }
+
+ // Is this an event for a current client request?
+ if (request == null) {
+ // Nope. Is it an event for an internal request?
+ EventRequestManagerImpl ermi = this.vm.getInternalEventRequestManager();
+ if (ermi.request(eventCmd, requestID) != null) {
+ // Yep
+ return EventDestination.INTERNAL_EVENT;
+ }
+ return EventDestination.UNKNOWN_EVENT;
+ }
+
+ // We found a client request
+ if (request.isEnabled()) {
+ return EventDestination.CLIENT_EVENT;
+ }
+ return EventDestination.UNKNOWN_EVENT;
+ }
+
+ abstract String eventName();
+
+ public String toString() {
+ return eventName();
+ }
+
+ }
+
+ abstract class ThreadedEventImpl extends EventImpl {
+ private ThreadReference thread;
+
+ ThreadedEventImpl(JDWP.Event.Composite.Events.EventsCommon evt,
+ int requestID, ThreadReference thread) {
+ super(evt, requestID);
+ this.thread = thread;
+ }
+
+ public ThreadReference thread() {
+ return thread;
+ }
+
+ public String toString() {
+ return eventName() + " in thread " + thread.name();
+ }
+ }
+
+ abstract class LocatableEventImpl extends ThreadedEventImpl
+ implements Locatable {
+ private Location location;
+
+ LocatableEventImpl(JDWP.Event.Composite.Events.EventsCommon evt,
+ int requestID,
+ ThreadReference thread, Location location) {
+ super(evt, requestID, thread);
+ this.location = location;
+ }
+
+ public Location location() {
+ return location;
+ }
+
+ /**
+ * For MethodEntry and MethodExit
+ */
+ public Method method() {
+ return location.method();
+ }
+
+ public String toString() {
+ return eventName() + "@" +
+ ((location() == null) ? " null" : location().toString()) +
+ " in thread " + thread().name();
+ }
+ }
+
+ class BreakpointEventImpl extends LocatableEventImpl
+ implements BreakpointEvent {
+ BreakpointEventImpl(JDWP.Event.Composite.Events.Breakpoint evt) {
+ super(evt, evt.requestID, evt.thread, evt.location);
+ }
+
+ String eventName() {
+ return "BreakpointEvent";
+ }
+ }
+
+ class StepEventImpl extends LocatableEventImpl implements StepEvent {
+ StepEventImpl(JDWP.Event.Composite.Events.SingleStep evt) {
+ super(evt, evt.requestID, evt.thread, evt.location);
+ }
+
+ String eventName() {
+ return "StepEvent";
+ }
+ }
+
+ class MethodEntryEventImpl extends LocatableEventImpl
+ implements MethodEntryEvent {
+ MethodEntryEventImpl(JDWP.Event.Composite.Events.MethodEntry evt) {
+ super(evt, evt.requestID, evt.thread, evt.location);
+ }
+
+ String eventName() {
+ return "MethodEntryEvent";
+ }
+ }
+
+ class MethodExitEventImpl extends LocatableEventImpl
+ implements MethodExitEvent {
+ private Value returnVal = null;
+
+ MethodExitEventImpl(JDWP.Event.Composite.Events.MethodExit evt) {
+ super(evt, evt.requestID, evt.thread, evt.location);
+ }
+
+ MethodExitEventImpl(JDWP.Event.Composite.Events.MethodExitWithReturnValue evt) {
+ super(evt, evt.requestID, evt.thread, evt.location);
+ returnVal = evt.value;
+ }
+
+ String eventName() {
+ return "MethodExitEvent";
+ }
+
+ public Value returnValue() {
+ if (!this.vm.canGetMethodReturnValues()) {
+ throw new UnsupportedOperationException(
+ "target does not support return values in MethodExit events");
+ }
+ return returnVal;
+ }
+
+ }
+
+ class MonitorContendedEnterEventImpl extends LocatableEventImpl
+ implements MonitorContendedEnterEvent {
+ private ObjectReference monitor = null;
+
+ MonitorContendedEnterEventImpl(JDWP.Event.Composite.Events.MonitorContendedEnter evt) {
+ super(evt, evt.requestID, evt.thread, evt.location);
+ this.monitor = evt.object;
+ }
+
+ String eventName() {
+ return "MonitorContendedEnter";
+ }
+
+ public ObjectReference monitor() {
+ return monitor;
+ };
+
+ }
+
+ class MonitorContendedEnteredEventImpl extends LocatableEventImpl
+ implements MonitorContendedEnteredEvent {
+ private ObjectReference monitor = null;
+
+ MonitorContendedEnteredEventImpl(JDWP.Event.Composite.Events.MonitorContendedEntered evt) {
+ super(evt, evt.requestID, evt.thread, evt.location);
+ this.monitor = evt.object;
+ }
+
+ String eventName() {
+ return "MonitorContendedEntered";
+ }
+
+ public ObjectReference monitor() {
+ return monitor;
+ };
+
+ }
+
+ class MonitorWaitEventImpl extends LocatableEventImpl
+ implements MonitorWaitEvent {
+ private ObjectReference monitor = null;
+ private long timeout;
+
+ MonitorWaitEventImpl(JDWP.Event.Composite.Events.MonitorWait evt) {
+ super(evt, evt.requestID, evt.thread, evt.location);
+ this.monitor = evt.object;
+ this.timeout = evt.timeout;
+ }
+
+ String eventName() {
+ return "MonitorWait";
+ }
+
+ public ObjectReference monitor() {
+ return monitor;
+ };
+
+ public long timeout() {
+ return timeout;
+ }
+ }
+
+ class MonitorWaitedEventImpl extends LocatableEventImpl
+ implements MonitorWaitedEvent {
+ private ObjectReference monitor = null;
+ private boolean timed_out;
+
+ MonitorWaitedEventImpl(JDWP.Event.Composite.Events.MonitorWaited evt) {
+ super(evt, evt.requestID, evt.thread, evt.location);
+ this.monitor = evt.object;
+ this.timed_out = evt.timed_out;
+ }
+
+ String eventName() {
+ return "MonitorWaited";
+ }
+
+ public ObjectReference monitor() {
+ return monitor;
+ };
+
+ public boolean timedout() {
+ return timed_out;
+ }
+ }
+
+ class ClassPrepareEventImpl extends ThreadedEventImpl
+ implements ClassPrepareEvent {
+ private ReferenceType referenceType;
+
+ ClassPrepareEventImpl(JDWP.Event.Composite.Events.ClassPrepare evt) {
+ super(evt, evt.requestID, evt.thread);
+ referenceType = this.vm.referenceType(evt.typeID, evt.refTypeTag,
+ evt.signature);
+ ((ReferenceTypeImpl)referenceType).setStatus(evt.status);
+ }
+
+ public ReferenceType referenceType() {
+ return referenceType;
+ }
+
+ String eventName() {
+ return "ClassPrepareEvent";
+ }
+ }
+
+ class ClassUnloadEventImpl extends EventImpl implements ClassUnloadEvent {
+ private String classSignature;
+
+ ClassUnloadEventImpl(JDWP.Event.Composite.Events.ClassUnload evt) {
+ super(evt, evt.requestID);
+ this.classSignature = evt.signature;
+ }
+
+ public String className() {
+ return classSignature.substring(1, classSignature.length()-1)
+ .replace('/', '.');
+ }
+
+ public String classSignature() {
+ return classSignature;
+ }
+
+ String eventName() {
+ return "ClassUnloadEvent";
+ }
+ }
+
+ class ExceptionEventImpl extends LocatableEventImpl
+ implements ExceptionEvent {
+ private ObjectReference exception;
+ private Location catchLocation;
+
+ ExceptionEventImpl(JDWP.Event.Composite.Events.Exception evt) {
+ super(evt, evt.requestID, evt.thread, evt.location);
+ this.exception = evt.exception;
+ this.catchLocation = evt.catchLocation;
+ }
+
+ public ObjectReference exception() {
+ return exception;
+ }
+
+ public Location catchLocation() {
+ return catchLocation;
+ }
+
+ String eventName() {
+ return "ExceptionEvent";
+ }
+ }
+
+ class ThreadDeathEventImpl extends ThreadedEventImpl
+ implements ThreadDeathEvent {
+ ThreadDeathEventImpl(JDWP.Event.Composite.Events.ThreadDeath evt) {
+ super(evt, evt.requestID, evt.thread);
+ }
+
+ String eventName() {
+ return "ThreadDeathEvent";
+ }
+ }
+
+ class ThreadStartEventImpl extends ThreadedEventImpl
+ implements ThreadStartEvent {
+ ThreadStartEventImpl(JDWP.Event.Composite.Events.ThreadStart evt) {
+ super(evt, evt.requestID, evt.thread);
+ }
+
+ String eventName() {
+ return "ThreadStartEvent";
+ }
+ }
+
+ class VMStartEventImpl extends ThreadedEventImpl
+ implements VMStartEvent {
+ VMStartEventImpl(JDWP.Event.Composite.Events.VMStart evt) {
+ super(evt, evt.requestID, evt.thread);
+ }
+
+ String eventName() {
+ return "VMStartEvent";
+ }
+ }
+
+ class VMDeathEventImpl extends EventImpl implements VMDeathEvent {
+
+ VMDeathEventImpl(JDWP.Event.Composite.Events.VMDeath evt) {
+ super(evt, evt.requestID);
+ }
+
+ String eventName() {
+ return "VMDeathEvent";
+ }
+ }
+
+ class VMDisconnectEventImpl extends EventImpl
+ implements VMDisconnectEvent {
+
+ VMDisconnectEventImpl() {
+ super((byte)JDWP.EventKind.VM_DISCONNECTED);
+ }
+
+ String eventName() {
+ return "VMDisconnectEvent";
+ }
+ }
+
+ abstract class WatchpointEventImpl extends LocatableEventImpl
+ implements WatchpointEvent {
+ private final ReferenceTypeImpl refType;
+ private final long fieldID;
+ private final ObjectReference object;
+ private Field field = null;
+
+ WatchpointEventImpl(JDWP.Event.Composite.Events.EventsCommon evt,
+ int requestID,
+ ThreadReference thread, Location location,
+ byte refTypeTag, long typeID, long fieldID,
+ ObjectReference object) {
+ super(evt, requestID, thread, location);
+ this.refType = this.vm.referenceType(typeID, refTypeTag);
+ this.fieldID = fieldID;
+ this.object = object;
+ }
+
+ public Field field() {
+ if (field == null) {
+ field = refType.getFieldMirror(fieldID);
+ }
+ return field;
+ }
+
+ public ObjectReference object() {
+ return object;
+ }
+
+ public Value valueCurrent() {
+ if (object == null) {
+ return refType.getValue(field());
+ } else {
+ return object.getValue(field());
+ }
+ }
+ }
+
+ class AccessWatchpointEventImpl extends WatchpointEventImpl
+ implements AccessWatchpointEvent {
+
+ AccessWatchpointEventImpl(JDWP.Event.Composite.Events.FieldAccess evt) {
+ super(evt, evt.requestID, evt.thread, evt.location,
+ evt.refTypeTag, evt.typeID, evt.fieldID, evt.object);
+ }
+
+ String eventName() {
+ return "AccessWatchpoint";
+ }
+ }
+
+ class ModificationWatchpointEventImpl extends WatchpointEventImpl
+ implements ModificationWatchpointEvent {
+ Value newValue;
+
+ ModificationWatchpointEventImpl(
+ JDWP.Event.Composite.Events.FieldModification evt) {
+ super(evt, evt.requestID, evt.thread, evt.location,
+ evt.refTypeTag, evt.typeID, evt.fieldID, evt.object);
+ this.newValue = evt.valueToBe;
+ }
+
+ public Value valueToBe() {
+ return newValue;
+ }
+
+ String eventName() {
+ return "ModificationWatchpoint";
+ }
+ }
+
+ /**
+ * Events are constructed on the thread which reads all data from the
+ * transport. This means that the packet cannot be converted to real
+ * JDI objects as that may involve further communications with the
+ * back end which would deadlock.
+ *
+ * Hence the {@link #build()} method below called by EventQueue.
+ */
+ EventSetImpl(VirtualMachine aVm, Packet pkt) {
+ super();
+
+ // From "MirrorImpl":
+ // Yes, its a bit of a hack. But by doing it this
+ // way, this is the only place we have to change
+ // typing to substitute a new impl.
+ vm = (VirtualMachineImpl)aVm;
+
+ this.pkt = pkt;
+ }
+
+ /**
+ * Constructor for special events like VM disconnected
+ */
+ EventSetImpl(VirtualMachine aVm, byte eventCmd) {
+ this(aVm, null);
+ suspendPolicy = JDWP.SuspendPolicy.NONE;
+ switch (eventCmd) {
+ case JDWP.EventKind.VM_DISCONNECTED:
+ addEvent(new VMDisconnectEventImpl());
+ break;
+
+ default:
+ throw new InternalException("Bad singleton event code");
+ }
+ }
+
+ private void addEvent(EventImpl evt) {
+ // Note that this class has a public add method that throws
+ // an exception so that clients can't modify the EventSet
+ super.add(evt);
+ }
+
+ /*
+ * Complete the construction of an EventSet. This is called from
+ * an event handler thread. It upacks the JDWP events inside
+ * the packet and creates EventImpls for them. The EventSet is already
+ * on EventQueues when this is called, so it has to be synch.
+ */
+ synchronized void build() {
+ if (pkt == null) {
+ return;
+ }
+ PacketStream ps = new PacketStream(vm, pkt);
+ JDWP.Event.Composite compEvt = new JDWP.Event.Composite(vm, ps);
+ suspendPolicy = compEvt.suspendPolicy;
+ if ((vm.traceFlags & VirtualMachine.TRACE_EVENTS) != 0) {
+ switch(suspendPolicy) {
+ case JDWP.SuspendPolicy.ALL:
+ vm.printTrace("EventSet: SUSPEND_ALL");
+ break;
+
+ case JDWP.SuspendPolicy.EVENT_THREAD:
+ vm.printTrace("EventSet: SUSPEND_EVENT_THREAD");
+ break;
+
+ case JDWP.SuspendPolicy.NONE:
+ vm.printTrace("EventSet: SUSPEND_NONE");
+ break;
+ }
+ }
+
+ ThreadReference fix6485605 = null;
+ for (int i = 0; i < compEvt.events.length; i++) {
+ EventImpl evt = createEvent(compEvt.events[i]);
+ if ((vm.traceFlags & VirtualMachine.TRACE_EVENTS) != 0) {
+ try {
+ vm.printTrace("Event: " + evt);
+ } catch (VMDisconnectedException ee) {
+ // ignore - see bug 6502716
+ }
+ }
+
+ switch (evt.destination()) {
+ case UNKNOWN_EVENT:
+ // Ignore disabled, deleted, unknown events, but
+ // save the thread if there is one since we might
+ // have to resume it. Note that events for different
+ // threads can't be in the same event set.
+ if (evt instanceof ThreadedEventImpl &&
+ suspendPolicy == JDWP.SuspendPolicy.EVENT_THREAD) {
+ fix6485605 = ((ThreadedEventImpl)evt).thread();
+ }
+ continue;
+ case CLIENT_EVENT:
+ addEvent(evt);
+ break;
+ case INTERNAL_EVENT:
+ if (internalEventSet == null) {
+ internalEventSet = new EventSetImpl(this.vm, null);
+ }
+ internalEventSet.addEvent(evt);
+ break;
+ default:
+ throw new InternalException("Invalid event destination");
+ }
+ }
+ pkt = null; // No longer needed - free it up
+
+ // Avoid hangs described in 6296125, 6293795
+ if (super.size() == 0) {
+ // This set has no client events. If we don't do
+ // needed resumes, no one else is going to.
+ if (suspendPolicy == JDWP.SuspendPolicy.ALL) {
+ vm.resume();
+ } else if (suspendPolicy == JDWP.SuspendPolicy.EVENT_THREAD) {
+ // See bug 6485605.
+ if (fix6485605 != null) {
+ fix6485605.resume();
+ } else {
+ // apparently, there is nothing to resume.
+ }
+ }
+ suspendPolicy = JDWP.SuspendPolicy.NONE;
+
+ }
+
+ }
+
+ /**
+ * Filter out internal events
+ */
+ EventSet userFilter() {
+ return this;
+ }
+
+ /**
+ * Filter out user events.
+ */
+ EventSet internalFilter() {
+ return this.internalEventSet;
+ }
+
+ EventImpl createEvent(JDWP.Event.Composite.Events evt) {
+ JDWP.Event.Composite.Events.EventsCommon comm = evt.aEventsCommon;
+ switch (evt.eventKind) {
+ case JDWP.EventKind.THREAD_START:
+ return new ThreadStartEventImpl(
+ (JDWP.Event.Composite.Events.ThreadStart)comm);
+
+ case JDWP.EventKind.THREAD_END:
+ return new ThreadDeathEventImpl(
+ (JDWP.Event.Composite.Events.ThreadDeath)comm);
+
+ case JDWP.EventKind.EXCEPTION:
+ return new ExceptionEventImpl(
+ (JDWP.Event.Composite.Events.Exception)comm);
+
+ case JDWP.EventKind.BREAKPOINT:
+ return new BreakpointEventImpl(
+ (JDWP.Event.Composite.Events.Breakpoint)comm);
+
+ case JDWP.EventKind.METHOD_ENTRY:
+ return new MethodEntryEventImpl(
+ (JDWP.Event.Composite.Events.MethodEntry)comm);
+
+ case JDWP.EventKind.METHOD_EXIT:
+ return new MethodExitEventImpl(
+ (JDWP.Event.Composite.Events.MethodExit)comm);
+
+ case JDWP.EventKind.METHOD_EXIT_WITH_RETURN_VALUE:
+ return new MethodExitEventImpl(
+ (JDWP.Event.Composite.Events.MethodExitWithReturnValue)comm);
+
+ case JDWP.EventKind.FIELD_ACCESS:
+ return new AccessWatchpointEventImpl(
+ (JDWP.Event.Composite.Events.FieldAccess)comm);
+
+ case JDWP.EventKind.FIELD_MODIFICATION:
+ return new ModificationWatchpointEventImpl(
+ (JDWP.Event.Composite.Events.FieldModification)comm);
+
+ case JDWP.EventKind.SINGLE_STEP:
+ return new StepEventImpl(
+ (JDWP.Event.Composite.Events.SingleStep)comm);
+
+ case JDWP.EventKind.CLASS_PREPARE:
+ return new ClassPrepareEventImpl(
+ (JDWP.Event.Composite.Events.ClassPrepare)comm);
+
+ case JDWP.EventKind.CLASS_UNLOAD:
+ return new ClassUnloadEventImpl(
+ (JDWP.Event.Composite.Events.ClassUnload)comm);
+
+ case JDWP.EventKind.MONITOR_CONTENDED_ENTER:
+ return new MonitorContendedEnterEventImpl(
+ (JDWP.Event.Composite.Events.MonitorContendedEnter)comm);
+
+ case JDWP.EventKind.MONITOR_CONTENDED_ENTERED:
+ return new MonitorContendedEnteredEventImpl(
+ (JDWP.Event.Composite.Events.MonitorContendedEntered)comm);
+
+ case JDWP.EventKind.MONITOR_WAIT:
+ return new MonitorWaitEventImpl(
+ (JDWP.Event.Composite.Events.MonitorWait)comm);
+
+ case JDWP.EventKind.MONITOR_WAITED:
+ return new MonitorWaitedEventImpl(
+ (JDWP.Event.Composite.Events.MonitorWaited)comm);
+
+ case JDWP.EventKind.VM_START:
+ return new VMStartEventImpl(
+ (JDWP.Event.Composite.Events.VMStart)comm);
+
+ case JDWP.EventKind.VM_DEATH:
+ return new VMDeathEventImpl(
+ (JDWP.Event.Composite.Events.VMDeath)comm);
+
+ default:
+ // Ignore unknown event types
+ System.err.println("Ignoring event cmd " +
+ evt.eventKind + " from the VM");
+ return null;
+ }
+ }
+
+ public VirtualMachine virtualMachine() {
+ return vm;
+ }
+
+ public int suspendPolicy() {
+ return EventRequestManagerImpl.JDWPtoJDISuspendPolicy(suspendPolicy);
+ }
+
+ private ThreadReference eventThread() {
+ for (Event event : this) {
+ if (event instanceof ThreadedEventImpl) {
+ return ((ThreadedEventImpl)event).thread();
+ }
+ }
+ return null;
+ }
+
+ public void resume() {
+ switch (suspendPolicy()) {
+ case EventRequest.SUSPEND_ALL:
+ vm.resume();
+ break;
+ case EventRequest.SUSPEND_EVENT_THREAD:
+ ThreadReference thread = eventThread();
+ if (thread == null) {
+ throw new InternalException("Inconsistent suspend policy");
+ }
+ thread.resume();
+ break;
+ case EventRequest.SUSPEND_NONE:
+ // Do nothing
+ break;
+ default:
+ throw new InternalException("Invalid suspend policy");
+ }
+ }
+
+ public Iterator<Event> iterator() {
+ return new Itr();
+ }
+
+ public EventIterator eventIterator() {
+ return new Itr();
+ }
+
+ public class Itr implements EventIterator {
+ /**
+ * Index of element to be returned by subsequent call to next.
+ */
+ int cursor = 0;
+
+ public boolean hasNext() {
+ return cursor != size();
+ }
+
+ public Event next() {
+ try {
+ Event nxt = get(cursor);
+ ++cursor;
+ return nxt;
+ } catch(IndexOutOfBoundsException e) {
+ throw new NoSuchElementException();
+ }
+ }
+
+ public Event nextEvent() {
+ return next();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ @Override
+ public Spliterator<Event> spliterator() {
+ return Spliterators.spliterator(this, Spliterator.DISTINCT);
+ }
+
+ /* below make this unmodifiable */
+
+ public boolean add(Event o){
+ throw new UnsupportedOperationException();
+ }
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+ public boolean addAll(Collection<? extends Event> coll) {
+ throw new UnsupportedOperationException();
+ }
+ public boolean removeAll(Collection<?> coll) {
+ throw new UnsupportedOperationException();
+ }
+ public boolean retainAll(Collection<?> coll) {
+ throw new UnsupportedOperationException();
+ }
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/FieldImpl.java b/src/share/classes/com/sun/tools/jdi/FieldImpl.java
new file mode 100644
index 0000000..ecf6fdc
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/FieldImpl.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 1998, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+
+public class FieldImpl extends TypeComponentImpl
+ implements Field, ValueContainer {
+
+ FieldImpl(VirtualMachine vm, ReferenceTypeImpl declaringType,
+ long ref,
+ String name, String signature,
+ String genericSignature, int modifiers) {
+ super(vm, declaringType, ref, name, signature,
+ genericSignature, modifiers);
+ }
+
+ public boolean equals(Object obj) {
+ if ((obj != null) && (obj instanceof FieldImpl)) {
+ FieldImpl other = (FieldImpl)obj;
+ return (declaringType().equals(other.declaringType())) &&
+ (ref() == other.ref()) &&
+ super.equals(obj);
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ return (int)ref();
+ }
+
+ public int compareTo(Field field) {
+ ReferenceTypeImpl declaringType = (ReferenceTypeImpl)declaringType();
+ int rc = declaringType.compareTo(field.declaringType());
+ if (rc == 0) {
+ rc = declaringType.indexOf(this) -
+ declaringType.indexOf(field);
+ }
+ return rc;
+ }
+
+ public Type type() throws ClassNotLoadedException {
+ return findType(signature());
+ }
+
+ public Type findType(String signature) throws ClassNotLoadedException {
+ ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType();
+ return enclosing.findType(signature);
+ }
+
+ /**
+ * @return a text representation of the declared type
+ * of this field.
+ */
+ public String typeName() {
+ JNITypeParser parser = new JNITypeParser(signature());
+ return parser.typeName();
+ }
+
+ public boolean isTransient() {
+ return isModifierSet(VMModifiers.TRANSIENT);
+ }
+
+ public boolean isVolatile() {
+ return isModifierSet(VMModifiers.VOLATILE);
+ }
+
+ public boolean isEnumConstant() {
+ return isModifierSet(VMModifiers.ENUM_CONSTANT);
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+
+ buf.append(declaringType().name());
+ buf.append('.');
+ buf.append(name());
+
+ return buf.toString();
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/FloatTypeImpl.java b/src/share/classes/com/sun/tools/jdi/FloatTypeImpl.java
new file mode 100644
index 0000000..dc6c857
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/FloatTypeImpl.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1998, 1999, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class FloatTypeImpl extends PrimitiveTypeImpl implements FloatType {
+ FloatTypeImpl(VirtualMachine vm) {
+ super(vm);
+ }
+
+
+ public String signature() {
+ return String.valueOf((char)JDWP.Tag.FLOAT);
+ }
+
+ PrimitiveValue convert(PrimitiveValue value) throws InvalidTypeException {
+ return vm.mirrorOf(((PrimitiveValueImpl)value).checkedFloatValue());
+ }
+
+}
diff --git a/src/share/classes/com/sun/tools/jdi/FloatValueImpl.java b/src/share/classes/com/sun/tools/jdi/FloatValueImpl.java
new file mode 100644
index 0000000..2e1d8d4
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/FloatValueImpl.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class FloatValueImpl extends PrimitiveValueImpl
+ implements FloatValue {
+ private float value;
+
+ FloatValueImpl(VirtualMachine aVm,float aValue) {
+ super(aVm);
+
+ value = aValue;
+ }
+
+ public boolean equals(Object obj) {
+ if ((obj != null) && (obj instanceof FloatValue)) {
+ return (value == ((FloatValue)obj).value()) &&
+ super.equals(obj);
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ /*
+ * TO DO: Better hash code
+ */
+ return intValue();
+ }
+
+ public int compareTo(FloatValue obj) {
+ float other = obj.value();
+ if (value() < other) {
+ return -1;
+ } else if (value() == other) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+
+ public Type type() {
+ return vm.theFloatType();
+ }
+
+ public float value() {
+ return value;
+ }
+
+ public boolean booleanValue() {
+ return(value == 0.0)?false:true;
+ }
+
+ public byte byteValue() {
+ return(byte)value;
+ }
+
+ public char charValue() {
+ return(char)value;
+ }
+
+ public short shortValue() {
+ return(short)value;
+ }
+
+ public int intValue() {
+ return(int)value;
+ }
+
+ public long longValue() {
+ return(long)value;
+ }
+
+ public float floatValue() {
+ return value;
+ }
+
+ public double doubleValue() {
+ return(double)value;
+ }
+
+ byte checkedByteValue() throws InvalidTypeException {
+ if ((value > Byte.MAX_VALUE) || (value < Byte.MIN_VALUE)) {
+ throw new InvalidTypeException("Can't convert " + value + " to byte");
+ } else {
+ return super.checkedByteValue();
+ }
+ }
+
+ char checkedCharValue() throws InvalidTypeException {
+ if ((value > Character.MAX_VALUE) || (value < Character.MIN_VALUE)) {
+ throw new InvalidTypeException("Can't convert " + value + " to char");
+ } else {
+ return super.checkedCharValue();
+ }
+ }
+
+ short checkedShortValue() throws InvalidTypeException {
+ if ((value > Short.MAX_VALUE) || (value < Short.MIN_VALUE)) {
+ throw new InvalidTypeException("Can't convert " + value + " to short");
+ } else {
+ return super.checkedShortValue();
+ }
+ }
+
+ int checkedIntValue() throws InvalidTypeException {
+ int intValue = (int)value;
+ if (intValue != value) {
+ throw new InvalidTypeException("Can't convert " + value + " to int");
+ } else {
+ return super.checkedIntValue();
+ }
+ }
+
+ long checkedLongValue() throws InvalidTypeException {
+ long longValue = (long)value;
+ if (longValue != value) {
+ throw new InvalidTypeException("Can't convert " + value + " to long");
+ } else {
+ return super.checkedLongValue();
+ }
+ }
+
+ public String toString() {
+ return "" + value;
+ }
+
+ byte typeValueKey() {
+ return JDWP.Tag.FLOAT;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/GenericAttachingConnector.java b/src/share/classes/com/sun/tools/jdi/GenericAttachingConnector.java
new file mode 100644
index 0000000..e90afc1
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/GenericAttachingConnector.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2003, 2011, 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.tools.jdi;
+
+import java.io.IOException;
+import java.util.Map;
+
+import com.sun.jdi.Bootstrap;
+import com.sun.jdi.VirtualMachine;
+import com.sun.jdi.connect.*;
+import com.sun.jdi.connect.spi.*;
+
+/*
+ * An AttachingConnector to attach to a running VM using any
+ * TransportService.
+ */
+
+public class GenericAttachingConnector
+ extends ConnectorImpl implements AttachingConnector
+{
+ /*
+ * The arguments that this connector supports
+ */
+ static final String ARG_ADDRESS = "address";
+ static final String ARG_TIMEOUT = "timeout";
+
+ TransportService transportService;
+ Transport transport;
+
+ /*
+ * Initialize a new instance of this connector. The connector
+ * encapsulates a transport service and optionally has an
+ * "address" connector argument.
+ */
+ private GenericAttachingConnector(TransportService ts,
+ boolean addAddressArgument)
+ {
+ transportService = ts;
+ transport = new Transport() {
+ public String name() {
+ // delegate name to the transport service
+ return transportService.name();
+ }
+ };
+
+ if (addAddressArgument) {
+ addStringArgument(
+ ARG_ADDRESS,
+ getString("generic_attaching.address.label"),
+ getString("generic_attaching.address"),
+ "",
+ true);
+ }
+
+
+ addIntegerArgument(
+ ARG_TIMEOUT,
+ getString("generic_attaching.timeout.label"),
+ getString("generic_attaching.timeout"),
+ "",
+ false,
+ 0, Integer.MAX_VALUE);
+ }
+
+ /**
+ * Initializes a new instance of this connector. This constructor
+ * is used when sub-classing - the resulting connector will have
+ * a "timeout" connector argument.
+ */
+ protected GenericAttachingConnector(TransportService ts) {
+ this(ts, false);
+ }
+
+ /*
+ * Create an instance of this connector. The resulting AttachingConnector
+ * will have address and timeout connector arguments.
+ */
+ public static GenericAttachingConnector create(TransportService ts) {
+ return new GenericAttachingConnector(ts, true);
+ }
+
+ /**
+ * Attach to a target VM using the specified address and Connector arguments.
+ */
+ public VirtualMachine attach(String address, Map<String, ? extends Connector.Argument> args)
+ throws IOException, IllegalConnectorArgumentsException
+ {
+ String ts = argument(ARG_TIMEOUT, args).value();
+ int timeout = 0;
+ if (ts.length() > 0) {
+ timeout = Integer.decode(ts).intValue();
+ }
+ Connection connection = transportService.attach(address, timeout, 0);
+ return Bootstrap.virtualMachineManager().createVirtualMachine(connection);
+ }
+
+ /**
+ * Attach to a target VM using the specified arguments - the address
+ * of the target VM is specified by the <code>address</code> connector
+ * argument.
+ */
+ public VirtualMachine
+ attach(Map<String,? extends Connector.Argument> args)
+ throws IOException, IllegalConnectorArgumentsException
+ {
+ String address = argument(ARG_ADDRESS, args).value();
+ return attach(address, args);
+ }
+
+ public String name() {
+ return transport.name() + "Attach";
+ }
+
+ public String description() {
+ return transportService.description();
+ }
+
+ public Transport transport() {
+ return transport;
+ }
+
+}
diff --git a/src/share/classes/com/sun/tools/jdi/GenericListeningConnector.java b/src/share/classes/com/sun/tools/jdi/GenericListeningConnector.java
new file mode 100644
index 0000000..886a954
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/GenericListeningConnector.java
@@ -0,0 +1,183 @@
+/*
+ * 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.tools.jdi;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.ArrayList;
+import java.io.IOException;
+
+import com.sun.jdi.Bootstrap;
+import com.sun.jdi.VirtualMachine;
+import com.sun.jdi.connect.*;
+import com.sun.jdi.connect.spi.*;
+
+/*
+ * A ListeningConnector to listen for connections from target VM
+ * using the configured transport service
+ */
+public class GenericListeningConnector
+ extends ConnectorImpl implements ListeningConnector
+{
+ static final String ARG_ADDRESS = "address";
+ static final String ARG_TIMEOUT = "timeout";
+
+ Map<Map<String,? extends Connector.Argument>, TransportService.ListenKey> listenMap;
+ TransportService transportService;
+ Transport transport;
+
+ /**
+ * Initialize a new instance of this connector. The connector
+ * encapsulates a transport service, has a "timeout" connector argument,
+ * and optionally an "address" connector argument.
+ */
+ private GenericListeningConnector(TransportService ts,
+ boolean addAddressArgument)
+ {
+ transportService = ts;
+ transport = new Transport() {
+ public String name() {
+ return transportService.name();
+ }
+ };
+
+ if (addAddressArgument) {
+ addStringArgument(
+ ARG_ADDRESS,
+ getString("generic_listening.address.label"),
+ getString("generic_listening.address"),
+ "",
+ false);
+ }
+
+ addIntegerArgument(
+ ARG_TIMEOUT,
+ getString("generic_listening.timeout.label"),
+ getString("generic_listening.timeout"),
+ "",
+ false,
+ 0, Integer.MAX_VALUE);
+
+ listenMap = new HashMap<Map<String,? extends Connector.Argument>,TransportService.ListenKey>(10);
+ }
+
+ /**
+ * Initialize a new instance of this connector. This constructor is used
+ * when sub-classing - the resulting connector will a "timeout" connector
+ * argument.
+ */
+ protected GenericListeningConnector(TransportService ts) {
+ this(ts, false);
+ }
+
+ /**
+ * Create an instance of this Connector. The resulting ListeningConnector will
+ * have "address" and "timeout" connector arguments.
+ */
+ public static GenericListeningConnector create(TransportService ts) {
+ return new GenericListeningConnector(ts, true);
+ }
+
+ public String startListening(String address, Map<String,? extends Connector.Argument> args)
+ throws IOException, IllegalConnectorArgumentsException
+ {
+ TransportService.ListenKey listener = listenMap.get(args);
+ if (listener != null) {
+ throw new IllegalConnectorArgumentsException("Already listening",
+ new ArrayList<String>(args.keySet()));
+ }
+
+ listener = transportService.startListening(address);
+ listenMap.put(args, listener);
+ return listener.address();
+ }
+
+ public String
+ startListening(Map<String,? extends Connector.Argument> args)
+ throws IOException, IllegalConnectorArgumentsException
+ {
+ String address = argument(ARG_ADDRESS, args).value();
+ return startListening(address, args);
+ }
+
+ public void stopListening(Map<String,? extends Connector.Argument> args)
+ throws IOException, IllegalConnectorArgumentsException
+ {
+ TransportService.ListenKey listener = listenMap.get(args);
+ if (listener == null) {
+ throw new IllegalConnectorArgumentsException("Not listening",
+ new ArrayList<String>(args.keySet()));
+ }
+ transportService.stopListening(listener);
+ listenMap.remove(args);
+ }
+
+ public VirtualMachine
+ accept(Map<String,? extends Connector.Argument> args)
+ throws IOException, IllegalConnectorArgumentsException
+ {
+ String ts = argument(ARG_TIMEOUT, args).value();
+ int timeout = 0;
+ if (ts.length() > 0) {
+ timeout = Integer.decode(ts).intValue();
+ }
+
+ TransportService.ListenKey listener = listenMap.get(args);
+ Connection connection;
+ if (listener != null) {
+ connection = transportService.accept(listener, timeout, 0);
+ } else {
+ /*
+ * Keep compatibility with previous releases - if the
+ * debugger hasn't called startListening then we do a
+ * once-off accept
+ */
+ startListening(args);
+ listener = listenMap.get(args);
+ assert listener != null;
+ connection = transportService.accept(listener, timeout, 0);
+ stopListening(args);
+ }
+ return Bootstrap.virtualMachineManager().createVirtualMachine(connection);
+ }
+
+ public boolean supportsMultipleConnections() {
+ return transportService.capabilities().supportsMultipleConnections();
+ }
+
+ public String name() {
+ return transport.name() + "Listen";
+ }
+
+ public String description() {
+ return transportService.description();
+ }
+
+ public Transport transport() {
+ return transport;
+ }
+
+}
diff --git a/src/share/classes/com/sun/tools/jdi/IntegerTypeImpl.java b/src/share/classes/com/sun/tools/jdi/IntegerTypeImpl.java
new file mode 100644
index 0000000..806f35d
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/IntegerTypeImpl.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1998, 1999, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class IntegerTypeImpl extends PrimitiveTypeImpl implements IntegerType {
+ IntegerTypeImpl(VirtualMachine vm) {
+ super(vm);
+ }
+
+
+ public String signature() {
+ return String.valueOf((char)JDWP.Tag.INT);
+ }
+
+ PrimitiveValue convert(PrimitiveValue value) throws InvalidTypeException {
+ return vm.mirrorOf(((PrimitiveValueImpl)value).checkedIntValue());
+ }
+
+}
diff --git a/src/share/classes/com/sun/tools/jdi/IntegerValueImpl.java b/src/share/classes/com/sun/tools/jdi/IntegerValueImpl.java
new file mode 100644
index 0000000..e748f1d
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/IntegerValueImpl.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class IntegerValueImpl extends PrimitiveValueImpl
+ implements IntegerValue {
+ private int value;
+
+ IntegerValueImpl(VirtualMachine aVm,int aValue) {
+ super(aVm);
+
+ value = aValue;
+ }
+
+ public boolean equals(Object obj) {
+ if ((obj != null) && (obj instanceof IntegerValue)) {
+ return (value == ((IntegerValue)obj).value()) &&
+ super.equals(obj);
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ /*
+ * TO DO: Better hash code
+ */
+ return intValue();
+ }
+
+ public int compareTo(IntegerValue obj) {
+ int other = obj.value();
+ return (value()<other ? -1 : (value()==other ? 0 : 1));
+ }
+
+ public Type type() {
+ return vm.theIntegerType();
+ }
+
+ public int value() {
+ return value;
+ }
+
+ public boolean booleanValue() {
+ return(value == 0)?false:true;
+ }
+
+ public byte byteValue() {
+ return(byte)value;
+ }
+
+ public char charValue() {
+ return(char)value;
+ }
+
+ public short shortValue() {
+ return(short)value;
+ }
+
+ public int intValue() {
+ return value;
+ }
+
+ public long longValue() {
+ return(long)value;
+ }
+
+ public float floatValue() {
+ return(float)value;
+ }
+
+ public double doubleValue() {
+ return(double)value;
+ }
+
+ byte checkedByteValue() throws InvalidTypeException {
+ if ((value > Byte.MAX_VALUE) || (value < Byte.MIN_VALUE)) {
+ throw new InvalidTypeException("Can't convert " + value + " to byte");
+ } else {
+ return super.checkedByteValue();
+ }
+ }
+
+ char checkedCharValue() throws InvalidTypeException {
+ if ((value > Character.MAX_VALUE) || (value < Character.MIN_VALUE)) {
+ throw new InvalidTypeException("Can't convert " + value + " to char");
+ } else {
+ return super.checkedCharValue();
+ }
+ }
+
+ short checkedShortValue() throws InvalidTypeException {
+ if ((value > Short.MAX_VALUE) || (value < Short.MIN_VALUE)) {
+ throw new InvalidTypeException("Can't convert " + value + " to short");
+ } else {
+ return super.checkedShortValue();
+ }
+ }
+
+ public String toString() {
+ return "" + value;
+ }
+
+ byte typeValueKey() {
+ return JDWP.Tag.INT;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/InterfaceTypeImpl.java b/src/share/classes/com/sun/tools/jdi/InterfaceTypeImpl.java
new file mode 100644
index 0000000..0f263ad
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/InterfaceTypeImpl.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 1998, 2015, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Set;
+import java.lang.ref.SoftReference;
+
+final public class InterfaceTypeImpl extends InvokableTypeImpl
+ implements InterfaceType {
+
+ private static class IResult implements InvocationResult {
+ final private JDWP.InterfaceType.InvokeMethod rslt;
+
+ public IResult(JDWP.InterfaceType.InvokeMethod rslt) {
+ this.rslt = rslt;
+ }
+
+ @Override
+ public ObjectReferenceImpl getException() {
+ return rslt.exception;
+ }
+
+ @Override
+ public ValueImpl getResult() {
+ return rslt.returnValue;
+ }
+
+ }
+
+ private SoftReference<List<InterfaceType>> superinterfacesRef = null;
+
+ protected InterfaceTypeImpl(VirtualMachine aVm,long aRef) {
+ super(aVm, aRef);
+ }
+
+ public List<InterfaceType> superinterfaces() {
+ List<InterfaceType> superinterfaces = (superinterfacesRef == null) ? null :
+ superinterfacesRef.get();
+ if (superinterfaces == null) {
+ superinterfaces = getInterfaces();
+ superinterfaces = Collections.unmodifiableList(superinterfaces);
+ superinterfacesRef = new SoftReference<List<InterfaceType>>(superinterfaces);
+ }
+ return superinterfaces;
+ }
+
+ public List<InterfaceType> subinterfaces() {
+ List<InterfaceType> subs = new ArrayList<InterfaceType>();
+ for (ReferenceType refType : vm.allClasses()) {
+ if (refType instanceof InterfaceType) {
+ InterfaceType interfaze = (InterfaceType)refType;
+ if (interfaze.isPrepared() && interfaze.superinterfaces().contains(this)) {
+ subs.add(interfaze);
+ }
+ }
+ }
+ return subs;
+ }
+
+ public List<ClassType> implementors() {
+ List<ClassType> implementors = new ArrayList<ClassType>();
+ for (ReferenceType refType : vm.allClasses()) {
+ if (refType instanceof ClassType) {
+ ClassType clazz = (ClassType)refType;
+ if (clazz.isPrepared() && clazz.interfaces().contains(this)) {
+ implementors.add(clazz);
+ }
+ }
+ }
+ return implementors;
+ }
+
+ public boolean isInitialized() {
+ return isPrepared();
+ }
+
+ public String toString() {
+ return "interface " + name() + " (" + loaderString() + ")";
+ }
+
+ @Override
+ InvocationResult waitForReply(PacketStream stream) throws JDWPException {
+ return new IResult(JDWP.InterfaceType.InvokeMethod.waitForReply(vm, stream));
+ }
+
+ @Override
+ CommandSender getInvokeMethodSender(final ThreadReferenceImpl thread,
+ final MethodImpl method,
+ final ValueImpl[] args,
+ final int options) {
+ return () ->
+ JDWP.InterfaceType.InvokeMethod.enqueueCommand(vm,
+ InterfaceTypeImpl.this,
+ thread,
+ method.ref(),
+ args,
+ options);
+ }
+
+ @Override
+ ClassType superclass() {
+ return null;
+ }
+
+ @Override
+ boolean isAssignableTo(ReferenceType type) {
+ if (type.name().equals("java.lang.Object")) {
+ // interfaces are always assignable to j.l.Object
+ return true;
+ }
+ return super.isAssignableTo(type);
+ }
+
+ @Override
+ List<InterfaceType> interfaces() {
+ return superinterfaces();
+ }
+
+ @Override
+ boolean canInvoke(Method method) {
+ // method must be directly in this interface
+ return this.equals(method.declaringType());
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/InternalEventHandler.java b/src/share/classes/com/sun/tools/jdi/InternalEventHandler.java
new file mode 100644
index 0000000..fdf13f0
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/InternalEventHandler.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+import java.util.*;
+
+public class InternalEventHandler implements Runnable
+{
+ EventQueueImpl queue;
+ VirtualMachineImpl vm;
+
+ InternalEventHandler(VirtualMachineImpl vm, EventQueueImpl queue)
+ {
+ this.vm = vm;
+ this.queue = queue;
+ Thread thread = new Thread(vm.threadGroupForJDI(), this,
+ "JDI Internal Event Handler");
+ thread.setDaemon(true);
+ thread.start();
+ }
+
+ public void run() {
+ if ((vm.traceFlags & VirtualMachine.TRACE_EVENTS) != 0) {
+ vm.printTrace("Internal event handler running");
+ }
+ try {
+ while (true) {
+ try {
+ EventSet eventSet = queue.removeInternal();
+ EventIterator it = eventSet.eventIterator();
+ while (it.hasNext()) {
+ Event event = it.nextEvent();
+ if (event instanceof ClassUnloadEvent) {
+ ClassUnloadEvent cuEvent = (ClassUnloadEvent)event;
+ vm.removeReferenceType(cuEvent.classSignature());
+
+ if ((vm.traceFlags & VirtualMachine.TRACE_EVENTS) != 0) {
+ vm.printTrace("Handled Unload Event for " +
+ cuEvent.classSignature());
+ }
+ } else if (event instanceof ClassPrepareEvent) {
+ ClassPrepareEvent cpEvent = (ClassPrepareEvent)event;
+ ((ReferenceTypeImpl)cpEvent.referenceType())
+ .markPrepared();
+
+ if ((vm.traceFlags & VirtualMachine.TRACE_EVENTS) != 0) {
+ vm.printTrace("Handled Prepare Event for " +
+ cpEvent.referenceType().name());
+ }
+ }
+
+ }
+
+ /*
+ * Handle exceptions that can occur in normal operation
+ * but which can't be accounted for by event builder
+ * methods. The thread should not be terminated if they
+ * occur.
+ *
+ * TO DO: We need a better way to log these conditions.
+ */
+ } catch (VMOutOfMemoryException vmme) {
+ vmme.printStackTrace();
+ } catch (InconsistentDebugInfoException idie) {
+ idie.printStackTrace();
+
+ /*
+ * If any of these exceptions below occurs, there is some
+ * sort of programming error that should be addressed in
+ * the JDI implemementation. However, it would cripple
+ * the implementation if we let this thread die due to
+ * one of them. So, a notification of the exception is
+ * given and we attempt to continue.
+ */
+ } catch (ObjectCollectedException oce) {
+ oce.printStackTrace();
+ } catch (ClassNotPreparedException cnpe) {
+ cnpe.printStackTrace();
+ }
+ }
+ } catch (InterruptedException e) { // should we really die here
+ } catch (VMDisconnectedException e) { // time to die
+ }
+ if ((vm.traceFlags & VirtualMachine.TRACE_EVENTS) != 0) {
+ vm.printTrace("Internal event handler exiting");
+ }
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/InvokableTypeImpl.java b/src/share/classes/com/sun/tools/jdi/InvokableTypeImpl.java
new file mode 100644
index 0000000..3672435
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/InvokableTypeImpl.java
@@ -0,0 +1,314 @@
+/*
+ * Copyright (c) 2014, 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.tools.jdi;
+
+import com.sun.jdi.ClassNotLoadedException;
+import com.sun.jdi.ClassType;
+import com.sun.jdi.IncompatibleThreadStateException;
+import com.sun.jdi.InterfaceType;
+import com.sun.jdi.InvalidTypeException;
+import com.sun.jdi.InvocationException;
+import com.sun.jdi.Method;
+import com.sun.jdi.ReferenceType;
+import com.sun.jdi.ThreadReference;
+import com.sun.jdi.Value;
+import com.sun.jdi.VirtualMachine;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A supertype for ReferenceTypes allowing method invocations
+ */
+abstract class InvokableTypeImpl extends ReferenceTypeImpl {
+ /**
+ * The invocation result wrapper
+ * It is necessary because both ClassType and InterfaceType
+ * use their own type to represent the invocation result
+ */
+ static interface InvocationResult {
+ ObjectReferenceImpl getException();
+ ValueImpl getResult();
+ }
+
+ InvokableTypeImpl(VirtualMachine aVm, long aRef) {
+ super(aVm, aRef);
+ }
+
+ /**
+ * Method invocation support.
+ * Shared by ClassType and InterfaceType
+ * @param threadIntf the thread in which to invoke.
+ * @param methodIntf method the {@link Method} to invoke.
+ * @param origArguments the list of {@link Value} arguments bound to the
+ * invoked method. Values from the list are assigned to arguments
+ * in the order they appear in the method signature.
+ * @param options the integer bit flag options.
+ * @return a {@link Value} mirror of the invoked method's return value.
+ * @throws java.lang.IllegalArgumentException if the method is not
+ * a member of this type, if the size of the argument list
+ * does not match the number of declared arguments for the method, or
+ * if the method is not static or is a static initializer.
+ * @throws {@link InvalidTypeException} if any argument in the
+ * argument list is not assignable to the corresponding method argument
+ * type.
+ * @throws ClassNotLoadedException if any argument type has not yet been loaded
+ * through the appropriate class loader.
+ * @throws IncompatibleThreadStateException if the specified thread has not
+ * been suspended by an event.
+ * @throws InvocationException if the method invocation resulted in
+ * an exception in the target VM.
+ * @throws InvalidTypeException If the arguments do not meet this requirement --
+ * Object arguments must be assignment compatible with the argument
+ * type. This implies that the argument type must be
+ * loaded through the enclosing class's class loader.
+ * Primitive arguments must be either assignment compatible with the
+ * argument type or must be convertible to the argument type without loss
+ * of information. See JLS section 5.2 for more information on assignment
+ * compatibility.
+ * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
+ */
+ final public Value invokeMethod(ThreadReference threadIntf, Method methodIntf,
+ List<? extends Value> origArguments, int options)
+ throws InvalidTypeException,
+ ClassNotLoadedException,
+ IncompatibleThreadStateException,
+ InvocationException {
+ validateMirror(threadIntf);
+ validateMirror(methodIntf);
+ validateMirrorsOrNulls(origArguments);
+ MethodImpl method = (MethodImpl) methodIntf;
+ ThreadReferenceImpl thread = (ThreadReferenceImpl) threadIntf;
+ validateMethodInvocation(method);
+ List<? extends Value> arguments = method.validateAndPrepareArgumentsForInvoke(origArguments);
+ ValueImpl[] args = arguments.toArray(new ValueImpl[0]);
+ InvocationResult ret;
+ try {
+ PacketStream stream = sendInvokeCommand(thread, method, args, options);
+ ret = waitForReply(stream);
+ } catch (JDWPException exc) {
+ if (exc.errorCode() == JDWP.Error.INVALID_THREAD) {
+ throw new IncompatibleThreadStateException();
+ } else {
+ throw exc.toJDIException();
+ }
+ }
+ /*
+ * There is an implict VM-wide suspend at the conclusion
+ * of a normal (non-single-threaded) method invoke
+ */
+ if ((options & ClassType.INVOKE_SINGLE_THREADED) == 0) {
+ vm.notifySuspend();
+ }
+ if (ret.getException() != null) {
+ throw new InvocationException(ret.getException());
+ } else {
+ return ret.getResult();
+ }
+ }
+
+ @Override
+ boolean isAssignableTo(ReferenceType type) {
+ ClassTypeImpl superclazz = (ClassTypeImpl) superclass();
+ if (this.equals(type)) {
+ return true;
+ } else if ((superclazz != null) && superclazz.isAssignableTo(type)) {
+ return true;
+ } else {
+ List<InterfaceType> interfaces = interfaces();
+ Iterator<InterfaceType> iter = interfaces.iterator();
+ while (iter.hasNext()) {
+ InterfaceTypeImpl interfaze = (InterfaceTypeImpl) iter.next();
+ if (interfaze.isAssignableTo(type)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ @Override
+ final void addVisibleMethods(Map<String, Method> methodMap, Set<InterfaceType> seenInterfaces) {
+ /*
+ * Add methods from
+ * parent types first, so that the methods in this class will
+ * overwrite them in the hash table
+ */
+ Iterator<InterfaceType> iter = interfaces().iterator();
+ while (iter.hasNext()) {
+ InterfaceTypeImpl interfaze = (InterfaceTypeImpl) iter.next();
+ if (!seenInterfaces.contains(interfaze)) {
+ interfaze.addVisibleMethods(methodMap, seenInterfaces);
+ seenInterfaces.add(interfaze);
+ }
+ }
+ ClassTypeImpl clazz = (ClassTypeImpl) superclass();
+ if (clazz != null) {
+ clazz.addVisibleMethods(methodMap, seenInterfaces);
+ }
+ addToMethodMap(methodMap, methods());
+ }
+
+ final void addInterfaces(List<InterfaceType> list) {
+ List<InterfaceType> immediate = interfaces();
+ list.addAll(interfaces());
+ Iterator<InterfaceType> iter = immediate.iterator();
+ while (iter.hasNext()) {
+ InterfaceTypeImpl interfaze = (InterfaceTypeImpl) iter.next();
+ interfaze.addInterfaces(list);
+ }
+ ClassTypeImpl superclass = (ClassTypeImpl) superclass();
+ if (superclass != null) {
+ superclass.addInterfaces(list);
+ }
+ }
+
+ /**
+ * Returns all the implemented interfaces recursively
+ * @return A list of all the implemented interfaces (recursively)
+ */
+ final List<InterfaceType> getAllInterfaces() {
+ List<InterfaceType> all = new ArrayList<>();
+ addInterfaces(all);
+ return all;
+ }
+
+ /**
+ * Shared implementation of {@linkplain ClassType#allMethods()} and
+ * {@linkplain InterfaceType#allMethods()}
+ * @return A list of all methods (recursively)
+ */
+ public final List<Method> allMethods() {
+ ArrayList<Method> list = new ArrayList<>(methods());
+ ClassType clazz = superclass();
+ while (clazz != null) {
+ list.addAll(clazz.methods());
+ clazz = clazz.superclass();
+ }
+ /*
+ * Avoid duplicate checking on each method by iterating through
+ * duplicate-free allInterfaces() rather than recursing
+ */
+ for (InterfaceType interfaze : getAllInterfaces()) {
+ list.addAll(interfaze.methods());
+ }
+ return list;
+ }
+
+ @Override
+ final List<ReferenceType> inheritedTypes() {
+ List<ReferenceType> inherited = new ArrayList<>();
+ if (superclass() != null) {
+ inherited.add(0, superclass()); /* insert at front */
+ }
+ for (ReferenceType rt : interfaces()) {
+ inherited.add(rt);
+ }
+ return inherited;
+ }
+
+ private PacketStream sendInvokeCommand(final ThreadReferenceImpl thread,
+ final MethodImpl method,
+ final ValueImpl[] args,
+ final int options) {
+ /*
+ * Cache the values of args when TRACE_SENDS is enabled, for later printing.
+ * If not cached, printing causes a remote call while synchronized, and deadlock.
+ */
+ if ((vm.traceFlags & VirtualMachineImpl.TRACE_SENDS) != 0) {
+ for (ValueImpl arg: args) {
+ arg.toString();
+ }
+ }
+ CommandSender sender = getInvokeMethodSender(thread, method, args, options);
+ PacketStream stream;
+ if ((options & ClassType.INVOKE_SINGLE_THREADED) != 0) {
+ stream = thread.sendResumingCommand(sender);
+ } else {
+ stream = vm.sendResumingCommand(sender);
+ }
+ return stream;
+ }
+
+ private void validateMethodInvocation(Method method)
+ throws InvalidTypeException,
+ InvocationException {
+ if (!canInvoke(method)) {
+ throw new IllegalArgumentException("Invalid method");
+ }
+ /*
+ * Method must be a static and not a static initializer
+ */
+ if (!method.isStatic()) {
+ throw new IllegalArgumentException("Cannot invoke instance method on a class/interface type");
+ } else if (method.isStaticInitializer()) {
+ throw new IllegalArgumentException("Cannot invoke static initializer");
+ }
+ }
+
+ /**
+ * A subclass will provide specific {@linkplain CommandSender}
+ * @param thread the current invocation thread
+ * @param method the method to invoke
+ * @param args the arguments to pass to the method
+ * @param options the integer bit flag options
+ * @return the specific {@literal CommandSender} instance
+ */
+ abstract CommandSender getInvokeMethodSender(ThreadReferenceImpl thread,
+ MethodImpl method,
+ ValueImpl[] args,
+ int options);
+
+ /**
+ * Waits for the reply to the last sent command
+ * @param stream the stream to listen for the reply on
+ * @return the {@linkplain InvocationResult} instance
+ * @throws JDWPException when something goes wrong in JDWP
+ */
+ abstract InvocationResult waitForReply(PacketStream stream) throws JDWPException;
+
+ /**
+ * Get the {@linkplain ReferenceType} superclass
+ * @return the superclass or null
+ */
+ abstract ClassType superclass();
+
+ /**
+ * Get the implemented/extended interfaces
+ * @return the list of implemented/extended interfaces
+ */
+ abstract List<InterfaceType> interfaces();
+
+ /**
+ * Checks the provided method whether it can be invoked
+ * @param method the method to check
+ * @return {@code TRUE} if the implementation knows how to invoke the method,
+ * {@code FALSE} otherwise
+ */
+ abstract boolean canInvoke(Method method);
+}
diff --git a/src/share/classes/com/sun/tools/jdi/JDWPException.java b/src/share/classes/com/sun/tools/jdi/JDWPException.java
new file mode 100644
index 0000000..6f3fdb5
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/JDWPException.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+import com.sun.jdi.*;
+
+class JDWPException extends Exception {
+ private static final long serialVersionUID = -6321344442751299874L;
+ short errorCode;
+
+ JDWPException(short errorCode) {
+ super();
+ this.errorCode = errorCode;
+ }
+
+ short errorCode() {
+ return errorCode;
+ }
+
+ RuntimeException toJDIException() {
+ switch (errorCode) {
+ case JDWP.Error.INVALID_OBJECT:
+ return new ObjectCollectedException();
+ case JDWP.Error.VM_DEAD:
+ return new VMDisconnectedException();
+ case JDWP.Error.OUT_OF_MEMORY:
+ return new VMOutOfMemoryException();
+ case JDWP.Error.CLASS_NOT_PREPARED:
+ return new ClassNotPreparedException();
+ case JDWP.Error.INVALID_FRAMEID:
+ case JDWP.Error.NOT_CURRENT_FRAME:
+ return new InvalidStackFrameException();
+ case JDWP.Error.NOT_IMPLEMENTED:
+ return new UnsupportedOperationException();
+ case JDWP.Error.INVALID_INDEX:
+ case JDWP.Error.INVALID_LENGTH:
+ return new IndexOutOfBoundsException();
+ case JDWP.Error.TYPE_MISMATCH:
+ return new InconsistentDebugInfoException();
+ case JDWP.Error.INVALID_THREAD:
+ return new IllegalThreadStateException();
+ default:
+ return new InternalException("Unexpected JDWP Error: " + errorCode, errorCode);
+ }
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/JNITypeParser.java b/src/share/classes/com/sun/tools/jdi/JNITypeParser.java
new file mode 100644
index 0000000..2ed7265
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/JNITypeParser.java
@@ -0,0 +1,241 @@
+/*
+ * Copyright (c) 1998, 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 com.sun.tools.jdi;
+
+import java.util.List;
+import java.util.ArrayList;
+
+public class JNITypeParser {
+
+ static final char SIGNATURE_ENDCLASS = ';';
+ static final char SIGNATURE_FUNC = '(';
+ static final char SIGNATURE_ENDFUNC = ')';
+
+ private String signature;
+ private List<String> typeNameList;
+ private List<String> signatureList;
+ private int currentIndex;
+
+ JNITypeParser(String signature) {
+ this.signature = signature;
+ }
+
+ static String typeNameToSignature(String signature) {
+ StringBuffer buffer = new StringBuffer();
+ int firstIndex = signature.indexOf('[');
+ int index = firstIndex;
+ while (index != -1) {
+ buffer.append('[');
+ index = signature.indexOf('[', index + 1);
+ }
+
+ if (firstIndex != -1) {
+ signature = signature.substring(0, firstIndex);
+ }
+
+ if (signature.equals("boolean")) {
+ buffer.append('Z');
+ } else if (signature.equals("byte")) {
+ buffer.append('B');
+ } else if (signature.equals("char")) {
+ buffer.append('C');
+ } else if (signature.equals("short")) {
+ buffer.append('S');
+ } else if (signature.equals("int")) {
+ buffer.append('I');
+ } else if (signature.equals("long")) {
+ buffer.append('J');
+ } else if (signature.equals("float")) {
+ buffer.append('F');
+ } else if (signature.equals("double")) {
+ buffer.append('D');
+ } else {
+ buffer.append('L');
+ buffer.append(signature.replace('.', '/'));
+ buffer.append(';');
+ }
+
+ return buffer.toString();
+ }
+
+ String typeName() {
+ return typeNameList().get(typeNameList().size()-1);
+ }
+
+ List<String> argumentTypeNames() {
+ return typeNameList().subList(0, typeNameList().size() - 1);
+ }
+
+ String signature() {
+ return signatureList().get(signatureList().size()-1);
+ }
+
+ List<String> argumentSignatures() {
+ return signatureList().subList(0, signatureList().size() - 1);
+ }
+
+ int dimensionCount() {
+ int count = 0;
+ String signature = signature();
+ while (signature.charAt(count) == '[') {
+ count++;
+ }
+ return count;
+ }
+
+ String componentSignature(int level) {
+ return signature().substring(level);
+ }
+
+ private synchronized List<String> signatureList() {
+ if (signatureList == null) {
+ signatureList = new ArrayList<String>(10);
+ String elem;
+
+ currentIndex = 0;
+
+ while(currentIndex < signature.length()) {
+ elem = nextSignature();
+ signatureList.add(elem);
+ }
+ if (signatureList.size() == 0) {
+ throw new IllegalArgumentException("Invalid JNI signature '" +
+ signature + "'");
+ }
+ }
+ return signatureList;
+ }
+
+ private synchronized List<String> typeNameList() {
+ if (typeNameList == null) {
+ typeNameList = new ArrayList<String>(10);
+ String elem;
+
+ currentIndex = 0;
+
+ while(currentIndex < signature.length()) {
+ elem = nextTypeName();
+ typeNameList.add(elem);
+ }
+ if (typeNameList.size() == 0) {
+ throw new IllegalArgumentException("Invalid JNI signature '" +
+ signature + "'");
+ }
+ }
+ return typeNameList;
+ }
+
+ private String nextSignature() {
+ char key = signature.charAt(currentIndex++);
+
+ switch(key) {
+ case (JDWP.Tag.ARRAY):
+ return key + nextSignature();
+
+ case (JDWP.Tag.OBJECT):
+ int endClass = signature.indexOf(SIGNATURE_ENDCLASS,
+ currentIndex);
+ String retVal = signature.substring(currentIndex - 1,
+ endClass + 1);
+ currentIndex = endClass + 1;
+ return retVal;
+
+ case (JDWP.Tag.VOID):
+ case (JDWP.Tag.BOOLEAN):
+ case (JDWP.Tag.BYTE):
+ case (JDWP.Tag.CHAR):
+ case (JDWP.Tag.SHORT):
+ case (JDWP.Tag.INT):
+ case (JDWP.Tag.LONG):
+ case (JDWP.Tag.FLOAT):
+ case (JDWP.Tag.DOUBLE):
+ return String.valueOf(key);
+
+ case SIGNATURE_ENDFUNC:
+ case SIGNATURE_FUNC:
+ return nextSignature();
+
+ default:
+ throw new IllegalArgumentException(
+ "Invalid JNI signature character '" + key + "'");
+
+ }
+ }
+
+ private String nextTypeName() {
+ char key = signature.charAt(currentIndex++);
+
+ switch(key) {
+ case (JDWP.Tag.ARRAY):
+ return nextTypeName() + "[]";
+
+ case (JDWP.Tag.BYTE):
+ return "byte";
+
+ case (JDWP.Tag.CHAR):
+ return "char";
+
+ case (JDWP.Tag.OBJECT):
+ int endClass = signature.indexOf(SIGNATURE_ENDCLASS,
+ currentIndex);
+ String retVal = signature.substring(currentIndex,
+ endClass);
+ retVal = retVal.replace('/','.');
+ currentIndex = endClass + 1;
+ return retVal;
+
+ case (JDWP.Tag.FLOAT):
+ return "float";
+
+ case (JDWP.Tag.DOUBLE):
+ return "double";
+
+ case (JDWP.Tag.INT):
+ return "int";
+
+ case (JDWP.Tag.LONG):
+ return "long";
+
+ case (JDWP.Tag.SHORT):
+ return "short";
+
+ case (JDWP.Tag.VOID):
+ return "void";
+
+ case (JDWP.Tag.BOOLEAN):
+ return "boolean";
+
+ case SIGNATURE_ENDFUNC:
+ case SIGNATURE_FUNC:
+ return nextTypeName();
+
+ default:
+ throw new IllegalArgumentException(
+ "Invalid JNI signature character '" + key + "'");
+
+ }
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/LineInfo.java b/src/share/classes/com/sun/tools/jdi/LineInfo.java
new file mode 100644
index 0000000..8a4bdef
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/LineInfo.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2001, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+interface LineInfo {
+
+ String liStratum();
+
+ int liLineNumber();
+
+ String liSourceName() throws AbsentInformationException;
+
+ String liSourcePath() throws AbsentInformationException;
+}
diff --git a/src/share/classes/com/sun/tools/jdi/LocalVariableImpl.java b/src/share/classes/com/sun/tools/jdi/LocalVariableImpl.java
new file mode 100644
index 0000000..0914eb1
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/LocalVariableImpl.java
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 1998, 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.tools.jdi;
+import com.sun.jdi.*;
+
+public class LocalVariableImpl extends MirrorImpl
+ implements LocalVariable, ValueContainer
+{
+ private final Method method;
+ private final int slot;
+ private final Location scopeStart;
+ private final Location scopeEnd;
+ private final String name;
+ private final String signature;
+ private String genericSignature = null;
+
+ LocalVariableImpl(VirtualMachine vm, Method method,
+ int slot, Location scopeStart, Location scopeEnd,
+ String name, String signature,
+ String genericSignature) {
+ super(vm);
+ this.method = method;
+ this.slot = slot;
+ this.scopeStart = scopeStart;
+ this.scopeEnd = scopeEnd;
+ this.name = name;
+ this.signature = signature;
+ if (genericSignature != null && genericSignature.length() > 0) {
+ this.genericSignature = genericSignature;
+ } else {
+ // The Spec says to return null for non-generic types
+ this.genericSignature = null;
+ }
+ }
+
+ public boolean equals(Object obj) {
+ if ((obj != null) && (obj instanceof LocalVariableImpl)) {
+ LocalVariableImpl other = (LocalVariableImpl)obj;
+ return ((slot() == other.slot()) &&
+ (scopeStart != null) &&
+ (scopeStart.equals(other.scopeStart)) &&
+ (super.equals(obj)));
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ /*
+ * TO DO: Better hash code
+ */
+ return ((scopeStart.hashCode() << 4) + slot());
+ }
+
+ public int compareTo(LocalVariable object) {
+ LocalVariableImpl other = (LocalVariableImpl)object;
+
+ int rc = scopeStart.compareTo(other.scopeStart);
+ if (rc == 0) {
+ rc = slot() - other.slot();
+ }
+ return rc;
+ }
+
+ public String name() {
+ return name;
+ }
+
+ /**
+ * @return a text representation of the declared type
+ * of this variable.
+ */
+ public String typeName() {
+ JNITypeParser parser = new JNITypeParser(signature);
+ return parser.typeName();
+ }
+
+ public Type type() throws ClassNotLoadedException {
+ return findType(signature());
+ }
+
+ public Type findType(String signature) throws ClassNotLoadedException {
+ ReferenceTypeImpl enclosing = (ReferenceTypeImpl)method.declaringType();
+ return enclosing.findType(signature);
+ }
+
+ public String signature() {
+ return signature;
+ }
+
+ public String genericSignature() {
+ return genericSignature;
+ }
+
+ public boolean isVisible(StackFrame frame) {
+ validateMirror(frame);
+ Method frameMethod = frame.location().method();
+
+ if (!frameMethod.equals(method)) {
+ throw new IllegalArgumentException(
+ "frame method different than variable's method");
+ }
+
+ // this is here to cover the possibility that we will
+ // allow LocalVariables for native methods. If we do
+ // so we will have to re-examinine this.
+ if (frameMethod.isNative()) {
+ return false;
+ }
+
+ return ((scopeStart.compareTo(frame.location()) <= 0)
+ && (scopeEnd.compareTo(frame.location()) >= 0));
+ }
+
+ public boolean isArgument() {
+ try {
+ MethodImpl method = (MethodImpl)scopeStart.method();
+ return (slot < method.argSlotCount());
+ } catch (AbsentInformationException e) {
+ // If this variable object exists, there shouldn't be absent info
+ throw new InternalException();
+ }
+ }
+
+ int slot() {
+ return slot;
+ }
+
+ /*
+ * Compilers/VMs can have byte code ranges for variables of the
+ * same names that overlap. This is because the byte code ranges
+ * aren't necessarily scopes; they may have more to do with the
+ * lifetime of the variable's slot, depending on implementation.
+ *
+ * This method determines whether this variable hides an
+ * identically named variable; ie, their byte code ranges overlap
+ * this one starts after the given one. If it returns true this
+ * variable should be preferred when looking for a single variable
+ * with its name when both variables are visible.
+ */
+ boolean hides(LocalVariable other) {
+ LocalVariableImpl otherImpl = (LocalVariableImpl)other;
+ if (!method.equals(otherImpl.method) ||
+ !name.equals(otherImpl.name)) {
+ return false;
+ } else {
+ return (scopeStart.compareTo(otherImpl.scopeStart) > 0);
+ }
+ }
+
+ public String toString() {
+ return name() + " in " + method.toString() +
+ "@" + scopeStart.toString();
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/LocationImpl.java b/src/share/classes/com/sun/tools/jdi/LocationImpl.java
new file mode 100644
index 0000000..5922dc0
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/LocationImpl.java
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 1998, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+import java.util.*;
+
+public class LocationImpl extends MirrorImpl implements Location {
+ private final ReferenceTypeImpl declaringType;
+ private Method method;
+ private long methodRef;
+ private long codeIndex;
+ private LineInfo baseLineInfo = null;
+ private LineInfo otherLineInfo = null;
+
+ LocationImpl(VirtualMachine vm,
+ Method method, long codeIndex) {
+ super(vm);
+
+ this.method = method;
+ this.codeIndex = method.isNative()? -1 : codeIndex;
+ this.declaringType = (ReferenceTypeImpl)method.declaringType();
+ }
+
+ /*
+ * This constructor allows lazy creation of the method mirror. This
+ * can be a performance savings if the method mirror does not yet
+ * exist.
+ */
+ LocationImpl(VirtualMachine vm, ReferenceTypeImpl declaringType,
+ long methodRef, long codeIndex) {
+ super(vm);
+
+ this.method = null;
+ this.codeIndex = codeIndex;
+ this.declaringType = declaringType;
+ this.methodRef = methodRef;
+ }
+
+ public boolean equals(Object obj) {
+ if ((obj != null) && (obj instanceof Location)) {
+ Location other = (Location)obj;
+ return (method().equals(other.method())) &&
+ (codeIndex() == other.codeIndex()) &&
+ super.equals(obj);
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ /*
+ * TO DO: better hash code?
+ */
+ return method().hashCode() + (int)codeIndex();
+ }
+
+ public int compareTo(Location object) {
+ LocationImpl other = (LocationImpl)object;
+ int rc = method().compareTo(other.method());
+ if (rc == 0) {
+ long diff = codeIndex() - other.codeIndex();
+ if (diff < 0)
+ return -1;
+ else if (diff > 0)
+ return 1;
+ else
+ return 0;
+ }
+ return rc;
+ }
+
+ public ReferenceType declaringType() {
+ return declaringType;
+ }
+
+ public Method method() {
+ if (method == null) {
+ method = declaringType.getMethodMirror(methodRef);
+ if (method.isNative()) {
+ codeIndex = -1;
+ }
+ }
+ return method;
+ }
+
+ public long codeIndex() {
+ method(); // be sure information is up-to-date
+ return codeIndex;
+ }
+
+ LineInfo getBaseLineInfo(SDE.Stratum stratum) {
+ LineInfo lineInfo;
+
+ /* check if there is cached info to use */
+ if (baseLineInfo != null) {
+ return baseLineInfo;
+ }
+
+ /* compute the line info */
+ MethodImpl methodImpl = (MethodImpl)method();
+ lineInfo = methodImpl.codeIndexToLineInfo(stratum,
+ codeIndex());
+
+ /* cache it */
+ addBaseLineInfo(lineInfo);
+
+ return lineInfo;
+ }
+
+ LineInfo getLineInfo(SDE.Stratum stratum) {
+ LineInfo lineInfo;
+
+ /* base stratum is done slighly differently */
+ if (stratum.isJava()) {
+ return getBaseLineInfo(stratum);
+ }
+
+ /* check if there is cached info to use */
+ lineInfo = otherLineInfo; // copy because of concurrency
+ if (lineInfo != null &&
+ stratum.id().equals(lineInfo.liStratum())) {
+ return lineInfo;
+ }
+
+ int baseLineNumber = lineNumber(SDE.BASE_STRATUM_NAME);
+ SDE.LineStratum lineStratum =
+ stratum.lineStratum(declaringType, baseLineNumber);
+
+ if (lineStratum != null && lineStratum.lineNumber() != -1) {
+ lineInfo = new StratumLineInfo(stratum.id(),
+ lineStratum.lineNumber(),
+ lineStratum.sourceName(),
+ lineStratum.sourcePath());
+ } else {
+ /* find best match */
+ MethodImpl methodImpl = (MethodImpl)method();
+ lineInfo = methodImpl.codeIndexToLineInfo(stratum,
+ codeIndex());
+ }
+
+ /* cache it */
+ addStratumLineInfo(lineInfo);
+
+ return lineInfo;
+ }
+
+ void addStratumLineInfo(LineInfo lineInfo) {
+ otherLineInfo = lineInfo;
+ }
+
+ void addBaseLineInfo(LineInfo lineInfo) {
+ baseLineInfo = lineInfo;
+ }
+
+ public String sourceName() throws AbsentInformationException {
+ return sourceName(vm.getDefaultStratum());
+ }
+
+ public String sourceName(String stratumID)
+ throws AbsentInformationException {
+ return sourceName(declaringType.stratum(stratumID));
+ }
+
+ String sourceName(SDE.Stratum stratum)
+ throws AbsentInformationException {
+ return getLineInfo(stratum).liSourceName();
+ }
+
+ public String sourcePath() throws AbsentInformationException {
+ return sourcePath(vm.getDefaultStratum());
+ }
+
+ public String sourcePath(String stratumID)
+ throws AbsentInformationException {
+ return sourcePath(declaringType.stratum(stratumID));
+ }
+
+ String sourcePath(SDE.Stratum stratum)
+ throws AbsentInformationException {
+ return getLineInfo(stratum).liSourcePath();
+ }
+
+ public int lineNumber() {
+ return lineNumber(vm.getDefaultStratum());
+ }
+
+ public int lineNumber(String stratumID) {
+ return lineNumber(declaringType.stratum(stratumID));
+ }
+
+ int lineNumber(SDE.Stratum stratum) {
+ return getLineInfo(stratum).liLineNumber();
+ }
+
+ public String toString() {
+ if (lineNumber() == -1) {
+ return method().toString() + "+" + codeIndex();
+ } else {
+ return declaringType().name() + ":" + lineNumber();
+ }
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/LockObject.java b/src/share/classes/com/sun/tools/jdi/LockObject.java
new file mode 100644
index 0000000..250a8ca
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/LockObject.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 1998, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+/**
+ * This class is used by the back end to do thread synchronization.
+ * We don't want to use java.lang.Object(s) for two reasons: we can't
+ * filter them out, and this class should use less heap.
+ */
+
+public class LockObject
+{
+}
diff --git a/src/share/classes/com/sun/tools/jdi/LongTypeImpl.java b/src/share/classes/com/sun/tools/jdi/LongTypeImpl.java
new file mode 100644
index 0000000..5854d5e
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/LongTypeImpl.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1998, 1999, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class LongTypeImpl extends PrimitiveTypeImpl implements LongType {
+ LongTypeImpl(VirtualMachine vm) {
+ super(vm);
+ }
+
+
+ public String signature() {
+ return String.valueOf((char)JDWP.Tag.LONG);
+ }
+
+ PrimitiveValue convert(PrimitiveValue value) throws InvalidTypeException {
+ return vm.mirrorOf(((PrimitiveValueImpl)value).checkedLongValue());
+ }
+
+}
diff --git a/src/share/classes/com/sun/tools/jdi/LongValueImpl.java b/src/share/classes/com/sun/tools/jdi/LongValueImpl.java
new file mode 100644
index 0000000..ee64d11
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/LongValueImpl.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class LongValueImpl extends PrimitiveValueImpl
+ implements LongValue {
+ private long value;
+
+ LongValueImpl(VirtualMachine aVm,long aValue) {
+ super(aVm);
+
+ value = aValue;
+ }
+
+ public boolean equals(Object obj) {
+ if ((obj != null) && (obj instanceof LongValue)) {
+ return (value == ((LongValue)obj).value()) &&
+ super.equals(obj);
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ /*
+ * TO DO: Better hash code
+ */
+ return intValue();
+ }
+
+ public int compareTo(LongValue obj) {
+ long other = obj.value();
+ if (value() < other) {
+ return -1;
+ } else if (value() == other) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+
+ public Type type() {
+ return vm.theLongType();
+ }
+
+ public long value() {
+ return value;
+ }
+
+ public boolean booleanValue() {
+ return(value == 0)?false:true;
+ }
+
+ public byte byteValue() {
+ return(byte)value;
+ }
+
+ public char charValue() {
+ return(char)value;
+ }
+
+ public short shortValue() {
+ return(short)value;
+ }
+
+ public int intValue() {
+ return(int)value;
+ }
+
+ public long longValue() {
+ return value;
+ }
+
+ public float floatValue() {
+ return(float)value;
+ }
+
+ public double doubleValue() {
+ return(double)value;
+ }
+
+ byte checkedByteValue() throws InvalidTypeException {
+ if ((value > Byte.MAX_VALUE) || (value < Byte.MIN_VALUE)) {
+ throw new InvalidTypeException("Can't convert " + value + " to byte");
+ } else {
+ return super.checkedByteValue();
+ }
+ }
+
+ char checkedCharValue() throws InvalidTypeException {
+ if ((value > Character.MAX_VALUE) || (value < Character.MIN_VALUE)) {
+ throw new InvalidTypeException("Can't convert " + value + " to char");
+ } else {
+ return super.checkedCharValue();
+ }
+ }
+
+ short checkedShortValue() throws InvalidTypeException {
+ if ((value > Short.MAX_VALUE) || (value < Short.MIN_VALUE)) {
+ throw new InvalidTypeException("Can't convert " + value + " to short");
+ } else {
+ return super.checkedShortValue();
+ }
+ }
+
+ int checkedIntValue() throws InvalidTypeException {
+ if ((value > Integer.MAX_VALUE) || (value < Integer.MIN_VALUE)) {
+ throw new InvalidTypeException("Can't convert " + value + " to int");
+ } else {
+ return super.checkedIntValue();
+ }
+ }
+
+ public String toString() {
+ return "" + value;
+ }
+
+ byte typeValueKey() {
+ return JDWP.Tag.LONG;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/META-INF/services/com.sun.jdi.connect.Connector b/src/share/classes/com/sun/tools/jdi/META-INF/services/com.sun.jdi.connect.Connector
new file mode 100644
index 0000000..e9ecb5e
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/META-INF/services/com.sun.jdi.connect.Connector
@@ -0,0 +1,38 @@
+#
+# Copyright (c) 2003, 2005, 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.
+#
+
+#
+# List all Sun provided connector providers here. If there
+# are providers that are only available on a particular OS
+# then prefix the line with #[OS] and they will automatically
+# uncommented by the build process - see make/jpda/front/Makefile.
+#
+com.sun.tools.jdi.SunCommandLineLauncher
+com.sun.tools.jdi.RawCommandLineLauncher
+com.sun.tools.jdi.SocketAttachingConnector
+com.sun.tools.jdi.SocketListeningConnector
+#[windows]com.sun.tools.jdi.SharedMemoryAttachingConnector
+#[windows]com.sun.tools.jdi.SharedMemoryListeningConnector
+com.sun.tools.jdi.ProcessAttachingConnector
diff --git a/src/share/classes/com/sun/tools/jdi/META-INF/services/com.sun.jdi.connect.spi.TransportService b/src/share/classes/com/sun/tools/jdi/META-INF/services/com.sun.jdi.connect.spi.TransportService
new file mode 100644
index 0000000..603dcc9
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/META-INF/services/com.sun.jdi.connect.spi.TransportService
@@ -0,0 +1,30 @@
+#
+# Copyright (c) 2003, 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.
+#
+
+#
+# List any additional Sun provided transport services here.
+# If any transport services are OS specific then prefix the line
+# with #[OS] and they will automatically be uncommented in the
+# build process - see make/jpda/front/Makefile.
diff --git a/src/share/classes/com/sun/tools/jdi/MethodImpl.java b/src/share/classes/com/sun/tools/jdi/MethodImpl.java
new file mode 100644
index 0000000..8135aed
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/MethodImpl.java
@@ -0,0 +1,410 @@
+/*
+ * Copyright (c) 1998, 2016, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.Comparator;
+
+public abstract class MethodImpl extends TypeComponentImpl
+ implements Method {
+ private JNITypeParser signatureParser;
+ abstract int argSlotCount() throws AbsentInformationException;
+
+ abstract List<Location> allLineLocations(SDE.Stratum stratum,
+ String sourceName)
+ throws AbsentInformationException;
+
+ abstract List<Location> locationsOfLine(SDE.Stratum stratum,
+ String sourceName,
+ int lineNumber)
+ throws AbsentInformationException;
+
+ MethodImpl(VirtualMachine vm, ReferenceTypeImpl declaringType,
+ long ref,
+ String name, String signature,
+ String genericSignature, int modifiers) {
+ super(vm, declaringType, ref, name, signature,
+ genericSignature, modifiers);
+ signatureParser = new JNITypeParser(signature);
+ }
+
+ static MethodImpl createMethodImpl(VirtualMachine vm,
+ ReferenceTypeImpl declaringType,
+ long ref,
+ String name,
+ String signature,
+ String genericSignature,
+ int modifiers) {
+ if ((modifiers &
+ (VMModifiers.NATIVE | VMModifiers.ABSTRACT)) != 0) {
+ return new NonConcreteMethodImpl(vm, declaringType, ref,
+ name, signature,
+ genericSignature,
+ modifiers);
+ } else {
+ return new ConcreteMethodImpl(vm, declaringType, ref,
+ name, signature,
+ genericSignature,
+ modifiers);
+ }
+ }
+
+ public boolean equals(Object obj) {
+ if ((obj != null) && (obj instanceof MethodImpl)) {
+ MethodImpl other = (MethodImpl)obj;
+ return (declaringType().equals(other.declaringType())) &&
+ (ref() == other.ref()) &&
+ super.equals(obj);
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ return (int)ref();
+ }
+
+ public final List<Location> allLineLocations()
+ throws AbsentInformationException {
+ return allLineLocations(vm.getDefaultStratum(), null);
+ }
+
+ public List<Location> allLineLocations(String stratumID,
+ String sourceName)
+ throws AbsentInformationException {
+ return allLineLocations(declaringType.stratum(stratumID),
+ sourceName);
+ }
+
+ public final List<Location> locationsOfLine(int lineNumber)
+ throws AbsentInformationException {
+ return locationsOfLine(vm.getDefaultStratum(),
+ null, lineNumber);
+ }
+
+ public List<Location> locationsOfLine(String stratumID,
+ String sourceName,
+ int lineNumber)
+ throws AbsentInformationException {
+ return locationsOfLine(declaringType.stratum(stratumID),
+ sourceName, lineNumber);
+ }
+
+ LineInfo codeIndexToLineInfo(SDE.Stratum stratum,
+ long codeIndex) {
+ if (stratum.isJava()) {
+ return new BaseLineInfo(-1, declaringType);
+ } else {
+ return new StratumLineInfo(stratum.id(), -1,
+ null, null);
+ }
+ }
+
+ /**
+ * @return a text representation of the declared return type
+ * of this method.
+ */
+ public String returnTypeName() {
+ return signatureParser.typeName();
+ }
+
+ private String returnSignature() {
+ return signatureParser.signature();
+ }
+
+ public Type returnType() throws ClassNotLoadedException {
+ return findType(returnSignature());
+ }
+
+ public Type findType(String signature) throws ClassNotLoadedException {
+ ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType();
+ return enclosing.findType(signature);
+ }
+
+ public List<String> argumentTypeNames() {
+ return signatureParser.argumentTypeNames();
+ }
+
+ public List<String> argumentSignatures() {
+ return signatureParser.argumentSignatures();
+ }
+
+ Type argumentType(int index) throws ClassNotLoadedException {
+ ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType();
+ String signature = argumentSignatures().get(index);
+ return enclosing.findType(signature);
+ }
+
+ public List<Type> argumentTypes() throws ClassNotLoadedException {
+ int size = argumentSignatures().size();
+ ArrayList<Type> types = new ArrayList<Type>(size);
+ for (int i = 0; i < size; i++) {
+ Type type = argumentType(i);
+ types.add(type);
+ }
+
+ return types;
+ }
+
+ public int compareTo(Method method) {
+ ReferenceTypeImpl declaringType = (ReferenceTypeImpl)declaringType();
+ int rc = declaringType.compareTo(method.declaringType());
+ if (rc == 0) {
+ rc = declaringType.indexOf(this) -
+ declaringType.indexOf(method);
+ }
+ return rc;
+ }
+
+ public boolean isAbstract() {
+ return isModifierSet(VMModifiers.ABSTRACT);
+ }
+
+ public boolean isDefault() {
+ return !isModifierSet(VMModifiers.ABSTRACT) &&
+ !isModifierSet(VMModifiers.STATIC) &&
+ !isModifierSet(VMModifiers.PRIVATE) &&
+ declaringType() instanceof InterfaceType;
+ }
+
+ public boolean isSynchronized() {
+ return isModifierSet(VMModifiers.SYNCHRONIZED);
+ }
+
+ public boolean isNative() {
+ return isModifierSet(VMModifiers.NATIVE);
+ }
+
+ public boolean isVarArgs() {
+ return isModifierSet(VMModifiers.VARARGS);
+ }
+
+ public boolean isBridge() {
+ return isModifierSet(VMModifiers.BRIDGE);
+ }
+
+ public boolean isConstructor() {
+ return name().equals("<init>");
+ }
+
+ public boolean isStaticInitializer() {
+ return name().equals("<clinit>");
+ }
+
+ public boolean isObsolete() {
+ try {
+ return JDWP.Method.IsObsolete.process(vm,
+ declaringType, ref).isObsolete;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+
+
+ /*
+ * A container class for the return value to allow
+ * proper type-checking.
+ */
+ class ReturnContainer implements ValueContainer {
+ ReturnContainer() {
+ }
+ public Type type() throws ClassNotLoadedException {
+ return returnType();
+ }
+ public String typeName(){
+ return returnTypeName();
+ }
+ public String signature() {
+ return returnSignature(); //type().signature();
+ }
+ public Type findType(String signature) throws ClassNotLoadedException {
+ return MethodImpl.this.findType(signature);
+ }
+ }
+ ReturnContainer retValContainer = null;
+ ReturnContainer getReturnValueContainer() {
+ if (retValContainer == null) {
+ retValContainer = new ReturnContainer();
+ }
+ return retValContainer;
+ }
+
+ /*
+ * A container class for the argument to allow
+ * proper type-checking.
+ */
+ class ArgumentContainer implements ValueContainer {
+ int index;
+
+ ArgumentContainer(int index) {
+ this.index = index;
+ }
+ public Type type() throws ClassNotLoadedException {
+ return argumentType(index);
+ }
+ public String typeName(){
+ return argumentTypeNames().get(index);
+ }
+ public String signature() {
+ return argumentSignatures().get(index);
+ }
+ public Type findType(String signature) throws ClassNotLoadedException {
+ return MethodImpl.this.findType(signature);
+ }
+ }
+
+ /*
+ * This is a var args method. Thus, its last param is an
+ * array. If the method has n params, then:
+ * 1. If there are n args and the last is the same type as the type of
+ * the last param, do nothing. IE, a String[]
+ * can be passed to a String...
+ * 2. If there are >= n arguments and for each arg whose number is >= n,
+ * the arg type is 'compatible' with the component type of
+ * the last param, then do
+ * - create an array of the type of the last param
+ * - put the n, ... args into this array.
+ * We might have to do conversions here.
+ * - put this array into arguments(n)
+ * - delete arguments(n+1), ...
+ * NOTE that this might modify the input list.
+ */
+ void handleVarArgs(List<Value> arguments)
+ throws ClassNotLoadedException, InvalidTypeException {
+ List<Type> paramTypes = this.argumentTypes();
+ ArrayType lastParamType = (ArrayType)paramTypes.get(paramTypes.size() - 1);
+ Type componentType = lastParamType.componentType();
+ int argCount = arguments.size();
+ int paramCount = paramTypes.size();
+ if (argCount < paramCount - 1) {
+ // Error; will be caught later.
+ return;
+ }
+ if (argCount == paramCount - 1) {
+ // It is ok to pass 0 args to the var arg.
+ // We have to gen a 0 length array.
+ ArrayReference argArray = lastParamType.newInstance(0);
+ arguments.add(argArray);
+ return;
+ }
+ Value nthArgValue = arguments.get(paramCount - 1);
+ if (nthArgValue == null && argCount == paramCount) {
+ // We have one varargs parameter and it is null
+ // so we don't have to do anything.
+ return;
+ }
+ // If the first varargs parameter is null, then don't
+ // access its type since it can't be an array.
+ Type nthArgType = (nthArgValue == null) ? null : nthArgValue.type();
+ if (nthArgType instanceof ArrayTypeImpl) {
+ if (argCount == paramCount &&
+ ((ArrayTypeImpl)nthArgType).isAssignableTo(lastParamType)) {
+ /*
+ * This is case 1. A compatible array is being passed to the
+ * var args array param. We don't have to do anything.
+ */
+ return;
+ }
+ }
+
+ /*
+ * Case 2. We have to verify that the n, n+1, ... args are compatible
+ * with componentType, and do conversions if necessary and create
+ * an array of componentType to hold these possibly converted values.
+ */
+ int count = argCount - paramCount + 1;
+ ArrayReference argArray = lastParamType.newInstance(count);
+
+ /*
+ * This will copy arguments(paramCount - 1) ... to argArray(0) ...
+ * doing whatever conversions are needed! It will throw an
+ * exception if an incompatible arg is encountered
+ */
+ argArray.setValues(0, arguments, paramCount - 1, count);
+ arguments.set(paramCount - 1, argArray);
+
+ /*
+ * Remove the excess args
+ */
+ for (int ii = paramCount; ii < argCount; ii++) {
+ arguments.remove(paramCount);
+ }
+ return;
+ }
+
+ /*
+ * The output list will be different than the input list.
+ */
+ List<Value> validateAndPrepareArgumentsForInvoke(List<? extends Value> origArguments)
+ throws ClassNotLoadedException, InvalidTypeException {
+
+ List<Value> arguments = new ArrayList<Value>(origArguments);
+ if (isVarArgs()) {
+ handleVarArgs(arguments);
+ }
+
+ int argSize = arguments.size();
+
+ JNITypeParser parser = new JNITypeParser(signature());
+ List<String> signatures = parser.argumentSignatures();
+
+ if (signatures.size() != argSize) {
+ throw new IllegalArgumentException("Invalid argument count: expected " +
+ signatures.size() + ", received " +
+ arguments.size());
+ }
+
+ for (int i = 0; i < argSize; i++) {
+ Value value = arguments.get(i);
+ value = ValueImpl.prepareForAssignment(value,
+ new ArgumentContainer(i));
+ arguments.set(i, value);
+ }
+ return arguments;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(declaringType().name());
+ sb.append(".");
+ sb.append(name());
+ sb.append("(");
+ boolean first = true;
+ for (String name : argumentTypeNames()) {
+ if (!first) {
+ sb.append(", ");
+ }
+ sb.append(name);
+ first = false;
+ }
+ sb.append(")");
+ return sb.toString();
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/MirrorImpl.java b/src/share/classes/com/sun/tools/jdi/MirrorImpl.java
new file mode 100644
index 0000000..554cb06
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/MirrorImpl.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+import java.util.Collection;
+import java.util.Iterator;
+
+abstract class MirrorImpl extends Object implements Mirror {
+
+ protected VirtualMachineImpl vm;
+
+ MirrorImpl(VirtualMachine aVm) {
+ super();
+
+ // Yes, its a bit of a hack. But by doing it this
+ // way, this is the only place we have to change
+ // typing to substitute a new impl.
+ vm = (VirtualMachineImpl)aVm;
+ }
+
+ public VirtualMachine virtualMachine() {
+ return vm;
+ }
+
+ public boolean equals(Object obj) {
+ if ((obj != null) && (obj instanceof Mirror)) {
+ Mirror other = (Mirror)obj;
+ return vm.equals(other.virtualMachine());
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ return vm.hashCode();
+ }
+
+ /**
+ * Throw NullPointerException on null mirror.
+ * Throw VMMismatchException on wrong VM.
+ */
+ void validateMirror(Mirror mirror) {
+ if (!vm.equals(mirror.virtualMachine())) {
+ throw new VMMismatchException(mirror.toString());
+ }
+ }
+
+ /**
+ * Allow null mirror.
+ * Throw VMMismatchException on wrong VM.
+ */
+ void validateMirrorOrNull(Mirror mirror) {
+ if ((mirror != null) && !vm.equals(mirror.virtualMachine())) {
+ throw new VMMismatchException(mirror.toString());
+ }
+ }
+
+ /**
+ * Throw NullPointerException on null mirrors.
+ * Throw VMMismatchException on wrong VM.
+ */
+ void validateMirrors(Collection<? extends Mirror> mirrors) {
+ Iterator<? extends Mirror> iter = mirrors.iterator();
+ while (iter.hasNext()) {
+ MirrorImpl mirror = (MirrorImpl)iter.next();
+ if (!vm.equals(mirror.vm)) {
+ throw new VMMismatchException(mirror.toString());
+ }
+ }
+ }
+ /**
+ * Allow null mirrors.
+ * Throw VMMismatchException on wrong VM.
+ */
+ void validateMirrorsOrNulls(Collection<? extends Mirror> mirrors) {
+ Iterator<? extends Mirror> iter = mirrors.iterator();
+ while (iter.hasNext()) {
+ MirrorImpl mirror = (MirrorImpl)iter.next();
+ if ((mirror != null) && !vm.equals(mirror.vm)) {
+ throw new VMMismatchException(mirror.toString());
+ }
+ }
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/MonitorInfoImpl.java b/src/share/classes/com/sun/tools/jdi/MonitorInfoImpl.java
new file mode 100644
index 0000000..9ebc059
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/MonitorInfoImpl.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2005, 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 com.sun.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class MonitorInfoImpl extends MirrorImpl
+ implements MonitorInfo, ThreadListener {
+
+ /* Once false, monitorInfo should not be used.
+ * access synchronized on (vm.state())
+ */
+ private boolean isValid = true;
+
+ ObjectReference monitor;
+ ThreadReference thread;
+ int stack_depth;
+
+ MonitorInfoImpl(VirtualMachine vm, ObjectReference mon,
+ ThreadReferenceImpl thread, int dpth) {
+ super(vm);
+ this.monitor = mon;
+ this.thread = thread;
+ this.stack_depth = dpth;
+ thread.addListener(this);
+ }
+
+
+ /*
+ * ThreadListener implementation
+ * Must be synchronized since we must protect against
+ * sending defunct (isValid == false) stack ids to the back-end.
+ */
+ public boolean threadResumable(ThreadAction action) {
+ synchronized (vm.state()) {
+ if (isValid) {
+ isValid = false;
+ return false; /* remove this stack frame as a listener */
+ } else {
+ throw new InternalException(
+ "Invalid stack frame thread listener");
+ }
+ }
+ }
+
+ private void validateMonitorInfo() {
+ if (!isValid) {
+ throw new InvalidStackFrameException("Thread has been resumed");
+ }
+ }
+
+ public ObjectReference monitor() {
+ validateMonitorInfo();
+ return monitor;
+ }
+
+ public int stackDepth() {
+ validateMonitorInfo();
+ return stack_depth;
+ }
+
+ public ThreadReference thread() {
+ validateMonitorInfo();
+ return thread;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/NonConcreteMethodImpl.java b/src/share/classes/com/sun/tools/jdi/NonConcreteMethodImpl.java
new file mode 100644
index 0000000..9fc7ddd
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/NonConcreteMethodImpl.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2000, 2003, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.ListIterator;
+import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.Collections;
+
+/**
+ * Represents non-concrete (that is, native or abstract) methods.
+ * Private to MethodImpl.
+ */
+public class NonConcreteMethodImpl extends MethodImpl {
+
+ private Location location = null;
+
+ NonConcreteMethodImpl(VirtualMachine vm,
+ ReferenceTypeImpl declaringType,
+ long ref,
+ String name, String signature,
+ String genericSignature, int modifiers) {
+
+ // The generic signature is set when this is created
+ super(vm, declaringType, ref, name, signature,
+ genericSignature, modifiers);
+ }
+
+ public Location location() {
+ if (isAbstract()) {
+ return null;
+ }
+ if (location == null) {
+ location = new LocationImpl(vm, this, -1);
+ }
+ return location;
+ }
+
+ public List<Location> allLineLocations(String stratumID,
+ String sourceName) {
+ return new ArrayList<Location>(0);
+ }
+
+ public List<Location> allLineLocations(SDE.Stratum stratum,
+ String sourceName) {
+ return new ArrayList<Location>(0);
+ }
+
+ public List<Location> locationsOfLine(String stratumID,
+ String sourceName,
+ int lineNumber) {
+ return new ArrayList<Location>(0);
+ }
+
+ public List<Location> locationsOfLine(SDE.Stratum stratum,
+ String sourceName,
+ int lineNumber) {
+ return new ArrayList<Location>(0);
+ }
+
+ public Location locationOfCodeIndex(long codeIndex) {
+ return null;
+ }
+
+ public List<LocalVariable> variables() throws AbsentInformationException {
+ throw new AbsentInformationException();
+ }
+
+ public List<LocalVariable> variablesByName(String name) throws AbsentInformationException {
+ throw new AbsentInformationException();
+ }
+
+ public List<LocalVariable> arguments() throws AbsentInformationException {
+ throw new AbsentInformationException();
+ }
+
+ public byte[] bytecodes() {
+ return new byte[0];
+ }
+
+ int argSlotCount() throws AbsentInformationException {
+ throw new InternalException("should not get here");
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java b/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java
new file mode 100644
index 0000000..f457337
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java
@@ -0,0 +1,631 @@
+/*
+ * Copyright (c) 1998, 2015, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+import java.util.*;
+import java.util.ArrayList;
+
+public class ObjectReferenceImpl extends ValueImpl
+ implements ObjectReference, VMListener {
+
+ protected long ref;
+ private ReferenceType type = null;
+ private int gcDisableCount = 0;
+ boolean addedListener = false;
+
+ // This is cached only while the VM is suspended
+ protected static class Cache {
+ JDWP.ObjectReference.MonitorInfo monitorInfo = null;
+ }
+
+ private static final Cache noInitCache = new Cache();
+ private static final Cache markerCache = new Cache();
+ private Cache cache = noInitCache;
+
+ private void disableCache() {
+ synchronized (vm.state()) {
+ cache = null;
+ }
+ }
+
+ private void enableCache() {
+ synchronized (vm.state()) {
+ cache = markerCache;
+ }
+ }
+
+ // Override in subclasses
+ protected Cache newCache() {
+ return new Cache();
+ }
+
+ protected Cache getCache() {
+ synchronized (vm.state()) {
+ if (cache == noInitCache) {
+ if (vm.state().isSuspended()) {
+ // Set cache now, otherwise newly created objects are
+ // not cached until resuspend
+ enableCache();
+ } else {
+ disableCache();
+ }
+ }
+ if (cache == markerCache) {
+ cache = newCache();
+ }
+ return cache;
+ }
+ }
+
+ // Return the ClassTypeImpl upon which to invoke a method.
+ // By default it is our very own referenceType() but subclasses
+ // can override.
+ protected ClassTypeImpl invokableReferenceType(Method method) {
+ return (ClassTypeImpl)referenceType();
+ }
+
+ ObjectReferenceImpl(VirtualMachine aVm,long aRef) {
+ super(aVm);
+
+ ref = aRef;
+ }
+
+ protected String description() {
+ return "ObjectReference " + uniqueID();
+ }
+
+ /*
+ * VMListener implementation
+ */
+ public boolean vmSuspended(VMAction action) {
+ enableCache();
+ return true;
+ }
+
+ public boolean vmNotSuspended(VMAction action) {
+ // make sure that cache and listener management are synchronized
+ synchronized (vm.state()) {
+ if (cache != null && (vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) {
+ vm.printTrace("Clearing temporary cache for " + description());
+ }
+ disableCache();
+ if (addedListener) {
+ /*
+ * If a listener was added (i.e. this is not a
+ * ObjectReference that adds a listener on startup),
+ * remove it here.
+ */
+ addedListener = false;
+ return false; // false says remove
+ } else {
+ return true;
+ }
+ }
+ }
+
+ public boolean equals(Object obj) {
+ if ((obj != null) && (obj instanceof ObjectReferenceImpl)) {
+ ObjectReferenceImpl other = (ObjectReferenceImpl)obj;
+ return (ref() == other.ref()) &&
+ super.equals(obj);
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ return(int)ref();
+ }
+
+ public Type type() {
+ return referenceType();
+ }
+
+ public ReferenceType referenceType() {
+ if (type == null) {
+ try {
+ JDWP.ObjectReference.ReferenceType rtinfo =
+ JDWP.ObjectReference.ReferenceType.process(vm, this);
+ type = vm.referenceType(rtinfo.typeID,
+ rtinfo.refTypeTag);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+ return type;
+ }
+
+ public Value getValue(Field sig) {
+ List<Field> list = new ArrayList<Field>(1);
+ list.add(sig);
+ Map<Field, Value> map = getValues(list);
+ return map.get(sig);
+ }
+
+ public Map<Field,Value> getValues(List<? extends Field> theFields) {
+ validateMirrors(theFields);
+
+ List<Field> staticFields = new ArrayList<Field>(0);
+ int size = theFields.size();
+ List<Field> instanceFields = new ArrayList<Field>(size);
+
+ for (int i=0; i<size; i++) {
+ Field field = (Field)theFields.get(i);
+
+ // Make sure the field is valid
+ ((ReferenceTypeImpl)referenceType()).validateFieldAccess(field);
+
+ // FIX ME! We need to do some sanity checking
+ // here; make sure the field belongs to this
+ // object.
+ if (field.isStatic())
+ staticFields.add(field);
+ else {
+ instanceFields.add(field);
+ }
+ }
+
+ Map<Field, Value> map;
+ if (staticFields.size() > 0) {
+ map = referenceType().getValues(staticFields);
+ } else {
+ map = new HashMap<Field, Value>(size);
+ }
+
+ size = instanceFields.size();
+
+ JDWP.ObjectReference.GetValues.Field[] queryFields =
+ new JDWP.ObjectReference.GetValues.Field[size];
+ for (int i=0; i<size; i++) {
+ FieldImpl field = (FieldImpl)instanceFields.get(i);/* thanks OTI */
+ queryFields[i] = new JDWP.ObjectReference.GetValues.Field(
+ field.ref());
+ }
+ ValueImpl[] values;
+ try {
+ values = JDWP.ObjectReference.GetValues.
+ process(vm, this, queryFields).values;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+
+ if (size != values.length) {
+ throw new InternalException(
+ "Wrong number of values returned from target VM");
+ }
+ for (int i=0; i<size; i++) {
+ FieldImpl field = (FieldImpl)instanceFields.get(i);
+ map.put(field, values[i]);
+ }
+
+ return map;
+ }
+
+ public void setValue(Field field, Value value)
+ throws InvalidTypeException, ClassNotLoadedException {
+
+ validateMirror(field);
+ validateMirrorOrNull(value);
+
+ // Make sure the field is valid
+ ((ReferenceTypeImpl)referenceType()).validateFieldSet(field);
+
+ if (field.isStatic()) {
+ ReferenceType type = referenceType();
+ if (type instanceof ClassType) {
+ ((ClassType)type).setValue(field, value);
+ return;
+ } else {
+ throw new IllegalArgumentException(
+ "Invalid type for static field set");
+ }
+ }
+
+ try {
+ JDWP.ObjectReference.SetValues.FieldValue[] fvals =
+ new JDWP.ObjectReference.SetValues.FieldValue[1];
+ fvals[0] = new JDWP.ObjectReference.SetValues.FieldValue(
+ ((FieldImpl)field).ref(),
+ // Validate and convert if necessary
+ ValueImpl.prepareForAssignment(value,
+ (FieldImpl)field));
+ try {
+ JDWP.ObjectReference.SetValues.process(vm, this, fvals);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ } catch (ClassNotLoadedException e) {
+ /*
+ * Since we got this exception,
+ * the field type must be a reference type. The value
+ * we're trying to set is null, but if the field's
+ * class has not yet been loaded through the enclosing
+ * class loader, then setting to null is essentially a
+ * no-op, and we should allow it without an exception.
+ */
+ if (value != null) {
+ throw e;
+ }
+ }
+ }
+
+ void validateMethodInvocation(Method method, int options)
+ throws InvalidTypeException,
+ InvocationException {
+ /*
+ * Method must be in this object's class, a superclass, or
+ * implemented interface
+ */
+ ReferenceTypeImpl declType = (ReferenceTypeImpl)method.declaringType();
+ if (!declType.isAssignableFrom(this)) {
+ throw new IllegalArgumentException("Invalid method");
+ }
+
+ if (declType instanceof ClassTypeImpl) {
+ validateClassMethodInvocation(method, options);
+ } else if (declType instanceof InterfaceTypeImpl) {
+ validateIfaceMethodInvocation(method, options);
+ } else {
+ throw new InvalidTypeException();
+ }
+ }
+
+ void validateClassMethodInvocation(Method method, int options)
+ throws InvalidTypeException,
+ InvocationException {
+
+ ClassTypeImpl clazz = invokableReferenceType(method);
+
+ /*
+ * Method must be a non-constructor
+ */
+ if (method.isConstructor()) {
+ throw new IllegalArgumentException("Cannot invoke constructor");
+ }
+
+ /*
+ * For nonvirtual invokes, method must have a body
+ */
+ if (isNonVirtual(options)) {
+ if (method.isAbstract()) {
+ throw new IllegalArgumentException("Abstract method");
+ }
+ }
+
+ /*
+ * Get the class containing the method that will be invoked.
+ * This class is needed only for proper validation of the
+ * method argument types.
+ */
+ ClassTypeImpl invokedClass;
+ if (isNonVirtual(options)) {
+ // No overrides in non-virtual invokes
+ invokedClass = clazz;
+ } else {
+ /*
+ * For virtual invokes, find any override of the method.
+ * Since we are looking for a method with a real body, we
+ * don't need to bother with interfaces/abstract methods.
+ */
+ Method invoker = clazz.concreteMethodByName(method.name(),
+ method.signature());
+ // invoker is supposed to be non-null under normal circumstances
+ invokedClass = (ClassTypeImpl)invoker.declaringType();
+ }
+ /* The above code is left over from previous versions.
+ * We haven't had time to divine the intent. jjh, 7/31/2003
+ */
+ }
+
+ void validateIfaceMethodInvocation(Method method, int options)
+ throws InvalidTypeException,
+ InvocationException {
+ /*
+ * Only default methods allowed for nonvirtual invokes
+ */
+ if (isNonVirtual(options) && !method.isDefault()) {
+ throw new IllegalArgumentException("Not a default method");
+ }
+ }
+
+ PacketStream sendInvokeCommand(final ThreadReferenceImpl thread,
+ final ClassTypeImpl refType,
+ final MethodImpl method,
+ final ValueImpl[] args,
+ final int options) {
+ CommandSender sender =
+ new CommandSender() {
+ public PacketStream send() {
+ return JDWP.ObjectReference.InvokeMethod.enqueueCommand(
+ vm, ObjectReferenceImpl.this,
+ thread, refType,
+ method.ref(), args, options);
+ }
+ };
+
+ PacketStream stream;
+ if ((options & INVOKE_SINGLE_THREADED) != 0) {
+ stream = thread.sendResumingCommand(sender);
+ } else {
+ stream = vm.sendResumingCommand(sender);
+ }
+ return stream;
+ }
+
+ public Value invokeMethod(ThreadReference threadIntf, Method methodIntf,
+ List<? extends Value> origArguments, int options)
+ throws InvalidTypeException,
+ IncompatibleThreadStateException,
+ InvocationException,
+ ClassNotLoadedException {
+ validateMirror(threadIntf);
+ validateMirror(methodIntf);
+ validateMirrorsOrNulls(origArguments);
+
+ MethodImpl method = (MethodImpl)methodIntf;
+ ThreadReferenceImpl thread = (ThreadReferenceImpl)threadIntf;
+
+ if (method.isStatic()) {
+ if (referenceType() instanceof InterfaceType) {
+ InterfaceType type = (InterfaceType)referenceType();
+ return type.invokeMethod(thread, method, origArguments, options);
+ } else if (referenceType() instanceof ClassType) {
+ ClassType type = (ClassType)referenceType();
+ return type.invokeMethod(thread, method, origArguments, options);
+ } else {
+ throw new IllegalArgumentException("Invalid type for static method invocation");
+ }
+ }
+
+ validateMethodInvocation(method, options);
+
+ List<Value> arguments = method.validateAndPrepareArgumentsForInvoke(
+ origArguments);
+
+ ValueImpl[] args = arguments.toArray(new ValueImpl[0]);
+ JDWP.ObjectReference.InvokeMethod ret;
+ try {
+ PacketStream stream =
+ sendInvokeCommand(thread, invokableReferenceType(method),
+ method, args, options);
+ ret = JDWP.ObjectReference.InvokeMethod.waitForReply(vm, stream);
+ } catch (JDWPException exc) {
+ if (exc.errorCode() == JDWP.Error.INVALID_THREAD) {
+ throw new IncompatibleThreadStateException();
+ } else {
+ throw exc.toJDIException();
+ }
+ }
+
+ /*
+ * There is an implict VM-wide suspend at the conclusion
+ * of a normal (non-single-threaded) method invoke
+ */
+ if ((options & INVOKE_SINGLE_THREADED) == 0) {
+ vm.notifySuspend();
+ }
+
+ if (ret.exception != null) {
+ throw new InvocationException(ret.exception);
+ } else {
+ return ret.returnValue;
+ }
+ }
+
+ /* leave synchronized to keep count accurate */
+ public synchronized void disableCollection() {
+ if (gcDisableCount == 0) {
+ try {
+ JDWP.ObjectReference.DisableCollection.process(vm, this);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+ gcDisableCount++;
+ }
+
+ /* leave synchronized to keep count accurate */
+ public synchronized void enableCollection() {
+ gcDisableCount--;
+
+ if (gcDisableCount == 0) {
+ try {
+ JDWP.ObjectReference.EnableCollection.process(vm, this);
+ } catch (JDWPException exc) {
+ // If already collected, no harm done, no exception
+ if (exc.errorCode() != JDWP.Error.INVALID_OBJECT) {
+ throw exc.toJDIException();
+ }
+ return;
+ }
+ }
+ }
+
+ public boolean isCollected() {
+ try {
+ return JDWP.ObjectReference.IsCollected.process(vm, this).
+ isCollected;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+
+ public long uniqueID() {
+ return ref();
+ }
+
+ JDWP.ObjectReference.MonitorInfo jdwpMonitorInfo()
+ throws IncompatibleThreadStateException {
+ JDWP.ObjectReference.MonitorInfo info = null;
+ try {
+ Cache local;
+
+ // getCache() and addlistener() must be synchronized
+ // so that no events are lost.
+ synchronized (vm.state()) {
+ local = getCache();
+
+ if (local != null) {
+ info = local.monitorInfo;
+
+ // Check if there will be something to cache
+ // and there is not already a listener
+ if (info == null && !vm.state().hasListener(this)) {
+ /* For other, less numerous objects, this is done
+ * in the constructor. Since there can be many
+ * ObjectReferences, the VM listener is installed
+ * and removed as needed.
+ * Listener must be installed before process()
+ */
+ vm.state().addListener(this);
+ addedListener = true;
+ }
+ }
+ }
+ if (info == null) {
+ info = JDWP.ObjectReference.MonitorInfo.process(vm, this);
+ if (local != null) {
+ local.monitorInfo = info;
+ if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) {
+ vm.printTrace("ObjectReference " + uniqueID() +
+ " temporarily caching monitor info");
+ }
+ }
+ }
+ } catch (JDWPException exc) {
+ if (exc.errorCode() == JDWP.Error.THREAD_NOT_SUSPENDED) {
+ throw new IncompatibleThreadStateException();
+ } else {
+ throw exc.toJDIException();
+ }
+ }
+ return info;
+ }
+
+ public List<ThreadReference> waitingThreads() throws IncompatibleThreadStateException {
+ return Arrays.asList((ThreadReference[])jdwpMonitorInfo().waiters);
+ }
+
+ public ThreadReference owningThread() throws IncompatibleThreadStateException {
+ return jdwpMonitorInfo().owner;
+ }
+
+ public int entryCount() throws IncompatibleThreadStateException {
+ return jdwpMonitorInfo().entryCount;
+ }
+
+
+ public List<ObjectReference> referringObjects(long maxReferrers) {
+ if (!vm.canGetInstanceInfo()) {
+ throw new UnsupportedOperationException(
+ "target does not support getting referring objects");
+ }
+
+ if (maxReferrers < 0) {
+ throw new IllegalArgumentException("maxReferrers is less than zero: "
+ + maxReferrers);
+ }
+
+ int intMax = (maxReferrers > Integer.MAX_VALUE)?
+ Integer.MAX_VALUE: (int)maxReferrers;
+ // JDWP can't currently handle more than this (in mustang)
+
+ try {
+ return Arrays.asList((ObjectReference[])JDWP.ObjectReference.ReferringObjects.
+ process(vm, this, intMax).referringObjects);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+
+ long ref() {
+ return ref;
+ }
+
+ boolean isClassObject() {
+ /*
+ * Don't need to worry about subclasses since java.lang.Class is final.
+ */
+ return referenceType().name().equals("java.lang.Class");
+ }
+
+ ValueImpl prepareForAssignmentTo(ValueContainer destination)
+ throws InvalidTypeException,
+ ClassNotLoadedException {
+
+ validateAssignment(destination);
+ return this; // conversion never necessary
+ }
+
+ void validateAssignment(ValueContainer destination)
+ throws InvalidTypeException, ClassNotLoadedException {
+
+ /*
+ * Do these simpler checks before attempting a query of the destination's
+ * type which might cause a confusing ClassNotLoadedException if
+ * the destination is primitive or an array.
+ */
+ /*
+ * TO DO: Centralize JNI signature knowledge
+ */
+ if (destination.signature().length() == 1) {
+ throw new InvalidTypeException("Can't assign object value to primitive");
+ }
+ if ((destination.signature().charAt(0) == '[') &&
+ (type().signature().charAt(0) != '[')) {
+ throw new InvalidTypeException("Can't assign non-array value to an array");
+ }
+ if ("void".equals(destination.typeName())) {
+ throw new InvalidTypeException("Can't assign object value to a void");
+ }
+
+ // Validate assignment
+ ReferenceType destType = (ReferenceTypeImpl)destination.type();
+ ReferenceTypeImpl myType = (ReferenceTypeImpl)referenceType();
+ if (!myType.isAssignableTo(destType)) {
+ JNITypeParser parser = new JNITypeParser(destType.signature());
+ String destTypeName = parser.typeName();
+ throw new InvalidTypeException("Can't assign " +
+ type().name() +
+ " to " + destTypeName);
+ }
+ }
+
+
+ public String toString() {
+ return "instance of " + referenceType().name() + "(id=" + uniqueID() + ")";
+ }
+
+ byte typeValueKey() {
+ return JDWP.Tag.OBJECT;
+ }
+
+ private static boolean isNonVirtual(int options) {
+ return (options & INVOKE_NONVIRTUAL) != 0;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ObsoleteMethodImpl.java b/src/share/classes/com/sun/tools/jdi/ObsoleteMethodImpl.java
new file mode 100644
index 0000000..d7113e9
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ObsoleteMethodImpl.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2000, 2003, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Represents methods which have changed when the class was redefined.
+ */
+public class ObsoleteMethodImpl extends NonConcreteMethodImpl {
+
+ private Location location = null;
+
+ ObsoleteMethodImpl(VirtualMachine vm,
+ ReferenceTypeImpl declaringType) {
+ super(vm, declaringType, 0, "<obsolete>", "", null, 0);
+ }
+
+ public boolean isObsolete() {
+ return true;
+ }
+
+ public String returnTypeName() {
+ return "<unknown>";
+ }
+
+ public Type returnType() throws ClassNotLoadedException {
+ throw new ClassNotLoadedException("type unknown");
+ }
+
+ public List<String> argumentTypeNames() {
+ return new ArrayList<String>();
+ }
+
+ public List<String> argumentSignatures() {
+ return new ArrayList<String>();
+ }
+
+ Type argumentType(int index) throws ClassNotLoadedException {
+ throw new ClassNotLoadedException("type unknown");
+ }
+
+ public List<Type> argumentTypes() throws ClassNotLoadedException {
+ return new ArrayList<Type>();
+ }
+
+}
diff --git a/src/share/classes/com/sun/tools/jdi/Packet.java b/src/share/classes/com/sun/tools/jdi/Packet.java
new file mode 100644
index 0000000..18f0392
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/Packet.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 1998, 2003, 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.tools.jdi;
+
+import com.sun.jdi.*;
+import java.io.IOException;
+
+public class Packet extends Object {
+ public final static short NoFlags = 0x0;
+ public final static short Reply = 0x80;
+ public final static short ReplyNoError = 0x0;
+
+ static int uID = 1;
+ final static byte[] nullData = new byte[0];
+
+ // Note! flags, cmdSet, and cmd are all byte values.
+ // We represent them as shorts to make them easier
+ // to work with.
+ int id;
+ short flags;
+ short cmdSet;
+ short cmd;
+ short errorCode;
+ byte[] data;
+ volatile boolean replied = false;
+
+ /**
+ * Return byte representation of the packet
+ */
+ public byte[] toByteArray() {
+ int len = data.length + 11;
+ byte b[] = new byte[len];
+ b[0] = (byte)((len >>> 24) & 0xff);
+ b[1] = (byte)((len >>> 16) & 0xff);
+ b[2] = (byte)((len >>> 8) & 0xff);
+ b[3] = (byte)((len >>> 0) & 0xff);
+ b[4] = (byte)((id >>> 24) & 0xff);
+ b[5] = (byte)((id >>> 16) & 0xff);
+ b[6] = (byte)((id >>> 8) & 0xff);
+ b[7] = (byte)((id >>> 0) & 0xff);
+ b[8] = (byte)flags;
+ if ((flags & Packet.Reply) == 0) {
+ b[9] = (byte)cmdSet;
+ b[10] = (byte)cmd;
+ } else {
+ b[9] = (byte)((errorCode >>> 8) & 0xff);
+ b[10] = (byte)((errorCode >>> 0) & 0xff);
+ }
+ if (data.length > 0) {
+ System.arraycopy(data, 0, b, 11, data.length);
+ }
+ return b;
+ }
+
+ /**
+ * Create a packet from its byte array representation
+ */
+ public static Packet fromByteArray(byte b[]) throws IOException {
+ if (b.length < 11) {
+ throw new IOException("packet is insufficient size");
+ }
+
+ int b0 = b[0] & 0xff;
+ int b1 = b[1] & 0xff;
+ int b2 = b[2] & 0xff;
+ int b3 = b[3] & 0xff;
+ int len = ((b0 << 24) | (b1 << 16) | (b2 << 8) | (b3 << 0));
+ if (len != b.length) {
+ throw new IOException("length size mis-match");
+ }
+
+ int b4 = b[4] & 0xff;
+ int b5 = b[5] & 0xff;
+ int b6 = b[6] & 0xff;
+ int b7 = b[7] & 0xff;
+
+ Packet p = new Packet();
+ p.id = ((b4 << 24) | (b5 << 16) | (b6 << 8) | (b7 << 0));
+
+ p.flags = (short)(b[8] & 0xff);
+
+ if ((p.flags & Packet.Reply) == 0) {
+ p.cmdSet = (short)(b[9] & 0xff);
+ p.cmd = (short)(b[10] & 0xff);
+ } else {
+ short b9 = (short)(b[9] & 0xff);
+ short b10 = (short)(b[10] & 0xff);
+ p.errorCode = (short)((b9 << 8) + (b10 << 0));
+ }
+
+ p.data = new byte[b.length - 11];
+ System.arraycopy(b, 11, p.data, 0, p.data.length);
+ return p;
+ }
+
+ Packet()
+ {
+ id = uniqID();
+ flags = NoFlags;
+ data = nullData;
+ }
+
+ static synchronized private int uniqID()
+ {
+ /*
+ * JDWP spec does not require this id to be sequential and
+ * increasing, but our implementation does. See
+ * VirtualMachine.notifySuspend, for example.
+ */
+ return uID++;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/PacketStream.java b/src/share/classes/com/sun/tools/jdi/PacketStream.java
new file mode 100644
index 0000000..a0cd2f3
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/PacketStream.java
@@ -0,0 +1,628 @@
+/*
+ * Copyright (c) 1998, 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 com.sun.tools.jdi;
+
+import com.sun.jdi.*;
+import java.util.*;
+import java.io.ByteArrayOutputStream;
+
+class PacketStream {
+ final VirtualMachineImpl vm;
+ private int inCursor = 0;
+ final Packet pkt;
+ private ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
+ private boolean isCommitted = false;
+
+ PacketStream(VirtualMachineImpl vm, int cmdSet, int cmd) {
+ this.vm = vm;
+ this.pkt = new Packet();
+ pkt.cmdSet = (short)cmdSet;
+ pkt.cmd = (short)cmd;
+ }
+
+ PacketStream(VirtualMachineImpl vm, Packet pkt) {
+ this.vm = vm;
+ this.pkt = pkt;
+ this.isCommitted = true; /* read only stream */
+ }
+
+ int id() {
+ return pkt.id;
+ }
+
+ void send() {
+ if (!isCommitted) {
+ pkt.data = dataStream.toByteArray();
+ vm.sendToTarget(pkt);
+ isCommitted = true;
+ }
+ }
+
+ void waitForReply() throws JDWPException {
+ if (!isCommitted) {
+ throw new InternalException("waitForReply without send");
+ }
+
+ vm.waitForTargetReply(pkt);
+
+ if (pkt.errorCode != Packet.ReplyNoError) {
+ throw new JDWPException(pkt.errorCode);
+ }
+ }
+
+ void writeBoolean(boolean data) {
+ if(data) {
+ dataStream.write( 1 );
+ } else {
+ dataStream.write( 0 );
+ }
+ }
+
+ void writeByte(byte data) {
+ dataStream.write( data );
+ }
+
+ void writeChar(char data) {
+ dataStream.write( (byte)((data >>> 8) & 0xFF) );
+ dataStream.write( (byte)((data >>> 0) & 0xFF) );
+ }
+
+ void writeShort(short data) {
+ dataStream.write( (byte)((data >>> 8) & 0xFF) );
+ dataStream.write( (byte)((data >>> 0) & 0xFF) );
+ }
+
+ void writeInt(int data) {
+ dataStream.write( (byte)((data >>> 24) & 0xFF) );
+ dataStream.write( (byte)((data >>> 16) & 0xFF) );
+ dataStream.write( (byte)((data >>> 8) & 0xFF) );
+ dataStream.write( (byte)((data >>> 0) & 0xFF) );
+ }
+
+ void writeLong(long data) {
+ dataStream.write( (byte)((data >>> 56) & 0xFF) );
+ dataStream.write( (byte)((data >>> 48) & 0xFF) );
+ dataStream.write( (byte)((data >>> 40) & 0xFF) );
+ dataStream.write( (byte)((data >>> 32) & 0xFF) );
+
+ dataStream.write( (byte)((data >>> 24) & 0xFF) );
+ dataStream.write( (byte)((data >>> 16) & 0xFF) );
+ dataStream.write( (byte)((data >>> 8) & 0xFF) );
+ dataStream.write( (byte)((data >>> 0) & 0xFF) );
+ }
+
+ void writeFloat(float data) {
+ writeInt(Float.floatToIntBits(data));
+ }
+
+ void writeDouble(double data) {
+ writeLong(Double.doubleToLongBits(data));
+ }
+
+ void writeID(int size, long data) {
+ switch (size) {
+ case 8:
+ writeLong(data);
+ break;
+ case 4:
+ writeInt((int)data);
+ break;
+ case 2:
+ writeShort((short)data);
+ break;
+ default:
+ throw new UnsupportedOperationException("JDWP: ID size not supported: " + size);
+ }
+ }
+
+ void writeNullObjectRef() {
+ writeObjectRef(0);
+ }
+
+ void writeObjectRef(long data) {
+ writeID(vm.sizeofObjectRef, data);
+ }
+
+ void writeClassRef(long data) {
+ writeID(vm.sizeofClassRef, data);
+ }
+
+ void writeMethodRef(long data) {
+ writeID(vm.sizeofMethodRef, data);
+ }
+
+ void writeFieldRef(long data) {
+ writeID(vm.sizeofFieldRef, data);
+ }
+
+ void writeFrameRef(long data) {
+ writeID(vm.sizeofFrameRef, data);
+ }
+
+ void writeByteArray(byte[] data) {
+ dataStream.write(data, 0, data.length);
+ }
+
+ void writeString(String string) {
+ try {
+ byte[] stringBytes = string.getBytes("UTF8");
+ writeInt(stringBytes.length);
+ writeByteArray(stringBytes);
+ } catch (java.io.UnsupportedEncodingException e) {
+ throw new InternalException("Cannot convert string to UTF8 bytes");
+ }
+ }
+
+ void writeLocation(Location location) {
+ ReferenceTypeImpl refType = (ReferenceTypeImpl)location.declaringType();
+ byte tag;
+ if (refType instanceof ClassType) {
+ tag = JDWP.TypeTag.CLASS;
+ } else if (refType instanceof InterfaceType) {
+ // It's possible to have executable code in an interface
+ tag = JDWP.TypeTag.INTERFACE;
+ } else {
+ throw new InternalException("Invalid Location");
+ }
+ writeByte(tag);
+ writeClassRef(refType.ref());
+ writeMethodRef(((MethodImpl)location.method()).ref());
+ writeLong(location.codeIndex());
+ }
+
+ void writeValue(Value val) {
+ try {
+ writeValueChecked(val);
+ } catch (InvalidTypeException exc) { // should never happen
+ throw new RuntimeException(
+ "Internal error: Invalid Tag/Type pair");
+ }
+ }
+
+ void writeValueChecked(Value val) throws InvalidTypeException {
+ writeByte(ValueImpl.typeValueKey(val));
+ writeUntaggedValue(val);
+ }
+
+ void writeUntaggedValue(Value val) {
+ try {
+ writeUntaggedValueChecked(val);
+ } catch (InvalidTypeException exc) { // should never happen
+ throw new RuntimeException(
+ "Internal error: Invalid Tag/Type pair");
+ }
+ }
+
+ void writeUntaggedValueChecked(Value val) throws InvalidTypeException {
+ byte tag = ValueImpl.typeValueKey(val);
+ if (isObjectTag(tag)) {
+ if (val == null) {
+ writeObjectRef(0);
+ } else {
+ if (!(val instanceof ObjectReference)) {
+ throw new InvalidTypeException();
+ }
+ writeObjectRef(((ObjectReferenceImpl)val).ref());
+ }
+ } else {
+ switch (tag) {
+ case JDWP.Tag.BYTE:
+ if(!(val instanceof ByteValue))
+ throw new InvalidTypeException();
+
+ writeByte(((PrimitiveValue)val).byteValue());
+ break;
+
+ case JDWP.Tag.CHAR:
+ if(!(val instanceof CharValue))
+ throw new InvalidTypeException();
+
+ writeChar(((PrimitiveValue)val).charValue());
+ break;
+
+ case JDWP.Tag.FLOAT:
+ if(!(val instanceof FloatValue))
+ throw new InvalidTypeException();
+
+ writeFloat(((PrimitiveValue)val).floatValue());
+ break;
+
+ case JDWP.Tag.DOUBLE:
+ if(!(val instanceof DoubleValue))
+ throw new InvalidTypeException();
+
+ writeDouble(((PrimitiveValue)val).doubleValue());
+ break;
+
+ case JDWP.Tag.INT:
+ if(!(val instanceof IntegerValue))
+ throw new InvalidTypeException();
+
+ writeInt(((PrimitiveValue)val).intValue());
+ break;
+
+ case JDWP.Tag.LONG:
+ if(!(val instanceof LongValue))
+ throw new InvalidTypeException();
+
+ writeLong(((PrimitiveValue)val).longValue());
+ break;
+
+ case JDWP.Tag.SHORT:
+ if(!(val instanceof ShortValue))
+ throw new InvalidTypeException();
+
+ writeShort(((PrimitiveValue)val).shortValue());
+ break;
+
+ case JDWP.Tag.BOOLEAN:
+ if(!(val instanceof BooleanValue))
+ throw new InvalidTypeException();
+
+ writeBoolean(((PrimitiveValue)val).booleanValue());
+ break;
+ }
+ }
+ }
+
+
+
+ /**
+ * Read byte represented as one bytes.
+ */
+ byte readByte() {
+ byte ret = pkt.data[inCursor];
+ inCursor += 1;
+ return ret;
+ }
+
+ /**
+ * Read boolean represented as one byte.
+ */
+ boolean readBoolean() {
+ byte ret = readByte();
+ return (ret != 0);
+ }
+
+ /**
+ * Read char represented as two bytes.
+ */
+ char readChar() {
+ int b1, b2;
+
+ b1 = pkt.data[inCursor++] & 0xff;
+ b2 = pkt.data[inCursor++] & 0xff;
+
+ return (char)((b1 << 8) + b2);
+ }
+
+ /**
+ * Read short represented as two bytes.
+ */
+ short readShort() {
+ int b1, b2;
+
+ b1 = pkt.data[inCursor++] & 0xff;
+ b2 = pkt.data[inCursor++] & 0xff;
+
+ return (short)((b1 << 8) + b2);
+ }
+
+ /**
+ * Read int represented as four bytes.
+ */
+ int readInt() {
+ int b1,b2,b3,b4;
+
+ b1 = pkt.data[inCursor++] & 0xff;
+ b2 = pkt.data[inCursor++] & 0xff;
+ b3 = pkt.data[inCursor++] & 0xff;
+ b4 = pkt.data[inCursor++] & 0xff;
+
+ return ((b1 << 24) + (b2 << 16) + (b3 << 8) + b4);
+ }
+
+ /**
+ * Read long represented as eight bytes.
+ */
+ long readLong() {
+ long b1,b2,b3,b4;
+ long b5,b6,b7,b8;
+
+ b1 = pkt.data[inCursor++] & 0xff;
+ b2 = pkt.data[inCursor++] & 0xff;
+ b3 = pkt.data[inCursor++] & 0xff;
+ b4 = pkt.data[inCursor++] & 0xff;
+
+ b5 = pkt.data[inCursor++] & 0xff;
+ b6 = pkt.data[inCursor++] & 0xff;
+ b7 = pkt.data[inCursor++] & 0xff;
+ b8 = pkt.data[inCursor++] & 0xff;
+
+ return ((b1 << 56) + (b2 << 48) + (b3 << 40) + (b4 << 32)
+ + (b5 << 24) + (b6 << 16) + (b7 << 8) + b8);
+ }
+
+ /**
+ * Read float represented as four bytes.
+ */
+ float readFloat() {
+ return Float.intBitsToFloat(readInt());
+ }
+
+ /**
+ * Read double represented as eight bytes.
+ */
+ double readDouble() {
+ return Double.longBitsToDouble(readLong());
+ }
+
+ /**
+ * Read string represented as four byte length followed by
+ * characters of the string.
+ */
+ String readString() {
+ String ret;
+ int len = readInt();
+
+ try {
+ ret = new String(pkt.data, inCursor, len, "UTF8");
+ } catch(java.io.UnsupportedEncodingException e) {
+ System.err.println(e);
+ ret = "Conversion error!";
+ }
+ inCursor += len;
+ return ret;
+ }
+
+ private long readID(int size) {
+ switch (size) {
+ case 8:
+ return readLong();
+ case 4:
+ return (long)readInt();
+ case 2:
+ return (long)readShort();
+ default:
+ throw new UnsupportedOperationException("JDWP: ID size not supported: " + size);
+ }
+ }
+
+ /**
+ * Read object represented as vm specific byte sequence.
+ */
+ long readObjectRef() {
+ return readID(vm.sizeofObjectRef);
+ }
+
+ long readClassRef() {
+ return readID(vm.sizeofClassRef);
+ }
+
+ ObjectReferenceImpl readTaggedObjectReference() {
+ byte typeKey = readByte();
+ return vm.objectMirror(readObjectRef(), typeKey);
+ }
+
+ ObjectReferenceImpl readObjectReference() {
+ return vm.objectMirror(readObjectRef());
+ }
+
+ StringReferenceImpl readStringReference() {
+ long ref = readObjectRef();
+ return vm.stringMirror(ref);
+ }
+
+ ArrayReferenceImpl readArrayReference() {
+ long ref = readObjectRef();
+ return vm.arrayMirror(ref);
+ }
+
+ ThreadReferenceImpl readThreadReference() {
+ long ref = readObjectRef();
+ return vm.threadMirror(ref);
+ }
+
+ ThreadGroupReferenceImpl readThreadGroupReference() {
+ long ref = readObjectRef();
+ return vm.threadGroupMirror(ref);
+ }
+
+ ClassLoaderReferenceImpl readClassLoaderReference() {
+ long ref = readObjectRef();
+ return vm.classLoaderMirror(ref);
+ }
+
+ ClassObjectReferenceImpl readClassObjectReference() {
+ long ref = readObjectRef();
+ return vm.classObjectMirror(ref);
+ }
+
+ ReferenceTypeImpl readReferenceType() {
+ byte tag = readByte();
+ long ref = readObjectRef();
+ return vm.referenceType(ref, tag);
+ }
+
+ /**
+ * Read method reference represented as vm specific byte sequence.
+ */
+ long readMethodRef() {
+ return readID(vm.sizeofMethodRef);
+ }
+
+ /**
+ * Read field reference represented as vm specific byte sequence.
+ */
+ long readFieldRef() {
+ return readID(vm.sizeofFieldRef);
+ }
+
+ /**
+ * Read field represented as vm specific byte sequence.
+ */
+ Field readField() {
+ ReferenceTypeImpl refType = readReferenceType();
+ long fieldRef = readFieldRef();
+ return refType.getFieldMirror(fieldRef);
+ }
+
+ /**
+ * Read frame represented as vm specific byte sequence.
+ */
+ long readFrameRef() {
+ return readID(vm.sizeofFrameRef);
+ }
+
+ /**
+ * Read a value, first byte describes type of value to read.
+ */
+ ValueImpl readValue() {
+ byte typeKey = readByte();
+ return readUntaggedValue(typeKey);
+ }
+
+ ValueImpl readUntaggedValue(byte typeKey) {
+ ValueImpl val = null;
+
+ if (isObjectTag(typeKey)) {
+ val = vm.objectMirror(readObjectRef(), typeKey);
+ } else {
+ switch(typeKey) {
+ case JDWP.Tag.BYTE:
+ val = new ByteValueImpl(vm, readByte());
+ break;
+
+ case JDWP.Tag.CHAR:
+ val = new CharValueImpl(vm, readChar());
+ break;
+
+ case JDWP.Tag.FLOAT:
+ val = new FloatValueImpl(vm, readFloat());
+ break;
+
+ case JDWP.Tag.DOUBLE:
+ val = new DoubleValueImpl(vm, readDouble());
+ break;
+
+ case JDWP.Tag.INT:
+ val = new IntegerValueImpl(vm, readInt());
+ break;
+
+ case JDWP.Tag.LONG:
+ val = new LongValueImpl(vm, readLong());
+ break;
+
+ case JDWP.Tag.SHORT:
+ val = new ShortValueImpl(vm, readShort());
+ break;
+
+ case JDWP.Tag.BOOLEAN:
+ val = new BooleanValueImpl(vm, readBoolean());
+ break;
+
+ case JDWP.Tag.VOID:
+ val = new VoidValueImpl(vm);
+ break;
+ }
+ }
+ return val;
+ }
+
+ /**
+ * Read location represented as vm specific byte sequence.
+ */
+ Location readLocation() {
+ byte tag = readByte();
+ long classRef = readObjectRef();
+ long methodRef = readMethodRef();
+ long codeIndex = readLong();
+ if (classRef != 0) {
+ /* Valid location */
+ ReferenceTypeImpl refType = vm.referenceType(classRef, tag);
+ return new LocationImpl(vm, refType, methodRef, codeIndex);
+ } else {
+ /* Null location (example: uncaught exception) */
+ return null;
+ }
+ }
+
+ byte[] readByteArray(int length) {
+ byte[] array = new byte[length];
+ System.arraycopy(pkt.data, inCursor, array, 0, length);
+ inCursor += length;
+ return array;
+ }
+
+ List<Value> readArrayRegion() {
+ byte typeKey = readByte();
+ int length = readInt();
+ List<Value> list = new ArrayList<Value>(length);
+ boolean gettingObjects = isObjectTag(typeKey);
+ for (int i = 0; i < length; i++) {
+ /*
+ * Each object comes back with a type key which might
+ * identify a more specific type than the type key we
+ * passed in, so we use it in the decodeValue call.
+ * (For primitives, we just use the original one)
+ */
+ if (gettingObjects) {
+ typeKey = readByte();
+ }
+ Value value = readUntaggedValue(typeKey);
+ list.add(value);
+ }
+
+ return list;
+ }
+
+ void writeArrayRegion(List<Value> srcValues) {
+ writeInt(srcValues.size());
+ for (int i = 0; i < srcValues.size(); i++) {
+ Value value = srcValues.get(i);
+ writeUntaggedValue(value);
+ }
+ }
+
+ int skipBytes(int n) {
+ inCursor += n;
+ return n;
+ }
+
+ byte command() {
+ return (byte)pkt.cmd;
+ }
+
+ static boolean isObjectTag(byte tag) {
+ return (tag == JDWP.Tag.OBJECT) ||
+ (tag == JDWP.Tag.ARRAY) ||
+ (tag == JDWP.Tag.STRING) ||
+ (tag == JDWP.Tag.THREAD) ||
+ (tag == JDWP.Tag.THREAD_GROUP) ||
+ (tag == JDWP.Tag.CLASS_LOADER) ||
+ (tag == JDWP.Tag.CLASS_OBJECT);
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/PrimitiveTypeImpl.java b/src/share/classes/com/sun/tools/jdi/PrimitiveTypeImpl.java
new file mode 100644
index 0000000..05d0370
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/PrimitiveTypeImpl.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1998, 1999, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+abstract class PrimitiveTypeImpl extends TypeImpl implements PrimitiveType {
+
+ PrimitiveTypeImpl(VirtualMachine vm) {
+ super(vm);
+ }
+
+ /*
+ * Converts the given primitive value to a value of this type.
+ */
+ abstract PrimitiveValue convert(PrimitiveValue value) throws InvalidTypeException;
+
+ public String toString() {
+ return name();
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/PrimitiveValueImpl.java b/src/share/classes/com/sun/tools/jdi/PrimitiveValueImpl.java
new file mode 100644
index 0000000..930ab68
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/PrimitiveValueImpl.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 1998, 2006, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public abstract class PrimitiveValueImpl extends ValueImpl
+ implements PrimitiveValue {
+
+ PrimitiveValueImpl(VirtualMachine aVm) {
+ super(aVm);
+ }
+
+ abstract public boolean booleanValue();
+ abstract public byte byteValue();
+ abstract public char charValue();
+ abstract public short shortValue();
+ abstract public int intValue();
+ abstract public long longValue();
+ abstract public float floatValue();
+ abstract public double doubleValue();
+
+ /*
+ * The checked versions of the value accessors throw
+ * InvalidTypeException if the required conversion is
+ * narrowing and would result in the loss of information
+ * (either magnitude or precision).
+ *
+ * Default implementations here do no checking; subclasses
+ * override as necessary to do the proper checking.
+ */
+ byte checkedByteValue() throws InvalidTypeException {
+ return byteValue();
+ }
+ char checkedCharValue() throws InvalidTypeException {
+ return charValue();
+ }
+ short checkedShortValue() throws InvalidTypeException {
+ return shortValue();
+ }
+ int checkedIntValue() throws InvalidTypeException {
+ return intValue();
+ }
+ long checkedLongValue() throws InvalidTypeException {
+ return longValue();
+ }
+ float checkedFloatValue() throws InvalidTypeException {
+ return floatValue();
+ }
+
+ final boolean checkedBooleanValue() throws InvalidTypeException {
+ /*
+ * Always disallow a conversion to boolean from any other
+ * primitive
+ */
+ if (this instanceof BooleanValue) {
+ return booleanValue();
+ } else {
+ throw new InvalidTypeException("Can't convert non-boolean value to boolean");
+ }
+ }
+
+ final double checkedDoubleValue() throws InvalidTypeException {
+ /*
+ * Can't overflow by converting to double, so this method
+ * is never overridden
+ */
+ return doubleValue();
+ }
+
+ ValueImpl prepareForAssignmentTo(ValueContainer destination)
+ throws InvalidTypeException {
+
+ return convertForAssignmentTo(destination);
+ }
+
+ ValueImpl convertForAssignmentTo(ValueContainer destination)
+ throws InvalidTypeException {
+
+ /*
+ * TO DO: Centralize JNI signature knowledge
+ */
+ if (destination.signature().length() > 1) {
+ throw new InvalidTypeException("Can't assign primitive value to object");
+ }
+
+ if ((destination.signature().charAt(0) == 'Z') &&
+ (type().signature().charAt(0) != 'Z')) {
+ throw new InvalidTypeException("Can't assign non-boolean value to a boolean");
+ }
+
+ if ((destination.signature().charAt(0) != 'Z') &&
+ (type().signature().charAt(0) == 'Z')) {
+ throw new InvalidTypeException("Can't assign boolean value to an non-boolean");
+ }
+
+ if ("void".equals(destination.typeName())) {
+ throw new InvalidTypeException("Can't assign primitive value to a void");
+ }
+
+ try {
+ PrimitiveTypeImpl primitiveType = (PrimitiveTypeImpl)destination.type();
+ return (ValueImpl)(primitiveType.convert(this));
+ } catch (ClassNotLoadedException e) {
+ throw new InternalException("Signature and type inconsistent for: " +
+ destination.typeName());
+ }
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ProcessAttachingConnector.java b/src/share/classes/com/sun/tools/jdi/ProcessAttachingConnector.java
new file mode 100644
index 0000000..35d209a
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ProcessAttachingConnector.java
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2005, 2011, 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.tools.jdi;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.Map;
+import java.util.Properties;
+
+import com.sun.jdi.Bootstrap;
+import com.sun.jdi.VirtualMachine;
+import com.sun.jdi.connect.*;
+import com.sun.jdi.connect.spi.*;
+
+/*
+ * An AttachingConnector that connects to a debuggee by specifying the process
+ * id (pid) as the connector argument. If the process is a debuggee listening
+ * on a transport address then this connector reads the transport address
+ * and attempts to attach to it using the appropriate transport.
+ */
+
+public class ProcessAttachingConnector
+ extends ConnectorImpl implements AttachingConnector
+{
+ /*
+ * The arguments that this connector supports
+ */
+ static final String ARG_PID = "pid";
+ static final String ARG_TIMEOUT = "timeout";
+
+ com.sun.tools.attach.VirtualMachine vm;
+ Transport transport;
+
+ public ProcessAttachingConnector() {
+ addStringArgument(
+ ARG_PID,
+ getString("process_attaching.pid.label"),
+ getString("process_attaching.pid"),
+ "",
+ true);
+
+ addIntegerArgument(
+ ARG_TIMEOUT,
+ getString("generic_attaching.timeout.label"), // use generic keys to keep
+ getString("generic_attaching.timeout"), // resource bundle small
+ "",
+ false,
+ 0, Integer.MAX_VALUE);
+
+ transport = new Transport() {
+ public String name() {
+ return "local";
+ }
+ };
+ }
+
+
+ /**
+ * Attach to a target VM using the specified address and Connector arguments.
+ */
+ public VirtualMachine attach(Map<String,? extends Connector.Argument> args)
+ throws IOException, IllegalConnectorArgumentsException
+ {
+ String pid = argument(ARG_PID, args).value();
+ String t = argument(ARG_TIMEOUT, args).value();
+ int timeout = 0;
+ if (t.length() > 0) {
+ timeout = Integer.decode(t).intValue();
+ }
+
+ // Use Attach API to attach to target VM and read value of
+ // sun.jdwp.listenAddress property.
+
+ String address = null;
+ com.sun.tools.attach.VirtualMachine vm = null;
+ try {
+ vm = com.sun.tools.attach.VirtualMachine.attach(pid);
+ Properties props = vm.getAgentProperties();
+ address = props.getProperty("sun.jdwp.listenerAddress");
+ } catch (Exception x) {
+ throw new IOException(x.getMessage());
+ } finally {
+ if (vm != null) vm.detach();
+ }
+
+ // check that the property value is formatted correctly
+
+ if (address == null) {
+ throw new IOException("Not a debuggee, or not listening for debugger to attach");
+ }
+ int pos = address.indexOf(':');
+ if (pos < 1) {
+ throw new IOException("Unable to determine transport endpoint");
+ }
+
+ // parse into transport library name and address
+
+ final String lib = address.substring(0, pos);
+ address = address.substring(pos+1, address.length());
+
+ TransportService ts = null;
+ if (lib.equals("dt_socket")) {
+ ts = new SocketTransportService();
+ } else {
+ if (lib.equals("dt_shmem")) {
+ try {
+ Class<?> c = Class.forName("com.sun.tools.jdi.SharedMemoryTransportService");
+ ts = (TransportService)c.newInstance();
+ } catch (Exception x) { }
+ }
+ }
+ if (ts == null) {
+ throw new IOException("Transport " + lib + " not recognized");
+ }
+
+ // connect to the debuggee
+
+ Connection connection = ts.attach(address, timeout, 0);
+ return Bootstrap.virtualMachineManager().createVirtualMachine(connection);
+ }
+
+ public String name() {
+ return "com.sun.jdi.ProcessAttach";
+ }
+
+ public String description() {
+ return getString("process_attaching.description");
+ }
+
+ public Transport transport() {
+ if (transport == null) {
+ return new Transport() {
+ public String name() {
+ return "local";
+ }
+ };
+ }
+ return transport;
+ }
+
+}
diff --git a/src/share/classes/com/sun/tools/jdi/RawCommandLineLauncher.java b/src/share/classes/com/sun/tools/jdi/RawCommandLineLauncher.java
new file mode 100644
index 0000000..525a840
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/RawCommandLineLauncher.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 1999, 2011, 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.tools.jdi;
+
+import com.sun.tools.jdi.*;
+import com.sun.jdi.connect.*;
+import com.sun.jdi.connect.spi.*;
+import com.sun.jdi.VirtualMachine;
+import java.util.Map;
+import java.io.IOException;
+
+public class RawCommandLineLauncher extends AbstractLauncher implements LaunchingConnector {
+
+ static private final String ARG_COMMAND = "command";
+ static private final String ARG_ADDRESS = "address";
+ static private final String ARG_QUOTE = "quote";
+
+ TransportService transportService;
+ Transport transport;
+
+ public TransportService transportService() {
+ return transportService;
+ }
+
+ public Transport transport() {
+ return transport;
+ }
+
+ public RawCommandLineLauncher() {
+ super();
+
+ try {
+ Class<?> c = Class.forName("com.sun.tools.jdi.SharedMemoryTransportService");
+ transportService = (TransportService)c.newInstance();
+ transport = new Transport() {
+ public String name() {
+ return "dt_shmem";
+ }
+ };
+ } catch (ClassNotFoundException x) {
+ } catch (UnsatisfiedLinkError x) {
+ } catch (InstantiationException x) {
+ } catch (IllegalAccessException x) {
+ };
+
+ if (transportService == null) {
+ transportService = new SocketTransportService();
+ transport = new Transport() {
+ public String name() {
+ return "dt_socket";
+ }
+ };
+ }
+
+ addStringArgument(
+ ARG_COMMAND,
+ getString("raw.command.label"),
+ getString("raw.command"),
+ "",
+ true);
+ addStringArgument(
+ ARG_QUOTE,
+ getString("raw.quote.label"),
+ getString("raw.quote"),
+ "\"",
+ true);
+
+ addStringArgument(
+ ARG_ADDRESS,
+ getString("raw.address.label"),
+ getString("raw.address"),
+ "",
+ true);
+ }
+
+
+ public VirtualMachine
+ launch(Map<String,? extends Connector.Argument> arguments)
+ throws IOException, IllegalConnectorArgumentsException,
+ VMStartException
+ {
+ String command = argument(ARG_COMMAND, arguments).value();
+ String address = argument(ARG_ADDRESS, arguments).value();
+
+ String quote = argument(ARG_QUOTE, arguments).value();
+
+ if (quote.length() > 1) {
+ throw new IllegalConnectorArgumentsException("Invalid length",
+ ARG_QUOTE);
+ }
+
+ TransportService.ListenKey listener = transportService.startListening(address);
+
+ try {
+ return launch(tokenizeCommand(command, quote.charAt(0)),
+ address, listener, transportService);
+ } finally {
+ transportService.stopListening(listener);
+ }
+ }
+
+ public String name() {
+ return "com.sun.jdi.RawCommandLineLaunch";
+ }
+
+ public String description() {
+ return getString("raw.description");
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java b/src/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java
new file mode 100644
index 0000000..51c4478
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java
@@ -0,0 +1,1174 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+import java.util.*;
+import java.lang.ref.SoftReference;
+
+public abstract class ReferenceTypeImpl extends TypeImpl
+implements ReferenceType {
+ protected long ref;
+ private String signature = null;
+ private String genericSignature = null;
+ private boolean genericSignatureGotten = false;
+ private String baseSourceName = null;
+ private String baseSourceDir = null;
+ private String baseSourcePath = null;
+ protected int modifiers = -1;
+ private SoftReference<List<Field>> fieldsRef = null;
+ private SoftReference<List<Method>> methodsRef = null;
+ private SoftReference<SDE> sdeRef = null;
+
+ private boolean isClassLoaderCached = false;
+ private ClassLoaderReference classLoader = null;
+ private ClassObjectReference classObject = null;
+
+ private int status = 0;
+ private boolean isPrepared = false;
+
+
+ private boolean versionNumberGotten = false;
+ private int majorVersion;
+ private int minorVersion;
+
+ private boolean constantPoolInfoGotten = false;
+ private int constanPoolCount;
+ private byte[] constantPoolBytes;
+ private SoftReference<byte[]> constantPoolBytesRef = null;
+
+ /* to mark a SourceFile request that returned a genuine JDWP.Error.ABSENT_INFORMATION */
+ private static final String ABSENT_BASE_SOURCE_NAME = "**ABSENT_BASE_SOURCE_NAME**";
+
+ /* to mark when no info available */
+ static final SDE NO_SDE_INFO_MARK = new SDE();
+
+ // bits set when initialization was attempted (succeeded or failed)
+ private static final int INITIALIZED_OR_FAILED =
+ JDWP.ClassStatus.INITIALIZED | JDWP.ClassStatus.ERROR;
+
+
+ protected ReferenceTypeImpl(VirtualMachine aVm, long aRef) {
+ super(aVm);
+ ref = aRef;
+ genericSignatureGotten = false;
+ }
+
+ void noticeRedefineClass() {
+ //Invalidate information previously fetched and cached.
+ //These will be refreshed later on demand.
+ baseSourceName = null;
+ baseSourcePath = null;
+ modifiers = -1;
+ fieldsRef = null;
+ methodsRef = null;
+ sdeRef = null;
+ versionNumberGotten = false;
+ constantPoolInfoGotten = false;
+ }
+
+ Method getMethodMirror(long ref) {
+ if (ref == 0) {
+ // obsolete method
+ return new ObsoleteMethodImpl(vm, this);
+ }
+ // Fetch all methods for the class, check performance impact
+ // Needs no synchronization now, since methods() returns
+ // unmodifiable local data
+ Iterator<Method> it = methods().iterator();
+ while (it.hasNext()) {
+ MethodImpl method = (MethodImpl)it.next();
+ if (method.ref() == ref) {
+ return method;
+ }
+ }
+ throw new IllegalArgumentException("Invalid method id: " + ref);
+ }
+
+ Field getFieldMirror(long ref) {
+ // Fetch all fields for the class, check performance impact
+ // Needs no synchronization now, since fields() returns
+ // unmodifiable local data
+ Iterator<Field>it = fields().iterator();
+ while (it.hasNext()) {
+ FieldImpl field = (FieldImpl)it.next();
+ if (field.ref() == ref) {
+ return field;
+ }
+ }
+ throw new IllegalArgumentException("Invalid field id: " + ref);
+ }
+
+ public boolean equals(Object obj) {
+ if ((obj != null) && (obj instanceof ReferenceTypeImpl)) {
+ ReferenceTypeImpl other = (ReferenceTypeImpl)obj;
+ return (ref() == other.ref()) &&
+ (vm.equals(other.virtualMachine()));
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ return(int)ref();
+ }
+
+ public int compareTo(ReferenceType object) {
+ /*
+ * Note that it is critical that compareTo() == 0
+ * implies that equals() == true. Otherwise, TreeSet
+ * will collapse classes.
+ *
+ * (Classes of the same name loaded by different class loaders
+ * or in different VMs must not return 0).
+ */
+ ReferenceTypeImpl other = (ReferenceTypeImpl)object;
+ int comp = name().compareTo(other.name());
+ if (comp == 0) {
+ long rf1 = ref();
+ long rf2 = other.ref();
+ // optimize for typical case: refs equal and VMs equal
+ if (rf1 == rf2) {
+ // sequenceNumbers are always positive
+ comp = vm.sequenceNumber -
+ ((VirtualMachineImpl)(other.virtualMachine())).sequenceNumber;
+ } else {
+ comp = (rf1 < rf2)? -1 : 1;
+ }
+ }
+ return comp;
+ }
+
+ public String signature() {
+ if (signature == null) {
+ // Does not need synchronization, since worst-case
+ // static info is fetched twice
+ if (vm.canGet1_5LanguageFeatures()) {
+ /*
+ * we might as well get both the signature and the
+ * generic signature.
+ */
+ genericSignature();
+ } else {
+ try {
+ signature = JDWP.ReferenceType.Signature.
+ process(vm, this).signature;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+ }
+ return signature;
+ }
+
+ public String genericSignature() {
+ // This gets both the signature and the generic signature
+ if (vm.canGet1_5LanguageFeatures() && !genericSignatureGotten) {
+ // Does not need synchronization, since worst-case
+ // static info is fetched twice
+ JDWP.ReferenceType.SignatureWithGeneric result;
+ try {
+ result = JDWP.ReferenceType.SignatureWithGeneric.
+ process(vm, this);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ signature = result.signature;
+ setGenericSignature(result.genericSignature);
+ }
+ return genericSignature;
+ }
+
+ public ClassLoaderReference classLoader() {
+ if (!isClassLoaderCached) {
+ // Does not need synchronization, since worst-case
+ // static info is fetched twice
+ try {
+ classLoader = (ClassLoaderReference)
+ JDWP.ReferenceType.ClassLoader.
+ process(vm, this).classLoader;
+ isClassLoaderCached = true;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+ return classLoader;
+ }
+
+ public boolean isPublic() {
+ if (modifiers == -1)
+ getModifiers();
+
+ return((modifiers & VMModifiers.PUBLIC) > 0);
+ }
+
+ public boolean isProtected() {
+ if (modifiers == -1)
+ getModifiers();
+
+ return((modifiers & VMModifiers.PROTECTED) > 0);
+ }
+
+ public boolean isPrivate() {
+ if (modifiers == -1)
+ getModifiers();
+
+ return((modifiers & VMModifiers.PRIVATE) > 0);
+ }
+
+ public boolean isPackagePrivate() {
+ return !isPublic() && !isPrivate() && !isProtected();
+ }
+
+ public boolean isAbstract() {
+ if (modifiers == -1)
+ getModifiers();
+
+ return((modifiers & VMModifiers.ABSTRACT) > 0);
+ }
+
+ public boolean isFinal() {
+ if (modifiers == -1)
+ getModifiers();
+
+ return((modifiers & VMModifiers.FINAL) > 0);
+ }
+
+ public boolean isStatic() {
+ if (modifiers == -1)
+ getModifiers();
+
+ return((modifiers & VMModifiers.STATIC) > 0);
+ }
+
+ public boolean isPrepared() {
+ // This ref type may have been prepared before we were getting
+ // events, so get it once. After that,
+ // this status flag is updated through the ClassPrepareEvent,
+ // there is no need for the expense of a JDWP query.
+ if (status == 0) {
+ updateStatus();
+ }
+ return isPrepared;
+ }
+
+ public boolean isVerified() {
+ // Once true, it never resets, so we don't need to update
+ if ((status & JDWP.ClassStatus.VERIFIED) == 0) {
+ updateStatus();
+ }
+ return (status & JDWP.ClassStatus.VERIFIED) != 0;
+ }
+
+ public boolean isInitialized() {
+ // Once initialization succeeds or fails, it never resets,
+ // so we don't need to update
+ if ((status & INITIALIZED_OR_FAILED) == 0) {
+ updateStatus();
+ }
+ return (status & JDWP.ClassStatus.INITIALIZED) != 0;
+ }
+
+ public boolean failedToInitialize() {
+ // Once initialization succeeds or fails, it never resets,
+ // so we don't need to update
+ if ((status & INITIALIZED_OR_FAILED) == 0) {
+ updateStatus();
+ }
+ return (status & JDWP.ClassStatus.ERROR) != 0;
+ }
+
+ public List<Field> fields() {
+ List<Field> fields = (fieldsRef == null) ? null : fieldsRef.get();
+ if (fields == null) {
+ if (vm.canGet1_5LanguageFeatures()) {
+ JDWP.ReferenceType.FieldsWithGeneric.FieldInfo[] jdwpFields;
+ try {
+ jdwpFields = JDWP.ReferenceType.FieldsWithGeneric.process(vm, this).declared;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ fields = new ArrayList<Field>(jdwpFields.length);
+ for (int i=0; i<jdwpFields.length; i++) {
+ JDWP.ReferenceType.FieldsWithGeneric.FieldInfo fi
+ = jdwpFields[i];
+
+ Field field = new FieldImpl(vm, this, fi.fieldID,
+ fi.name, fi.signature,
+ fi.genericSignature,
+ fi.modBits);
+ fields.add(field);
+ }
+ } else {
+ JDWP.ReferenceType.Fields.FieldInfo[] jdwpFields;
+ try {
+ jdwpFields = JDWP.ReferenceType.Fields.
+ process(vm, this).declared;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ fields = new ArrayList<Field>(jdwpFields.length);
+ for (int i=0; i<jdwpFields.length; i++) {
+ JDWP.ReferenceType.Fields.FieldInfo fi = jdwpFields[i];
+
+ Field field = new FieldImpl(vm, this, fi.fieldID,
+ fi.name, fi.signature,
+ null,
+ fi.modBits);
+ fields.add(field);
+ }
+ }
+
+ fields = Collections.unmodifiableList(fields);
+ fieldsRef = new SoftReference<List<Field>>(fields);
+ }
+ return fields;
+ }
+
+ abstract List<? extends ReferenceType> inheritedTypes();
+
+ void addVisibleFields(List<Field> visibleList, Map<String, Field> visibleTable, List<String> ambiguousNames) {
+ for (Field field : visibleFields()) {
+ String name = field.name();
+ if (!ambiguousNames.contains(name)) {
+ Field duplicate = visibleTable.get(name);
+ if (duplicate == null) {
+ visibleList.add(field);
+ visibleTable.put(name, field);
+ } else if (!field.equals(duplicate)) {
+ ambiguousNames.add(name);
+ visibleTable.remove(name);
+ visibleList.remove(duplicate);
+ } else {
+ // identical field from two branches; do nothing
+ }
+ }
+ }
+ }
+
+ public List<Field> visibleFields() {
+ /*
+ * Maintain two different collections of visible fields. The
+ * list maintains a reasonable order for return. The
+ * hash map provides an efficient way to lookup visible fields
+ * by name, important for finding hidden or ambiguous fields.
+ */
+ List<Field> visibleList = new ArrayList<Field>();
+ Map<String, Field> visibleTable = new HashMap<String, Field>();
+
+ /* Track fields removed from above collection due to ambiguity */
+ List<String> ambiguousNames = new ArrayList<String>();
+
+ /* Add inherited, visible fields */
+ List<? extends ReferenceType> types = inheritedTypes();
+ Iterator<? extends ReferenceType> iter = types.iterator();
+ while (iter.hasNext()) {
+ /*
+ * TO DO: Be defensive and check for cyclic interface inheritance
+ */
+ ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next();
+ type.addVisibleFields(visibleList, visibleTable, ambiguousNames);
+ }
+
+ /*
+ * Insert fields from this type, removing any inherited fields they
+ * hide.
+ */
+ List<Field> retList = new ArrayList<Field>(fields());
+ for (Field field : retList) {
+ Field hidden = visibleTable.get(field.name());
+ if (hidden != null) {
+ visibleList.remove(hidden);
+ }
+ }
+ retList.addAll(visibleList);
+ return retList;
+ }
+
+ void addAllFields(List<Field> fieldList, Set<ReferenceType> typeSet) {
+ /* Continue the recursion only if this type is new */
+ if (!typeSet.contains(this)) {
+ typeSet.add((ReferenceType)this);
+
+ /* Add local fields */
+ fieldList.addAll(fields());
+
+ /* Add inherited fields */
+ List<? extends ReferenceType> types = inheritedTypes();
+ Iterator<? extends ReferenceType> iter = types.iterator();
+ while (iter.hasNext()) {
+ ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next();
+ type.addAllFields(fieldList, typeSet);
+ }
+ }
+ }
+ public List<Field> allFields() {
+ List<Field> fieldList = new ArrayList<Field>();
+ Set<ReferenceType> typeSet = new HashSet<ReferenceType>();
+ addAllFields(fieldList, typeSet);
+ return fieldList;
+ }
+
+ public Field fieldByName(String fieldName) {
+ List<Field> searchList = visibleFields();
+
+ for (int i=0; i<searchList.size(); i++) {
+ Field f = searchList.get(i);
+
+ if (f.name().equals(fieldName)) {
+ return f;
+ }
+ }
+ //throw new NoSuchFieldException("Field '" + fieldName + "' not found in " + name());
+ return null;
+ }
+
+ public List<Method> methods() {
+ List<Method> methods = (methodsRef == null) ? null : methodsRef.get();
+ if (methods == null) {
+ if (!vm.canGet1_5LanguageFeatures()) {
+ methods = methods1_4();
+ } else {
+ JDWP.ReferenceType.MethodsWithGeneric.MethodInfo[] declared;
+ try {
+ declared = JDWP.ReferenceType.MethodsWithGeneric.
+ process(vm, this).declared;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ methods = new ArrayList<Method>(declared.length);
+ for (int i=0; i<declared.length; i++) {
+ JDWP.ReferenceType.MethodsWithGeneric.MethodInfo
+ mi = declared[i];
+
+ Method method = MethodImpl.createMethodImpl(vm, this,
+ mi.methodID,
+ mi.name, mi.signature,
+ mi.genericSignature,
+ mi.modBits);
+ methods.add(method);
+ }
+ }
+ methods = Collections.unmodifiableList(methods);
+ methodsRef = new SoftReference<List<Method>>(methods);
+ }
+ return methods;
+ }
+
+ private List<Method> methods1_4() {
+ List<Method> methods;
+ JDWP.ReferenceType.Methods.MethodInfo[] declared;
+ try {
+ declared = JDWP.ReferenceType.Methods.
+ process(vm, this).declared;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ methods = new ArrayList<Method>(declared.length);
+ for (int i=0; i<declared.length; i++) {
+ JDWP.ReferenceType.Methods.MethodInfo mi = declared[i];
+
+ Method method = MethodImpl.createMethodImpl(vm, this,
+ mi.methodID,
+ mi.name, mi.signature,
+ null,
+ mi.modBits);
+ methods.add(method);
+ }
+ return methods;
+ }
+
+ /*
+ * Utility method used by subclasses to build lists of visible
+ * methods.
+ */
+ void addToMethodMap(Map<String, Method> methodMap, List<Method> methodList) {
+ for (Method method : methodList)
+ methodMap.put(method.name().concat(method.signature()), method);
+ }
+
+ abstract void addVisibleMethods(Map<String, Method> methodMap, Set<InterfaceType> seenInterfaces);
+
+ public List<Method> visibleMethods() {
+ /*
+ * Build a collection of all visible methods. The hash
+ * map allows us to do this efficiently by keying on the
+ * concatenation of name and signature.
+ */
+ Map<String, Method> map = new HashMap<String, Method>();
+ addVisibleMethods(map, new HashSet<InterfaceType>());
+
+ /*
+ * ... but the hash map destroys order. Methods should be
+ * returned in a sensible order, as they are in allMethods().
+ * So, start over with allMethods() and use the hash map
+ * to filter that ordered collection.
+ */
+ List<Method> list = allMethods();
+ list.retainAll(map.values());
+ return list;
+ }
+
+ abstract public List<Method> allMethods();
+
+ public List<Method> methodsByName(String name) {
+ List<Method> methods = visibleMethods();
+ ArrayList<Method> retList = new ArrayList<Method>(methods.size());
+ for (Method candidate : methods) {
+ if (candidate.name().equals(name)) {
+ retList.add(candidate);
+ }
+ }
+ retList.trimToSize();
+ return retList;
+ }
+
+ public List<Method> methodsByName(String name, String signature) {
+ List<Method> methods = visibleMethods();
+ ArrayList<Method> retList = new ArrayList<Method>(methods.size());
+ for (Method candidate : methods) {
+ if (candidate.name().equals(name) &&
+ candidate.signature().equals(signature)) {
+ retList.add(candidate);
+ }
+ }
+ retList.trimToSize();
+ return retList;
+ }
+
+ List<InterfaceType> getInterfaces() {
+ InterfaceTypeImpl[] intfs;
+ try {
+ intfs = JDWP.ReferenceType.Interfaces.
+ process(vm, this).interfaces;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ return Arrays.asList((InterfaceType[])intfs);
+ }
+
+ public List<ReferenceType> nestedTypes() {
+ List<ReferenceType> all = vm.allClasses();
+ List<ReferenceType> nested = new ArrayList<ReferenceType>();
+ String outername = name();
+ int outerlen = outername.length();
+ Iterator<ReferenceType> iter = all.iterator();
+ while (iter.hasNext()) {
+ ReferenceType refType = iter.next();
+ String name = refType.name();
+ int len = name.length();
+ /* The separator is historically '$' but could also be '#' */
+ if ( len > outerlen && name.startsWith(outername) ) {
+ char c = name.charAt(outerlen);
+ if ( c =='$' || c== '#' ) {
+ nested.add(refType);
+ }
+ }
+ }
+ return nested;
+ }
+
+ public Value getValue(Field sig) {
+ List<Field> list = new ArrayList<Field>(1);
+ list.add(sig);
+ Map<Field, Value> map = getValues(list);
+ return map.get(sig);
+ }
+
+
+ void validateFieldAccess(Field field) {
+ /*
+ * Field must be in this object's class, a superclass, or
+ * implemented interface
+ */
+ ReferenceTypeImpl declType = (ReferenceTypeImpl)field.declaringType();
+ if (!declType.isAssignableFrom(this)) {
+ throw new IllegalArgumentException("Invalid field");
+ }
+ }
+
+ void validateFieldSet(Field field) {
+ validateFieldAccess(field);
+ if (field.isFinal()) {
+ throw new IllegalArgumentException("Cannot set value of final field");
+ }
+ }
+
+ /**
+ * Returns a map of field values
+ */
+ public Map<Field,Value> getValues(List<? extends Field> theFields) {
+ validateMirrors(theFields);
+
+ int size = theFields.size();
+ JDWP.ReferenceType.GetValues.Field[] queryFields =
+ new JDWP.ReferenceType.GetValues.Field[size];
+
+ for (int i=0; i<size; i++) {
+ FieldImpl field = (FieldImpl)theFields.get(i);
+
+ validateFieldAccess(field);
+
+ // Do more validation specific to ReferenceType field getting
+ if (!field.isStatic()) {
+ throw new IllegalArgumentException(
+ "Attempt to use non-static field with ReferenceType");
+ }
+ queryFields[i] = new JDWP.ReferenceType.GetValues.Field(
+ field.ref());
+ }
+
+ Map<Field, Value> map = new HashMap<Field, Value>(size);
+
+ ValueImpl[] values;
+ try {
+ values = JDWP.ReferenceType.GetValues.
+ process(vm, this, queryFields).values;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+
+ if (size != values.length) {
+ throw new InternalException(
+ "Wrong number of values returned from target VM");
+ }
+ for (int i=0; i<size; i++) {
+ FieldImpl field = (FieldImpl)theFields.get(i);
+ map.put(field, values[i]);
+ }
+
+ return map;
+ }
+
+ public ClassObjectReference classObject() {
+ if (classObject == null) {
+ // Are classObjects unique for an Object, or
+ // created each time? Is this spec'ed?
+ synchronized(this) {
+ if (classObject == null) {
+ try {
+ classObject = JDWP.ReferenceType.ClassObject.
+ process(vm, this).classObject;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+ }
+ }
+ return classObject;
+ }
+
+ SDE.Stratum stratum(String stratumID) {
+ SDE sde = sourceDebugExtensionInfo();
+ if (!sde.isValid()) {
+ sde = NO_SDE_INFO_MARK;
+ }
+ return sde.stratum(stratumID);
+ }
+
+ public String sourceName() throws AbsentInformationException {
+ return sourceNames(vm.getDefaultStratum()).get(0);
+ }
+
+ public List<String> sourceNames(String stratumID)
+ throws AbsentInformationException {
+ SDE.Stratum stratum = stratum(stratumID);
+ if (stratum.isJava()) {
+ List<String> result = new ArrayList<String>(1);
+ result.add(baseSourceName());
+ return result;
+ }
+ return stratum.sourceNames(this);
+ }
+
+ public List<String> sourcePaths(String stratumID)
+ throws AbsentInformationException {
+ SDE.Stratum stratum = stratum(stratumID);
+ if (stratum.isJava()) {
+ List<String> result = new ArrayList<String>(1);
+ result.add(baseSourceDir() + baseSourceName());
+ return result;
+ }
+ return stratum.sourcePaths(this);
+ }
+
+ String baseSourceName() throws AbsentInformationException {
+ String bsn = baseSourceName;
+ if (bsn == null) {
+ // Does not need synchronization, since worst-case
+ // static info is fetched twice
+ try {
+ bsn = JDWP.ReferenceType.SourceFile.
+ process(vm, this).sourceFile;
+ } catch (JDWPException exc) {
+ if (exc.errorCode() == JDWP.Error.ABSENT_INFORMATION) {
+ bsn = ABSENT_BASE_SOURCE_NAME;
+ } else {
+ throw exc.toJDIException();
+ }
+ }
+ baseSourceName = bsn;
+ }
+ if (bsn == ABSENT_BASE_SOURCE_NAME) {
+ throw new AbsentInformationException();
+ }
+ return bsn;
+ }
+
+ String baseSourcePath() throws AbsentInformationException {
+ String bsp = baseSourcePath;
+ if (bsp == null) {
+ bsp = baseSourceDir() + baseSourceName();
+ baseSourcePath = bsp;
+ }
+ return bsp;
+ }
+
+ String baseSourceDir() {
+ if (baseSourceDir == null) {
+ String typeName = name();
+ StringBuffer sb = new StringBuffer(typeName.length() + 10);
+ int index = 0;
+ int nextIndex;
+
+ while ((nextIndex = typeName.indexOf('.', index)) > 0) {
+ sb.append(typeName.substring(index, nextIndex));
+ sb.append(java.io.File.separatorChar);
+ index = nextIndex + 1;
+ }
+ baseSourceDir = sb.toString();
+ }
+ return baseSourceDir;
+ }
+
+ public String sourceDebugExtension()
+ throws AbsentInformationException {
+ if (!vm.canGetSourceDebugExtension()) {
+ throw new UnsupportedOperationException();
+ }
+ SDE sde = sourceDebugExtensionInfo();
+ if (sde == NO_SDE_INFO_MARK) {
+ throw new AbsentInformationException();
+ }
+ return sde.sourceDebugExtension;
+ }
+
+ private SDE sourceDebugExtensionInfo() {
+ if (!vm.canGetSourceDebugExtension()) {
+ return NO_SDE_INFO_MARK;
+ }
+ SDE sde = (sdeRef == null) ? null : sdeRef.get();
+ if (sde == null) {
+ String extension = null;
+ try {
+ extension = JDWP.ReferenceType.SourceDebugExtension.
+ process(vm, this).extension;
+ } catch (JDWPException exc) {
+ if (exc.errorCode() != JDWP.Error.ABSENT_INFORMATION) {
+ sdeRef = new SoftReference<SDE>(NO_SDE_INFO_MARK);
+ throw exc.toJDIException();
+ }
+ }
+ if (extension == null) {
+ sde = NO_SDE_INFO_MARK;
+ } else {
+ sde = new SDE(extension);
+ }
+ sdeRef = new SoftReference<SDE>(sde);
+ }
+ return sde;
+ }
+
+ public List<String> availableStrata() {
+ SDE sde = sourceDebugExtensionInfo();
+ if (sde.isValid()) {
+ return sde.availableStrata();
+ } else {
+ List<String> strata = new ArrayList<String>();
+ strata.add(SDE.BASE_STRATUM_NAME);
+ return strata;
+ }
+ }
+
+ /**
+ * Always returns non-null stratumID
+ */
+ public String defaultStratum() {
+ SDE sdei = sourceDebugExtensionInfo();
+ if (sdei.isValid()) {
+ return sdei.defaultStratumId;
+ } else {
+ return SDE.BASE_STRATUM_NAME;
+ }
+ }
+
+ public int modifiers() {
+ if (modifiers == -1)
+ getModifiers();
+
+ return modifiers;
+ }
+
+ public List<Location> allLineLocations()
+ throws AbsentInformationException {
+ return allLineLocations(vm.getDefaultStratum(), null);
+ }
+
+ public List<Location> allLineLocations(String stratumID, String sourceName)
+ throws AbsentInformationException {
+ boolean someAbsent = false; // A method that should have info, didn't
+ SDE.Stratum stratum = stratum(stratumID);
+ List<Location> list = new ArrayList<Location>(); // location list
+
+ for (Iterator<Method> iter = methods().iterator(); iter.hasNext(); ) {
+ MethodImpl method = (MethodImpl)iter.next();
+ try {
+ list.addAll(
+ method.allLineLocations(stratum, sourceName));
+ } catch(AbsentInformationException exc) {
+ someAbsent = true;
+ }
+ }
+
+ // If we retrieved no line info, and at least one of the methods
+ // should have had some (as determined by an
+ // AbsentInformationException being thrown) then we rethrow
+ // the AbsentInformationException.
+ if (someAbsent && list.size() == 0) {
+ throw new AbsentInformationException();
+ }
+ return list;
+ }
+
+ public List<Location> locationsOfLine(int lineNumber)
+ throws AbsentInformationException {
+ return locationsOfLine(vm.getDefaultStratum(),
+ null,
+ lineNumber);
+ }
+
+ public List<Location> locationsOfLine(String stratumID,
+ String sourceName,
+ int lineNumber)
+ throws AbsentInformationException {
+ // A method that should have info, didn't
+ boolean someAbsent = false;
+ // A method that should have info, did
+ boolean somePresent = false;
+ List<Method> methods = methods();
+ SDE.Stratum stratum = stratum(stratumID);
+
+ List<Location> list = new ArrayList<Location>();
+
+ Iterator<Method> iter = methods.iterator();
+ while(iter.hasNext()) {
+ MethodImpl method = (MethodImpl)iter.next();
+ // eliminate native and abstract to eliminate
+ // false positives
+ if (!method.isAbstract() &&
+ !method.isNative()) {
+ try {
+ list.addAll(
+ method.locationsOfLine(stratum,
+ sourceName,
+ lineNumber));
+ somePresent = true;
+ } catch(AbsentInformationException exc) {
+ someAbsent = true;
+ }
+ }
+ }
+ if (someAbsent && !somePresent) {
+ throw new AbsentInformationException();
+ }
+ return list;
+ }
+
+ public List<ObjectReference> instances(long maxInstances) {
+ if (!vm.canGetInstanceInfo()) {
+ throw new UnsupportedOperationException(
+ "target does not support getting instances");
+ }
+
+ if (maxInstances < 0) {
+ throw new IllegalArgumentException("maxInstances is less than zero: "
+ + maxInstances);
+ }
+ int intMax = (maxInstances > Integer.MAX_VALUE)?
+ Integer.MAX_VALUE: (int)maxInstances;
+ // JDWP can't currently handle more than this (in mustang)
+
+ try {
+ return Arrays.asList(
+ (ObjectReference[])JDWP.ReferenceType.Instances.
+ process(vm, this, intMax).instances);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+
+ private void getClassFileVersion() {
+ if (!vm.canGetClassFileVersion()) {
+ throw new UnsupportedOperationException();
+ }
+ JDWP.ReferenceType.ClassFileVersion classFileVersion;
+ if (versionNumberGotten) {
+ return;
+ } else {
+ try {
+ classFileVersion = JDWP.ReferenceType.ClassFileVersion.process(vm, this);
+ } catch (JDWPException exc) {
+ if (exc.errorCode() == JDWP.Error.ABSENT_INFORMATION) {
+ majorVersion = 0;
+ minorVersion = 0;
+ versionNumberGotten = true;
+ return;
+ } else {
+ throw exc.toJDIException();
+ }
+ }
+ majorVersion = classFileVersion.majorVersion;
+ minorVersion = classFileVersion.minorVersion;
+ versionNumberGotten = true;
+ }
+ }
+
+ public int majorVersion() {
+ try {
+ getClassFileVersion();
+ } catch (RuntimeException exc) {
+ throw exc;
+ }
+ return majorVersion;
+ }
+
+ public int minorVersion() {
+ try {
+ getClassFileVersion();
+ } catch (RuntimeException exc) {
+ throw exc;
+ }
+ return minorVersion;
+ }
+
+ private byte[] getConstantPoolInfo() {
+ JDWP.ReferenceType.ConstantPool jdwpCPool;
+ if (!vm.canGetConstantPool()) {
+ throw new UnsupportedOperationException();
+ }
+ if (constantPoolInfoGotten) {
+ if (constantPoolBytesRef == null) {
+ return null;
+ }
+ byte[] cpbytes = constantPoolBytesRef.get();
+ if (cpbytes != null) {
+ return cpbytes;
+ }
+ }
+
+ try {
+ jdwpCPool = JDWP.ReferenceType.ConstantPool.process(vm, this);
+ } catch (JDWPException exc) {
+ if (exc.errorCode() == JDWP.Error.ABSENT_INFORMATION) {
+ constanPoolCount = 0;
+ constantPoolBytesRef = null;
+ constantPoolInfoGotten = true;
+ return null;
+ } else {
+ throw exc.toJDIException();
+ }
+ }
+ byte[] cpbytes;
+ constanPoolCount = jdwpCPool.count;
+ cpbytes = jdwpCPool.bytes;
+ constantPoolBytesRef = new SoftReference<byte[]>(cpbytes);
+ constantPoolInfoGotten = true;
+ return cpbytes;
+ }
+
+ public int constantPoolCount() {
+ try {
+ getConstantPoolInfo();
+ } catch (RuntimeException exc) {
+ throw exc;
+ }
+ return constanPoolCount;
+ }
+
+ public byte[] constantPool() {
+ byte[] cpbytes;
+ try {
+ cpbytes = getConstantPoolInfo();
+ } catch (RuntimeException exc) {
+ throw exc;
+ }
+ if (cpbytes != null) {
+ /*
+ * Arrays are always modifiable, so it is a little unsafe
+ * to return the cached bytecodes directly; instead, we
+ * make a clone at the cost of using more memory.
+ */
+ return cpbytes.clone();
+ } else {
+ return null;
+ }
+ }
+
+ // Does not need synchronization, since worst-case
+ // static info is fetched twice
+ void getModifiers() {
+ if (modifiers != -1) {
+ return;
+ }
+ try {
+ modifiers = JDWP.ReferenceType.Modifiers.
+ process(vm, this).modBits;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+
+ void decodeStatus(int status) {
+ this.status = status;
+ if ((status & JDWP.ClassStatus.PREPARED) != 0) {
+ isPrepared = true;
+ }
+ }
+
+ void updateStatus() {
+ try {
+ decodeStatus(JDWP.ReferenceType.Status.process(vm, this).status);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+
+ void markPrepared() {
+ isPrepared = true;
+ }
+
+ long ref() {
+ return ref;
+ }
+
+ int indexOf(Method method) {
+ // Make sure they're all here - the obsolete method
+ // won't be found and so will have index -1
+ return methods().indexOf(method);
+ }
+
+ int indexOf(Field field) {
+ // Make sure they're all here
+ return fields().indexOf(field);
+ }
+
+ /*
+ * Return true if an instance of this type
+ * can be assigned to a variable of the given type
+ */
+ abstract boolean isAssignableTo(ReferenceType type);
+
+ boolean isAssignableFrom(ReferenceType type) {
+ return ((ReferenceTypeImpl)type).isAssignableTo(this);
+ }
+
+ boolean isAssignableFrom(ObjectReference object) {
+ return object == null ||
+ isAssignableFrom(object.referenceType());
+ }
+
+ void setStatus(int status) {
+ decodeStatus(status);
+ }
+
+ void setSignature(String signature) {
+ this.signature = signature;
+ }
+
+ void setGenericSignature(String signature) {
+ if (signature != null && signature.length() == 0) {
+ this.genericSignature = null;
+ } else{
+ this.genericSignature = signature;
+ }
+ this.genericSignatureGotten = true;
+ }
+
+ private static boolean isPrimitiveArray(String signature) {
+ int i = signature.lastIndexOf('[');
+ /*
+ * TO DO: Centralize JNI signature knowledge.
+ *
+ * Ref:
+ * jdk1.4/doc/guide/jpda/jdi/com/sun/jdi/doc-files/signature.html
+ */
+ boolean isPA;
+ if (i < 0) {
+ isPA = false;
+ } else {
+ char c = signature.charAt(i + 1);
+ isPA = (c != 'L');
+ }
+ return isPA;
+ }
+
+ Type findType(String signature) throws ClassNotLoadedException {
+ Type type;
+ if (signature.length() == 1) {
+ /* OTI FIX: Must be a primitive type or the void type */
+ char sig = signature.charAt(0);
+ if (sig == 'V') {
+ type = vm.theVoidType();
+ } else {
+ type = vm.primitiveTypeMirror((byte)sig);
+ }
+ } else {
+ // Must be a reference type.
+ ClassLoaderReferenceImpl loader =
+ (ClassLoaderReferenceImpl)classLoader();
+ if ((loader == null) ||
+ (isPrimitiveArray(signature)) //Work around 4450091
+ ) {
+ // Caller wants type of boot class field
+ type = vm.findBootType(signature);
+ } else {
+ // Caller wants type of non-boot class field
+ type = loader.findType(signature);
+ }
+ }
+ return type;
+ }
+
+ String loaderString() {
+ if (classLoader() != null) {
+ return "loaded by " + classLoader().toString();
+ } else {
+ return "no class loader";
+ }
+ }
+
+}
diff --git a/src/share/classes/com/sun/tools/jdi/SDE.java b/src/share/classes/com/sun/tools/jdi/SDE.java
new file mode 100644
index 0000000..2ccaf25
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/SDE.java
@@ -0,0 +1,691 @@
+/*
+ * Copyright (c) 2001, 2013, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+import java.util.*;
+import java.io.File;
+
+class SDE {
+ private static final int INIT_SIZE_FILE = 3;
+ private static final int INIT_SIZE_LINE = 100;
+ private static final int INIT_SIZE_STRATUM = 3;
+
+ static final String BASE_STRATUM_NAME = "Java";
+
+ /* for C capatibility */
+ static final String NullString = null;
+
+ private class FileTableRecord {
+ int fileId;
+ String sourceName;
+ String sourcePath; // do not read - use accessor
+ boolean isConverted = false;
+
+ /**
+ * Return the sourcePath, computing it if not set.
+ * If set, convert '/' in the sourcePath to the
+ * local file separator.
+ */
+ String getSourcePath(ReferenceTypeImpl refType) {
+ if (!isConverted) {
+ if (sourcePath == null) {
+ sourcePath = refType.baseSourceDir() + sourceName;
+ } else {
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < sourcePath.length(); ++i) {
+ char ch = sourcePath.charAt(i);
+ if (ch == '/') {
+ buf.append(File.separatorChar);
+ } else {
+ buf.append(ch);
+ }
+ }
+ sourcePath = buf.toString();
+ }
+ isConverted = true;
+ }
+ return sourcePath;
+ }
+ }
+
+ private class LineTableRecord {
+ int jplsStart;
+ int jplsEnd;
+ int jplsLineInc;
+ int njplsStart;
+ int njplsEnd;
+ int fileId;
+ }
+
+ private class StratumTableRecord {
+ String id;
+ int fileIndex;
+ int lineIndex;
+ }
+
+ class Stratum {
+ private final int sti; /* stratum index */
+
+ private Stratum(int sti) {
+ this.sti = sti;
+ }
+
+ String id() {
+ return stratumTable[sti].id;
+ }
+
+ boolean isJava() {
+ return sti == baseStratumIndex;
+ }
+
+ /**
+ * Return all the sourceNames for this stratum.
+ * Look from our starting fileIndex upto the starting
+ * fileIndex of next stratum - can do this since there
+ * is always a terminator stratum.
+ * Default sourceName (the first one) must be first.
+ */
+ List<String> sourceNames(ReferenceTypeImpl refType) {
+ int i;
+ int fileIndexStart = stratumTable[sti].fileIndex;
+ /* one past end */
+ int fileIndexEnd = stratumTable[sti+1].fileIndex;
+ List<String> result = new ArrayList<String>(fileIndexEnd - fileIndexStart);
+ for (i = fileIndexStart; i < fileIndexEnd; ++i) {
+ result.add(fileTable[i].sourceName);
+ }
+ return result;
+ }
+
+ /**
+ * Return all the sourcePaths for this stratum.
+ * Look from our starting fileIndex upto the starting
+ * fileIndex of next stratum - can do this since there
+ * is always a terminator stratum.
+ * Default sourcePath (the first one) must be first.
+ */
+ List<String> sourcePaths(ReferenceTypeImpl refType) {
+ int i;
+ int fileIndexStart = stratumTable[sti].fileIndex;
+ /* one past end */
+ int fileIndexEnd = stratumTable[sti+1].fileIndex;
+ List<String> result = new ArrayList<String>(fileIndexEnd - fileIndexStart);
+ for (i = fileIndexStart; i < fileIndexEnd; ++i) {
+ result.add(fileTable[i].getSourcePath(refType));
+ }
+ return result;
+ }
+
+ LineStratum lineStratum(ReferenceTypeImpl refType,
+ int jplsLine) {
+ int lti = stiLineTableIndex(sti, jplsLine);
+ if (lti < 0) {
+ return null;
+ } else {
+ return new LineStratum(sti, lti, refType,
+ jplsLine);
+ }
+ }
+ }
+
+ class LineStratum {
+ private final int sti; /* stratum index */
+ private final int lti; /* line table index */
+ private final ReferenceTypeImpl refType;
+ private final int jplsLine;
+ private String sourceName = null;
+ private String sourcePath = null;
+
+ private LineStratum(int sti, int lti,
+ ReferenceTypeImpl refType,
+ int jplsLine) {
+ this.sti = sti;
+ this.lti = lti;
+ this.refType = refType;
+ this.jplsLine = jplsLine;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof LineStratum) {
+ LineStratum other = (LineStratum)obj;
+ return (lti == other.lti) &&
+ (sti == other.sti) &&
+ (lineNumber() == other.lineNumber()) &&
+ (refType.equals(other.refType));
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return (lineNumber() * 17) ^ refType.hashCode();
+ }
+
+ int lineNumber() {
+ return stiLineNumber(sti, lti, jplsLine);
+ }
+
+ /**
+ * Fetch the source name and source path for
+ * this line, converting or constructing
+ * the source path if needed.
+ */
+ void getSourceInfo() {
+ if (sourceName != null) {
+ // already done
+ return;
+ }
+ int fti = stiFileTableIndex(sti, lti);
+ if (fti == -1) {
+ throw new InternalError(
+ "Bad SourceDebugExtension, no matching source id " +
+ lineTable[lti].fileId + " jplsLine: " + jplsLine);
+ }
+ FileTableRecord ftr = fileTable[fti];
+ sourceName = ftr.sourceName;
+ sourcePath = ftr.getSourcePath(refType);
+ }
+
+ String sourceName() {
+ getSourceInfo();
+ return sourceName;
+ }
+
+ String sourcePath() {
+ getSourceInfo();
+ return sourcePath;
+ }
+ }
+
+ private FileTableRecord[] fileTable = null;
+ private LineTableRecord[] lineTable = null;
+ private StratumTableRecord[] stratumTable = null;
+
+ private int fileIndex = 0;
+ private int lineIndex = 0;
+ private int stratumIndex = 0;
+ private int currentFileId = 0;
+
+ private int defaultStratumIndex = -1;
+ private int baseStratumIndex = -2; /* so as not to match -1 above */
+ private int sdePos = 0;
+
+ final String sourceDebugExtension;
+ String jplsFilename = null;
+ String defaultStratumId = null;
+ boolean isValid = false;
+
+ SDE(String sourceDebugExtension) {
+ this.sourceDebugExtension = sourceDebugExtension;
+ decode();
+ }
+
+ SDE() {
+ this.sourceDebugExtension = null;
+ createProxyForAbsentSDE();
+ }
+
+ char sdePeek() {
+ if (sdePos >= sourceDebugExtension.length()) {
+ syntax();
+ }
+ return sourceDebugExtension.charAt(sdePos);
+ }
+
+ char sdeRead() {
+ if (sdePos >= sourceDebugExtension.length()) {
+ syntax();
+ }
+ return sourceDebugExtension.charAt(sdePos++);
+ }
+
+ void sdeAdvance() {
+ sdePos++;
+ }
+
+ void syntax() {
+ throw new InternalError("bad SourceDebugExtension syntax - position " +
+ sdePos);
+ }
+
+ void syntax(String msg) {
+ throw new InternalError("bad SourceDebugExtension syntax: " + msg);
+ }
+
+ void assureLineTableSize() {
+ int len = lineTable == null? 0 : lineTable.length;
+ if (lineIndex >= len) {
+ int i;
+ int newLen = len == 0? INIT_SIZE_LINE : len * 2;
+ LineTableRecord[] newTable = new LineTableRecord[newLen];
+ for (i = 0; i < len; ++i) {
+ newTable[i] = lineTable[i];
+ }
+ for (; i < newLen; ++i) {
+ newTable[i] = new LineTableRecord();
+ }
+ lineTable = newTable;
+ }
+ }
+
+ void assureFileTableSize() {
+ int len = fileTable == null? 0 : fileTable.length;
+ if (fileIndex >= len) {
+ int i;
+ int newLen = len == 0? INIT_SIZE_FILE : len * 2;
+ FileTableRecord[] newTable = new FileTableRecord[newLen];
+ for (i = 0; i < len; ++i) {
+ newTable[i] = fileTable[i];
+ }
+ for (; i < newLen; ++i) {
+ newTable[i] = new FileTableRecord();
+ }
+ fileTable = newTable;
+ }
+ }
+
+ void assureStratumTableSize() {
+ int len = stratumTable == null? 0 : stratumTable.length;
+ if (stratumIndex >= len) {
+ int i;
+ int newLen = len == 0? INIT_SIZE_STRATUM : len * 2;
+ StratumTableRecord[] newTable = new StratumTableRecord[newLen];
+ for (i = 0; i < len; ++i) {
+ newTable[i] = stratumTable[i];
+ }
+ for (; i < newLen; ++i) {
+ newTable[i] = new StratumTableRecord();
+ }
+ stratumTable = newTable;
+ }
+ }
+
+ String readLine() {
+ StringBuffer sb = new StringBuffer();
+ char ch;
+
+ ignoreWhite();
+ while (((ch = sdeRead()) != '\n') && (ch != '\r')) {
+ sb.append(ch);
+ }
+ // check for CR LF
+ if ((ch == '\r') && (sdePeek() == '\n')) {
+ sdeRead();
+ }
+ ignoreWhite(); // leading white
+ return sb.toString();
+ }
+
+ private int defaultStratumTableIndex() {
+ if ((defaultStratumIndex == -1) && (defaultStratumId != null)) {
+ defaultStratumIndex =
+ stratumTableIndex(defaultStratumId);
+ }
+ return defaultStratumIndex;
+ }
+
+ int stratumTableIndex(String stratumId) {
+ int i;
+
+ if (stratumId == null) {
+ return defaultStratumTableIndex();
+ }
+ for (i = 0; i < (stratumIndex-1); ++i) {
+ if (stratumTable[i].id.equals(stratumId)) {
+ return i;
+ }
+ }
+ return defaultStratumTableIndex();
+ }
+
+ Stratum stratum(String stratumID) {
+ int sti = stratumTableIndex(stratumID);
+ return new Stratum(sti);
+ }
+
+ List<String> availableStrata() {
+ List<String> strata = new ArrayList<String>();
+
+ for (int i = 0; i < (stratumIndex-1); ++i) {
+ StratumTableRecord rec = stratumTable[i];
+ strata.add(rec.id);
+ }
+ return strata;
+ }
+
+/*****************************
+ * below functions/methods are written to compile under either Java or C
+ *
+ * Needed support functions:
+ * sdePeek()
+ * sdeRead()
+ * sdeAdvance()
+ * readLine()
+ * assureLineTableSize()
+ * assureFileTableSize()
+ * assureStratumTableSize()
+ * syntax()
+ *
+ * stratumTableIndex(String)
+ *
+ * Needed support variables:
+ * lineTable
+ * lineIndex
+ * fileTable
+ * fileIndex
+ * currentFileId
+ *
+ * Needed types:
+ * String
+ *
+ * Needed constants:
+ * NullString
+ */
+
+ void ignoreWhite() {
+ char ch;
+
+ while (((ch = sdePeek()) == ' ') || (ch == '\t')) {
+ sdeAdvance();
+ }
+ }
+
+ void ignoreLine() {
+ char ch;
+
+ while (((ch = sdeRead()) != '\n') && (ch != '\r')) {
+ }
+ /* check for CR LF */
+ if ((ch == '\r') && (sdePeek() == '\n')) {
+ sdeAdvance();
+ }
+ ignoreWhite(); /* leading white */
+ }
+
+ int readNumber() {
+ int value = 0;
+ char ch;
+
+ ignoreWhite();
+ while (((ch = sdePeek()) >= '0') && (ch <= '9')) {
+ sdeAdvance();
+ value = (value * 10) + ch - '0';
+ }
+ ignoreWhite();
+ return value;
+ }
+
+ void storeFile(int fileId, String sourceName, String sourcePath) {
+ assureFileTableSize();
+ fileTable[fileIndex].fileId = fileId;
+ fileTable[fileIndex].sourceName = sourceName;
+ fileTable[fileIndex].sourcePath = sourcePath;
+ ++fileIndex;
+ }
+
+ void fileLine() {
+ int hasAbsolute = 0; /* acts as boolean */
+ int fileId;
+ String sourceName;
+ String sourcePath = null;
+
+ /* is there an absolute filename? */
+ if (sdePeek() == '+') {
+ sdeAdvance();
+ hasAbsolute = 1;
+ }
+ fileId = readNumber();
+ sourceName = readLine();
+ if (hasAbsolute == 1) {
+ sourcePath = readLine();
+ }
+
+ storeFile(fileId, sourceName, sourcePath);
+ }
+
+ void storeLine(int jplsStart, int jplsEnd, int jplsLineInc,
+ int njplsStart, int njplsEnd, int fileId) {
+ assureLineTableSize();
+ lineTable[lineIndex].jplsStart = jplsStart;
+ lineTable[lineIndex].jplsEnd = jplsEnd;
+ lineTable[lineIndex].jplsLineInc = jplsLineInc;
+ lineTable[lineIndex].njplsStart = njplsStart;
+ lineTable[lineIndex].njplsEnd = njplsEnd;
+ lineTable[lineIndex].fileId = fileId;
+ ++lineIndex;
+ }
+
+ /**
+ * Parse line translation info. Syntax is
+ * <NJ-start-line> [ # <file-id> ] [ , <line-count> ] :
+ * <J-start-line> [ , <line-increment> ] CR
+ */
+ void lineLine() {
+ int lineCount = 1;
+ int lineIncrement = 1;
+ int njplsStart;
+ int jplsStart;
+
+ njplsStart = readNumber();
+
+ /* is there a fileID? */
+ if (sdePeek() == '#') {
+ sdeAdvance();
+ currentFileId = readNumber();
+ }
+
+ /* is there a line count? */
+ if (sdePeek() == ',') {
+ sdeAdvance();
+ lineCount = readNumber();
+ }
+
+ if (sdeRead() != ':') {
+ syntax();
+ }
+ jplsStart = readNumber();
+ if (sdePeek() == ',') {
+ sdeAdvance();
+ lineIncrement = readNumber();
+ }
+ ignoreLine(); /* flush the rest */
+
+ storeLine(jplsStart,
+ jplsStart + (lineCount * lineIncrement) -1,
+ lineIncrement,
+ njplsStart,
+ njplsStart + lineCount -1,
+ currentFileId);
+ }
+
+ /**
+ * Until the next stratum section, everything after this
+ * is in stratumId - so, store the current indicies.
+ */
+ void storeStratum(String stratumId) {
+ /* remove redundant strata */
+ if (stratumIndex > 0) {
+ if ((stratumTable[stratumIndex-1].fileIndex
+ == fileIndex) &&
+ (stratumTable[stratumIndex-1].lineIndex
+ == lineIndex)) {
+ /* nothing changed overwrite it */
+ --stratumIndex;
+ }
+ }
+ /* store the results */
+ assureStratumTableSize();
+ stratumTable[stratumIndex].id = stratumId;
+ stratumTable[stratumIndex].fileIndex = fileIndex;
+ stratumTable[stratumIndex].lineIndex = lineIndex;
+ ++stratumIndex;
+ currentFileId = 0;
+ }
+
+ /**
+ * The beginning of a stratum's info
+ */
+ void stratumSection() {
+ storeStratum(readLine());
+ }
+
+ void fileSection() {
+ ignoreLine();
+ while (sdePeek() != '*') {
+ fileLine();
+ }
+ }
+
+ void lineSection() {
+ ignoreLine();
+ while (sdePeek() != '*') {
+ lineLine();
+ }
+ }
+
+ /**
+ * Ignore a section we don't know about.
+ */
+ void ignoreSection() {
+ ignoreLine();
+ while (sdePeek() != '*') {
+ ignoreLine();
+ }
+ }
+
+ /**
+ * A base "Java" stratum is always available, though
+ * it is not in the SourceDebugExtension.
+ * Create the base stratum.
+ */
+ void createJavaStratum() {
+ baseStratumIndex = stratumIndex;
+ storeStratum(BASE_STRATUM_NAME);
+ storeFile(1, jplsFilename, NullString);
+ /* JPL line numbers cannot exceed 65535 */
+ storeLine(1, 65536, 1, 1, 65536, 1);
+ storeStratum("Aux"); /* in case they don't declare */
+ }
+
+ /**
+ * Decode a SourceDebugExtension which is in SourceMap format.
+ * This is the entry point into the recursive descent parser.
+ */
+ void decode() {
+ /* check for "SMAP" - allow EOF if not ours */
+ if ((sourceDebugExtension.length() < 4) ||
+ (sdeRead() != 'S') ||
+ (sdeRead() != 'M') ||
+ (sdeRead() != 'A') ||
+ (sdeRead() != 'P')) {
+ return; /* not our info */
+ }
+ ignoreLine(); /* flush the rest */
+ jplsFilename = readLine();
+ defaultStratumId = readLine();
+ createJavaStratum();
+ while (true) {
+ if (sdeRead() != '*') {
+ syntax();
+ }
+ switch (sdeRead()) {
+ case 'S':
+ stratumSection();
+ break;
+ case 'F':
+ fileSection();
+ break;
+ case 'L':
+ lineSection();
+ break;
+ case 'E':
+ /* set end points */
+ storeStratum("*terminator*");
+ isValid = true;
+ return;
+ default:
+ ignoreSection();
+ }
+ }
+ }
+
+ void createProxyForAbsentSDE() {
+ jplsFilename = null;
+ defaultStratumId = BASE_STRATUM_NAME;
+ defaultStratumIndex = stratumIndex;
+ createJavaStratum();
+ storeStratum("*terminator*");
+ }
+
+ /***************** query functions ***********************/
+
+ private int stiLineTableIndex(int sti, int jplsLine) {
+ int i;
+ int lineIndexStart;
+ int lineIndexEnd;
+
+ lineIndexStart = stratumTable[sti].lineIndex;
+ /* one past end */
+ lineIndexEnd = stratumTable[sti+1].lineIndex;
+ for (i = lineIndexStart; i < lineIndexEnd; ++i) {
+ if ((jplsLine >= lineTable[i].jplsStart) &&
+ (jplsLine <= lineTable[i].jplsEnd)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ private int stiLineNumber(int sti, int lti, int jplsLine) {
+ return lineTable[lti].njplsStart +
+ (((jplsLine - lineTable[lti].jplsStart) /
+ lineTable[lti].jplsLineInc));
+ }
+
+ private int fileTableIndex(int sti, int fileId) {
+ int i;
+ int fileIndexStart = stratumTable[sti].fileIndex;
+ /* one past end */
+ int fileIndexEnd = stratumTable[sti+1].fileIndex;
+ for (i = fileIndexStart; i < fileIndexEnd; ++i) {
+ if (fileTable[i].fileId == fileId) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ private int stiFileTableIndex(int sti, int lti) {
+ return fileTableIndex(sti, lineTable[lti].fileId);
+ }
+
+ boolean isValid() {
+ return isValid;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ShortTypeImpl.java b/src/share/classes/com/sun/tools/jdi/ShortTypeImpl.java
new file mode 100644
index 0000000..fa8795b
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ShortTypeImpl.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1998, 1999, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class ShortTypeImpl extends PrimitiveTypeImpl implements ShortType {
+ ShortTypeImpl(VirtualMachine vm) {
+ super(vm);
+ }
+
+
+ public String signature() {
+ return String.valueOf((char)JDWP.Tag.SHORT);
+ }
+
+ PrimitiveValue convert(PrimitiveValue value) throws InvalidTypeException {
+ return vm.mirrorOf(((PrimitiveValueImpl)value).checkedShortValue());
+ }
+
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ShortValueImpl.java b/src/share/classes/com/sun/tools/jdi/ShortValueImpl.java
new file mode 100644
index 0000000..dd980fe
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ShortValueImpl.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class ShortValueImpl extends PrimitiveValueImpl
+ implements ShortValue {
+ private short value;
+
+ ShortValueImpl(VirtualMachine aVm,short aValue) {
+ super(aVm);
+
+ value = aValue;
+ }
+
+ public boolean equals(Object obj) {
+ if ((obj != null) && (obj instanceof ShortValue)) {
+ return (value == ((ShortValue)obj).value()) &&
+ super.equals(obj);
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ /*
+ * TO DO: Better hash code
+ */
+ return intValue();
+ }
+
+ public int compareTo(ShortValue obj) {
+ short other = obj.value();
+ return value() - other;
+ }
+
+ public Type type() {
+ return vm.theShortType();
+ }
+
+ public short value() {
+ return value;
+ }
+
+ public boolean booleanValue() {
+ return(value == 0)?false:true;
+ }
+
+ public byte byteValue() {
+ return(byte)value;
+ }
+
+ public char charValue() {
+ return(char)value;
+ }
+
+ public short shortValue() {
+ return value;
+ }
+
+ public int intValue() {
+ return(int)value;
+ }
+
+ public long longValue() {
+ return(long)value;
+ }
+
+ public float floatValue() {
+ return(float)value;
+ }
+
+ public double doubleValue() {
+ return(double)value;
+ }
+
+ byte checkedByteValue() throws InvalidTypeException {
+ if ((value > Byte.MAX_VALUE) || (value < Byte.MIN_VALUE)) {
+ throw new InvalidTypeException("Can't convert " + value + " to byte");
+ } else {
+ return super.checkedByteValue();
+ }
+ }
+
+ char checkedCharValue() throws InvalidTypeException {
+ if ((value > Character.MAX_VALUE) || (value < Character.MIN_VALUE)) {
+ throw new InvalidTypeException("Can't convert " + value + " to char");
+ } else {
+ return super.checkedCharValue();
+ }
+ }
+
+ public String toString() {
+ return "" + value;
+ }
+
+ byte typeValueKey() {
+ return JDWP.Tag.SHORT;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/SocketAttachingConnector.java b/src/share/classes/com/sun/tools/jdi/SocketAttachingConnector.java
new file mode 100644
index 0000000..a8c2bed
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/SocketAttachingConnector.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 1998, 2013, 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.tools.jdi;
+
+import com.sun.jdi.VirtualMachine;
+import com.sun.jdi.connect.*;
+import com.sun.jdi.connect.spi.*;
+import java.util.Map;
+import java.util.HashMap;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/*
+ * An AttachingConnector that uses the SocketTransportService
+ */
+public class SocketAttachingConnector extends GenericAttachingConnector {
+
+ static final String ARG_PORT = "port";
+ static final String ARG_HOST = "hostname";
+
+ public SocketAttachingConnector() {
+ super(new SocketTransportService());
+
+ String defaultHostName;
+ try {
+ defaultHostName = InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ defaultHostName = "";
+ }
+
+ addStringArgument(
+ ARG_HOST,
+ getString("socket_attaching.host.label"),
+ getString("socket_attaching.host"),
+ defaultHostName,
+ false);
+
+ addIntegerArgument(
+ ARG_PORT,
+ getString("socket_attaching.port.label"),
+ getString("socket_attaching.port"),
+ "",
+ true,
+ 0, Integer.MAX_VALUE);
+
+ transport = new Transport() {
+ public String name() {
+ return "dt_socket"; // for compatibility reasons
+ }
+ };
+
+ }
+
+ /*
+ * Create an "address" from the hostname and port connector
+ * arguments and attach to the target VM.
+ */
+ public VirtualMachine
+ attach(Map<String,? extends Connector.Argument> arguments)
+ throws IOException, IllegalConnectorArgumentsException
+ {
+ String host = argument(ARG_HOST, arguments).value();
+ if (host.length() > 0) {
+ host = host + ":";
+ }
+ String address = host + argument(ARG_PORT, arguments).value();
+ return super.attach(address, arguments);
+ }
+
+ public String name() {
+ return "com.sun.jdi.SocketAttach";
+ }
+
+ public String description() {
+ return getString("socket_attaching.description");
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/SocketListeningConnector.java b/src/share/classes/com/sun/tools/jdi/SocketListeningConnector.java
new file mode 100644
index 0000000..95f0410
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/SocketListeningConnector.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 1998, 2013, 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.tools.jdi;
+
+import com.sun.jdi.connect.*;
+import com.sun.jdi.connect.spi.*;
+import java.util.Map;
+import java.util.HashMap;
+import java.io.IOException;
+
+/*
+ * An ListeningConnector that uses the SocketTransportService
+ */
+public class SocketListeningConnector extends GenericListeningConnector {
+
+ static final String ARG_PORT = "port";
+ static final String ARG_LOCALADDR = "localAddress";
+
+ public SocketListeningConnector() {
+ super(new SocketTransportService());
+
+ addIntegerArgument(
+ ARG_PORT,
+ getString("socket_listening.port.label"),
+ getString("socket_listening.port"),
+ "",
+ false,
+ 0, Integer.MAX_VALUE);
+
+ addStringArgument(
+ ARG_LOCALADDR,
+ getString("socket_listening.localaddr.label"),
+ getString("socket_listening.localaddr"),
+ "", // default is wildcard
+ false);
+
+ transport = new Transport() {
+ public String name() {
+ return "dt_socket"; // for compatibility reasons
+ }
+ };
+ }
+
+
+ public String
+ startListening(Map<String,? extends Connector.Argument> args)
+ throws IOException, IllegalConnectorArgumentsException
+ {
+ String port = argument(ARG_PORT, args).value();
+ String localaddr = argument(ARG_LOCALADDR, args).value();
+
+ // default to system chosen port
+ if (port.length() == 0) {
+ port = "0";
+ }
+
+ if (localaddr.length() > 0) {
+ localaddr = localaddr + ":" + port;
+ } else {
+ localaddr = port;
+ }
+
+ return super.startListening(localaddr, args);
+ }
+
+ public String name() {
+ return "com.sun.jdi.SocketListen";
+ }
+
+ public String description() {
+ return getString("socket_listening.description");
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/SocketTransportService.java b/src/share/classes/com/sun/tools/jdi/SocketTransportService.java
new file mode 100644
index 0000000..5585a00
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/SocketTransportService.java
@@ -0,0 +1,536 @@
+/*
+ * Copyright (c) 1998, 2003, 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.tools.jdi;
+
+import com.sun.jdi.*;
+import com.sun.jdi.connect.*;
+import com.sun.jdi.connect.spi.*;
+import java.net.*;
+import java.io.*;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+/*
+ * A transport service based on a TCP connection between the
+ * debugger and debugee.
+ */
+
+public class SocketTransportService extends TransportService {
+ private ResourceBundle messages = null;
+
+ /**
+ * The listener returned by startListening encapsulates
+ * the ServerSocket.
+ */
+ static class SocketListenKey extends ListenKey {
+ ServerSocket ss;
+
+ SocketListenKey(ServerSocket ss) {
+ this.ss = ss;
+ }
+
+ ServerSocket socket() {
+ return ss;
+ }
+
+ /*
+ * Returns the string representation of the address that this
+ * listen key represents.
+ */
+ public String address() {
+ InetAddress address = ss.getInetAddress();
+
+ /*
+ * If bound to the wildcard address then use current local
+ * hostname. In the event that we don't know our own hostname
+ * then assume that host supports IPv4 and return something to
+ * represent the loopback address.
+ */
+ if (address.isAnyLocalAddress()) {
+ try {
+ address = InetAddress.getLocalHost();
+ } catch (UnknownHostException uhe) {
+ byte[] loopback = {0x7f,0x00,0x00,0x01};
+ try {
+ address = InetAddress.getByAddress("127.0.0.1", loopback);
+ } catch (UnknownHostException x) {
+ throw new InternalError("unable to get local hostname");
+ }
+ }
+ }
+
+ /*
+ * Now decide if we return a hostname or IP address. Where possible
+ * return a hostname but in the case that we are bound to an
+ * address that isn't registered in the name service then we
+ * return an address.
+ */
+ String result;
+ String hostname = address.getHostName();
+ String hostaddr = address.getHostAddress();
+ if (hostname.equals(hostaddr)) {
+ if (address instanceof Inet6Address) {
+ result = "[" + hostaddr + "]";
+ } else {
+ result = hostaddr;
+ }
+ } else {
+ result = hostname;
+ }
+
+ /*
+ * Finally return "hostname:port", "ipv4-address:port" or
+ * "[ipv6-address]:port".
+ */
+ return result + ":" + ss.getLocalPort();
+ }
+
+ public String toString() {
+ return address();
+ }
+ }
+
+ /**
+ * Handshake with the debuggee
+ */
+ void handshake(Socket s, long timeout) throws IOException {
+ s.setSoTimeout((int)timeout);
+
+ byte[] hello = "JDWP-Handshake".getBytes("UTF-8");
+ s.getOutputStream().write(hello);
+
+ byte[] b = new byte[hello.length];
+ int received = 0;
+ while (received < hello.length) {
+ int n;
+ try {
+ n = s.getInputStream().read(b, received, hello.length-received);
+ } catch (SocketTimeoutException x) {
+ throw new IOException("handshake timeout");
+ }
+ if (n < 0) {
+ s.close();
+ throw new IOException("handshake failed - connection prematurally closed");
+ }
+ received += n;
+ }
+ for (int i=0; i<hello.length; i++) {
+ if (b[i] != hello[i]) {
+ throw new IOException("handshake failed - unrecognized message from target VM");
+ }
+ }
+
+ // disable read timeout
+ s.setSoTimeout(0);
+ }
+
+ /**
+ * No-arg constructor
+ */
+ public SocketTransportService() {
+ }
+
+ /**
+ * The name of this transport service
+ */
+ public String name() {
+ return "Socket";
+ }
+
+ /**
+ * Return localized description of this transport service
+ */
+ public String description() {
+ synchronized (this) {
+ if (messages == null) {
+ messages = ResourceBundle.getBundle("com.sun.tools.jdi.resources.jdi");
+ }
+ }
+ return messages.getString("socket_transportservice.description");
+ }
+
+ /**
+ * Return the capabilities of this transport service
+ */
+ public Capabilities capabilities() {
+ return new SocketTransportServiceCapabilities();
+ }
+
+
+ /**
+ * Attach to the specified address with optional attach and handshake
+ * timeout.
+ */
+ public Connection attach(String address, long attachTimeout, long handshakeTimeout)
+ throws IOException {
+
+ if (address == null) {
+ throw new NullPointerException("address is null");
+ }
+ if (attachTimeout < 0 || handshakeTimeout < 0) {
+ throw new IllegalArgumentException("timeout is negative");
+ }
+
+ int splitIndex = address.indexOf(':');
+ String host;
+ String portStr;
+ if (splitIndex < 0) {
+ host = InetAddress.getLocalHost().getHostName();
+ portStr = address;
+ } else {
+ host = address.substring(0, splitIndex);
+ portStr = address.substring(splitIndex+1);
+ }
+
+ int port;
+ try {
+ port = Integer.decode(portStr).intValue();
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException(
+ "unable to parse port number in address");
+ }
+
+
+ // open TCP connection to VM
+
+ InetSocketAddress sa = new InetSocketAddress(host, port);
+ Socket s = new Socket();
+ try {
+ s.connect(sa, (int)attachTimeout);
+ } catch (SocketTimeoutException exc) {
+ try {
+ s.close();
+ } catch (IOException x) { }
+ throw new TransportTimeoutException("timed out trying to establish connection");
+ }
+
+ // handshake with the target VM
+ try {
+ handshake(s, handshakeTimeout);
+ } catch (IOException exc) {
+ try {
+ s.close();
+ } catch (IOException x) { }
+ throw exc;
+ }
+
+ return new SocketConnection(s);
+ }
+
+ /*
+ * Listen on the specified address and port. Return a listener
+ * that encapsulates the ServerSocket.
+ */
+ ListenKey startListening(String localaddress, int port) throws IOException {
+ InetSocketAddress sa;
+ if (localaddress == null) {
+ sa = new InetSocketAddress(port);
+ } else {
+ sa = new InetSocketAddress(localaddress, port);
+ }
+ ServerSocket ss = new ServerSocket();
+ ss.bind(sa);
+ return new SocketListenKey(ss);
+ }
+
+ /**
+ * Listen on the specified address
+ */
+ public ListenKey startListening(String address) throws IOException {
+ // use ephemeral port if address isn't specified.
+ if (address == null || address.length() == 0) {
+ address = "0";
+ }
+
+ int splitIndex = address.indexOf(':');
+ String localaddr = null;
+ if (splitIndex >= 0) {
+ localaddr = address.substring(0, splitIndex);
+ address = address.substring(splitIndex+1);
+ }
+
+ int port;
+ try {
+ port = Integer.decode(address).intValue();
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException(
+ "unable to parse port number in address");
+ }
+
+ return startListening(localaddr, port);
+ }
+
+ /**
+ * Listen on the default address
+ */
+ public ListenKey startListening() throws IOException {
+ return startListening(null, 0);
+ }
+
+ /**
+ * Stop the listener
+ */
+ public void stopListening(ListenKey listener) throws IOException {
+ if (!(listener instanceof SocketListenKey)) {
+ throw new IllegalArgumentException("Invalid listener");
+ }
+
+ synchronized (listener) {
+ ServerSocket ss = ((SocketListenKey)listener).socket();
+
+ // if the ServerSocket has been closed it means
+ // the listener is invalid
+ if (ss.isClosed()) {
+ throw new IllegalArgumentException("Invalid listener");
+ }
+ ss.close();
+ }
+ }
+
+ /**
+ * Accept a connection from a debuggee and handshake with it.
+ */
+ public Connection accept(ListenKey listener, long acceptTimeout, long handshakeTimeout) throws IOException {
+ if (acceptTimeout < 0 || handshakeTimeout < 0) {
+ throw new IllegalArgumentException("timeout is negative");
+ }
+ if (!(listener instanceof SocketListenKey)) {
+ throw new IllegalArgumentException("Invalid listener");
+ }
+ ServerSocket ss;
+
+ // obtain the ServerSocket from the listener - if the
+ // socket is closed it means the listener is invalid
+ synchronized (listener) {
+ ss = ((SocketListenKey)listener).socket();
+ if (ss.isClosed()) {
+ throw new IllegalArgumentException("Invalid listener");
+ }
+ }
+
+ // from here onwards it's possible that the ServerSocket
+ // may be closed by a call to stopListening - that's okay
+ // because the ServerSocket methods will throw an
+ // IOException indicating the socket is closed.
+ //
+ // Additionally, it's possible that another thread calls accept
+ // with a different accept timeout - that creates a same race
+ // condition between setting the timeout and calling accept.
+ // As it is such an unlikely scenario (requires both threads
+ // to be using the same listener we've chosen to ignore the issue).
+
+ ss.setSoTimeout((int)acceptTimeout);
+ Socket s;
+ try {
+ s = ss.accept();
+ } catch (SocketTimeoutException x) {
+ throw new TransportTimeoutException("timeout waiting for connection");
+ }
+
+ // handshake here
+ handshake(s, handshakeTimeout);
+
+ return new SocketConnection(s);
+ }
+
+ public String toString() {
+ return name();
+ }
+}
+
+
+/*
+ * The Connection returned by attach and accept is one of these
+ */
+class SocketConnection extends Connection {
+ private Socket socket;
+ private boolean closed = false;
+ private OutputStream socketOutput;
+ private InputStream socketInput;
+ private Object receiveLock = new Object();
+ private Object sendLock = new Object();
+ private Object closeLock = new Object();
+
+ SocketConnection(Socket socket) throws IOException {
+ this.socket = socket;
+ socket.setTcpNoDelay(true);
+ socketInput = socket.getInputStream();
+ socketOutput = socket.getOutputStream();
+ }
+
+ public void close() throws IOException {
+ synchronized (closeLock) {
+ if (closed) {
+ return;
+ }
+ socketOutput.close();
+ socketInput.close();
+ socket.close();
+ closed = true;
+ }
+ }
+
+ public boolean isOpen() {
+ synchronized (closeLock) {
+ return !closed;
+ }
+ }
+
+ public byte[] readPacket() throws IOException {
+ if (!isOpen()) {
+ throw new ClosedConnectionException("connection is closed");
+ }
+ synchronized (receiveLock) {
+ int b1,b2,b3,b4;
+
+ // length
+ try {
+ b1 = socketInput.read();
+ b2 = socketInput.read();
+ b3 = socketInput.read();
+ b4 = socketInput.read();
+ } catch (IOException ioe) {
+ if (!isOpen()) {
+ throw new ClosedConnectionException("connection is closed");
+ } else {
+ throw ioe;
+ }
+ }
+
+ // EOF
+ if (b1<0) {
+ return new byte[0];
+ }
+
+ if (b2<0 || b3<0 || b4<0) {
+ throw new IOException("protocol error - premature EOF");
+ }
+
+ int len = ((b1 << 24) | (b2 << 16) | (b3 << 8) | (b4 << 0));
+
+ if (len < 0) {
+ throw new IOException("protocol error - invalid length");
+ }
+
+ byte b[] = new byte[len];
+ b[0] = (byte)b1;
+ b[1] = (byte)b2;
+ b[2] = (byte)b3;
+ b[3] = (byte)b4;
+
+ int off = 4;
+ len -= off;
+
+ while (len > 0) {
+ int count;
+ try {
+ count = socketInput.read(b, off, len);
+ } catch (IOException ioe) {
+ if (!isOpen()) {
+ throw new ClosedConnectionException("connection is closed");
+ } else {
+ throw ioe;
+ }
+ }
+ if (count < 0) {
+ throw new IOException("protocol error - premature EOF");
+ }
+ len -= count;
+ off += count;
+ }
+
+ return b;
+ }
+ }
+
+ public void writePacket(byte b[]) throws IOException {
+ if (!isOpen()) {
+ throw new ClosedConnectionException("connection is closed");
+ }
+
+ /*
+ * Check the packet size
+ */
+ if (b.length < 11) {
+ throw new IllegalArgumentException("packet is insufficient size");
+ }
+ int b0 = b[0] & 0xff;
+ int b1 = b[1] & 0xff;
+ int b2 = b[2] & 0xff;
+ int b3 = b[3] & 0xff;
+ int len = ((b0 << 24) | (b1 << 16) | (b2 << 8) | (b3 << 0));
+ if (len < 11) {
+ throw new IllegalArgumentException("packet is insufficient size");
+ }
+
+ /*
+ * Check that the byte array contains the complete packet
+ */
+ if (len > b.length) {
+ throw new IllegalArgumentException("length mis-match");
+ }
+
+ synchronized (sendLock) {
+ try {
+ /*
+ * Send the packet (ignoring any bytes that follow
+ * the packet in the byte array).
+ */
+ socketOutput.write(b, 0, len);
+ } catch (IOException ioe) {
+ if (!isOpen()) {
+ throw new ClosedConnectionException("connection is closed");
+ } else {
+ throw ioe;
+ }
+ }
+ }
+ }
+}
+
+
+/*
+ * The capabilities of the socket transport service
+ */
+class SocketTransportServiceCapabilities extends TransportService.Capabilities {
+
+ public boolean supportsMultipleConnections() {
+ return true;
+ }
+
+ public boolean supportsAttachTimeout() {
+ return true;
+ }
+
+ public boolean supportsAcceptTimeout() {
+ return true;
+ }
+
+ public boolean supportsHandshakeTimeout() {
+ return true;
+ }
+
+}
diff --git a/src/share/classes/com/sun/tools/jdi/StackFrameImpl.java b/src/share/classes/com/sun/tools/jdi/StackFrameImpl.java
new file mode 100644
index 0000000..04eeea1
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/StackFrameImpl.java
@@ -0,0 +1,404 @@
+/*
+ * Copyright (c) 1998, 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 com.sun.tools.jdi;
+
+import com.sun.jdi.*;
+
+import java.util.List;
+import java.util.Map;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Collections;
+
+public class StackFrameImpl extends MirrorImpl
+ implements StackFrame, ThreadListener
+{
+ /* Once false, frame should not be used.
+ * access synchronized on (vm.state())
+ */
+ private boolean isValid = true;
+
+ private final ThreadReferenceImpl thread;
+ private final long id;
+ private final Location location;
+ private Map<String, LocalVariable> visibleVariables = null;
+ private ObjectReference thisObject = null;
+
+ StackFrameImpl(VirtualMachine vm, ThreadReferenceImpl thread,
+ long id, Location location) {
+ super(vm);
+ this.thread = thread;
+ this.id = id;
+ this.location = location;
+ thread.addListener(this);
+ }
+
+ /*
+ * ThreadListener implementation
+ * Must be synchronized since we must protect against
+ * sending defunct (isValid == false) stack ids to the back-end.
+ */
+ public boolean threadResumable(ThreadAction action) {
+ synchronized (vm.state()) {
+ if (isValid) {
+ isValid = false;
+ return false; /* remove this stack frame as a listener */
+ } else {
+ throw new InternalException(
+ "Invalid stack frame thread listener");
+ }
+ }
+ }
+
+ void validateStackFrame() {
+ if (!isValid) {
+ throw new InvalidStackFrameException("Thread has been resumed");
+ }
+ }
+
+ /**
+ * Return the frame location.
+ * Need not be synchronized since it cannot be provably stale.
+ */
+ public Location location() {
+ validateStackFrame();
+ return location;
+ }
+
+ /**
+ * Return the thread holding the frame.
+ * Need not be synchronized since it cannot be provably stale.
+ */
+ public ThreadReference thread() {
+ validateStackFrame();
+ return thread;
+ }
+
+ public boolean equals(Object obj) {
+ if ((obj != null) && (obj instanceof StackFrameImpl)) {
+ StackFrameImpl other = (StackFrameImpl)obj;
+ return (id == other.id) &&
+ (thread().equals(other.thread())) &&
+ (location().equals(other.location())) &&
+ super.equals(obj);
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ return (thread().hashCode() << 4) + ((int)id);
+ }
+
+ public ObjectReference thisObject() {
+ validateStackFrame();
+ MethodImpl currentMethod = (MethodImpl)location.method();
+ if (currentMethod.isStatic() || currentMethod.isNative()) {
+ return null;
+ } else {
+ if (thisObject == null) {
+ PacketStream ps;
+
+ /* protect against defunct frame id */
+ synchronized (vm.state()) {
+ validateStackFrame();
+ ps = JDWP.StackFrame.ThisObject.
+ enqueueCommand(vm, thread, id);
+ }
+
+ /* actually get it, now that order is guaranteed */
+ try {
+ thisObject = JDWP.StackFrame.ThisObject.
+ waitForReply(vm, ps).objectThis;
+ } catch (JDWPException exc) {
+ switch (exc.errorCode()) {
+ case JDWP.Error.INVALID_FRAMEID:
+ case JDWP.Error.THREAD_NOT_SUSPENDED:
+ case JDWP.Error.INVALID_THREAD:
+ throw new InvalidStackFrameException();
+ default:
+ throw exc.toJDIException();
+ }
+ }
+ }
+ }
+ return thisObject;
+ }
+
+ /**
+ * Build the visible variable map.
+ * Need not be synchronized since it cannot be provably stale.
+ */
+ private void createVisibleVariables() throws AbsentInformationException {
+ if (visibleVariables == null) {
+ List<LocalVariable> allVariables = location.method().variables();
+ Map<String, LocalVariable> map = new HashMap<String, LocalVariable>(allVariables.size());
+
+ for (LocalVariable variable : allVariables) {
+ String name = variable.name();
+ if (variable.isVisible(this)) {
+ LocalVariable existing = map.get(name);
+ if ((existing == null) ||
+ ((LocalVariableImpl)variable).hides(existing)) {
+ map.put(name, variable);
+ }
+ }
+ }
+ visibleVariables = map;
+ }
+ }
+
+ /**
+ * Return the list of visible variable in the frame.
+ * Need not be synchronized since it cannot be provably stale.
+ */
+ public List<LocalVariable> visibleVariables() throws AbsentInformationException {
+ validateStackFrame();
+ createVisibleVariables();
+ List<LocalVariable> mapAsList = new ArrayList<LocalVariable>(visibleVariables.values());
+ Collections.sort(mapAsList);
+ return mapAsList;
+ }
+
+ /**
+ * Return a particular variable in the frame.
+ * Need not be synchronized since it cannot be provably stale.
+ */
+ public LocalVariable visibleVariableByName(String name) throws AbsentInformationException {
+ validateStackFrame();
+ createVisibleVariables();
+ return visibleVariables.get(name);
+ }
+
+ public Value getValue(LocalVariable variable) {
+ List<LocalVariable> list = new ArrayList<LocalVariable>(1);
+ list.add(variable);
+ return getValues(list).get(variable);
+ }
+
+ public Map<LocalVariable, Value> getValues(List<? extends LocalVariable> variables) {
+ validateStackFrame();
+ validateMirrors(variables);
+
+ int count = variables.size();
+ JDWP.StackFrame.GetValues.SlotInfo[] slots =
+ new JDWP.StackFrame.GetValues.SlotInfo[count];
+
+ for (int i=0; i<count; ++i) {
+ LocalVariableImpl variable = (LocalVariableImpl)variables.get(i);
+ if (!variable.isVisible(this)) {
+ throw new IllegalArgumentException(variable.name() +
+ " is not valid at this frame location");
+ }
+ slots[i] = new JDWP.StackFrame.GetValues.SlotInfo(variable.slot(),
+ (byte)variable.signature().charAt(0));
+ }
+
+ PacketStream ps;
+
+ /* protect against defunct frame id */
+ synchronized (vm.state()) {
+ validateStackFrame();
+ ps = JDWP.StackFrame.GetValues.enqueueCommand(vm, thread, id, slots);
+ }
+
+ /* actually get it, now that order is guaranteed */
+ ValueImpl[] values;
+ try {
+ values = JDWP.StackFrame.GetValues.waitForReply(vm, ps).values;
+ } catch (JDWPException exc) {
+ switch (exc.errorCode()) {
+ case JDWP.Error.INVALID_FRAMEID:
+ case JDWP.Error.THREAD_NOT_SUSPENDED:
+ case JDWP.Error.INVALID_THREAD:
+ throw new InvalidStackFrameException();
+ default:
+ throw exc.toJDIException();
+ }
+ }
+
+ if (count != values.length) {
+ throw new InternalException(
+ "Wrong number of values returned from target VM");
+ }
+ Map<LocalVariable, Value> map = new HashMap<LocalVariable, Value>(count);
+ for (int i=0; i<count; ++i) {
+ LocalVariableImpl variable = (LocalVariableImpl)variables.get(i);
+ map.put(variable, values[i]);
+ }
+ return map;
+ }
+
+ public void setValue(LocalVariable variableIntf, Value valueIntf)
+ throws InvalidTypeException, ClassNotLoadedException {
+
+ validateStackFrame();
+ validateMirror(variableIntf);
+ validateMirrorOrNull(valueIntf);
+
+ LocalVariableImpl variable = (LocalVariableImpl)variableIntf;
+ ValueImpl value = (ValueImpl)valueIntf;
+
+ if (!variable.isVisible(this)) {
+ throw new IllegalArgumentException(variable.name() +
+ " is not valid at this frame location");
+ }
+
+ try {
+ // Validate and convert value if necessary
+ value = ValueImpl.prepareForAssignment(value, variable);
+
+ JDWP.StackFrame.SetValues.SlotInfo[] slotVals =
+ new JDWP.StackFrame.SetValues.SlotInfo[1];
+ slotVals[0] = new JDWP.StackFrame.SetValues.
+ SlotInfo(variable.slot(), value);
+
+ PacketStream ps;
+
+ /* protect against defunct frame id */
+ synchronized (vm.state()) {
+ validateStackFrame();
+ ps = JDWP.StackFrame.SetValues.
+ enqueueCommand(vm, thread, id, slotVals);
+ }
+
+ /* actually set it, now that order is guaranteed */
+ try {
+ JDWP.StackFrame.SetValues.waitForReply(vm, ps);
+ } catch (JDWPException exc) {
+ switch (exc.errorCode()) {
+ case JDWP.Error.INVALID_FRAMEID:
+ case JDWP.Error.THREAD_NOT_SUSPENDED:
+ case JDWP.Error.INVALID_THREAD:
+ throw new InvalidStackFrameException();
+ default:
+ throw exc.toJDIException();
+ }
+ }
+ } catch (ClassNotLoadedException e) {
+ /*
+ * Since we got this exception,
+ * the variable type must be a reference type. The value
+ * we're trying to set is null, but if the variable's
+ * class has not yet been loaded through the enclosing
+ * class loader, then setting to null is essentially a
+ * no-op, and we should allow it without an exception.
+ */
+ if (value != null) {
+ throw e;
+ }
+ }
+ }
+
+ public List<Value> getArgumentValues() {
+ validateStackFrame();
+ MethodImpl mmm = (MethodImpl)location.method();
+ List<String> argSigs = mmm.argumentSignatures();
+ int count = argSigs.size();
+ JDWP.StackFrame.GetValues.SlotInfo[] slots =
+ new JDWP.StackFrame.GetValues.SlotInfo[count];
+
+ int slot;
+ if (mmm.isStatic()) {
+ slot = 0;
+ } else {
+ slot = 1;
+ }
+ for (int ii = 0; ii < count; ++ii) {
+ char sigChar = argSigs.get(ii).charAt(0);
+ slots[ii] = new JDWP.StackFrame.GetValues.SlotInfo(slot++,(byte)sigChar);
+ if (sigChar == 'J' || sigChar == 'D') {
+ slot++;
+ }
+ }
+
+ PacketStream ps;
+
+ /* protect against defunct frame id */
+ synchronized (vm.state()) {
+ validateStackFrame();
+ ps = JDWP.StackFrame.GetValues.enqueueCommand(vm, thread, id, slots);
+ }
+
+ ValueImpl[] values;
+ try {
+ values = JDWP.StackFrame.GetValues.waitForReply(vm, ps).values;
+ } catch (JDWPException exc) {
+ switch (exc.errorCode()) {
+ case JDWP.Error.INVALID_FRAMEID:
+ case JDWP.Error.THREAD_NOT_SUSPENDED:
+ case JDWP.Error.INVALID_THREAD:
+ throw new InvalidStackFrameException();
+ default:
+ throw exc.toJDIException();
+ }
+ }
+
+ if (count != values.length) {
+ throw new InternalException(
+ "Wrong number of values returned from target VM");
+ }
+ return Arrays.asList((Value[])values);
+ }
+
+ void pop() throws IncompatibleThreadStateException {
+ validateStackFrame();
+ // flush caches and disable caching until command completion
+ CommandSender sender =
+ new CommandSender() {
+ public PacketStream send() {
+ return JDWP.StackFrame.PopFrames.enqueueCommand(vm,
+ thread, id);
+ }
+ };
+ try {
+ PacketStream stream = thread.sendResumingCommand(sender);
+ JDWP.StackFrame.PopFrames.waitForReply(vm, stream);
+ } catch (JDWPException exc) {
+ switch (exc.errorCode()) {
+ case JDWP.Error.THREAD_NOT_SUSPENDED:
+ throw new IncompatibleThreadStateException(
+ "Thread not current or suspended");
+ case JDWP.Error.INVALID_THREAD: /* zombie */
+ throw new IncompatibleThreadStateException("zombie");
+ case JDWP.Error.NO_MORE_FRAMES:
+ throw new InvalidStackFrameException(
+ "No more frames on the stack");
+ default:
+ throw exc.toJDIException();
+ }
+ }
+
+ // enable caching - suspended again
+ vm.state().freeze();
+ }
+
+ public String toString() {
+ return location.toString() + " in thread " + thread.toString();
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/StratumLineInfo.java b/src/share/classes/com/sun/tools/jdi/StratumLineInfo.java
new file mode 100644
index 0000000..197b5bd
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/StratumLineInfo.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2001, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+class StratumLineInfo implements LineInfo {
+ private final String stratumID;
+ private final int lineNumber;
+ private final String sourceName;
+ private final String sourcePath;
+
+ StratumLineInfo(String stratumID, int lineNumber,
+ String sourceName, String sourcePath) {
+ this.stratumID = stratumID;
+ this.lineNumber = lineNumber;
+ this.sourceName = sourceName;
+ this.sourcePath = sourcePath;
+ }
+
+ public String liStratum() {
+ return stratumID;
+ }
+
+ public int liLineNumber() {
+ return lineNumber;
+ }
+
+ public String liSourceName()
+ throws AbsentInformationException {
+ if (sourceName == null) {
+ throw new AbsentInformationException();
+ }
+ return sourceName;
+ }
+
+ public String liSourcePath()
+ throws AbsentInformationException {
+ if (sourcePath == null) {
+ throw new AbsentInformationException();
+ }
+ return sourcePath;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/StringReferenceImpl.java b/src/share/classes/com/sun/tools/jdi/StringReferenceImpl.java
new file mode 100644
index 0000000..eeeec68
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/StringReferenceImpl.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 1998, 1999, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class StringReferenceImpl extends ObjectReferenceImpl
+ implements StringReference
+{
+ private String value;
+
+ StringReferenceImpl(VirtualMachine aVm,long aRef) {
+ super(aVm,aRef);
+ }
+
+ public String value() {
+ if(value == null) {
+ // Does not need synchronization, since worst-case
+ // static info is fetched twice
+ try {
+ value = JDWP.StringReference.Value.
+ process(vm, this).stringValue;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+ return value;
+ }
+
+ public String toString() {
+ return "\"" + value() + "\"";
+ }
+
+ byte typeValueKey() {
+ return JDWP.Tag.STRING;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/SunCommandLineLauncher.java b/src/share/classes/com/sun/tools/jdi/SunCommandLineLauncher.java
new file mode 100644
index 0000000..84a1455
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/SunCommandLineLauncher.java
@@ -0,0 +1,240 @@
+/*
+ * Copyright (c) 1998, 2013, 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.tools.jdi;
+
+import com.sun.tools.jdi.*;
+import com.sun.jdi.connect.*;
+import com.sun.jdi.connect.spi.*;
+import com.sun.jdi.VirtualMachine;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Random;
+import java.io.IOException;
+import java.io.File;
+
+public class SunCommandLineLauncher extends AbstractLauncher implements LaunchingConnector {
+
+ static private final String ARG_HOME = "home";
+ static private final String ARG_OPTIONS = "options";
+ static private final String ARG_MAIN = "main";
+ static private final String ARG_INIT_SUSPEND = "suspend";
+ static private final String ARG_QUOTE = "quote";
+ static private final String ARG_VM_EXEC = "vmexec";
+
+ TransportService transportService;
+ Transport transport;
+ boolean usingSharedMemory = false;
+
+ TransportService transportService() {
+ return transportService;
+ }
+
+ public Transport transport() {
+ return transport;
+ }
+
+ public SunCommandLineLauncher() {
+ super();
+
+ /**
+ * By default this connector uses either the shared memory
+ * transport or the socket transport
+ */
+ try {
+ Class<?> c = Class.forName("com.sun.tools.jdi.SharedMemoryTransportService");
+ transportService = (TransportService)c.newInstance();
+ transport = new Transport() {
+ public String name() {
+ return "dt_shmem";
+ }
+ };
+ usingSharedMemory = true;
+ } catch (ClassNotFoundException x) {
+ } catch (UnsatisfiedLinkError x) {
+ } catch (InstantiationException x) {
+ } catch (IllegalAccessException x) {
+ };
+ if (transportService == null) {
+ transportService = new SocketTransportService();
+ transport = new Transport() {
+ public String name() {
+ return "dt_socket";
+ }
+ };
+ }
+
+ addStringArgument(
+ ARG_HOME,
+ getString("sun.home.label"),
+ getString("sun.home"),
+ System.getProperty("java.home"),
+ false);
+ addStringArgument(
+ ARG_OPTIONS,
+ getString("sun.options.label"),
+ getString("sun.options"),
+ "",
+ false);
+ addStringArgument(
+ ARG_MAIN,
+ getString("sun.main.label"),
+ getString("sun.main"),
+ "",
+ true);
+
+ addBooleanArgument(
+ ARG_INIT_SUSPEND,
+ getString("sun.init_suspend.label"),
+ getString("sun.init_suspend"),
+ true,
+ false);
+
+ addStringArgument(
+ ARG_QUOTE,
+ getString("sun.quote.label"),
+ getString("sun.quote"),
+ "\"",
+ true);
+ addStringArgument(
+ ARG_VM_EXEC,
+ getString("sun.vm_exec.label"),
+ getString("sun.vm_exec"),
+ "java",
+ true);
+ }
+
+ static boolean hasWhitespace(String string) {
+ int length = string.length();
+ for (int i = 0; i < length; i++) {
+ if (Character.isWhitespace(string.charAt(i))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public VirtualMachine
+ launch(Map<String,? extends Connector.Argument> arguments)
+ throws IOException, IllegalConnectorArgumentsException,
+ VMStartException
+ {
+ VirtualMachine vm;
+
+ String home = argument(ARG_HOME, arguments).value();
+ String options = argument(ARG_OPTIONS, arguments).value();
+ String mainClassAndArgs = argument(ARG_MAIN, arguments).value();
+ boolean wait = ((BooleanArgumentImpl)argument(ARG_INIT_SUSPEND,
+ arguments)).booleanValue();
+ String quote = argument(ARG_QUOTE, arguments).value();
+ String exe = argument(ARG_VM_EXEC, arguments).value();
+ String exePath = null;
+
+ if (quote.length() > 1) {
+ throw new IllegalConnectorArgumentsException("Invalid length",
+ ARG_QUOTE);
+ }
+
+ if ((options.indexOf("-Djava.compiler=") != -1) &&
+ (options.toLowerCase().indexOf("-djava.compiler=none") == -1)) {
+ throw new IllegalConnectorArgumentsException("Cannot debug with a JIT compiler",
+ ARG_OPTIONS);
+ }
+
+ /*
+ * Start listening.
+ * If we're using the shared memory transport then we pick a
+ * random address rather than using the (fixed) default.
+ * Random() uses System.currentTimeMillis() as the seed
+ * which can be a problem on windows (many calls to
+ * currentTimeMillis can return the same value), so
+ * we do a few retries if we get an IOException (we
+ * assume the IOException is the filename is already in use.)
+ */
+ TransportService.ListenKey listenKey;
+ if (usingSharedMemory) {
+ Random rr = new Random();
+ int failCount = 0;
+ while(true) {
+ try {
+ String address = "javadebug" +
+ String.valueOf(rr.nextInt(100000));
+ listenKey = transportService().startListening(address);
+ break;
+ } catch (IOException ioe) {
+ if (++failCount > 5) {
+ throw ioe;
+ }
+ }
+ }
+ } else {
+ listenKey = transportService().startListening();
+ }
+ String address = listenKey.address();
+
+ try {
+ if (home.length() > 0) {
+ exePath = home + File.separator + "bin" + File.separator + exe;
+ } else {
+ exePath = exe;
+ }
+ // Quote only if necessary in case the quote arg value is bogus
+ if (hasWhitespace(exePath)) {
+ exePath = quote + exePath + quote;
+ }
+
+ String xrun = "transport=" + transport().name() +
+ ",address=" + address +
+ ",suspend=" + (wait? 'y' : 'n');
+ // Quote only if necessary in case the quote arg value is bogus
+ if (hasWhitespace(xrun)) {
+ xrun = quote + xrun + quote;
+ }
+
+ String command = exePath + ' ' +
+ options + ' ' +
+ "-Xdebug " +
+ "-Xrunjdwp:" + xrun + ' ' +
+ mainClassAndArgs;
+
+ // System.err.println("Command: \"" + command + '"');
+ vm = launch(tokenizeCommand(command, quote.charAt(0)), address, listenKey,
+ transportService());
+ } finally {
+ transportService().stopListening(listenKey);
+ }
+
+ return vm;
+ }
+
+ public String name() {
+ return "com.sun.jdi.CommandLineLaunch";
+ }
+
+ public String description() {
+ return getString("sun.description");
+
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/TargetVM.java b/src/share/classes/com/sun/tools/jdi/TargetVM.java
new file mode 100644
index 0000000..b4fdcb8
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/TargetVM.java
@@ -0,0 +1,378 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+import com.sun.jdi.event.*;
+import com.sun.jdi.connect.spi.Connection;
+import com.sun.jdi.event.EventSet;
+
+import java.util.*;
+import java.io.IOException;
+
+public class TargetVM implements Runnable {
+ private Map<String, Packet> waitingQueue = new HashMap<String, Packet>(32,0.75f);
+ private boolean shouldListen = true;
+ private List<EventQueue> eventQueues = Collections.synchronizedList(new ArrayList<EventQueue>(2));
+ private VirtualMachineImpl vm;
+ private Connection connection;
+ private Thread readerThread;
+ private EventController eventController = null;
+ private boolean eventsHeld = false;
+
+ /*
+ * TO DO: The limit numbers below are somewhat arbitrary and should
+ * be configurable in the future.
+ */
+ static private final int OVERLOADED_QUEUE = 2000;
+ static private final int UNDERLOADED_QUEUE = 100;
+
+ TargetVM(VirtualMachineImpl vm, Connection connection) {
+ this.vm = vm;
+ this.connection = connection;
+ this.readerThread = new Thread(vm.threadGroupForJDI(),
+ this, "JDI Target VM Interface");
+ this.readerThread.setDaemon(true);
+ }
+
+ void start() {
+ readerThread.start();
+ }
+
+ private void dumpPacket(Packet packet, boolean sending) {
+ String direction = sending ? "Sending" : "Receiving";
+ if (sending) {
+ vm.printTrace(direction + " Command. id=" + packet.id +
+ ", length=" + packet.data.length +
+ ", commandSet=" + packet.cmdSet +
+ ", command=" + packet.cmd +
+ ", flags=" + packet.flags);
+ } else {
+ String type = (packet.flags & Packet.Reply) != 0 ?
+ "Reply" : "Event";
+ vm.printTrace(direction + " " + type + ". id=" + packet.id +
+ ", length=" + packet.data.length +
+ ", errorCode=" + packet.errorCode +
+ ", flags=" + packet.flags);
+ }
+ StringBuffer line = new StringBuffer(80);
+ line.append("0000: ");
+ for (int i = 0; i < packet.data.length; i++) {
+ if ((i > 0) && (i % 16 == 0)) {
+ vm.printTrace(line.toString());
+ line.setLength(0);
+ line.append(String.valueOf(i));
+ line.append(": ");
+ int len = line.length();
+ for (int j = 0; j < 6 - len; j++) {
+ line.insert(0, '0');
+ }
+ }
+ int val = 0xff & packet.data[i];
+ String str = Integer.toHexString(val);
+ if (str.length() == 1) {
+ line.append('0');
+ }
+ line.append(str);
+ line.append(' ');
+ }
+ if (line.length() > 6) {
+ vm.printTrace(line.toString());
+ }
+ }
+
+ public void run() {
+ if ((vm.traceFlags & VirtualMachine.TRACE_SENDS) != 0) {
+ vm.printTrace("Target VM interface thread running");
+ }
+ Packet p=null,p2;
+ String idString;
+
+ while(shouldListen) {
+
+ boolean done = false;
+ try {
+ byte b[] = connection.readPacket();
+ if (b.length == 0) {
+ done = true;
+ }
+ p = Packet.fromByteArray(b);
+ } catch (IOException e) {
+ done = true;
+ }
+
+ if (done) {
+ shouldListen = false;
+ try {
+ connection.close();
+ } catch (IOException ioe) { }
+ break;
+ }
+
+ if ((vm.traceFlags & VirtualMachineImpl.TRACE_RAW_RECEIVES) != 0) {
+ dumpPacket(p, false);
+ }
+
+ if((p.flags & Packet.Reply) == 0) {
+ // It's a command
+ handleVMCommand(p);
+ } else {
+ /*if(p.errorCode != Packet.ReplyNoError) {
+ System.err.println("Packet " + p.id + " returned failure = " + p.errorCode);
+ }*/
+
+ vm.state().notifyCommandComplete(p.id);
+ idString = String.valueOf(p.id);
+
+ synchronized(waitingQueue) {
+ p2 = waitingQueue.get(idString);
+
+ if (p2 != null)
+ waitingQueue.remove(idString);
+ }
+
+ if(p2 == null) {
+ // Whoa! a reply without a sender. Problem.
+ // FIX ME! Need to post an error.
+
+ System.err.println("Recieved reply with no sender!");
+ continue;
+ }
+ p2.errorCode = p.errorCode;
+ p2.data = p.data;
+ p2.replied = true;
+
+ synchronized(p2) {
+ p2.notify();
+ }
+ }
+ }
+
+ // inform the VM mamager that this VM is history
+ vm.vmManager.disposeVirtualMachine(vm);
+
+ if (eventController != null) {
+ eventController.release();
+ }
+
+ // close down all the event queues
+ // Closing a queue causes a VMDisconnectEvent to
+ // be put onto the queue.
+ synchronized(eventQueues) {
+ Iterator<EventQueue> iter = eventQueues.iterator();
+ while (iter.hasNext()) {
+ ((EventQueueImpl)iter.next()).close();
+ }
+ }
+
+ // indirectly throw VMDisconnectedException to
+ // command requesters.
+ synchronized(waitingQueue) {
+ Iterator<Packet> iter = waitingQueue.values().iterator();
+ while (iter.hasNext()) {
+ Packet packet = iter.next();
+ synchronized(packet) {
+ packet.notify();
+ }
+ }
+ waitingQueue.clear();
+ }
+
+ if ((vm.traceFlags & VirtualMachine.TRACE_SENDS) != 0) {
+ vm.printTrace("Target VM interface thread exiting");
+ }
+ }
+
+ protected void handleVMCommand(Packet p) {
+ switch (p.cmdSet) {
+ case JDWP.Event.COMMAND_SET:
+ handleEventCmdSet(p);
+ break;
+
+ default:
+ System.err.println("Ignoring cmd " + p.id + "/" +
+ p.cmdSet + "/" + p.cmd + " from the VM");
+ return;
+ }
+ }
+
+ /* Events should not be constructed on this thread (the thread
+ * which reads all data from the transport). This means that the
+ * packet cannot be converted to real JDI objects as that may
+ * involve further communications with the back end which would
+ * deadlock.
+ *
+ * Instead the whole packet is passed for lazy eval by a queue
+ * reading thread.
+ */
+ protected void handleEventCmdSet(Packet p) {
+ EventSet eventSet = new EventSetImpl(vm, p);
+
+ if (eventSet != null) {
+ queueEventSet(eventSet);
+ }
+ }
+
+ private EventController eventController() {
+ if (eventController == null) {
+ eventController = new EventController(vm);
+ }
+ return eventController;
+ }
+
+ private synchronized void controlEventFlow(int maxQueueSize) {
+ if (!eventsHeld && (maxQueueSize > OVERLOADED_QUEUE)) {
+ eventController().hold();
+ eventsHeld = true;
+ } else if (eventsHeld && (maxQueueSize < UNDERLOADED_QUEUE)) {
+ eventController().release();
+ eventsHeld = false;
+ }
+ }
+
+ void notifyDequeueEventSet() {
+ int maxQueueSize = 0;
+ synchronized(eventQueues) {
+ Iterator<EventQueue> iter = eventQueues.iterator();
+ while (iter.hasNext()) {
+ EventQueueImpl queue = (EventQueueImpl)iter.next();
+ maxQueueSize = Math.max(maxQueueSize, queue.size());
+ }
+ }
+ controlEventFlow(maxQueueSize);
+ }
+
+ private void queueEventSet(EventSet eventSet) {
+ int maxQueueSize = 0;
+
+ synchronized(eventQueues) {
+ Iterator<EventQueue> iter = eventQueues.iterator();
+ while (iter.hasNext()) {
+ EventQueueImpl queue = (EventQueueImpl)iter.next();
+ queue.enqueue(eventSet);
+ maxQueueSize = Math.max(maxQueueSize, queue.size());
+ }
+ }
+
+ controlEventFlow(maxQueueSize);
+ }
+
+ void send(Packet packet) {
+ String id = String.valueOf(packet.id);
+
+ synchronized(waitingQueue) {
+ waitingQueue.put(id, packet);
+ }
+
+ if ((vm.traceFlags & VirtualMachineImpl.TRACE_RAW_SENDS) != 0) {
+ dumpPacket(packet, true);
+ }
+
+ try {
+ connection.writePacket(packet.toByteArray());
+ } catch (IOException e) {
+ throw new VMDisconnectedException(e.getMessage());
+ }
+ }
+
+ void waitForReply(Packet packet) {
+ synchronized(packet) {
+ while ((!packet.replied) && shouldListen) {
+ try { packet.wait(); } catch (InterruptedException e) {;}
+ }
+
+ if (!packet.replied) {
+ throw new VMDisconnectedException();
+ }
+ }
+ }
+
+ void addEventQueue(EventQueueImpl queue) {
+ if ((vm.traceFlags & VirtualMachine.TRACE_EVENTS) != 0) {
+ vm.printTrace("New event queue added");
+ }
+ eventQueues.add(queue);
+ }
+
+ void stopListening() {
+ if ((vm.traceFlags & VirtualMachine.TRACE_EVENTS) != 0) {
+ vm.printTrace("Target VM i/f closing event queues");
+ }
+ shouldListen = false;
+ try {
+ connection.close();
+ } catch (IOException ioe) { }
+ }
+
+ private class EventController extends Thread {
+ int controlRequest = 0;
+
+ EventController(VirtualMachineImpl vm) {
+ super(vm.threadGroupForJDI(), "JDI Event Control Thread");
+ setDaemon(true);
+ setPriority((MAX_PRIORITY + NORM_PRIORITY)/2);
+ super.start();
+ }
+
+ synchronized void hold() {
+ controlRequest++;
+ notifyAll();
+ }
+
+ synchronized void release() {
+ controlRequest--;
+ notifyAll();
+ }
+
+ public void run() {
+ while(true) {
+ int currentRequest;
+ synchronized(this) {
+ while (controlRequest == 0) {
+ try {wait();} catch (InterruptedException e) {}
+ if (!shouldListen) return;
+ }
+ currentRequest = controlRequest;
+ controlRequest = 0;
+ }
+ try {
+ if (currentRequest > 0) {
+ JDWP.VirtualMachine.HoldEvents.process(vm);
+ } else {
+ JDWP.VirtualMachine.ReleaseEvents.process(vm);
+ }
+ } catch (JDWPException e) {
+ /*
+ * Don't want to terminate the thread, so the
+ * stack trace is printed and we continue.
+ */
+ e.toJDIException().printStackTrace(System.err);
+ }
+ }
+ }
+ }
+
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ThreadAction.java b/src/share/classes/com/sun/tools/jdi/ThreadAction.java
new file mode 100644
index 0000000..da50652
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ThreadAction.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 1999, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+import java.util.EventObject;
+
+/*
+ * The name "action" is used to avoid confusion
+ * with JDI events.
+ */
+class ThreadAction extends EventObject {
+ private static final long serialVersionUID = 5690763191100515283L;
+ // Event ids
+ /*static final int THREAD_SUSPENDED = 1;*/
+ static final int THREAD_RESUMABLE = 2;
+
+ int id;
+
+ ThreadAction(ThreadReference thread, int id) {
+ super(thread);
+ this.id = id;
+ }
+ ThreadReference thread() {
+ return (ThreadReference)getSource();
+ }
+ int id() {
+ return id;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ThreadGroupReferenceImpl.java b/src/share/classes/com/sun/tools/jdi/ThreadGroupReferenceImpl.java
new file mode 100644
index 0000000..c4fd6aa
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ThreadGroupReferenceImpl.java
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 1998, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+import java.util.*;
+
+public class ThreadGroupReferenceImpl extends ObjectReferenceImpl
+ implements ThreadGroupReference, VMListener
+{
+ // Cached components that cannot change
+ String name;
+ ThreadGroupReference parent;
+ boolean triedParent;
+
+ // This is cached only while the VM is suspended
+ private static class Cache extends ObjectReferenceImpl.Cache {
+ JDWP.ThreadGroupReference.Children kids = null;
+ }
+
+ protected ObjectReferenceImpl.Cache newCache() {
+ return new Cache();
+ }
+
+ ThreadGroupReferenceImpl(VirtualMachine aVm,long aRef) {
+ super(aVm,aRef);
+ vm.state().addListener(this);
+ }
+
+ protected String description() {
+ return "ThreadGroupReference " + uniqueID();
+ }
+
+ public String name() {
+ if (name == null) {
+ // Does not need synchronization, since worst-case
+ // static info is fetched twice (Thread group name
+ // cannot change)
+ try {
+ name = JDWP.ThreadGroupReference.Name.
+ process(vm, this).groupName;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+ return name;
+ }
+
+ public ThreadGroupReference parent() {
+ if (!triedParent) {
+ // Does not need synchronization, since worst-case
+ // static info is fetched twice (Thread group parent cannot
+ // change)
+ try {
+ parent = JDWP.ThreadGroupReference.Parent.
+ process(vm, this).parentGroup;
+ triedParent = true;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+ return parent;
+ }
+
+ public void suspend() {
+ for (ThreadReference thread : threads()) {
+ thread.suspend();
+ }
+
+ for (ThreadGroupReference threadGroup : threadGroups()) {
+ threadGroup.suspend();
+ }
+ }
+
+ public void resume() {
+ for (ThreadReference thread : threads()) {
+ thread.resume();
+ }
+
+ for (ThreadGroupReference threadGroup : threadGroups()) {
+ threadGroup.resume();
+ }
+ }
+
+ private JDWP.ThreadGroupReference.Children kids() {
+ JDWP.ThreadGroupReference.Children kids = null;
+ try {
+ Cache local = (Cache)getCache();
+
+ if (local != null) {
+ kids = local.kids;
+ }
+ if (kids == null) {
+ kids = JDWP.ThreadGroupReference.Children
+ .process(vm, this);
+ if (local != null) {
+ local.kids = kids;
+ if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) {
+ vm.printTrace(description() +
+ " temporarily caching children ");
+ }
+ }
+ }
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ return kids;
+ }
+
+ public List<ThreadReference> threads() {
+ return Arrays.asList((ThreadReference[])kids().childThreads);
+ }
+
+ public List<ThreadGroupReference> threadGroups() {
+ return Arrays.asList((ThreadGroupReference[])kids().childGroups);
+ }
+
+ public String toString() {
+ return "instance of " + referenceType().name() +
+ "(name='" + name() + "', " + "id=" + uniqueID() + ")";
+ }
+
+ byte typeValueKey() {
+ return JDWP.Tag.THREAD_GROUP;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ThreadListener.java b/src/share/classes/com/sun/tools/jdi/ThreadListener.java
new file mode 100644
index 0000000..d14622c
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ThreadListener.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 1999, 2013, 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.tools.jdi;
+
+import com.sun.jdi.*;
+import java.util.EventListener;
+
+interface ThreadListener extends EventListener {
+ boolean threadResumable(ThreadAction action);
+ /*
+ * Not needed for current implementation, and hard to implement
+ * correctly. (See TargetVM.handleEventCmdSet)
+ * void threadSuspended(ThreadAction action);
+ */
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ThreadReferenceImpl.java b/src/share/classes/com/sun/tools/jdi/ThreadReferenceImpl.java
new file mode 100644
index 0000000..9034771
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ThreadReferenceImpl.java
@@ -0,0 +1,644 @@
+/*
+ * Copyright (c) 1998, 2013, 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.tools.jdi;
+
+import com.sun.jdi.*;
+import com.sun.jdi.request.BreakpointRequest;
+import java.util.*;
+import java.lang.ref.WeakReference;
+
+public class ThreadReferenceImpl extends ObjectReferenceImpl
+ implements ThreadReference, VMListener {
+ static final int SUSPEND_STATUS_SUSPENDED = 0x1;
+ static final int SUSPEND_STATUS_BREAK = 0x2;
+
+ private int suspendedZombieCount = 0;
+
+ /*
+ * Some objects can only be created while a thread is suspended and are valid
+ * only while the thread remains suspended. Examples are StackFrameImpl
+ * and MonitorInfoImpl. When the thread resumes, these objects have to be
+ * marked as invalid so that their methods can throw
+ * InvalidStackFrameException if they are called. To do this, such objects
+ * register themselves as listeners of the associated thread. When the
+ * thread is resumed, its listeners are notified and mark themselves
+ * invalid.
+ * Also, note that ThreadReferenceImpl itself caches some info that
+ * is valid only as long as the thread is suspended. When the thread
+ * is resumed, that cache must be purged.
+ * Lastly, note that ThreadReferenceImpl and its super, ObjectReferenceImpl
+ * cache some info that is only valid as long as the entire VM is suspended.
+ * If _any_ thread is resumed, this cache must be purged. To handle this,
+ * both ThreadReferenceImpl and ObjectReferenceImpl register themselves as
+ * VMListeners so that they get notified when all threads are suspended and
+ * when any thread is resumed.
+ */
+
+ // This is cached for the life of the thread
+ private ThreadGroupReference threadGroup;
+
+ // This is cached only while this one thread is suspended. Each time
+ // the thread is resumed, we abandon the current cache object and
+ // create a new initialized one.
+ private static class LocalCache {
+ JDWP.ThreadReference.Status status = null;
+ List<StackFrame> frames = null;
+ int framesStart = -1;
+ int framesLength = 0;
+ int frameCount = -1;
+ List<ObjectReference> ownedMonitors = null;
+ List<MonitorInfo> ownedMonitorsInfo = null;
+ ObjectReference contendedMonitor = null;
+ boolean triedCurrentContended = false;
+ }
+
+ /*
+ * The localCache instance var is set by resetLocalCache to an initialized
+ * object as shown above. This occurs when the ThreadReference
+ * object is created, and when the mirrored thread is resumed.
+ * The fields are then filled in by the relevant methods as they
+ * are called. A problem can occur if resetLocalCache is called
+ * (ie, a resume() is executed) at certain points in the execution
+ * of some of these methods - see 6751643. To avoid this, each
+ * method that wants to use this cache must make a local copy of
+ * this variable and use that. This means that each invocation of
+ * these methods will use a copy of the cache object that was in
+ * effect at the point that the copy was made; if a racy resume
+ * occurs, it won't affect the method's local copy. This means that
+ * the values returned by these calls may not match the state of
+ * the debuggee at the time the caller gets the values. EG,
+ * frameCount() is called and comes up with 5 frames. But before
+ * it returns this, a resume of the debuggee thread is executed in a
+ * different debugger thread. The thread is resumed and running at
+ * the time that the value 5 is returned. Or even worse, the thread
+ * could be suspended again and have a different number of frames, eg, 24,
+ * but this call will still return 5.
+ */
+ private LocalCache localCache;
+
+ private void resetLocalCache() {
+ localCache = new LocalCache();
+ }
+
+ // This is cached only while all threads in the VM are suspended
+ // Yes, someone could change the name of a thread while it is suspended.
+ private static class Cache extends ObjectReferenceImpl.Cache {
+ String name = null;
+ }
+ protected ObjectReferenceImpl.Cache newCache() {
+ return new Cache();
+ }
+
+ // Listeners - synchronized on vm.state()
+ private List<WeakReference<ThreadListener>> listeners = new ArrayList<WeakReference<ThreadListener>>();
+
+
+ ThreadReferenceImpl(VirtualMachine aVm, long aRef) {
+ super(aVm,aRef);
+ resetLocalCache();
+ vm.state().addListener(this);
+ }
+
+ protected String description() {
+ return "ThreadReference " + uniqueID();
+ }
+
+ /*
+ * VMListener implementation
+ */
+ public boolean vmNotSuspended(VMAction action) {
+ if (action.resumingThread() == null) {
+ // all threads are being resumed
+ synchronized (vm.state()) {
+ processThreadAction(new ThreadAction(this,
+ ThreadAction.THREAD_RESUMABLE));
+ }
+
+ }
+
+ /*
+ * Othewise, only one thread is being resumed:
+ * if it is us,
+ * we have already done our processThreadAction to notify our
+ * listeners when we processed the resume.
+ * if it is not us,
+ * we don't want to notify our listeners
+ * because we are not being resumed.
+ */
+ return super.vmNotSuspended(action);
+ }
+
+ /**
+ * Note that we only cache the name string while the entire VM is suspended
+ * because the name can change via Thread.setName arbitrarily while this
+ * thread is running.
+ */
+ public String name() {
+ String name = null;
+ try {
+ Cache local = (Cache)getCache();
+
+ if (local != null) {
+ name = local.name;
+ }
+ if (name == null) {
+ name = JDWP.ThreadReference.Name.process(vm, this)
+ .threadName;
+ if (local != null) {
+ local.name = name;
+ }
+ }
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ return name;
+ }
+
+ /*
+ * Sends a command to the back end which is defined to do an
+ * implicit vm-wide resume.
+ */
+ PacketStream sendResumingCommand(CommandSender sender) {
+ synchronized (vm.state()) {
+ processThreadAction(new ThreadAction(this,
+ ThreadAction.THREAD_RESUMABLE));
+ return sender.send();
+ }
+ }
+
+ public void suspend() {
+ try {
+ JDWP.ThreadReference.Suspend.process(vm, this);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ // Don't consider the thread suspended yet. On reply, notifySuspend()
+ // will be called.
+ }
+
+ public void resume() {
+ /*
+ * If it's a zombie, we can just update internal state without
+ * going to back end.
+ */
+ if (suspendedZombieCount > 0) {
+ suspendedZombieCount--;
+ return;
+ }
+
+ PacketStream stream;
+ synchronized (vm.state()) {
+ processThreadAction(new ThreadAction(this,
+ ThreadAction.THREAD_RESUMABLE));
+ stream = JDWP.ThreadReference.Resume.enqueueCommand(vm, this);
+ }
+ try {
+ JDWP.ThreadReference.Resume.waitForReply(vm, stream);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+
+ public int suspendCount() {
+ /*
+ * If it's a zombie, we maintain the count in the front end.
+ */
+ if (suspendedZombieCount > 0) {
+ return suspendedZombieCount;
+ }
+
+ try {
+ return JDWP.ThreadReference.SuspendCount.process(vm, this).suspendCount;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+
+ public void stop(ObjectReference throwable) throws InvalidTypeException {
+ validateMirror(throwable);
+ // Verify that the given object is a Throwable instance
+ List<ReferenceType> list = vm.classesByName("java.lang.Throwable");
+ ClassTypeImpl throwableClass = (ClassTypeImpl)list.get(0);
+ if ((throwable == null) ||
+ !throwableClass.isAssignableFrom(throwable)) {
+ throw new InvalidTypeException("Not an instance of Throwable");
+ }
+
+ try {
+ JDWP.ThreadReference.Stop.process(vm, this,
+ (ObjectReferenceImpl)throwable);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+
+ public void interrupt() {
+ try {
+ JDWP.ThreadReference.Interrupt.process(vm, this);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+
+ private JDWP.ThreadReference.Status jdwpStatus() {
+ LocalCache snapshot = localCache;
+ JDWP.ThreadReference.Status myStatus = snapshot.status;
+ try {
+ if (myStatus == null) {
+ myStatus = JDWP.ThreadReference.Status.process(vm, this);
+ if ((myStatus.suspendStatus & SUSPEND_STATUS_SUSPENDED) != 0) {
+ // thread is suspended, we can cache the status.
+ snapshot.status = myStatus;
+ }
+ }
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ return myStatus;
+ }
+
+ public int status() {
+ return jdwpStatus().threadStatus;
+ }
+
+ public boolean isSuspended() {
+ return ((suspendedZombieCount > 0) ||
+ ((jdwpStatus().suspendStatus & SUSPEND_STATUS_SUSPENDED) != 0));
+ }
+
+ public boolean isAtBreakpoint() {
+ /*
+ * TO DO: This fails to take filters into account.
+ */
+ try {
+ StackFrame frame = frame(0);
+ Location location = frame.location();
+ List<BreakpointRequest> requests = vm.eventRequestManager().breakpointRequests();
+ Iterator<BreakpointRequest> iter = requests.iterator();
+ while (iter.hasNext()) {
+ BreakpointRequest request = iter.next();
+ if (location.equals(request.location())) {
+ return true;
+ }
+ }
+ return false;
+ } catch (IndexOutOfBoundsException iobe) {
+ return false; // no frames on stack => not at breakpoint
+ } catch (IncompatibleThreadStateException itse) {
+ // Per the javadoc, not suspended => return false
+ return false;
+ }
+ }
+
+ public ThreadGroupReference threadGroup() {
+ /*
+ * Thread group can't change, so it's cached once and for all.
+ */
+ if (threadGroup == null) {
+ try {
+ threadGroup = JDWP.ThreadReference.ThreadGroup.
+ process(vm, this).group;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+ return threadGroup;
+ }
+
+ public int frameCount() throws IncompatibleThreadStateException {
+ LocalCache snapshot = localCache;
+ try {
+ if (snapshot.frameCount == -1) {
+ snapshot.frameCount = JDWP.ThreadReference.FrameCount
+ .process(vm, this).frameCount;
+ }
+ } catch (JDWPException exc) {
+ switch (exc.errorCode()) {
+ case JDWP.Error.THREAD_NOT_SUSPENDED:
+ case JDWP.Error.INVALID_THREAD: /* zombie */
+ throw new IncompatibleThreadStateException();
+ default:
+ throw exc.toJDIException();
+ }
+ }
+ return snapshot.frameCount;
+ }
+
+ public List<StackFrame> frames() throws IncompatibleThreadStateException {
+ return privateFrames(0, -1);
+ }
+
+ public StackFrame frame(int index) throws IncompatibleThreadStateException {
+ List<StackFrame> list = privateFrames(index, 1);
+ return list.get(0);
+ }
+
+ /**
+ * Is the requested subrange within what has been retrieved?
+ * local is known to be non-null. Should only be called from
+ * a sync method.
+ */
+ private boolean isSubrange(LocalCache snapshot,
+ int start, int length) {
+ if (start < snapshot.framesStart) {
+ return false;
+ }
+ if (length == -1) {
+ return (snapshot.framesLength == -1);
+ }
+ if (snapshot.framesLength == -1) {
+ if ((start + length) > (snapshot.framesStart +
+ snapshot.frames.size())) {
+ throw new IndexOutOfBoundsException();
+ }
+ return true;
+ }
+ return ((start + length) <= (snapshot.framesStart + snapshot.framesLength));
+ }
+
+ public List<StackFrame> frames(int start, int length)
+ throws IncompatibleThreadStateException {
+ if (length < 0) {
+ throw new IndexOutOfBoundsException(
+ "length must be greater than or equal to zero");
+ }
+ return privateFrames(start, length);
+ }
+
+ /**
+ * Private version of frames() allows "-1" to specify all
+ * remaining frames.
+ */
+ synchronized private List<StackFrame> privateFrames(int start, int length)
+ throws IncompatibleThreadStateException {
+
+ // Lock must be held while creating stack frames so if that two threads
+ // do this at the same time, one won't clobber the subset created by the other.
+ LocalCache snapshot = localCache;
+ try {
+ if (snapshot.frames == null || !isSubrange(snapshot, start, length)) {
+ JDWP.ThreadReference.Frames.Frame[] jdwpFrames
+ = JDWP.ThreadReference.Frames.
+ process(vm, this, start, length).frames;
+ int count = jdwpFrames.length;
+ snapshot.frames = new ArrayList<StackFrame>(count);
+
+ for (int i = 0; i<count; i++) {
+ if (jdwpFrames[i].location == null) {
+ throw new InternalException("Invalid frame location");
+ }
+ StackFrame frame = new StackFrameImpl(vm, this,
+ jdwpFrames[i].frameID,
+ jdwpFrames[i].location);
+ // Add to the frame list
+ snapshot.frames.add(frame);
+ }
+ snapshot.framesStart = start;
+ snapshot.framesLength = length;
+ return Collections.unmodifiableList(snapshot.frames);
+ } else {
+ int fromIndex = start - snapshot.framesStart;
+ int toIndex;
+ if (length == -1) {
+ toIndex = snapshot.frames.size() - fromIndex;
+ } else {
+ toIndex = fromIndex + length;
+ }
+ return Collections.unmodifiableList(snapshot.frames.subList(fromIndex, toIndex));
+ }
+ } catch (JDWPException exc) {
+ switch (exc.errorCode()) {
+ case JDWP.Error.THREAD_NOT_SUSPENDED:
+ case JDWP.Error.INVALID_THREAD: /* zombie */
+ throw new IncompatibleThreadStateException();
+ default:
+ throw exc.toJDIException();
+ }
+ }
+ }
+
+ public List<ObjectReference> ownedMonitors() throws IncompatibleThreadStateException {
+ LocalCache snapshot = localCache;
+ try {
+ if (snapshot.ownedMonitors == null) {
+ snapshot.ownedMonitors = Arrays.asList(
+ (ObjectReference[])JDWP.ThreadReference.OwnedMonitors.
+ process(vm, this).owned);
+ if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) {
+ vm.printTrace(description() +
+ " temporarily caching owned monitors"+
+ " (count = " + snapshot.ownedMonitors.size() + ")");
+ }
+ }
+ } catch (JDWPException exc) {
+ switch (exc.errorCode()) {
+ case JDWP.Error.THREAD_NOT_SUSPENDED:
+ case JDWP.Error.INVALID_THREAD: /* zombie */
+ throw new IncompatibleThreadStateException();
+ default:
+ throw exc.toJDIException();
+ }
+ }
+ return snapshot.ownedMonitors;
+ }
+
+ public ObjectReference currentContendedMonitor()
+ throws IncompatibleThreadStateException {
+ LocalCache snapshot = localCache;
+ try {
+ if (snapshot.contendedMonitor == null &&
+ !snapshot.triedCurrentContended) {
+ snapshot.contendedMonitor = JDWP.ThreadReference.CurrentContendedMonitor.
+ process(vm, this).monitor;
+ snapshot.triedCurrentContended = true;
+ if ((snapshot.contendedMonitor != null) &&
+ ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0)) {
+ vm.printTrace(description() +
+ " temporarily caching contended monitor"+
+ " (id = " + snapshot.contendedMonitor.uniqueID() + ")");
+ }
+ }
+ } catch (JDWPException exc) {
+ switch (exc.errorCode()) {
+ case JDWP.Error.THREAD_NOT_SUSPENDED:
+ case JDWP.Error.INVALID_THREAD: /* zombie */
+ throw new IncompatibleThreadStateException();
+ default:
+ throw exc.toJDIException();
+ }
+ }
+ return snapshot.contendedMonitor;
+ }
+
+ public List<MonitorInfo> ownedMonitorsAndFrames() throws IncompatibleThreadStateException {
+ LocalCache snapshot = localCache;
+ try {
+ if (snapshot.ownedMonitorsInfo == null) {
+ JDWP.ThreadReference.OwnedMonitorsStackDepthInfo.monitor[] minfo;
+ minfo = JDWP.ThreadReference.OwnedMonitorsStackDepthInfo.process(vm, this).owned;
+
+ snapshot.ownedMonitorsInfo = new ArrayList<MonitorInfo>(minfo.length);
+
+ for (int i=0; i < minfo.length; i++) {
+ JDWP.ThreadReference.OwnedMonitorsStackDepthInfo.monitor mi =
+ minfo[i];
+ MonitorInfo mon = new MonitorInfoImpl(vm, minfo[i].monitor, this, minfo[i].stack_depth);
+ snapshot.ownedMonitorsInfo.add(mon);
+ }
+
+ if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) {
+ vm.printTrace(description() +
+ " temporarily caching owned monitors"+
+ " (count = " + snapshot.ownedMonitorsInfo.size() + ")");
+ }
+ }
+
+ } catch (JDWPException exc) {
+ switch (exc.errorCode()) {
+ case JDWP.Error.THREAD_NOT_SUSPENDED:
+ case JDWP.Error.INVALID_THREAD: /* zombie */
+ throw new IncompatibleThreadStateException();
+ default:
+ throw exc.toJDIException();
+ }
+ }
+ return snapshot.ownedMonitorsInfo;
+ }
+
+ public void popFrames(StackFrame frame) throws IncompatibleThreadStateException {
+ // Note that interface-wise this functionality belongs
+ // here in ThreadReference, but implementation-wise it
+ // belongs in StackFrame, so we just forward it.
+ if (!frame.thread().equals(this)) {
+ throw new IllegalArgumentException("frame does not belong to this thread");
+ }
+ if (!vm.canPopFrames()) {
+ throw new UnsupportedOperationException(
+ "target does not support popping frames");
+ }
+ ((StackFrameImpl)frame).pop();
+ }
+
+ public void forceEarlyReturn(Value returnValue) throws InvalidTypeException,
+ ClassNotLoadedException,
+ IncompatibleThreadStateException {
+ if (!vm.canForceEarlyReturn()) {
+ throw new UnsupportedOperationException(
+ "target does not support the forcing of a method to return early");
+ }
+
+ validateMirrorOrNull(returnValue);
+
+ StackFrameImpl sf;
+ try {
+ sf = (StackFrameImpl)frame(0);
+ } catch (IndexOutOfBoundsException exc) {
+ throw new InvalidStackFrameException("No more frames on the stack");
+ }
+ sf.validateStackFrame();
+ MethodImpl meth = (MethodImpl)sf.location().method();
+ ValueImpl convertedValue = ValueImpl.prepareForAssignment(returnValue,
+ meth.getReturnValueContainer());
+
+ try {
+ JDWP.ThreadReference.ForceEarlyReturn.process(vm, this, convertedValue);
+ } catch (JDWPException exc) {
+ switch (exc.errorCode()) {
+ case JDWP.Error.OPAQUE_FRAME:
+ throw new NativeMethodException();
+ case JDWP.Error.THREAD_NOT_SUSPENDED:
+ throw new IncompatibleThreadStateException(
+ "Thread not suspended");
+ case JDWP.Error.THREAD_NOT_ALIVE:
+ throw new IncompatibleThreadStateException(
+ "Thread has not started or has finished");
+ case JDWP.Error.NO_MORE_FRAMES:
+ throw new InvalidStackFrameException(
+ "No more frames on the stack");
+ default:
+ throw exc.toJDIException();
+ }
+ }
+ }
+
+ public String toString() {
+ return "instance of " + referenceType().name() +
+ "(name='" + name() + "', " + "id=" + uniqueID() + ")";
+ }
+
+ byte typeValueKey() {
+ return JDWP.Tag.THREAD;
+ }
+
+ void addListener(ThreadListener listener) {
+ synchronized (vm.state()) {
+ listeners.add(new WeakReference<ThreadListener>(listener));
+ }
+ }
+
+ void removeListener(ThreadListener listener) {
+ synchronized (vm.state()) {
+ Iterator<WeakReference<ThreadListener>> iter = listeners.iterator();
+ while (iter.hasNext()) {
+ WeakReference<ThreadListener> ref = iter.next();
+ if (listener.equals(ref.get())) {
+ iter.remove();
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Propagate the the thread state change information
+ * to registered listeners.
+ * Must be entered while synchronized on vm.state()
+ */
+ private void processThreadAction(ThreadAction action) {
+ synchronized (vm.state()) {
+ Iterator<WeakReference<ThreadListener>> iter = listeners.iterator();
+ while (iter.hasNext()) {
+ WeakReference<ThreadListener> ref = iter.next();
+ ThreadListener listener = ref.get();
+ if (listener != null) {
+ switch (action.id()) {
+ case ThreadAction.THREAD_RESUMABLE:
+ if (!listener.threadResumable(action)) {
+ iter.remove();
+ }
+ break;
+ }
+ } else {
+ // Listener is unreachable; clean up
+ iter.remove();
+ }
+ }
+
+ // Discard our local cache
+ resetLocalCache();
+ }
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/TypeComponentImpl.java b/src/share/classes/com/sun/tools/jdi/TypeComponentImpl.java
new file mode 100644
index 0000000..593940d
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/TypeComponentImpl.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 1998, 2003, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+import java.util.List;
+
+abstract public class TypeComponentImpl extends MirrorImpl
+ implements TypeComponent
+{
+ protected final long ref;
+ protected final String name;
+ protected final String signature;
+ protected final String genericSignature;
+ protected final ReferenceTypeImpl declaringType;
+ private final int modifiers;
+
+ TypeComponentImpl(VirtualMachine vm, ReferenceTypeImpl declaringType,
+ long ref,
+ String name, String signature,
+ String genericSignature, int modifiers) {
+ // The generic signature is set when this is created.
+ super(vm);
+ this.declaringType = declaringType;
+ this.ref = ref;
+ this.name = name;
+ this.signature = signature;
+ if (genericSignature != null && genericSignature.length() != 0) {
+ this.genericSignature = genericSignature;
+ } else {
+ this.genericSignature = null;
+ }
+ this.modifiers = modifiers;
+ }
+
+ public String name() {
+ return name;
+ }
+
+ public String signature() {
+ return signature;
+ }
+ public String genericSignature() {
+ return genericSignature;
+ }
+
+ public int modifiers() {
+ return modifiers;
+ }
+
+ public ReferenceType declaringType() {
+ return declaringType;
+ }
+
+ public boolean isStatic() {
+ return isModifierSet(VMModifiers.STATIC);
+ }
+
+ public boolean isFinal() {
+ return isModifierSet(VMModifiers.FINAL);
+ }
+
+ public boolean isPrivate() {
+ return isModifierSet(VMModifiers.PRIVATE);
+ }
+
+ public boolean isPackagePrivate() {
+ return !isModifierSet(VMModifiers.PRIVATE
+ | VMModifiers.PROTECTED
+ | VMModifiers.PUBLIC);
+ }
+
+ public boolean isProtected() {
+ return isModifierSet(VMModifiers.PROTECTED);
+ }
+
+ public boolean isPublic() {
+ return isModifierSet(VMModifiers.PUBLIC);
+ }
+
+ public boolean isSynthetic() {
+ return isModifierSet(VMModifiers.SYNTHETIC);
+ }
+
+ long ref() {
+ return ref;
+ }
+
+ boolean isModifierSet(int compareBits) {
+ return (modifiers & compareBits) != 0;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/TypeImpl.java b/src/share/classes/com/sun/tools/jdi/TypeImpl.java
new file mode 100644
index 0000000..5f85184
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/TypeImpl.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 1998, 2005, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public abstract class TypeImpl extends MirrorImpl implements Type
+{
+ private String myName = null;
+
+ TypeImpl(VirtualMachine vm)
+ {
+ super(vm);
+ }
+
+ public abstract String signature();
+
+ public String name() {
+ if (myName == null) {
+ JNITypeParser parser = new JNITypeParser(signature());
+ myName = parser.typeName();
+ }
+ return myName;
+ }
+
+ public boolean equals(Object obj) {
+ if ((obj != null) && (obj instanceof Type)) {
+ Type other = (Type)obj;
+ return signature().equals(other.signature()) &&
+ super.equals(obj);
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ return signature().hashCode();
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/VMAction.java b/src/share/classes/com/sun/tools/jdi/VMAction.java
new file mode 100644
index 0000000..242a9d9
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/VMAction.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 1999, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+import java.util.EventObject;
+
+/*
+ * The name "action" is used to avoid confusion
+ * with JDI events.
+ */
+class VMAction extends EventObject {
+ private static final long serialVersionUID = -1701944679310296090L;
+
+ // Event ids
+ static final int VM_SUSPENDED = 1;
+ static final int VM_NOT_SUSPENDED = 2;
+
+ int id;
+ ThreadReference resumingThread;
+
+ VMAction(VirtualMachine vm, int id) {
+ this(vm, null, id);
+ }
+
+ // For id = VM_NOT_SUSPENDED, if resumingThread != null, then it is
+ // the only thread that is being resumed.
+ VMAction(VirtualMachine vm, ThreadReference resumingThread, int id) {
+ super(vm);
+ this.id = id;
+ this.resumingThread = resumingThread;
+ }
+ VirtualMachine vm() {
+ return (VirtualMachine)getSource();
+ }
+ int id() {
+ return id;
+ }
+
+ ThreadReference resumingThread() {
+ return resumingThread;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/VMListener.java b/src/share/classes/com/sun/tools/jdi/VMListener.java
new file mode 100644
index 0000000..9da16b3
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/VMListener.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 1999, 2000, 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.tools.jdi;
+
+import com.sun.jdi.*;
+import java.util.EventListener;
+
+interface VMListener extends EventListener {
+ boolean vmSuspended(VMAction action);
+ boolean vmNotSuspended(VMAction action);
+}
diff --git a/src/share/classes/com/sun/tools/jdi/VMModifiers.java b/src/share/classes/com/sun/tools/jdi/VMModifiers.java
new file mode 100644
index 0000000..8713521
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/VMModifiers.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 1998, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public interface VMModifiers
+{
+ int PUBLIC = 0x00000001; /* visible to everyone */
+ int PRIVATE = 0x00000002; /* visible only to the defining class */
+ int PROTECTED = 0x00000004; /* visible to subclasses */
+ int STATIC = 0x00000008; /* instance variable is static */
+ int FINAL = 0x00000010; /* no further subclassing, overriding */
+ int SYNCHRONIZED = 0x00000020; /* wrap method call in monitor lock */
+ int VOLATILE = 0x00000040; /* can cache in registers */
+ int BRIDGE = 0x00000040; /* Bridge method generated by compiler */
+ int TRANSIENT = 0x00000080; /* not persistant */
+ int VARARGS = 0x00000080; /* Method accepts var. args*/
+ int NATIVE = 0x00000100; /* implemented in C */
+ int INTERFACE = 0x00000200; /* class is an interface */
+ int ABSTRACT = 0x00000400; /* no definition provided */
+ int ENUM_CONSTANT = 0x00004000; /* enum constant field*/
+ int SYNTHETIC = 0xf0000000; /* not in source code */
+}
diff --git a/src/share/classes/com/sun/tools/jdi/VMState.java b/src/share/classes/com/sun/tools/jdi/VMState.java
new file mode 100644
index 0000000..b4cd56f
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/VMState.java
@@ -0,0 +1,245 @@
+/*
+ * Copyright (c) 1999, 2011, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+import java.lang.ref.WeakReference;
+import java.util.*;
+
+class VMState {
+ private final VirtualMachineImpl vm;
+
+ // Listeners
+ private final List<WeakReference<VMListener>> listeners = new ArrayList<WeakReference<VMListener>>(); // synchronized (this)
+ private boolean notifyingListeners = false; // synchronized (this)
+
+ /*
+ * Certain information can be cached only when the entire VM is
+ * suspended and there are no pending resumes. The fields below
+ * are used to track whether there are pending resumes. (There
+ * is an assumption that JDWP command ids are increasing over time.)
+ */
+ private int lastCompletedCommandId = 0; // synchronized (this)
+ private int lastResumeCommandId = 0; // synchronized (this)
+
+ // This is cached only while the VM is suspended
+ private static class Cache {
+ List<ThreadGroupReference> groups = null; // cached Top Level ThreadGroups
+ List<ThreadReference> threads = null; // cached Threads
+ }
+
+ private Cache cache = null; // synchronized (this)
+ private static final Cache markerCache = new Cache();
+
+ private void disableCache() {
+ synchronized (this) {
+ cache = null;
+ }
+ }
+
+ private void enableCache() {
+ synchronized (this) {
+ cache = markerCache;
+ }
+ }
+
+ private Cache getCache() {
+ synchronized (this) {
+ if (cache == markerCache) {
+ cache = new Cache();
+ }
+ return cache;
+ }
+ }
+
+ VMState(VirtualMachineImpl vm) {
+ this.vm = vm;
+ }
+
+ /**
+ * Is the VM currently suspended, for the purpose of caching?
+ * Must be called synchronized on vm.state()
+ */
+ boolean isSuspended() {
+ return cache != null;
+ }
+
+ /*
+ * A JDWP command has been completed (reply has been received).
+ * Update data that tracks pending resume commands.
+ */
+ synchronized void notifyCommandComplete(int id) {
+ lastCompletedCommandId = id;
+ }
+
+ synchronized void freeze() {
+ if (cache == null && (lastCompletedCommandId >= lastResumeCommandId)) {
+ /*
+ * No pending resumes to worry about. The VM is suspended
+ * and additional state can be cached. Notify all
+ * interested listeners.
+ */
+ processVMAction(new VMAction(vm, VMAction.VM_SUSPENDED));
+ enableCache();
+ }
+ }
+
+ synchronized PacketStream thawCommand(CommandSender sender) {
+ PacketStream stream = sender.send();
+ lastResumeCommandId = stream.id();
+ thaw();
+ return stream;
+ }
+
+ /**
+ * All threads are resuming
+ */
+ void thaw() {
+ thaw(null);
+ }
+
+ /**
+ * Tell listeners to invalidate suspend-sensitive caches.
+ * If resumingThread != null, then only that thread is being
+ * resumed.
+ */
+ synchronized void thaw(ThreadReference resumingThread) {
+ if (cache != null) {
+ if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) {
+ vm.printTrace("Clearing VM suspended cache");
+ }
+ disableCache();
+ }
+ processVMAction(new VMAction(vm, resumingThread, VMAction.VM_NOT_SUSPENDED));
+ }
+
+ private synchronized void processVMAction(VMAction action) {
+ if (!notifyingListeners) {
+ // Prevent recursion
+ notifyingListeners = true;
+
+ Iterator<WeakReference<VMListener>> iter = listeners.iterator();
+ while (iter.hasNext()) {
+ WeakReference<VMListener> ref = iter.next();
+ VMListener listener = ref.get();
+ if (listener != null) {
+ boolean keep = true;
+ switch (action.id()) {
+ case VMAction.VM_SUSPENDED:
+ keep = listener.vmSuspended(action);
+ break;
+ case VMAction.VM_NOT_SUSPENDED:
+ keep = listener.vmNotSuspended(action);
+ break;
+ }
+ if (!keep) {
+ iter.remove();
+ }
+ } else {
+ // Listener is unreachable; clean up
+ iter.remove();
+ }
+ }
+
+ notifyingListeners = false;
+ }
+ }
+
+ synchronized void addListener(VMListener listener) {
+ listeners.add(new WeakReference<VMListener>(listener));
+ }
+
+ synchronized boolean hasListener(VMListener listener) {
+ return listeners.contains(listener);
+ }
+
+ synchronized void removeListener(VMListener listener) {
+ Iterator<WeakReference<VMListener>> iter = listeners.iterator();
+ while (iter.hasNext()) {
+ WeakReference<VMListener> ref = iter.next();
+ if (listener.equals(ref.get())) {
+ iter.remove();
+ break;
+ }
+ }
+ }
+
+ List<ThreadReference> allThreads() {
+ List<ThreadReference> threads = null;
+ try {
+ Cache local = getCache();
+
+ if (local != null) {
+ // may be stale when returned, but not provably so
+ threads = local.threads;
+ }
+ if (threads == null) {
+ threads = Arrays.asList((ThreadReference[])JDWP.VirtualMachine.AllThreads.
+ process(vm).threads);
+ if (local != null) {
+ local.threads = threads;
+ if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) {
+ vm.printTrace("Caching all threads (count = " +
+ threads.size() + ") while VM suspended");
+ }
+ }
+ }
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ return threads;
+ }
+
+
+ List<ThreadGroupReference> topLevelThreadGroups() {
+ List<ThreadGroupReference> groups = null;
+ try {
+ Cache local = getCache();
+
+ if (local != null) {
+ groups = local.groups;
+ }
+ if (groups == null) {
+ groups = Arrays.asList(
+ (ThreadGroupReference[])JDWP.VirtualMachine.TopLevelThreadGroups.
+ process(vm).groups);
+ if (local != null) {
+ local.groups = groups;
+ if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) {
+ vm.printTrace(
+ "Caching top level thread groups (count = " +
+ groups.size() + ") while VM suspended");
+ }
+ }
+ }
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ return groups;
+ }
+
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ValueContainer.java b/src/share/classes/com/sun/tools/jdi/ValueContainer.java
new file mode 100644
index 0000000..a0a5135
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ValueContainer.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 1999, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+/*
+ * This interface allows us to pass fields, variables, and
+ * array components through the same interfaces. This currently allows
+ * more common code for type checking. In the future we could use it for
+ * more.
+ */
+interface ValueContainer {
+ Type type() throws ClassNotLoadedException;
+ Type findType(String signature) throws ClassNotLoadedException;
+ String typeName();
+ String signature();
+}
diff --git a/src/share/classes/com/sun/tools/jdi/ValueImpl.java b/src/share/classes/com/sun/tools/jdi/ValueImpl.java
new file mode 100644
index 0000000..6a9ca4b
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/ValueImpl.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 1998, 1999, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+abstract class ValueImpl extends MirrorImpl implements Value {
+
+ ValueImpl(VirtualMachine aVm) {
+ super(aVm);
+ }
+
+ static ValueImpl prepareForAssignment(Value value,
+ ValueContainer destination)
+ throws InvalidTypeException, ClassNotLoadedException {
+ if (value == null) {
+ /*
+ * TO DO: Centralize JNI signature knowledge
+ */
+ if (destination.signature().length() == 1) {
+ throw new InvalidTypeException("Can't set a primitive type to null");
+ }
+ return null; // no further checking or conversion necessary
+ } else {
+ return ((ValueImpl)value).prepareForAssignmentTo(destination);
+ }
+ }
+
+ static byte typeValueKey(Value val) {
+ if (val == null) {
+ return JDWP.Tag.OBJECT;
+ } else {
+ return ((ValueImpl)val).typeValueKey();
+ }
+ }
+
+ abstract ValueImpl prepareForAssignmentTo(ValueContainer destination)
+ throws InvalidTypeException, ClassNotLoadedException;
+
+ abstract byte typeValueKey();
+}
diff --git a/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java b/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java
new file mode 100644
index 0000000..83547e4
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java
@@ -0,0 +1,1441 @@
+/*
+ * Copyright (c) 1998, 2015, 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.tools.jdi;
+
+import com.sun.jdi.*;
+import com.sun.jdi.connect.spi.Connection;
+import com.sun.jdi.request.EventRequestManager;
+import com.sun.jdi.request.EventRequest;
+import com.sun.jdi.request.BreakpointRequest;
+import com.sun.jdi.event.EventQueue;
+
+import java.util.*;
+import java.text.MessageFormat;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
+import java.lang.ref.WeakReference;
+
+class VirtualMachineImpl extends MirrorImpl
+ implements PathSearchingVirtualMachine, ThreadListener {
+ // VM Level exported variables, these
+ // are unique to a given vm
+ public final int sizeofFieldRef;
+ public final int sizeofMethodRef;
+ public final int sizeofObjectRef;
+ public final int sizeofClassRef;
+ public final int sizeofFrameRef;
+
+ final int sequenceNumber;
+
+ private final TargetVM target;
+ private final EventQueueImpl eventQueue;
+ private final EventRequestManagerImpl internalEventRequestManager;
+ private final EventRequestManagerImpl eventRequestManager;
+ final VirtualMachineManagerImpl vmManager;
+ private final ThreadGroup threadGroupForJDI;
+
+ // Allow direct access to this field so that that tracing code slows down
+ // JDI as little as possible when not enabled.
+ int traceFlags = TRACE_NONE;
+
+ static int TRACE_RAW_SENDS = 0x01000000;
+ static int TRACE_RAW_RECEIVES = 0x02000000;
+
+ boolean traceReceives = false; // pre-compute because of frequency
+
+ // ReferenceType access - updated with class prepare and unload events
+ // Protected by "synchronized(this)". "retrievedAllTypes" may be
+ // tested unsynchronized (since once true, it stays true), but must
+ // be set synchronously
+ private Map<Long, ReferenceType> typesByID;
+ private TreeSet<ReferenceType> typesBySignature;
+ private boolean retrievedAllTypes = false;
+
+ // For other languages support
+ private String defaultStratum = null;
+
+ // ObjectReference cache
+ // "objectsByID" protected by "synchronized(this)".
+ private final Map<Long, SoftObjectReference> objectsByID = new HashMap<Long, SoftObjectReference>();
+ private final ReferenceQueue<ObjectReferenceImpl> referenceQueue = new ReferenceQueue<ObjectReferenceImpl>();
+ static private final int DISPOSE_THRESHOLD = 50;
+ private final List<SoftObjectReference> batchedDisposeRequests =
+ Collections.synchronizedList(new ArrayList<SoftObjectReference>(DISPOSE_THRESHOLD + 10));
+
+ // These are cached once for the life of the VM
+ private JDWP.VirtualMachine.Version versionInfo;
+ private JDWP.VirtualMachine.ClassPaths pathInfo;
+ private JDWP.VirtualMachine.Capabilities capabilities = null;
+ private JDWP.VirtualMachine.CapabilitiesNew capabilitiesNew = null;
+
+ // Per-vm singletons for primitive types and for void.
+ // singleton-ness protected by "synchronized(this)".
+ private BooleanType theBooleanType;
+ private ByteType theByteType;
+ private CharType theCharType;
+ private ShortType theShortType;
+ private IntegerType theIntegerType;
+ private LongType theLongType;
+ private FloatType theFloatType;
+ private DoubleType theDoubleType;
+
+ private VoidType theVoidType;
+
+ private VoidValue voidVal;
+
+ // Launched debuggee process
+ private Process process;
+
+ // coordinates state changes and corresponding listener notifications
+ private VMState state = new VMState(this);
+
+ private Object initMonitor = new Object();
+ private boolean initComplete = false;
+ private boolean shutdown = false;
+
+ private void notifyInitCompletion() {
+ synchronized(initMonitor) {
+ initComplete = true;
+ initMonitor.notifyAll();
+ }
+ }
+
+ void waitInitCompletion() {
+ synchronized(initMonitor) {
+ while (!initComplete) {
+ try {
+ initMonitor.wait();
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ VMState state() {
+ return state;
+ }
+
+ /*
+ * ThreadListener implementation
+ */
+ public boolean threadResumable(ThreadAction action) {
+ /*
+ * If any thread is resumed, the VM is considered not suspended.
+ * Just one thread is being resumed so pass it to thaw.
+ */
+ state.thaw(action.thread());
+ return true;
+ }
+
+ VirtualMachineImpl(VirtualMachineManager manager,
+ Connection connection, Process process,
+ int sequenceNumber) {
+ super(null); // Can't use super(this)
+ vm = this;
+
+ this.vmManager = (VirtualMachineManagerImpl)manager;
+ this.process = process;
+ this.sequenceNumber = sequenceNumber;
+
+ /* Create ThreadGroup to be used by all threads servicing
+ * this VM.
+ */
+ threadGroupForJDI = new ThreadGroup(vmManager.mainGroupForJDI(),
+ "JDI [" +
+ this.hashCode() + "]");
+
+ /*
+ * Set up a thread to communicate with the target VM over
+ * the specified transport.
+ */
+ target = new TargetVM(this, connection);
+
+ /*
+ * Set up a thread to handle events processed internally
+ * the JDI implementation.
+ */
+ EventQueueImpl internalEventQueue = new EventQueueImpl(this, target);
+ new InternalEventHandler(this, internalEventQueue);
+ /*
+ * Initialize client access to event setting and handling
+ */
+ eventQueue = new EventQueueImpl(this, target);
+ eventRequestManager = new EventRequestManagerImpl(this);
+
+ target.start();
+
+ /*
+ * Many ids are variably sized, depending on target VM.
+ * Find out the sizes right away.
+ */
+ JDWP.VirtualMachine.IDSizes idSizes;
+ try {
+ idSizes = JDWP.VirtualMachine.IDSizes.process(vm);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ sizeofFieldRef = idSizes.fieldIDSize;
+ sizeofMethodRef = idSizes.methodIDSize;
+ sizeofObjectRef = idSizes.objectIDSize;
+ sizeofClassRef = idSizes.referenceTypeIDSize;
+ sizeofFrameRef = idSizes.frameIDSize;
+
+ /**
+ * Set up requests needed by internal event handler.
+ * Make sure they are distinguished by creating them with
+ * an internal event request manager.
+ *
+ * Warning: create events only with SUSPEND_NONE policy.
+ * In the current implementation other policies will not
+ * be handled correctly when the event comes in. (notfiySuspend()
+ * will not be properly called, and if the event is combined
+ * with external events in the same set, suspend policy is not
+ * correctly determined for the internal vs. external event sets)
+ */
+ internalEventRequestManager = new EventRequestManagerImpl(this);
+ EventRequest er = internalEventRequestManager.createClassPrepareRequest();
+ er.setSuspendPolicy(EventRequest.SUSPEND_NONE);
+ er.enable();
+ er = internalEventRequestManager.createClassUnloadRequest();
+ er.setSuspendPolicy(EventRequest.SUSPEND_NONE);
+ er.enable();
+
+ /*
+ * Tell other threads, notably TargetVM, that initialization
+ * is complete.
+ */
+ notifyInitCompletion();
+ }
+
+ EventRequestManagerImpl getInternalEventRequestManager() {
+ return internalEventRequestManager;
+ }
+
+ void validateVM() {
+ /*
+ * We no longer need to do this. The spec now says
+ * that a VMDisconnected _may_ be thrown in these
+ * cases, not that it _will_ be thrown.
+ * So, to simplify things we will just let the
+ * caller's of this method proceed with their business.
+ * If the debuggee is disconnected, either because it
+ * crashed or finished or something, or because the
+ * debugger called exit() or dispose(), then if
+ * we end up trying to communicate with the debuggee,
+ * code in TargetVM will throw a VMDisconnectedException.
+ * This means that if we can satisfy a request without
+ * talking to the debuggee, (eg, with cached data) then
+ * VMDisconnectedException will _not_ be thrown.
+ * if (shutdown) {
+ * throw new VMDisconnectedException();
+ * }
+ */
+ }
+
+ public boolean equals(Object obj) {
+ return this == obj;
+ }
+
+ public int hashCode() {
+ return System.identityHashCode(this);
+ }
+
+ public List<ReferenceType> classesByName(String className) {
+ validateVM();
+ String signature = JNITypeParser.typeNameToSignature(className);
+ List<ReferenceType> list;
+ if (retrievedAllTypes) {
+ list = findReferenceTypes(signature);
+ } else {
+ list = retrieveClassesBySignature(signature);
+ }
+ return Collections.unmodifiableList(list);
+ }
+
+ public List<ReferenceType> allClasses() {
+ validateVM();
+
+ if (!retrievedAllTypes) {
+ retrieveAllClasses();
+ }
+ ArrayList<ReferenceType> a;
+ synchronized (this) {
+ a = new ArrayList<ReferenceType>(typesBySignature);
+ }
+ return Collections.unmodifiableList(a);
+ }
+
+ public void
+ redefineClasses(Map<? extends ReferenceType,byte[]> classToBytes)
+ {
+ int cnt = classToBytes.size();
+ JDWP.VirtualMachine.RedefineClasses.ClassDef[] defs =
+ new JDWP.VirtualMachine.RedefineClasses.ClassDef[cnt];
+ validateVM();
+ if (!canRedefineClasses()) {
+ throw new UnsupportedOperationException();
+ }
+ Iterator<?> it = classToBytes.entrySet().iterator();
+ for (int i = 0; it.hasNext(); i++) {
+ Map.Entry<?,?> entry = (Map.Entry)it.next();
+ ReferenceTypeImpl refType = (ReferenceTypeImpl)entry.getKey();
+ validateMirror(refType);
+ defs[i] = new JDWP.VirtualMachine.RedefineClasses
+ .ClassDef(refType, (byte[])entry.getValue());
+ }
+
+ // flush caches and disable caching until the next suspend
+ vm.state().thaw();
+
+ try {
+ JDWP.VirtualMachine.RedefineClasses.
+ process(vm, defs);
+ } catch (JDWPException exc) {
+ switch (exc.errorCode()) {
+ case JDWP.Error.INVALID_CLASS_FORMAT :
+ throw new ClassFormatError(
+ "class not in class file format");
+ case JDWP.Error.CIRCULAR_CLASS_DEFINITION :
+ throw new ClassCircularityError(
+ "circularity has been detected while initializing a class");
+ case JDWP.Error.FAILS_VERIFICATION :
+ throw new VerifyError(
+ "verifier detected internal inconsistency or security problem");
+ case JDWP.Error.UNSUPPORTED_VERSION :
+ throw new UnsupportedClassVersionError(
+ "version numbers of class are not supported");
+ case JDWP.Error.ADD_METHOD_NOT_IMPLEMENTED:
+ throw new UnsupportedOperationException(
+ "add method not implemented");
+ case JDWP.Error.SCHEMA_CHANGE_NOT_IMPLEMENTED :
+ throw new UnsupportedOperationException(
+ "schema change not implemented");
+ case JDWP.Error.HIERARCHY_CHANGE_NOT_IMPLEMENTED:
+ throw new UnsupportedOperationException(
+ "hierarchy change not implemented");
+ case JDWP.Error.DELETE_METHOD_NOT_IMPLEMENTED :
+ throw new UnsupportedOperationException(
+ "delete method not implemented");
+ case JDWP.Error.CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED:
+ throw new UnsupportedOperationException(
+ "changes to class modifiers not implemented");
+ case JDWP.Error.METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED :
+ throw new UnsupportedOperationException(
+ "changes to method modifiers not implemented");
+ case JDWP.Error.NAMES_DONT_MATCH :
+ throw new NoClassDefFoundError(
+ "class names do not match");
+ default:
+ throw exc.toJDIException();
+ }
+ }
+
+ // Delete any record of the breakpoints
+ List<BreakpointRequest> toDelete = new ArrayList<BreakpointRequest>();
+ EventRequestManager erm = eventRequestManager();
+ it = erm.breakpointRequests().iterator();
+ while (it.hasNext()) {
+ BreakpointRequest req = (BreakpointRequest)it.next();
+ if (classToBytes.containsKey(req.location().declaringType())) {
+ toDelete.add(req);
+ }
+ }
+ erm.deleteEventRequests(toDelete);
+
+ // Invalidate any information cached for the classes just redefined.
+ it = classToBytes.keySet().iterator();
+ while (it.hasNext()) {
+ ReferenceTypeImpl rti = (ReferenceTypeImpl)it.next();
+ rti.noticeRedefineClass();
+ }
+ }
+
+ public List<ThreadReference> allThreads() {
+ validateVM();
+ return state.allThreads();
+ }
+
+ public List<ThreadGroupReference> topLevelThreadGroups() {
+ validateVM();
+ return state.topLevelThreadGroups();
+ }
+
+ /*
+ * Sends a command to the back end which is defined to do an
+ * implicit vm-wide resume. The VM can no longer be considered
+ * suspended, so certain cached data must be invalidated.
+ */
+ PacketStream sendResumingCommand(CommandSender sender) {
+ return state.thawCommand(sender);
+ }
+
+ /*
+ * The VM has been suspended. Additional caching can be done
+ * as long as there are no pending resumes.
+ */
+ void notifySuspend() {
+ state.freeze();
+ }
+
+ public void suspend() {
+ validateVM();
+ try {
+ JDWP.VirtualMachine.Suspend.process(vm);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ notifySuspend();
+ }
+
+ public void resume() {
+ validateVM();
+ CommandSender sender =
+ new CommandSender() {
+ public PacketStream send() {
+ return JDWP.VirtualMachine.Resume.enqueueCommand(vm);
+ }
+ };
+ try {
+ PacketStream stream = state.thawCommand(sender);
+ JDWP.VirtualMachine.Resume.waitForReply(vm, stream);
+ } catch (VMDisconnectedException exc) {
+ /*
+ * If the debugger makes a VMDeathRequest with SUSPEND_ALL,
+ * then when it does an EventSet.resume after getting the
+ * VMDeathEvent, the normal flow of events is that the
+ * BE shuts down, but the waitForReply comes back ok. In this
+ * case, the run loop in TargetVM that is waiting for a packet
+ * gets an EOF because the socket closes. It generates a
+ * VMDisconnectedEvent and everyone is happy.
+ * However, sometimes, the BE gets shutdown before this
+ * waitForReply completes. In this case, TargetVM.waitForReply
+ * gets awakened with no reply and so gens a VMDisconnectedException
+ * which is not what we want. It might be possible to fix this
+ * in the BE, but it is ok to just ignore the VMDisconnectedException
+ * here. This will allow the VMDisconnectedEvent to be generated
+ * correctly. And, if the debugger should happen to make another
+ * request, it will get a VMDisconnectedException at that time.
+ */
+ } catch (JDWPException exc) {
+ switch (exc.errorCode()) {
+ case JDWP.Error.VM_DEAD:
+ return;
+ default:
+ throw exc.toJDIException();
+ }
+ }
+ }
+
+ public EventQueue eventQueue() {
+ /*
+ * No VM validation here. We allow access to the event queue
+ * after disconnection, so that there is access to the terminating
+ * events.
+ */
+ return eventQueue;
+ }
+
+ public EventRequestManager eventRequestManager() {
+ validateVM();
+ return eventRequestManager;
+ }
+
+ EventRequestManagerImpl eventRequestManagerImpl() {
+ return eventRequestManager;
+ }
+
+ public BooleanValue mirrorOf(boolean value) {
+ validateVM();
+ return new BooleanValueImpl(this,value);
+ }
+
+ public ByteValue mirrorOf(byte value) {
+ validateVM();
+ return new ByteValueImpl(this,value);
+ }
+
+ public CharValue mirrorOf(char value) {
+ validateVM();
+ return new CharValueImpl(this,value);
+ }
+
+ public ShortValue mirrorOf(short value) {
+ validateVM();
+ return new ShortValueImpl(this,value);
+ }
+
+ public IntegerValue mirrorOf(int value) {
+ validateVM();
+ return new IntegerValueImpl(this,value);
+ }
+
+ public LongValue mirrorOf(long value) {
+ validateVM();
+ return new LongValueImpl(this,value);
+ }
+
+ public FloatValue mirrorOf(float value) {
+ validateVM();
+ return new FloatValueImpl(this,value);
+ }
+
+ public DoubleValue mirrorOf(double value) {
+ validateVM();
+ return new DoubleValueImpl(this,value);
+ }
+
+ public StringReference mirrorOf(String value) {
+ validateVM();
+ try {
+ return (StringReference)JDWP.VirtualMachine.CreateString.
+ process(vm, value).stringObject;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+
+ public VoidValue mirrorOfVoid() {
+ if (voidVal == null) {
+ voidVal = new VoidValueImpl(this);
+ }
+ return voidVal;
+ }
+
+ public long[] instanceCounts(List<? extends ReferenceType> classes) {
+ if (!canGetInstanceInfo()) {
+ throw new UnsupportedOperationException(
+ "target does not support getting instances");
+ }
+ long[] retValue ;
+ ReferenceTypeImpl[] rtArray = new ReferenceTypeImpl[classes.size()];
+ int ii = 0;
+ for (ReferenceType rti: classes) {
+ validateMirror(rti);
+ rtArray[ii++] = (ReferenceTypeImpl)rti;
+ }
+ try {
+ retValue = JDWP.VirtualMachine.InstanceCounts.
+ process(vm, rtArray).counts;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+
+ return retValue;
+ }
+
+ public void dispose() {
+ validateVM();
+ shutdown = true;
+ try {
+ JDWP.VirtualMachine.Dispose.process(vm);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ target.stopListening();
+ }
+
+ public void exit(int exitCode) {
+ validateVM();
+ shutdown = true;
+ try {
+ JDWP.VirtualMachine.Exit.process(vm, exitCode);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ target.stopListening();
+ }
+
+ public Process process() {
+ validateVM();
+ return process;
+ }
+
+ private JDWP.VirtualMachine.Version versionInfo() {
+ try {
+ if (versionInfo == null) {
+ // Need not be synchronized since it is static information
+ versionInfo = JDWP.VirtualMachine.Version.process(vm);
+ }
+ return versionInfo;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+ public String description() {
+ validateVM();
+
+ return MessageFormat.format(vmManager.getString("version_format"),
+ "" + vmManager.majorInterfaceVersion(),
+ "" + vmManager.minorInterfaceVersion(),
+ versionInfo().description);
+ }
+
+ public String version() {
+ validateVM();
+ return versionInfo().vmVersion;
+ }
+
+ public String name() {
+ validateVM();
+ return versionInfo().vmName;
+ }
+
+ public boolean canWatchFieldModification() {
+ validateVM();
+ return capabilities().canWatchFieldModification;
+ }
+ public boolean canWatchFieldAccess() {
+ validateVM();
+ return capabilities().canWatchFieldAccess;
+ }
+ public boolean canGetBytecodes() {
+ validateVM();
+ return capabilities().canGetBytecodes;
+ }
+ public boolean canGetSyntheticAttribute() {
+ validateVM();
+ return capabilities().canGetSyntheticAttribute;
+ }
+ public boolean canGetOwnedMonitorInfo() {
+ validateVM();
+ return capabilities().canGetOwnedMonitorInfo;
+ }
+ public boolean canGetCurrentContendedMonitor() {
+ validateVM();
+ return capabilities().canGetCurrentContendedMonitor;
+ }
+ public boolean canGetMonitorInfo() {
+ validateVM();
+ return capabilities().canGetMonitorInfo;
+ }
+
+ private boolean hasNewCapabilities() {
+ return versionInfo().jdwpMajor > 1 ||
+ versionInfo().jdwpMinor >= 4;
+ }
+
+ boolean canGet1_5LanguageFeatures() {
+ return versionInfo().jdwpMajor > 1 ||
+ versionInfo().jdwpMinor >= 5;
+ }
+
+ public boolean canUseInstanceFilters() {
+ validateVM();
+ return hasNewCapabilities() &&
+ capabilitiesNew().canUseInstanceFilters;
+ }
+ public boolean canRedefineClasses() {
+ validateVM();
+ return hasNewCapabilities() &&
+ capabilitiesNew().canRedefineClasses;
+ }
+ public boolean canAddMethod() {
+ validateVM();
+ return hasNewCapabilities() &&
+ capabilitiesNew().canAddMethod;
+ }
+ public boolean canUnrestrictedlyRedefineClasses() {
+ validateVM();
+ return hasNewCapabilities() &&
+ capabilitiesNew().canUnrestrictedlyRedefineClasses;
+ }
+ public boolean canPopFrames() {
+ validateVM();
+ return hasNewCapabilities() &&
+ capabilitiesNew().canPopFrames;
+ }
+ public boolean canGetMethodReturnValues() {
+ return versionInfo().jdwpMajor > 1 ||
+ versionInfo().jdwpMinor >= 6;
+ }
+ public boolean canGetInstanceInfo() {
+ if (versionInfo().jdwpMajor < 1 ||
+ versionInfo().jdwpMinor < 6) {
+ return false;
+ }
+ validateVM();
+ return hasNewCapabilities() &&
+ capabilitiesNew().canGetInstanceInfo;
+ }
+ public boolean canUseSourceNameFilters() {
+ if (versionInfo().jdwpMajor < 1 ||
+ versionInfo().jdwpMinor < 6) {
+ return false;
+ }
+ return true;
+ }
+ public boolean canForceEarlyReturn() {
+ validateVM();
+ return hasNewCapabilities() &&
+ capabilitiesNew().canForceEarlyReturn;
+ }
+ public boolean canBeModified() {
+ return true;
+ }
+ public boolean canGetSourceDebugExtension() {
+ validateVM();
+ return hasNewCapabilities() &&
+ capabilitiesNew().canGetSourceDebugExtension;
+ }
+ public boolean canGetClassFileVersion() {
+ if ( versionInfo().jdwpMajor < 1 &&
+ versionInfo().jdwpMinor < 6) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ public boolean canGetConstantPool() {
+ validateVM();
+ return hasNewCapabilities() &&
+ capabilitiesNew().canGetConstantPool;
+ }
+ public boolean canRequestVMDeathEvent() {
+ validateVM();
+ return hasNewCapabilities() &&
+ capabilitiesNew().canRequestVMDeathEvent;
+ }
+ public boolean canRequestMonitorEvents() {
+ validateVM();
+ return hasNewCapabilities() &&
+ capabilitiesNew().canRequestMonitorEvents;
+ }
+ public boolean canGetMonitorFrameInfo() {
+ validateVM();
+ return hasNewCapabilities() &&
+ capabilitiesNew().canGetMonitorFrameInfo;
+ }
+
+ public void setDebugTraceMode(int traceFlags) {
+ validateVM();
+ this.traceFlags = traceFlags;
+ this.traceReceives = (traceFlags & TRACE_RECEIVES) != 0;
+ }
+
+ void printTrace(String string) {
+ System.err.println("[JDI: " + string + "]");
+ }
+
+ void printReceiveTrace(int depth, String string) {
+ StringBuffer sb = new StringBuffer("Receiving:");
+ for (int i = depth; i > 0; --i) {
+ sb.append(" ");
+ }
+ sb.append(string);
+ printTrace(sb.toString());
+ }
+
+ private synchronized ReferenceTypeImpl addReferenceType(long id,
+ int tag,
+ String signature) {
+ if (typesByID == null) {
+ initReferenceTypes();
+ }
+ ReferenceTypeImpl type = null;
+ switch(tag) {
+ case JDWP.TypeTag.CLASS:
+ type = new ClassTypeImpl(vm, id);
+ break;
+ case JDWP.TypeTag.INTERFACE:
+ type = new InterfaceTypeImpl(vm, id);
+ break;
+ case JDWP.TypeTag.ARRAY:
+ type = new ArrayTypeImpl(vm, id);
+ break;
+ default:
+ throw new InternalException("Invalid reference type tag");
+ }
+
+ /*
+ * If a signature was specified, make sure to set it ASAP, to
+ * prevent any needless JDWP command to retrieve it. (for example,
+ * typesBySignature.add needs the signature, to maintain proper
+ * ordering.
+ */
+ if (signature != null) {
+ type.setSignature(signature);
+ }
+
+ typesByID.put(new Long(id), type);
+ typesBySignature.add(type);
+
+ if ((vm.traceFlags & VirtualMachine.TRACE_REFTYPES) != 0) {
+ vm.printTrace("Caching new ReferenceType, sig=" + signature +
+ ", id=" + id);
+ }
+
+ return type;
+ }
+
+ synchronized void removeReferenceType(String signature) {
+ if (typesByID == null) {
+ return;
+ }
+ /*
+ * There can be multiple classes with the same name. Since
+ * we can't differentiate here, we first remove all
+ * matching classes from our cache...
+ */
+ Iterator<ReferenceType> iter = typesBySignature.iterator();
+ int matches = 0;
+ while (iter.hasNext()) {
+ ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next();
+ int comp = signature.compareTo(type.signature());
+ if (comp == 0) {
+ matches++;
+ iter.remove();
+ typesByID.remove(new Long(type.ref()));
+ if ((vm.traceFlags & VirtualMachine.TRACE_REFTYPES) != 0) {
+ vm.printTrace("Uncaching ReferenceType, sig=" + signature +
+ ", id=" + type.ref());
+ }
+/* fix for 4359077 , don't break out. list is no longer sorted
+ in the order we think
+ */
+ }
+ }
+
+ /*
+ * ...and if there was more than one, re-retrieve the classes
+ * with that name
+ */
+ if (matches > 1) {
+ retrieveClassesBySignature(signature);
+ }
+ }
+
+ private synchronized List<ReferenceType> findReferenceTypes(String signature) {
+ if (typesByID == null) {
+ return new ArrayList<ReferenceType>(0);
+ }
+ Iterator<ReferenceType> iter = typesBySignature.iterator();
+ List<ReferenceType> list = new ArrayList<ReferenceType>();
+ while (iter.hasNext()) {
+ ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next();
+ int comp = signature.compareTo(type.signature());
+ if (comp == 0) {
+ list.add(type);
+/* fix for 4359077 , don't break out. list is no longer sorted
+ in the order we think
+ */
+ }
+ }
+ return list;
+ }
+
+ private void initReferenceTypes() {
+ typesByID = new HashMap<Long, ReferenceType>(300);
+ typesBySignature = new TreeSet<ReferenceType>();
+ }
+
+ ReferenceTypeImpl referenceType(long ref, byte tag) {
+ return referenceType(ref, tag, null);
+ }
+
+ ClassTypeImpl classType(long ref) {
+ return (ClassTypeImpl)referenceType(ref, JDWP.TypeTag.CLASS, null);
+ }
+
+ InterfaceTypeImpl interfaceType(long ref) {
+ return (InterfaceTypeImpl)referenceType(ref, JDWP.TypeTag.INTERFACE, null);
+ }
+
+ ArrayTypeImpl arrayType(long ref) {
+ return (ArrayTypeImpl)referenceType(ref, JDWP.TypeTag.ARRAY, null);
+ }
+
+ ReferenceTypeImpl referenceType(long id, int tag,
+ String signature) {
+ if ((vm.traceFlags & VirtualMachine.TRACE_REFTYPES) != 0) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Looking up ");
+ if (tag == JDWP.TypeTag.CLASS) {
+ sb.append("Class");
+ } else if (tag == JDWP.TypeTag.INTERFACE) {
+ sb.append("Interface");
+ } else if (tag == JDWP.TypeTag.ARRAY) {
+ sb.append("ArrayType");
+ } else {
+ sb.append("UNKNOWN TAG: " + tag);
+ }
+ if (signature != null) {
+ sb.append(", signature='" + signature + "'");
+ }
+ sb.append(", id=" + id);
+ vm.printTrace(sb.toString());
+ }
+ if (id == 0) {
+ return null;
+ } else {
+ ReferenceTypeImpl retType = null;
+ synchronized (this) {
+ if (typesByID != null) {
+ retType = (ReferenceTypeImpl)typesByID.get(new Long(id));
+ }
+ if (retType == null) {
+ retType = addReferenceType(id, tag, signature);
+ }
+ }
+ return retType;
+ }
+ }
+
+ private JDWP.VirtualMachine.Capabilities capabilities() {
+ if (capabilities == null) {
+ try {
+ capabilities = JDWP.VirtualMachine
+ .Capabilities.process(vm);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+ return capabilities;
+ }
+
+ private JDWP.VirtualMachine.CapabilitiesNew capabilitiesNew() {
+ if (capabilitiesNew == null) {
+ try {
+ capabilitiesNew = JDWP.VirtualMachine
+ .CapabilitiesNew.process(vm);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+ return capabilitiesNew;
+ }
+
+ private List<ReferenceType> retrieveClassesBySignature(String signature) {
+ if ((vm.traceFlags & VirtualMachine.TRACE_REFTYPES) != 0) {
+ vm.printTrace("Retrieving matching ReferenceTypes, sig=" + signature);
+ }
+ JDWP.VirtualMachine.ClassesBySignature.ClassInfo[] cinfos;
+ try {
+ cinfos = JDWP.VirtualMachine.ClassesBySignature.
+ process(vm, signature).classes;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+
+ int count = cinfos.length;
+ List<ReferenceType> list = new ArrayList<ReferenceType>(count);
+
+ // Hold lock during processing to improve performance
+ synchronized (this) {
+ for (int i = 0; i < count; i++) {
+ JDWP.VirtualMachine.ClassesBySignature.ClassInfo ci =
+ cinfos[i];
+ ReferenceTypeImpl type = referenceType(ci.typeID,
+ ci.refTypeTag,
+ signature);
+ type.setStatus(ci.status);
+ list.add(type);
+ }
+ }
+ return list;
+ }
+
+ private void retrieveAllClasses1_4() {
+ JDWP.VirtualMachine.AllClasses.ClassInfo[] cinfos;
+ try {
+ cinfos = JDWP.VirtualMachine.AllClasses.process(vm).classes;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+
+ // Hold lock during processing to improve performance
+ // and to have safe check/set of retrievedAllTypes
+ synchronized (this) {
+ if (!retrievedAllTypes) {
+ // Number of classes
+ int count = cinfos.length;
+ for (int i=0; i<count; i++) {
+ JDWP.VirtualMachine.AllClasses.ClassInfo ci =
+ cinfos[i];
+ ReferenceTypeImpl type = referenceType(ci.typeID,
+ ci.refTypeTag,
+ ci.signature);
+ type.setStatus(ci.status);
+ }
+ retrievedAllTypes = true;
+ }
+ }
+ }
+
+ private void retrieveAllClasses() {
+ if ((vm.traceFlags & VirtualMachine.TRACE_REFTYPES) != 0) {
+ vm.printTrace("Retrieving all ReferenceTypes");
+ }
+
+ if (!vm.canGet1_5LanguageFeatures()) {
+ retrieveAllClasses1_4();
+ return;
+ }
+
+ /*
+ * To save time (assuming the caller will be
+ * using then) we will get the generic sigs too.
+ */
+
+ JDWP.VirtualMachine.AllClassesWithGeneric.ClassInfo[] cinfos;
+ try {
+ cinfos = JDWP.VirtualMachine.AllClassesWithGeneric.process(vm).classes;
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+
+ // Hold lock during processing to improve performance
+ // and to have safe check/set of retrievedAllTypes
+ synchronized (this) {
+ if (!retrievedAllTypes) {
+ // Number of classes
+ int count = cinfos.length;
+ for (int i=0; i<count; i++) {
+ JDWP.VirtualMachine.AllClassesWithGeneric.ClassInfo ci =
+ cinfos[i];
+ ReferenceTypeImpl type = referenceType(ci.typeID,
+ ci.refTypeTag,
+ ci.signature);
+ type.setGenericSignature(ci.genericSignature);
+ type.setStatus(ci.status);
+ }
+ retrievedAllTypes = true;
+ }
+ }
+ }
+
+ void sendToTarget(Packet packet) {
+ target.send(packet);
+ }
+
+ void waitForTargetReply(Packet packet) {
+ target.waitForReply(packet);
+ /*
+ * If any object disposes have been batched up, send them now.
+ */
+ processBatchedDisposes();
+ }
+
+ Type findBootType(String signature) throws ClassNotLoadedException {
+ List<ReferenceType> types = retrieveClassesBySignature(signature);
+ Iterator<ReferenceType> iter = types.iterator();
+ while (iter.hasNext()) {
+ ReferenceType type = iter.next();
+ if (type.classLoader() == null) {
+ return type;
+ }
+ }
+ JNITypeParser parser = new JNITypeParser(signature);
+ throw new ClassNotLoadedException(parser.typeName(),
+ "Type " + parser.typeName() + " not loaded");
+ }
+
+ BooleanType theBooleanType() {
+ if (theBooleanType == null) {
+ synchronized(this) {
+ if (theBooleanType == null) {
+ theBooleanType = new BooleanTypeImpl(this);
+ }
+ }
+ }
+ return theBooleanType;
+ }
+
+ ByteType theByteType() {
+ if (theByteType == null) {
+ synchronized(this) {
+ if (theByteType == null) {
+ theByteType = new ByteTypeImpl(this);
+ }
+ }
+ }
+ return theByteType;
+ }
+
+ CharType theCharType() {
+ if (theCharType == null) {
+ synchronized(this) {
+ if (theCharType == null) {
+ theCharType = new CharTypeImpl(this);
+ }
+ }
+ }
+ return theCharType;
+ }
+
+ ShortType theShortType() {
+ if (theShortType == null) {
+ synchronized(this) {
+ if (theShortType == null) {
+ theShortType = new ShortTypeImpl(this);
+ }
+ }
+ }
+ return theShortType;
+ }
+
+ IntegerType theIntegerType() {
+ if (theIntegerType == null) {
+ synchronized(this) {
+ if (theIntegerType == null) {
+ theIntegerType = new IntegerTypeImpl(this);
+ }
+ }
+ }
+ return theIntegerType;
+ }
+
+ LongType theLongType() {
+ if (theLongType == null) {
+ synchronized(this) {
+ if (theLongType == null) {
+ theLongType = new LongTypeImpl(this);
+ }
+ }
+ }
+ return theLongType;
+ }
+
+ FloatType theFloatType() {
+ if (theFloatType == null) {
+ synchronized(this) {
+ if (theFloatType == null) {
+ theFloatType = new FloatTypeImpl(this);
+ }
+ }
+ }
+ return theFloatType;
+ }
+
+ DoubleType theDoubleType() {
+ if (theDoubleType == null) {
+ synchronized(this) {
+ if (theDoubleType == null) {
+ theDoubleType = new DoubleTypeImpl(this);
+ }
+ }
+ }
+ return theDoubleType;
+ }
+
+ VoidType theVoidType() {
+ if (theVoidType == null) {
+ synchronized(this) {
+ if (theVoidType == null) {
+ theVoidType = new VoidTypeImpl(this);
+ }
+ }
+ }
+ return theVoidType;
+ }
+
+ PrimitiveType primitiveTypeMirror(byte tag) {
+ switch (tag) {
+ case JDWP.Tag.BOOLEAN:
+ return theBooleanType();
+ case JDWP.Tag.BYTE:
+ return theByteType();
+ case JDWP.Tag.CHAR:
+ return theCharType();
+ case JDWP.Tag.SHORT:
+ return theShortType();
+ case JDWP.Tag.INT:
+ return theIntegerType();
+ case JDWP.Tag.LONG:
+ return theLongType();
+ case JDWP.Tag.FLOAT:
+ return theFloatType();
+ case JDWP.Tag.DOUBLE:
+ return theDoubleType();
+ default:
+ throw new IllegalArgumentException("Unrecognized primitive tag " + tag);
+ }
+ }
+
+ private void processBatchedDisposes() {
+ if (shutdown) {
+ return;
+ }
+
+ JDWP.VirtualMachine.DisposeObjects.Request[] requests = null;
+ synchronized(batchedDisposeRequests) {
+ int size = batchedDisposeRequests.size();
+ if (size >= DISPOSE_THRESHOLD) {
+ if ((traceFlags & TRACE_OBJREFS) != 0) {
+ printTrace("Dispose threashold reached. Will dispose "
+ + size + " object references...");
+ }
+ requests = new JDWP.VirtualMachine.DisposeObjects.Request[size];
+ for (int i = 0; i < requests.length; i++) {
+ SoftObjectReference ref = batchedDisposeRequests.get(i);
+ if ((traceFlags & TRACE_OBJREFS) != 0) {
+ printTrace("Disposing object " + ref.key().longValue() +
+ " (ref count = " + ref.count() + ")");
+ }
+
+ // This is kludgy. We temporarily re-create an object
+ // reference so that we can correctly pass its id to the
+ // JDWP command.
+ requests[i] =
+ new JDWP.VirtualMachine.DisposeObjects.Request(
+ new ObjectReferenceImpl(this, ref.key().longValue()),
+ ref.count());
+ }
+ batchedDisposeRequests.clear();
+ }
+ }
+ if (requests != null) {
+ try {
+ JDWP.VirtualMachine.DisposeObjects.process(vm, requests);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+ }
+
+ private void batchForDispose(SoftObjectReference ref) {
+ if ((traceFlags & TRACE_OBJREFS) != 0) {
+ printTrace("Batching object " + ref.key().longValue() +
+ " for dispose (ref count = " + ref.count() + ")");
+ }
+ batchedDisposeRequests.add(ref);
+ }
+
+ private void processQueue() {
+ Reference<?> ref;
+ //if ((traceFlags & TRACE_OBJREFS) != 0) {
+ // printTrace("Checking for softly reachable objects");
+ //}
+ while ((ref = referenceQueue.poll()) != null) {
+ SoftObjectReference softRef = (SoftObjectReference)ref;
+ removeObjectMirror(softRef);
+ batchForDispose(softRef);
+ }
+ }
+
+ synchronized ObjectReferenceImpl objectMirror(long id, int tag) {
+
+ // Handle any queue elements that are not strongly reachable
+ processQueue();
+
+ if (id == 0) {
+ return null;
+ }
+ ObjectReferenceImpl object = null;
+ Long key = new Long(id);
+
+ /*
+ * Attempt to retrieve an existing object object reference
+ */
+ SoftObjectReference ref = objectsByID.get(key);
+ if (ref != null) {
+ object = ref.object();
+ }
+
+ /*
+ * If the object wasn't in the table, or it's soft reference was
+ * cleared, create a new instance.
+ */
+ if (object == null) {
+ switch (tag) {
+ case JDWP.Tag.OBJECT:
+ object = new ObjectReferenceImpl(vm, id);
+ break;
+ case JDWP.Tag.STRING:
+ object = new StringReferenceImpl(vm, id);
+ break;
+ case JDWP.Tag.ARRAY:
+ object = new ArrayReferenceImpl(vm, id);
+ break;
+ case JDWP.Tag.THREAD:
+ ThreadReferenceImpl thread =
+ new ThreadReferenceImpl(vm, id);
+ thread.addListener(this);
+ object = thread;
+ break;
+ case JDWP.Tag.THREAD_GROUP:
+ object = new ThreadGroupReferenceImpl(vm, id);
+ break;
+ case JDWP.Tag.CLASS_LOADER:
+ object = new ClassLoaderReferenceImpl(vm, id);
+ break;
+ case JDWP.Tag.CLASS_OBJECT:
+ object = new ClassObjectReferenceImpl(vm, id);
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid object tag: " + tag);
+ }
+ ref = new SoftObjectReference(key, object, referenceQueue);
+
+ /*
+ * If there was no previous entry in the table, we add one here
+ * If the previous entry was cleared, we replace it here.
+ */
+ objectsByID.put(key, ref);
+ if ((traceFlags & TRACE_OBJREFS) != 0) {
+ printTrace("Creating new " +
+ object.getClass().getName() + " (id = " + id + ")");
+ }
+ } else {
+ ref.incrementCount();
+ }
+
+ return object;
+ }
+
+ synchronized void removeObjectMirror(ObjectReferenceImpl object) {
+
+ // Handle any queue elements that are not strongly reachable
+ processQueue();
+
+ SoftObjectReference ref = objectsByID.remove(new Long(object.ref()));
+ if (ref != null) {
+ batchForDispose(ref);
+ } else {
+ /*
+ * If there's a live ObjectReference about, it better be part
+ * of the cache.
+ */
+ throw new InternalException("ObjectReference " + object.ref() +
+ " not found in object cache");
+ }
+ }
+
+ synchronized void removeObjectMirror(SoftObjectReference ref) {
+ /*
+ * This will remove the soft reference if it has not been
+ * replaced in the cache.
+ */
+ objectsByID.remove(ref.key());
+ }
+
+ ObjectReferenceImpl objectMirror(long id) {
+ return objectMirror(id, JDWP.Tag.OBJECT);
+ }
+
+ StringReferenceImpl stringMirror(long id) {
+ return (StringReferenceImpl)objectMirror(id, JDWP.Tag.STRING);
+ }
+
+ ArrayReferenceImpl arrayMirror(long id) {
+ return (ArrayReferenceImpl)objectMirror(id, JDWP.Tag.ARRAY);
+ }
+
+ ThreadReferenceImpl threadMirror(long id) {
+ return (ThreadReferenceImpl)objectMirror(id, JDWP.Tag.THREAD);
+ }
+
+ ThreadGroupReferenceImpl threadGroupMirror(long id) {
+ return (ThreadGroupReferenceImpl)objectMirror(id,
+ JDWP.Tag.THREAD_GROUP);
+ }
+
+ ClassLoaderReferenceImpl classLoaderMirror(long id) {
+ return (ClassLoaderReferenceImpl)objectMirror(id,
+ JDWP.Tag.CLASS_LOADER);
+ }
+
+ ClassObjectReferenceImpl classObjectMirror(long id) {
+ return (ClassObjectReferenceImpl)objectMirror(id,
+ JDWP.Tag.CLASS_OBJECT);
+ }
+
+ /*
+ * Implementation of PathSearchingVirtualMachine
+ */
+ private JDWP.VirtualMachine.ClassPaths getClasspath() {
+ if (pathInfo == null) {
+ try {
+ pathInfo = JDWP.VirtualMachine.ClassPaths.process(vm);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+ return pathInfo;
+ }
+
+ public List<String> classPath() {
+ return Arrays.asList(getClasspath().classpaths);
+ }
+
+ public List<String> bootClassPath() {
+ return Arrays.asList(getClasspath().bootclasspaths);
+ }
+
+ public String baseDirectory() {
+ return getClasspath().baseDir;
+ }
+
+ public void setDefaultStratum(String stratum) {
+ defaultStratum = stratum;
+ if (stratum == null) {
+ stratum = "";
+ }
+ try {
+ JDWP.VirtualMachine.SetDefaultStratum.process(vm,
+ stratum);
+ } catch (JDWPException exc) {
+ throw exc.toJDIException();
+ }
+ }
+
+ public String getDefaultStratum() {
+ return defaultStratum;
+ }
+
+ ThreadGroup threadGroupForJDI() {
+ return threadGroupForJDI;
+ }
+
+ static private class SoftObjectReference extends SoftReference<ObjectReferenceImpl> {
+ int count;
+ Long key;
+
+ SoftObjectReference(Long key, ObjectReferenceImpl mirror,
+ ReferenceQueue<ObjectReferenceImpl> queue) {
+ super(mirror, queue);
+ this.count = 1;
+ this.key = key;
+ }
+
+ int count() {
+ return count;
+ }
+
+ void incrementCount() {
+ count++;
+ }
+
+ Long key() {
+ return key;
+ }
+
+ ObjectReferenceImpl object() {
+ return get();
+ }
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/VirtualMachineManagerImpl.java b/src/share/classes/com/sun/tools/jdi/VirtualMachineManagerImpl.java
new file mode 100644
index 0000000..3704b41
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/VirtualMachineManagerImpl.java
@@ -0,0 +1,271 @@
+/*
+ * Copyright (c) 1998, 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 com.sun.tools.jdi;
+
+import com.sun.jdi.*;
+import com.sun.jdi.connect.*;
+import com.sun.jdi.connect.spi.*;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.ResourceBundle;
+import java.io.IOException;
+
+import java.util.ServiceLoader;
+
+/* Public for use by com.sun.jdi.Bootstrap */
+public class VirtualMachineManagerImpl implements VirtualMachineManagerService {
+ private List<Connector> connectors = new ArrayList<Connector>();
+ private LaunchingConnector defaultConnector = null;
+ private List<VirtualMachine> targets = new ArrayList<VirtualMachine>();
+ private final ThreadGroup mainGroupForJDI;
+ private ResourceBundle messages = null;
+ private int vmSequenceNumber = 0;
+ private static final int majorVersion = 1;
+ private static final int minorVersion = 8;
+
+ private static final Object lock = new Object();
+ private static VirtualMachineManagerImpl vmm;
+
+ public static VirtualMachineManager virtualMachineManager() {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ JDIPermission vmmPermission =
+ new JDIPermission("virtualMachineManager");
+ sm.checkPermission(vmmPermission);
+ }
+ synchronized (lock) {
+ if (vmm == null) {
+ vmm = new VirtualMachineManagerImpl();
+ }
+ }
+ return vmm;
+ }
+
+ protected VirtualMachineManagerImpl() {
+
+ /*
+ * Create a top-level thread group
+ */
+ ThreadGroup top = Thread.currentThread().getThreadGroup();
+ ThreadGroup parent = null;
+ while ((parent = top.getParent()) != null) {
+ top = parent;
+ }
+ mainGroupForJDI = new ThreadGroup(top, "JDI main");
+
+ /*
+ * Load the connectors
+ */
+ ServiceLoader<Connector> connectorLoader =
+ ServiceLoader.load(Connector.class, Connector.class.getClassLoader());
+
+ Iterator<Connector> connectors = connectorLoader.iterator();
+
+ while (connectors.hasNext()) {
+ Connector connector;
+
+ try {
+ connector = connectors.next();
+ } catch (ThreadDeath x) {
+ throw x;
+ } catch (Exception x) {
+ System.err.println(x);
+ continue;
+ } catch (Error x) {
+ System.err.println(x);
+ continue;
+ }
+
+ addConnector(connector);
+ }
+
+ /*
+ * Load any transport services and encapsulate them with
+ * an attaching and listening connector.
+ */
+ ServiceLoader<TransportService> transportLoader =
+ ServiceLoader.load(TransportService.class,
+ TransportService.class.getClassLoader());
+
+ Iterator<TransportService> transportServices =
+ transportLoader.iterator();
+
+ while (transportServices.hasNext()) {
+ TransportService transportService;
+
+ try {
+ transportService = transportServices.next();
+ } catch (ThreadDeath x) {
+ throw x;
+ } catch (Exception x) {
+ System.err.println(x);
+ continue;
+ } catch (Error x) {
+ System.err.println(x);
+ continue;
+ }
+
+ addConnector(GenericAttachingConnector.create(transportService));
+ addConnector(GenericListeningConnector.create(transportService));
+ }
+
+ // no connectors found
+ if (allConnectors().size() == 0) {
+ throw new Error("no Connectors loaded");
+ }
+
+ // Set the default launcher. In order to be compatible
+ // 1.2/1.3/1.4 we try to make the default launcher
+ // "com.sun.jdi.CommandLineLaunch". If this connector
+ // isn't found then we arbitarly pick the first connector.
+ //
+ boolean found = false;
+ List<LaunchingConnector> launchers = launchingConnectors();
+ for (LaunchingConnector lc: launchers) {
+ if (lc.name().equals("com.sun.jdi.CommandLineLaunch")) {
+ setDefaultConnector(lc);
+ found = true;
+ break;
+ }
+ }
+ if (!found && launchers.size() > 0) {
+ setDefaultConnector(launchers.get(0));
+ }
+
+ }
+
+ public LaunchingConnector defaultConnector() {
+ if (defaultConnector == null) {
+ throw new Error("no default LaunchingConnector");
+ }
+ return defaultConnector;
+ }
+
+ public void setDefaultConnector(LaunchingConnector connector) {
+ defaultConnector = connector;
+ }
+
+ public List<LaunchingConnector> launchingConnectors() {
+ List<LaunchingConnector> launchingConnectors = new ArrayList<LaunchingConnector>(connectors.size());
+ for (Connector connector: connectors) {
+ if (connector instanceof LaunchingConnector) {
+ launchingConnectors.add((LaunchingConnector)connector);
+ }
+ }
+ return Collections.unmodifiableList(launchingConnectors);
+ }
+
+ public List<AttachingConnector> attachingConnectors() {
+ List<AttachingConnector> attachingConnectors = new ArrayList<AttachingConnector>(connectors.size());
+ for (Connector connector: connectors) {
+ if (connector instanceof AttachingConnector) {
+ attachingConnectors.add((AttachingConnector)connector);
+ }
+ }
+ return Collections.unmodifiableList(attachingConnectors);
+ }
+
+ public List<ListeningConnector> listeningConnectors() {
+ List<ListeningConnector> listeningConnectors = new ArrayList<ListeningConnector>(connectors.size());
+ for (Connector connector: connectors) {
+ if (connector instanceof ListeningConnector) {
+ listeningConnectors.add((ListeningConnector)connector);
+ }
+ }
+ return Collections.unmodifiableList(listeningConnectors);
+ }
+
+ public List<Connector> allConnectors() {
+ return Collections.unmodifiableList(connectors);
+ }
+
+ public List<VirtualMachine> connectedVirtualMachines() {
+ return Collections.unmodifiableList(targets);
+ }
+
+ public void addConnector(Connector connector) {
+ connectors.add(connector);
+ }
+
+ public void removeConnector(Connector connector) {
+ connectors.remove(connector);
+ }
+
+ public synchronized VirtualMachine createVirtualMachine(
+ Connection connection,
+ Process process) throws IOException {
+
+ if (!connection.isOpen()) {
+ throw new IllegalStateException("connection is not open");
+ }
+
+ VirtualMachine vm;
+ try {
+ vm = new VirtualMachineImpl(this, connection, process,
+ ++vmSequenceNumber);
+ } catch (VMDisconnectedException e) {
+ throw new IOException(e.getMessage());
+ }
+ targets.add(vm);
+ return vm;
+ }
+
+ public VirtualMachine createVirtualMachine(Connection connection) throws IOException {
+ return createVirtualMachine(connection, null);
+ }
+
+ public void addVirtualMachine(VirtualMachine vm) {
+ targets.add(vm);
+ }
+
+ void disposeVirtualMachine(VirtualMachine vm) {
+ targets.remove(vm);
+ }
+
+ public int majorInterfaceVersion() {
+ return majorVersion;
+ }
+
+ public int minorInterfaceVersion() {
+ return minorVersion;
+ }
+
+ ThreadGroup mainGroupForJDI() {
+ return mainGroupForJDI;
+ }
+
+ String getString(String key) {
+ if (messages == null) {
+ messages = ResourceBundle.getBundle("com.sun.tools.jdi.resources.jdi");
+ }
+ return messages.getString(key);
+ }
+
+}
diff --git a/src/share/classes/com/sun/tools/jdi/VirtualMachineManagerService.java b/src/share/classes/com/sun/tools/jdi/VirtualMachineManagerService.java
new file mode 100644
index 0000000..55252ad
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/VirtualMachineManagerService.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 1998, 2003, 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.tools.jdi;
+
+import com.sun.jdi.connect.*;
+import com.sun.jdi.VirtualMachine;
+import com.sun.jdi.VirtualMachineManager;
+import java.io.IOException;
+
+/**
+ * VirtualMachineManager SPI
+ */
+public interface VirtualMachineManagerService extends VirtualMachineManager {
+ /**
+ * Replaces the default connector.
+ *
+ * @return the default {@link LaunchingConnector}
+ * @throws java.lang.IllegalArgumentException if the given
+ * connector is not a member of the list returned by
+ * {@link #launchingConnectors}
+ *
+ * @param connector the new default connector
+ */
+ void setDefaultConnector(LaunchingConnector connector);
+
+ /**
+ * Adds a connector to the list of known connectors.
+ *
+ * @param connector the connector to be added
+ */
+ void addConnector(Connector connector);
+
+ /**
+ * Removes a connector from the list of known connectors.
+ *
+ * @param connector the connector to be removed
+ */
+ void removeConnector(Connector connector);
+
+}
diff --git a/src/share/classes/com/sun/tools/jdi/VoidTypeImpl.java b/src/share/classes/com/sun/tools/jdi/VoidTypeImpl.java
new file mode 100644
index 0000000..dba2a86
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/VoidTypeImpl.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 1998, 1999, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class VoidTypeImpl extends TypeImpl implements VoidType {
+ VoidTypeImpl(VirtualMachine vm) {
+ super(vm);
+ }
+
+ public String signature() {
+ return String.valueOf((char)JDWP.Tag.VOID);
+ }
+
+ public String toString() {
+ return name();
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/VoidValueImpl.java b/src/share/classes/com/sun/tools/jdi/VoidValueImpl.java
new file mode 100644
index 0000000..8ad5f64
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/VoidValueImpl.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 1998, 2006, 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.tools.jdi;
+
+import com.sun.jdi.*;
+
+public class VoidValueImpl extends ValueImpl implements VoidValue {
+
+ VoidValueImpl(VirtualMachine aVm) {
+ super(aVm);
+ }
+
+ public boolean equals(Object obj) {
+ return (obj != null) && (obj instanceof VoidValue) && super.equals(obj);
+ }
+
+ public int hashCode() {
+ /*
+ * TO DO: Better hash code
+ */
+ return 47245;
+ }
+
+ public Type type() {
+ return vm.theVoidType();
+ }
+
+ ValueImpl prepareForAssignmentTo(ValueContainer destination)
+ throws InvalidTypeException {
+ if ("void".equals(destination.typeName())) {
+ return this;
+ }
+ throw new InvalidTypeException();
+ }
+
+ public String toString() {
+ return "<void value>";
+ }
+
+ byte typeValueKey() {
+ return JDWP.Tag.VOID;
+ }
+}
diff --git a/src/share/classes/com/sun/tools/jdi/resources/jdi.properties b/src/share/classes/com/sun/tools/jdi/resources/jdi.properties
new file mode 100644
index 0000000..44ee7d7
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/resources/jdi.properties
@@ -0,0 +1,52 @@
+true = true
+false = false
+version_format = Java Debug Interface (Reference Implementation) version {0}.{1} \n{2}
+raw.command = Raw command to start the debugged application VM
+raw.command.label = Command
+raw.address = Address from which to listen for a connection after the raw command is run
+raw.address.label = Address
+raw.quote = Character used to combine space-delimited text into a single command line argument
+raw.quote.label = Quote
+raw.description = Launches target using user-specified command line and attaches to it
+sun.home = Home directory of the SDK or runtime environment used to launch the application
+sun.home.label = Home
+sun.options = Launched VM options
+sun.options.label = Options
+sun.main = Main class and arguments, or if -jar is an option, the main jar file and arguments
+sun.main.label = Main
+sun.init_suspend = All threads will be suspended before execution of main
+sun.init_suspend.label = Suspend
+sun.quote = Character used to combine space-delimited text into a single command line argument
+sun.quote.label = Quote
+sun.vm_exec = Name of the Java VM launcher
+sun.vm_exec.label = Launcher
+sun.description = Launches target using Sun Java VM command line and attaches to it
+generic_attaching.address = Address to which to attach for VM connections
+generic_attaching.address.label = Address
+generic_attaching.timeout = Timeout while waiting to attach
+generic_attaching.timeout.label = Timeout
+generic_listening.address = Address to listen for VM connections
+generic_listening.address.label = Address
+generic_listening.timeout = Timeout while waiting for connection
+generic_listening.timeout.label = Timeout
+socket_transportservice.description = Connects debugger and debugee using a TCP connection
+memory_transportservice.description = Connects debugger and debugee using a shared memory connection
+socket_attaching.host = Machine name to which to attach for VM connections
+socket_attaching.host.label = Host
+socket_attaching.port = Port number to which to attach for VM connections
+socket_attaching.port.label = Port
+socket_attaching.description = Attaches by socket to other VMs
+socket_listening.localaddr = Local address that the listener binds to
+socket_listening.localaddr.label = Local address
+socket_listening.port = Port number at which to listen for VM connections
+socket_listening.port.label = Port
+socket_listening.description = Accepts socket connections initiated by other VMs
+memory_attaching.name = Name of the shared memory area to which to attach for VM connections
+memory_attaching.name.label = Name
+memory_attaching.description = Attaches by shared memory to other VMs
+memory_listening.name = Name of the shared memory area at which to listen for VM connection
+memory_listening.name.label = Name
+memory_listening.description = Accepts shared memory connections initiated by other VMs
+process_attaching.description = Attaches to debuggee by process-id (pid)
+process_attaching.pid = pid
+process_attaching.pid.label = Process-id (pid) of debuggee
diff --git a/src/share/classes/com/sun/tools/jdi/resources/jdi_ja.properties b/src/share/classes/com/sun/tools/jdi/resources/jdi_ja.properties
new file mode 100644
index 0000000..072936b
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/resources/jdi_ja.properties
@@ -0,0 +1,52 @@
+true = true
+false = false
+version_format = Java Debug Interface(\u30EA\u30D5\u30A1\u30EC\u30F3\u30B9\u5B9F\u88C5)\u30D0\u30FC\u30B8\u30E7\u30F3{0}.{1}\n{2}
+raw.command = \u30C7\u30D0\u30C3\u30B0\u3059\u308B\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3VM\u3092\u8D77\u52D5\u3055\u305B\u308Braw\u30B3\u30DE\u30F3\u30C9
+raw.command.label = \u30B3\u30DE\u30F3\u30C9
+raw.address = raw\u30B3\u30DE\u30F3\u30C9\u5B9F\u884C\u5F8C\u306B\u63A5\u7D9A\u3092\u30EA\u30B9\u30CB\u30F3\u30B0\u3059\u308B\u30A2\u30C9\u30EC\u30B9
+raw.address.label = \u30A2\u30C9\u30EC\u30B9
+raw.quote = \u5358\u4E00\u306E\u30B3\u30DE\u30F3\u30C9\u884C\u5F15\u6570\u5185\u306B\u30B9\u30DA\u30FC\u30B9\u3067\u533A\u5207\u3089\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u3092\u7D50\u3073\u4ED8\u3051\u308B\u305F\u3081\u306B\u4F7F\u7528\u3055\u308C\u308B\u6587\u5B57
+raw.quote.label = \u5F15\u7528\u7B26
+raw.description = \u30E6\u30FC\u30B6\u30FC\u304C\u6307\u5B9A\u3057\u305F\u30B3\u30DE\u30F3\u30C9\u884C\u3092\u4F7F\u7528\u3057\u3066\u30BF\u30FC\u30B2\u30C3\u30C8\u3092\u8D77\u52D5\u3057\u3001\u63A5\u7D9A\u3057\u307E\u3059
+sun.home = SDK\u306E\u30DB\u30FC\u30E0\u30FB\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u307E\u305F\u306F\u3001\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u306E\u8D77\u52D5\u306B\u4F7F\u7528\u3055\u308C\u308B\u5B9F\u884C\u74B0\u5883
+sun.home.label = \u30DB\u30FC\u30E0
+sun.options = \u8D77\u52D5\u3059\u308BVM\u306E\u30AA\u30D7\u30B7\u30E7\u30F3
+sun.options.label = \u30AA\u30D7\u30B7\u30E7\u30F3
+sun.main = \u30E1\u30A4\u30F3\u30FB\u30AF\u30E9\u30B9\u3068\u5F15\u6570\u3001\u307E\u305F\u306F-jar\u304C\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u5834\u5408\u306B\u306F\u30E1\u30A4\u30F3jar\u30D5\u30A1\u30A4\u30EB\u3068\u5F15\u6570
+sun.main.label = \u30E1\u30A4\u30F3
+sun.init_suspend = \u30E1\u30A4\u30F3\u306E\u5B9F\u884C\u524D\u306B\u3059\u3079\u3066\u306E\u30B9\u30EC\u30C3\u30C9\u304C\u4E2D\u65AD\u3055\u308C\u307E\u3059\u3002
+sun.init_suspend.label = \u4E2D\u65AD
+sun.quote = \u5358\u4E00\u306E\u30B3\u30DE\u30F3\u30C9\u884C\u5F15\u6570\u5185\u306B\u30B9\u30DA\u30FC\u30B9\u3067\u533A\u5207\u3089\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u3092\u7D50\u3073\u4ED8\u3051\u308B\u305F\u3081\u306B\u4F7F\u7528\u3055\u308C\u308B\u6587\u5B57
+sun.quote.label = \u5F15\u7528\u7B26
+sun.vm_exec = Java VM\u8D77\u52D5\u30C4\u30FC\u30EB\u540D
+sun.vm_exec.label = \u8D77\u52D5\u30C4\u30FC\u30EB
+sun.description = Sun\u306EJava VM\u30B3\u30DE\u30F3\u30C9\u884C\u3092\u4F7F\u7528\u3057\u3066\u30BF\u30FC\u30B2\u30C3\u30C8\u3092\u8D77\u52D5\u3057\u3001\u63A5\u7D9A\u3057\u307E\u3059
+generic_attaching.address = VM\u306B\u63A5\u7D9A\u3059\u308B\u30A2\u30C9\u30EC\u30B9
+generic_attaching.address.label = \u30A2\u30C9\u30EC\u30B9
+generic_attaching.timeout = \u63A5\u7D9A\u3092\u5F85\u3064\u9593\u306E\u30BF\u30A4\u30E0\u30A2\u30A6\u30C8
+generic_attaching.timeout.label = \u30BF\u30A4\u30E0\u30A2\u30A6\u30C8
+generic_listening.address = VM\u3078\u306E\u63A5\u7D9A\u3092\u30EA\u30B9\u30CB\u30F3\u30B0\u3059\u308B\u30A2\u30C9\u30EC\u30B9
+generic_listening.address.label = \u30A2\u30C9\u30EC\u30B9
+generic_listening.timeout = \u63A5\u7D9A\u3092\u5F85\u3064\u9593\u306E\u30BF\u30A4\u30E0\u30A2\u30A6\u30C8
+generic_listening.timeout.label = \u30BF\u30A4\u30E0\u30A2\u30A6\u30C8
+socket_transportservice.description = TCP\u63A5\u7D9A\u3067\u30C7\u30D0\u30C3\u30AC\u3068\u30BF\u30FC\u30B2\u30C3\u30C8\u3092\u63A5\u7D9A\u3057\u307E\u3059
+memory_transportservice.description = \u5171\u6709\u30E1\u30E2\u30EA\u30FC\u63A5\u7D9A\u3067\u30C7\u30D0\u30C3\u30AC\u3068\u30BF\u30FC\u30B2\u30C3\u30C8\u3092\u63A5\u7D9A\u3057\u307E\u3059
+socket_attaching.host = VM\u306B\u63A5\u7D9A\u3059\u308B\u30DE\u30B7\u30F3\u540D
+socket_attaching.host.label = \u30DB\u30B9\u30C8
+socket_attaching.port = VM\u306B\u63A5\u7D9A\u3059\u308B\u30DD\u30FC\u30C8\u756A\u53F7
+socket_attaching.port.label = \u30DD\u30FC\u30C8
+socket_attaching.description = \u30BD\u30B1\u30C3\u30C8\u3067\u305D\u306E\u4ED6\u306EVM\u306B\u63A5\u7D9A\u3057\u307E\u3059
+socket_listening.localaddr = \u30EA\u30B9\u30CA\u30FC\u306E\u30D0\u30A4\u30F3\u30C9\u5148\u30ED\u30FC\u30AB\u30EB\u30FB\u30A2\u30C9\u30EC\u30B9
+socket_listening.localaddr.label = \u30ED\u30FC\u30AB\u30EB\u30FB\u30A2\u30C9\u30EC\u30B9
+socket_listening.port = VM\u3078\u306E\u63A5\u7D9A\u3092\u30EA\u30B9\u30CB\u30F3\u30B0\u3059\u308B\u30DD\u30FC\u30C8\u756A\u53F7
+socket_listening.port.label = \u30DD\u30FC\u30C8
+socket_listening.description = \u305D\u306E\u4ED6\u306EVM\u306B\u3088\u308A\u958B\u59CB\u3055\u308C\u308B\u30BD\u30B1\u30C3\u30C8\u63A5\u7D9A\u3092\u53D7\u5165\u308C\u307E\u3059
+memory_attaching.name = VM\u3078\u306E\u63A5\u7D9A\u306B\u4F7F\u7528\u3055\u308C\u308B\u5171\u6709\u30E1\u30E2\u30EA\u30FC\u9818\u57DF\u540D
+memory_attaching.name.label = \u540D\u524D
+memory_attaching.description = \u5171\u6709\u30E1\u30E2\u30EA\u30FC\u3067\u305D\u306E\u4ED6\u306EVM\u306B\u63A5\u7D9A\u3057\u307E\u3059
+memory_listening.name = VM\u3078\u306E\u63A5\u7D9A\u3092\u30EA\u30B9\u30CB\u30F3\u30B0\u3059\u308B\u305F\u3081\u306E\u5171\u6709\u30E1\u30E2\u30EA\u30FC\u9818\u57DF\u540D
+memory_listening.name.label = \u540D\u524D
+memory_listening.description = \u305D\u306E\u4ED6\u306EVM\u306B\u3088\u308A\u958B\u59CB\u3055\u308C\u308B\u5171\u6709\u30E1\u30E2\u30EA\u30FC\u63A5\u7D9A\u3092\u53D7\u3051\u5165\u308C\u307E\u3059
+process_attaching.description = \u30C7\u30D0\u30C3\u30B0\u3059\u308B\u30D7\u30ED\u30BB\u30B9\u306B\u30D7\u30ED\u30BB\u30B9ID (pid)\u3092\u4F7F\u7528\u3057\u3066\u63A5\u7D9A\u3057\u307E\u3059
+process_attaching.pid = pid
+process_attaching.pid.label = \u30C7\u30D0\u30C3\u30B0\u3059\u308B\u30D7\u30ED\u30BB\u30B9ID (pid)
diff --git a/src/share/classes/com/sun/tools/jdi/resources/jdi_zh_CN.properties b/src/share/classes/com/sun/tools/jdi/resources/jdi_zh_CN.properties
new file mode 100644
index 0000000..743a203
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdi/resources/jdi_zh_CN.properties
@@ -0,0 +1,52 @@
+true = true
+false = false
+version_format = Java \u8C03\u8BD5\u63A5\u53E3 (\u53C2\u8003\u5B9E\u73B0) \u7248\u672C {0}.{1}\n{2}
+raw.command = \u7528\u4E8E\u542F\u52A8\u8C03\u8BD5\u5E94\u7528\u7A0B\u5E8F VM \u7684\u539F\u59CB\u547D\u4EE4
+raw.command.label = \u547D\u4EE4
+raw.address = \u8FD0\u884C\u539F\u59CB\u547D\u4EE4\u4E4B\u540E, \u76D1\u542C\u8FDE\u63A5\u65F6\u4F7F\u7528\u7684\u5730\u5740
+raw.address.label = \u5730\u5740
+raw.quote = \u7528\u4E8E\u5C06\u4EE5\u7A7A\u683C\u5206\u9694\u7684\u6587\u672C\u7EC4\u5408\u4E3A\u4E00\u4E2A\u547D\u4EE4\u884C\u53C2\u6570\u7684\u5B57\u7B26
+raw.quote.label = \u5F15\u53F7
+raw.description = \u4F7F\u7528\u7528\u6237\u6307\u5B9A\u7684\u547D\u4EE4\u884C\u542F\u52A8\u76EE\u6807\u5E76\u9644\u52A0\u5230\u8BE5\u76EE\u6807
+sun.home = \u7528\u4E8E\u542F\u52A8\u5E94\u7528\u7A0B\u5E8F\u7684 SDK \u6216\u8FD0\u884C\u65F6\u73AF\u5883\u7684\u4E3B\u76EE\u5F55
+sun.home.label = \u4E3B\u76EE\u5F55
+sun.options = \u5DF2\u542F\u52A8\u7684 VM \u9009\u9879
+sun.options.label = \u9009\u9879
+sun.main = \u4E3B\u7C7B\u548C\u53C2\u6570, \u6216\u8005\u5982\u679C -jar \u662F\u4E00\u4E2A\u9009\u9879, \u5219\u4E3A\u4E3B jar \u6587\u4EF6\u548C\u53C2\u6570
+sun.main.label = \u4E3B
+sun.init_suspend = \u5728\u6267\u884C\u4E3B\u7C7B\u4E4B\u524D, \u5C06\u6302\u8D77\u6240\u6709\u7EBF\u7A0B
+sun.init_suspend.label = \u6302\u8D77
+sun.quote = \u7528\u4E8E\u5C06\u4EE5\u7A7A\u683C\u5206\u9694\u7684\u6587\u672C\u7EC4\u5408\u4E3A\u4E00\u4E2A\u547D\u4EE4\u884C\u53C2\u6570\u7684\u5B57\u7B26
+sun.quote.label = \u5F15\u53F7
+sun.vm_exec = Java VM \u542F\u52A8\u7A0B\u5E8F\u7684\u540D\u79F0
+sun.vm_exec.label = \u542F\u52A8\u7A0B\u5E8F
+sun.description = \u4F7F\u7528 Sun Java VM \u547D\u4EE4\u884C\u542F\u52A8\u76EE\u6807\u5E76\u9644\u52A0\u5230\u8BE5\u76EE\u6807
+generic_attaching.address = VM \u8FDE\u63A5\u6240\u9644\u52A0\u5230\u7684\u5730\u5740
+generic_attaching.address.label = \u5730\u5740
+generic_attaching.timeout = \u7B49\u5F85\u9644\u52A0\u64CD\u4F5C\u65F6\u7684\u8D85\u65F6
+generic_attaching.timeout.label = \u8D85\u65F6
+generic_listening.address = \u76D1\u542C VM \u8FDE\u63A5\u65F6\u4F7F\u7528\u7684\u5730\u5740
+generic_listening.address.label = \u5730\u5740
+generic_listening.timeout = \u7B49\u5F85\u8FDE\u63A5\u65F6\u7684\u8D85\u65F6
+generic_listening.timeout.label = \u8D85\u65F6
+socket_transportservice.description = \u4F7F\u7528 TCP \u8FDE\u63A5\u6765\u8FDE\u63A5\u8C03\u8BD5\u5668\u548C\u88AB\u8C03\u8BD5\u8FDB\u7A0B
+memory_transportservice.description = \u4F7F\u7528\u5171\u4EAB\u5185\u5B58\u8FDE\u63A5\u6765\u8FDE\u63A5\u8C03\u8BD5\u5668\u548C\u88AB\u8C03\u8BD5\u8FDB\u7A0B
+socket_attaching.host = VM \u8FDE\u63A5\u6240\u9644\u52A0\u5230\u7684\u8BA1\u7B97\u673A\u540D\u79F0
+socket_attaching.host.label = \u4E3B\u673A
+socket_attaching.port = VM \u8FDE\u63A5\u6240\u9644\u52A0\u5230\u7684\u7AEF\u53E3\u53F7
+socket_attaching.port.label = \u7AEF\u53E3
+socket_attaching.description = \u901A\u8FC7\u5957\u63A5\u5B57\u9644\u52A0\u5230\u5176\u4ED6 VM
+socket_listening.localaddr = \u76D1\u542C\u7A0B\u5E8F\u7ED1\u5B9A\u5230\u7684\u672C\u5730\u5730\u5740
+socket_listening.localaddr.label = \u672C\u5730\u5730\u5740
+socket_listening.port = \u76D1\u542C VM \u8FDE\u63A5\u65F6\u4F7F\u7528\u7684\u7AEF\u53E3\u53F7
+socket_listening.port.label = \u7AEF\u53E3
+socket_listening.description = \u63A5\u53D7\u7531\u5176\u4ED6 VM \u542F\u52A8\u7684\u5957\u63A5\u5B57\u8FDE\u63A5
+memory_attaching.name = VM \u8FDE\u63A5\u6240\u9644\u52A0\u5230\u7684\u5171\u4EAB\u5185\u5B58\u533A\u57DF\u7684\u540D\u79F0
+memory_attaching.name.label = \u540D\u79F0
+memory_attaching.description = \u901A\u8FC7\u5171\u4EAB\u5185\u5B58\u9644\u52A0\u5230\u5176\u4ED6 VM
+memory_listening.name = \u76D1\u542C VM \u8FDE\u63A5\u65F6\u6240\u5728\u7684\u5171\u4EAB\u5185\u5B58\u533A\u57DF\u7684\u540D\u79F0
+memory_listening.name.label = \u540D\u79F0
+memory_listening.description = \u63A5\u53D7\u7531\u5176\u4ED6 VM \u542F\u52A8\u7684\u5171\u4EAB\u5185\u5B58\u8FDE\u63A5
+process_attaching.description = \u901A\u8FC7\u8FDB\u7A0B ID (PID) \u9644\u52A0\u5230\u88AB\u8C03\u8BD5\u8FDB\u7A0B
+process_attaching.pid = PID
+process_attaching.pid.label = \u88AB\u8C03\u8BD5\u8FDB\u7A0B\u7684\u8FDB\u7A0B ID (PID)