diff options
Diffstat (limited to 'gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util')
8 files changed, 831 insertions, 0 deletions
diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/JdwpString.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/JdwpString.java new file mode 100644 index 000000000..e94700fe1 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/JdwpString.java @@ -0,0 +1,95 @@ +/* JdwpString.java -- utility class to read and write jdwp strings + 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 +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.util; + +import gnu.classpath.jdwp.exception.JdwpInternalErrorException; + +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.nio.ByteBuffer; + +/** + * A class to compute the JDWP representation of Strings. + * + * @author Aaron Luchko <aluchko@redhat.com> + */ +public class JdwpString +{ + + /** + * Write this String to the outStream as a string understood by jdwp. + * + * @param os write the String here + * @param string the String to write + * @throws IOException + */ + public static void writeString(DataOutputStream os, String string) + throws IOException + { + // Get the bytes of the string as a string in UTF-8 + byte[] strBytes = string.getBytes("UTF-8"); + os.writeInt(strBytes.length); + os.write(strBytes); + } + + /** + * Read a jdwp style string from the ByteBuffer. + * + * @param bb contains the string + * @return the String that was read + * @throws JdwpInternalErrorException bb didn't contain a value UTF-8 string + */ + public static String readString(ByteBuffer bb) + throws JdwpInternalErrorException + { + int length = bb.getInt(); + byte[] strBytes = new byte[length]; + bb.get(strBytes); + try + { + return new String(strBytes, "UTF-8"); + } + catch (UnsupportedEncodingException ex) + { + // Any string from the VM should be in UTF-8 so an encoding error + // shouldn't be possible + throw new JdwpInternalErrorException(ex); + } + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/LineTable.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/LineTable.java new file mode 100644 index 000000000..7078b17db --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/LineTable.java @@ -0,0 +1,95 @@ +/* LineTable.java -- A class representing a Line Table for a method + 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.util; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * A class representing a Line Table for a method. + * + * @author Aaron Luchko <aluchko@redhat.com> + */ +public class LineTable +{ + + private final long start; + private final long end; + private final int[] lineNum; + private final long[] lineCI; + + /** + * Construct a line table with the given parameters. + * + * @param start lowest code index for method, -1 if native + * @param end highest code index for method, -1 if native + * @param lineNum line numbers for in line tables + * @param lineCI code indicies for entries in line tables + */ + public LineTable(long start, long end, int[] lineNum, long[] lineCI) + { + if (lineNum.length != lineCI.length) + throw new AssertionError("code index and line numbers tables " + + "not same length"); + this.start = start; + this.end = end; + this.lineNum = lineNum; + this.lineCI = lineCI; + } + + /** + * Writes this line table to the given DataOutputStream. + * + * @param os the stream to write it to + * @throws IOException + */ + public void write(DataOutputStream os) + throws IOException + { + os.writeLong(start); + os.writeLong(end); + os.writeInt(lineNum.length); + for (int i = 0; i < lineNum.length; i++) + { + os.writeLong(lineCI[i]); + os.writeInt(lineNum[i]); + } + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/Location.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/Location.java new file mode 100644 index 000000000..ff045a5ec --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/Location.java @@ -0,0 +1,168 @@ +/* Location.java -- class to read/write JDWP locations + Copyright (C) 2005, 2006, 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.util; + +import gnu.classpath.jdwp.VMIdManager; +import gnu.classpath.jdwp.VMMethod; +import gnu.classpath.jdwp.exception.JdwpException; +import gnu.classpath.jdwp.id.ClassReferenceTypeId; + +import java.io.DataOutputStream; +import java.io.IOException; +import java.nio.ByteBuffer; + +/** + * A class to read/write JDWP locations. + * + * @author Aaron Luchko <aluchko@redhat.com> + */ +public class Location +{ + private VMMethod method; + private long index; + + /** + * Create a location with the given parameters. + * + * @param method the method + * @param index location in the method + */ + public Location(VMMethod method, long index) + { + this.method = method; + this.index = index; + } + + /** + * Read a location from the given bytebuffer, consists of a TAG (byte), + * followed by a ReferenceTypeId, a MethodId and an index (long). + * + * @param bb this holds the location + * @throws IOException when an error occurs reading from the buffer + * @throws JdwpException for invalid class or method IDs + */ + public Location(ByteBuffer bb) + throws IOException, JdwpException + { + byte tag = bb.get(); + ClassReferenceTypeId classId = + (ClassReferenceTypeId) VMIdManager.getDefault().readReferenceTypeId(bb); + Class klass = classId.getType(); + method = VMMethod.readId(klass, bb); + index = bb.getLong(); + } + + /** + * Write the given location to an output stream. + * + * @param os stream to write to + * @throws IOException when an error occurs writing to the stream + */ + public void write(DataOutputStream os) + throws IOException + { + // check if this is an empty location + if (method != null) + { + VMIdManager idm = VMIdManager.getDefault(); + ClassReferenceTypeId crti = + (ClassReferenceTypeId) + idm.getReferenceTypeId(method.getDeclaringClass()); + + crti.writeTagged(os); + method.writeId(os); + os.writeLong(index); + } + else + { + os.writeByte(1); + os.writeLong((long) 0); + os.writeLong((long) 0); + os.writeLong((long) 0); + } + } + + /** + * Sets up an empty location + * + * @return new Location (setup as empty) + */ + public static Location getEmptyLocation() + { + return new Location(null, 0); + } + + /** + * Gets the method of this location + * + * @return the method + */ + public VMMethod getMethod() + { + return method; + } + + /** + * Gets the code index of this location + * + * @return the code index + */ + public long getIndex () + { + return index; + } + + // convenient for debugging + public String toString () + { + return method.toString () + "." + index; + } + + public boolean equals(Object obj) + { + if (obj instanceof Location) + { + Location l = (Location) obj; + return (getMethod().equals(l.getMethod()) + && getIndex() == l.getIndex()); + } + + return false; + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/MethodResult.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/MethodResult.java new file mode 100644 index 000000000..bf3ee8ed5 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/MethodResult.java @@ -0,0 +1,86 @@ +/* MethodResult.java -- class to wrap around values returned from a Method call + in the VM + Copyright (C) 2005, 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 +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.util; + +import gnu.classpath.jdwp.value.Value; + +/** + * A class to wrap around values returned from a Method call in the VM. + * + * @author Aaron Luchko <aluchko@redhat.com> + */ +public class MethodResult +{ + // The Object returned by the executing method + private Value returnedValue; + + // Any Exception that was thrown by the executing method + private Throwable thrownException; + + /** + * Constructs a new MethodResult object + * + * @param return_value the return value of the method invocation + * @param exc exception thrown during the invocation (or null if none) + */ + public MethodResult (Value return_value, Throwable exc) + { + returnedValue = return_value; + thrownException = exc; + } + + /** + * Returns the return value of the method invocation + */ + public Value getReturnedValue() + { + return returnedValue; + } + + /** + * Returns the exception thrown during the method invocation + * (or null if none) + */ + public Throwable getThrownException() + { + return thrownException; + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/MonitorInfo.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/MonitorInfo.java new file mode 100644 index 000000000..f28eabf83 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/MonitorInfo.java @@ -0,0 +1,76 @@ +/* MonitorInfo.java -- class used to return monitor information + for JDWP. + + 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 +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.util; + +import gnu.classpath.jdwp.VMIdManager; +import gnu.classpath.jdwp.id.ObjectId; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * This class is used to pass monitor information between + * the JDWP back-end and the virtual machine. + * + * @author Keith Seitz (keiths@redhat.com) + */ +public class MonitorInfo +{ + public int entryCount; + public Thread owner; + public Thread[] waiters; + + public void write(DataOutputStream os) + throws IOException + { + VMIdManager idm = VMIdManager.getDefault(); + ObjectId id = idm.getObjectId(owner); + id.write(os); + os.write(entryCount); + os.write(waiters.length); + for (int i = 0; i < waiters.length; ++i) + { + id = idm.getObjectId(waiters[i]); + id.write(os); + } + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/NullObject.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/NullObject.java new file mode 100644 index 000000000..ec762fc2f --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/NullObject.java @@ -0,0 +1,50 @@ +/* NullObject.java -- placeholder 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.util; + +/** + * This is a placeholder for null. There are several places in JDWP where null + * is a valid value (i.e. when geting the value of a variable slot that + * contains a null reference at that time). This class distinguishes between + * these "meaningful" null values and invalid null pointers. + * + * @author Kyle Galloway <kgallowa@redhat.com> + */ +public class NullObject +{ +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/Signature.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/Signature.java new file mode 100644 index 000000000..e7453bf01 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/Signature.java @@ -0,0 +1,151 @@ +/* Signature.java -- utility class to compute class and method signatures + 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.util; + +import gnu.java.lang.CPStringBuilder; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +/** + * A class to compute class and method signatures. + * + * @author Tom Tromey (tromey@redhat.com) + * @author Keith Seitz (keiths@redhat.com) + */ +public class Signature +{ + /** + * Computes the class signature, i.e., java.lang.String.class + * returns "Ljava/lang/String;". + * + * @param theClass the class for which to compute the signature + * @return the class's type signature + */ + public static String computeClassSignature (Class theClass) + { + CPStringBuilder sb = new CPStringBuilder (); + _addToSignature (sb, theClass); + return sb.toString (); + } + + /** + * Computes the field signature which is just the class signature of the + * field's type, ie a Field of type java.lang.String this will return + * "Ljava/lang/String;". + * + * @param field the field for which to compute the signature + * @return the field's type signature + */ + public static String computeFieldSignature (Field field) + { + return computeClassSignature (field.getType()); + } + + /** + * Computes the method signature, i.e., java.lang.String.split (String, int) + * returns "(Ljava/lang/String;I)[Ljava/lang/String;" + * + * @param method the method for which to compute the signature + * @return the method's type signature + */ + public static String computeMethodSignature (Method method) + { + return _computeSignature (method.getReturnType (), + method.getParameterTypes ()); + } + + private static String _computeSignature (Class returnType, + Class[] paramTypes) + { + CPStringBuilder sb = new CPStringBuilder ("("); + if (paramTypes != null) + { + for (int i = 0; i < paramTypes.length; ++i) + _addToSignature (sb, paramTypes[i]); + } + sb.append (")"); + _addToSignature (sb, returnType); + return sb.toString(); + } + + private static void _addToSignature (CPStringBuilder sb, Class k) + { + // For some reason there's no easy way to get the signature of a + // class. + if (k.isPrimitive ()) + { + if (k == void.class) + sb.append('V'); + else if (k == boolean.class) + sb.append('Z'); + else if (k == byte.class) + sb.append('B'); + else if (k == char.class) + sb.append('C'); + else if (k == short.class) + sb.append('S'); + else if (k == int.class) + sb.append('I'); + else if (k == float.class) + sb.append('F'); + else if (k == double.class) + sb.append('D'); + else if (k == long.class) + sb.append('J'); + return; + } + + String name = k.getName (); + int len = name.length (); + sb.ensureCapacity (len); + if (! k.isArray ()) + sb.append('L'); + for (int i = 0; i < len; ++i) + { + char c = name.charAt (i); + if (c == '.') + c = '/'; + sb.append (c); + } + if (! k.isArray ()) + sb.append(';'); + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/VariableTable.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/VariableTable.java new file mode 100644 index 000000000..9732422f5 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/util/VariableTable.java @@ -0,0 +1,110 @@ +/* VariableTable.java -- A class representing a Variable Table for a method + Copyright (C) 2005, 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 +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.util; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * A class representing a Variable Table for a method. + * + * @author Aaron Luchko <aluchko@redhat.com> + */ +public class VariableTable +{ + + private final int argCnt; + + private final int slots; + + private final long[] lineCI; + + private int[] slot; + + private int[] lengths; + + private String[] sigs; + + private String[] names; + + /** + * Make a new variable table with the given values. + * + * @param argCnt number of words used by arguments in this frame + * @param slots number of variables + * @param lineCI first code index of given variable (size slots) + * @param names name of given variable (size slots) + * @param sigs signature of given variable (size slots) + * @param lengths size of region where variable is active (size slots) + * @param slot index of variable in this frame (size slots) + */ + public VariableTable(int argCnt, int slots, long lineCI[], String names[], + String sigs[], int lengths[], int slot[]) + { + this.argCnt = argCnt; + this.slots = slots; + this.lineCI = lineCI; + this.names = names; + this.sigs = sigs; + this.lengths = lengths; + this.slot = slot; + } + + /** + * Writes this line table to the given DataOutputStream. + * + * @param os the stream to write it to + * @throws IOException + */ + public void write(DataOutputStream os) throws IOException + { + os.writeInt(argCnt); + os.writeInt(slots); + for (int i = 0; i < slots; i++) + { + os.writeLong(lineCI[i]); + JdwpString.writeString(os, names[i]); + JdwpString.writeString(os, sigs[i]); + os.writeInt(lengths[i]); + os.writeInt(slot[i]); + } + } + +} |