diff options
Diffstat (limited to 'gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id')
13 files changed, 1104 insertions, 0 deletions
diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ArrayId.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ArrayId.java new file mode 100644 index 000000000..cd428a172 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ArrayId.java @@ -0,0 +1,62 @@ +/* ArrayId.java -- array object IDs + Copyright (C) 2005 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.classpath.jdwp.id; + +import gnu.classpath.jdwp.JdwpConstants; + +/** + * A class which represents a JDWP array id + * + * @author Keith Seitz <keiths@redhat.com> + */ +public class ArrayId + extends ObjectId +{ + // Arrays are handled a little differently than other IDs + //public static final Class typeClass = UNDEFINED + + /** + * Constructs a new <code>ArrayId</code> + */ + public ArrayId () + { + super (JdwpConstants.Tag.ARRAY); + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ArrayReferenceTypeId.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ArrayReferenceTypeId.java new file mode 100644 index 000000000..14a73dc5b --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ArrayReferenceTypeId.java @@ -0,0 +1,59 @@ +/* ArrayReferenceTypeId.java -- array reference type ids + Copyright (C) 2005 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.classpath.jdwp.id; + +import gnu.classpath.jdwp.JdwpConstants; + +/** + * A reference type ID representing java arrays + * + * @author Keith Seitz <keiths@redhat.com> + */ +public class ArrayReferenceTypeId + extends ReferenceTypeId +{ + /** + * Constructs a new <code>ArrayReferenceTypeId</code> + */ + public ArrayReferenceTypeId () + { + super (JdwpConstants.TypeTag.ARRAY); + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ClassLoaderId.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ClassLoaderId.java new file mode 100644 index 000000000..37c4c3655 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ClassLoaderId.java @@ -0,0 +1,82 @@ +/* ClassLoaderId.java -- class loader IDs + Copyright (C) 2005 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.classpath.jdwp.id; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.exception.InvalidClassLoaderException; + +/** + * A class which represents a JDWP thread id + * + * @author Keith Seitz <keiths@redhat.com> + */ +public class ClassLoaderId + extends ObjectId +{ + /** + * The object class that this id represents + */ + public static final Class typeClass = ClassLoader.class; + + /** + * Constructs a new <code>ClassLoaderId</code> + */ + public ClassLoaderId () + { + super (JdwpConstants.Tag.CLASS_LOADER); + } + + /** + * Gets the ClassLoader represented by this ID + * + * @throws InvalidClassLoaderException if ClassLoader is garbage collected, + * or otherwise invalid + */ + public ClassLoader getClassLoader () + throws InvalidClassLoaderException + { + ClassLoader cl = (ClassLoader) _reference.get (); + + if (cl == null) + throw new InvalidClassLoaderException (getId ()); + + return cl; + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ClassObjectId.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ClassObjectId.java new file mode 100644 index 000000000..3e1642212 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ClassObjectId.java @@ -0,0 +1,82 @@ +/* ClassObjectId.java -- class object IDs + Copyright (C) 2005 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.classpath.jdwp.id; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.exception.InvalidClassException; + +/** + * A class which represents a JDWP class object id + * + * @author Keith Seitz <keiths@redhat.com> + */ +public class ClassObjectId + extends ObjectId +{ + /** + * The object class that this id represents + */ + public static final Class typeClass = Class.class; + + /** + * Constructs a new <code>ClassObjectId</code> + */ + public ClassObjectId () + { + super (JdwpConstants.Tag.CLASS_OBJECT); + } + + /** + * Gets the Class object represented by this ID + * + * @throws InvalidClassException if Class is garbage collected, + * or otherwise invalid + */ + public Class getClassObject () + throws InvalidClassException + { + Class cl = (Class) _reference.get (); + + if (cl == null) + throw new InvalidClassException (getId ()); + + return cl; + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ClassReferenceTypeId.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ClassReferenceTypeId.java new file mode 100644 index 000000000..6b57673f8 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ClassReferenceTypeId.java @@ -0,0 +1,59 @@ +/* ClassReferenceTypeId.java -- class reference type ids + Copyright (C) 2005 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.classpath.jdwp.id; + +import gnu.classpath.jdwp.JdwpConstants; + +/** + * A reference type ID representing java classes + * + * @author Keith Seitz <keiths@redhat.com> + */ +public class ClassReferenceTypeId + extends ReferenceTypeId +{ + /** + * Constructs a new <code>ClassReferenceTypeId</code> + */ + public ClassReferenceTypeId () + { + super (JdwpConstants.TypeTag.CLASS); + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/InterfaceReferenceTypeId.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/InterfaceReferenceTypeId.java new file mode 100644 index 000000000..bdbd6b6eb --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/InterfaceReferenceTypeId.java @@ -0,0 +1,59 @@ +/* InterfaceReferenceTypeId.java -- interface reference type ids + Copyright (C) 2005 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.classpath.jdwp.id; + +import gnu.classpath.jdwp.JdwpConstants; + +/** + * A reference type ID representing java interfaces + * + * @author Keith Seitz <keiths@redhat.com> + */ +public class InterfaceReferenceTypeId + extends ReferenceTypeId +{ + /** + * Constructs a new <code>InterfaceReferenceTypeId</code> + */ + public InterfaceReferenceTypeId () + { + super (JdwpConstants.TypeTag.INTERFACE); + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/JdwpId.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/JdwpId.java new file mode 100644 index 000000000..61cc15d2e --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/JdwpId.java @@ -0,0 +1,151 @@ +/* JdwpId.java -- base class for all object ID types + Copyright (C) 2005, 2006 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.classpath.jdwp.id; + +import java.io.DataOutputStream; +import java.io.IOException; +import java.lang.ref.SoftReference; + +/** + * A baseclass for all object types reported to the debugger + * + * @author Keith Seitz <keiths@redhat.com> + */ +public abstract class JdwpId +{ + /** + * The size of an ID. The default is 8 bytes (a long). + */ + public static final int SIZE = 8; + + /** + * ID assigned to this object + */ + protected long _id; + + /** + * Tag of ID's type (see {@link gnu.classpath.jdwp.JdwpConstants.Tag}) + * for object-like IDs or the type tag (see {@link + * gnu.classpath.jdwp.JdwpConstants.TypeTag}) for reference type IDs. + */ + private byte _tag; + + /** + * The object/class represented by this Id + */ + protected SoftReference _reference; + + /** + * Constructs an empty <code>JdwpId</code> + */ + public JdwpId (byte tag) + { + _tag = tag; + } + + /** + * Sets the id for this object reference + */ + public void setId (long id) + { + _id = id; + } + + /** + * Returns the id for this object reference + */ + public long getId () + { + return _id; + } + + /** + * Gets the object/class reference for this ID + * + * @returns a refernce to the object or class + */ + public SoftReference getReference () + { + return _reference; + } + + /** + * Sets the object/class reference for this ID + * + * @param ref a refernce to the object or class + */ + public void setReference (SoftReference ref) + { + _reference = ref; + } + + /** + * Compares two object ids for equality. Two object ids + * are equal if they point to the same type and contain to + * the same id number. + */ + public boolean equals (JdwpId id) + { + return (id.getId () == getId ()); + } + + /** + * Writes the contents of this type to the <code>DataOutputStream</code> + * @param outStream the <code>DataOutputStream</code> to use + * @throws IOException when an error occurs on the <code>OutputStream</code> + */ + public abstract void write (DataOutputStream outStream) + throws IOException; + + /** + * Writes the contents of this type to the output stream, preceded + * by a one-byte tag for tagged object IDs or type tag for + * reference type IDs. + * + * @param outStream the <code>DataOutputStream</code> to use + * @throws IOException when an error occurs on the <code>OutputStream</code> + */ + public void writeTagged (DataOutputStream outStream) + throws IOException + { + outStream.writeByte (_tag); + write (outStream); + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/NullObjectId.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/NullObjectId.java new file mode 100644 index 000000000..0e7b5e39c --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/NullObjectId.java @@ -0,0 +1,79 @@ +/* NullObjectId.java -- special objectId for null values + Copyright (C) 2007 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.classpath.jdwp.id; + +import gnu.classpath.jdwp.exception.InvalidObjectException; +import gnu.classpath.jdwp.util.NullObject; + +import java.lang.ref.SoftReference; + +/** + * This is a special case of an ObjectId. When a varaible slot contains + * null as its value, this is a valid value despite the fact that it does + * not reference an object. To represent this, this will always be the id + * of the NullObject (0). + * + * @author Kyle Galloway <kgallowa@redhat.com> + */ +public class NullObjectId + extends ObjectId +{ + /** + * The object class that this id represents + */ + public static final Class typeClass = NullObject.class; + + /** + * Constructs a new <code>NullObjectId</code> + */ + public NullObjectId() + { + super(); + setId((long) 0); + _reference = new SoftReference<NullObject>(new NullObject()); + try + { + disableCollection(); + } + catch(InvalidObjectException ex) + { + //This will not happen + } + } + +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ObjectId.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ObjectId.java new file mode 100644 index 000000000..a4a37fd13 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ObjectId.java @@ -0,0 +1,131 @@ +/* ObjectId.java -- object IDs + Copyright (C) 2005, 2006 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.classpath.jdwp.id; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.exception.InvalidObjectException; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * This is a base class for all ObjectID-like entities in JDWP, + * inculding Objects, ClassObject, ClassLoader, Thread, ThreadGroup, + * etc. + * + * @author Keith Seitz <keiths@redhat.com> + */ +public class ObjectId + extends JdwpId +{ + /** + * The object class that this id represents + */ + public static final Class typeClass = Object.class; + + // Handle to disable garbage collection + private Object _handle; + + /** + * Constructs a new <code>ObjectId</code> + */ + public ObjectId () + { + super (JdwpConstants.Tag.OBJECT); + } + + /** + * Constructs a new <code>ObjectId</code> of the + * given type. + * + * @param tag the tag of this type of object ID + */ + public ObjectId (byte tag) + { + super (tag); + } + + /** + * Returns the object referred to by this ID + * + * @returns the object + * @throws InvalidObjectException if the object was garbage collected + * or is invalid + */ + public Object getObject () + throws InvalidObjectException + { + Object obj = _reference.get (); + if (obj == null) + throw new InvalidObjectException (_id); + + return obj; + } + + /** + * Writes the id to the stream + * + * @param outStream the stream to which to write + * @throws IOException when an error occurs on the <code>OutputStream</code> + */ + public void write (DataOutputStream outStream) + throws IOException + { + // All we need to do is write out our id as an 8-byte integer + outStream.writeLong (_id); + } + + /** + * Disable garbage collection on object + */ + public void disableCollection () + throws InvalidObjectException + { + _handle = getObject (); + } + + /** + * Enable garbage collection on object + */ + public void enableCollection () + { + _handle = null; + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ReferenceTypeId.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ReferenceTypeId.java new file mode 100644 index 000000000..b82acf34a --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ReferenceTypeId.java @@ -0,0 +1,91 @@ +/* ReferenceTypeId.java -- a base class for all reference type IDs + Copyright (C) 2005, 2006 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.classpath.jdwp.id; + +import gnu.classpath.jdwp.exception.InvalidClassException; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Base class for reference type IDs. This class usurps + * <code>JdwpId</code>'s tag member for its own use (type tag). + * + * @author Keith Seitz <keiths@redhat.com> + */ +public class ReferenceTypeId + extends JdwpId +{ + /** + * Constructor used by {Array,Interface,Class}ReferenceTypeId + */ + public ReferenceTypeId (byte tag) + { + super (tag); + } + + /** + * Gets the class associated with this ID + * + * @returns the class + * @throws InvalidClassException if the class is not valid + */ + public Class getType () + throws InvalidClassException + { + Class clazz = (Class) _reference.get (); + if (clazz == null) + throw new InvalidClassException (_id); + + return clazz; + } + + /** + * Outputs the reference type ID to the given output stream + * + * @param outStream the stream to which to write the data + * @throws IOException for errors writing to the stream + */ + public void write (DataOutputStream outStream) + throws IOException + { + outStream.writeLong (_id); + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/StringId.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/StringId.java new file mode 100644 index 000000000..1ba8f6d4d --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/StringId.java @@ -0,0 +1,82 @@ +/* StringId.java -- string IDs + Copyright (C) 2005 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.classpath.jdwp.id; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.exception.InvalidStringException; + +/** + * A class which represents a JDWP string id + * + * @author Keith Seitz <keiths@redhat.com> + */ +public class StringId + extends ObjectId +{ + /** + * The object class that this id represents + */ + public static final Class typeClass = String.class; + + /** + * Constructs a new <code>StringId</code> + */ + public StringId () + { + super (JdwpConstants.Tag.STRING); + } + + /** + * Gets the String represented by this ID + * + * @throws InvalidStringException if String is garbage collected, + * or otherwise invalid + */ + public String getString () + throws InvalidStringException + { + String string = (String) _reference.get (); + + if (string == null) + throw new InvalidStringException (getId ()); + + return string; + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ThreadGroupId.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ThreadGroupId.java new file mode 100644 index 000000000..f4d9d803d --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ThreadGroupId.java @@ -0,0 +1,82 @@ +/* ThreadGroupId.java -- thread group IDs + Copyright (C) 2005 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.classpath.jdwp.id; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.exception.InvalidThreadGroupException; + +/** + * A class which represents a JDWP thread group id + * + * @author Keith Seitz <keiths@redhat.com> + */ +public class ThreadGroupId + extends ObjectId +{ + /** + * The object class that this id represents + */ + public static final Class typeClass = ThreadGroup.class; + + /** + * Constructs a new <code>ThreadGroupId</code> + */ + public ThreadGroupId () + { + super (JdwpConstants.Tag.THREAD_GROUP); + } + + /** + * Gets the thread group represented by this ID + * + * @throws InvalidThreadGroupException if the group is invalid + * or garbage collected + */ + public ThreadGroup getThreadGroup () + throws InvalidThreadGroupException + { + ThreadGroup group = (ThreadGroup) _reference.get (); + + if (group == null) + throw new InvalidThreadGroupException (getId ()); + + return group; + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ThreadId.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ThreadId.java new file mode 100644 index 000000000..207d6b0a1 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/id/ThreadId.java @@ -0,0 +1,85 @@ +/* ThreadId.java -- thread IDs + Copyright (C) 2005 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.classpath.jdwp.id; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.exception.InvalidThreadException; + +/** + * A class which represents a JDWP thread id + * + * @author Keith Seitz <keiths@redhat.com> + */ +public class ThreadId + extends ObjectId +{ + /** + * The object class that this id represents + */ + public static final Class typeClass = Thread.class; + + /** + * Constructs a new <code>ThreadId</code> + */ + public ThreadId () + { + super (JdwpConstants.Tag.THREAD); + } + + /** + * Gets the Thread represented by this ID + * + * @throws InvalidThreadException if thread is garbage collected, + * exited, or otherwise invalid + */ + public Thread getThread () + throws InvalidThreadException + { + Thread thread = (Thread) _reference.get (); + + /* Spec says if thread is null, not valid, or exited, + throw invalid thread */ + // FIXME: not valid? exited? Is this check valid? + if (thread == null || !thread.isAlive ()) + throw new InvalidThreadException (getId ()); + + return thread; + } +} |