harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r480141 [18/38] - in /harmony/enhanced/jdktools/trunk/modules/jpda: ./ doc/ doc/images/ make/ src/ src/common/ src/common/other/ src/common/other/jpda/ src/common/other/jpda/jdwp/ src/common/other/jpda/jdwp/agent/ src/common/other/jpda/jdwp...
Date Tue, 28 Nov 2006 17:49:31 GMT
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/JDWPConstants.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/JDWPConstants.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/JDWPConstants.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/JDWPConstants.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,801 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Aleksey V. Yantsen
+ * @version $Revision: 1.5 $
+ */
+
+/**
+ * Created on 10.25.2004
+ */
+package org.apache.harmony.jpda.tests.framework.jdwp;
+
+/**
+ * This class defines various constants from JDWP specifications.
+ * Each class has getName function to convert a constant value
+ * to string equivalent.
+ */
+public class JDWPConstants {
+
+    /**
+     * JDWP ThreadStatus constants
+     */
+    public static class ThreadStatus {
+
+        public static final byte ZOMBIE = 0;
+
+        public static final byte RUNNING = 1;
+
+        public static final byte SLEEPING = 2;
+
+        public static final byte MONITOR = 3;
+
+        public static final byte WAIT = 4;
+
+        /**
+         * Gets name for corresponding constant value.
+         * 
+         * @param status
+         *            a constant from ones declared in this class
+         * @return String
+         */
+        public static String getName(int status) {
+            switch (status) {
+            case ZOMBIE:
+                return "ZOMBIE";
+            case RUNNING:
+                return "RUNNING";
+            case SLEEPING:
+                return "SLEEPING";
+            case MONITOR:
+                return "MONITOR";
+            case WAIT:
+                return "WAIT";
+            default:
+                return "<unknown>";
+            }
+        }
+    }
+
+    /**
+     * JDWP SuspendStatus constants
+     */
+    public static class SuspendStatus {
+
+        public static final byte SUSPEND_STATUS_SUSPENDED = 1;
+
+        /**
+         * Gets name for corresponding constant value.
+         * 
+         * @param status
+         *            a constant from ones declared in this class
+         * @return String
+         */
+        public static String getName(int status) {
+            if (status == SUSPEND_STATUS_SUSPENDED)
+                return "SUSPENDED";
+            return "NONE";
+        }
+    }
+
+    /**
+     * JDWP ClassStatus constants
+     */
+    public static class ClassStatus {
+
+        public static final byte VERIFIED = 1;
+
+        public static final byte PREPARED = 2;
+
+        public static final byte INITIALIZED = 4;
+
+        public static final byte ERROR = 8;
+
+        // it looks like JDWP spec becomes out of date
+        // see JVMTI specification for GetClassStatus:
+        // 
+        public static final byte ARRAY = 16;
+
+        public static final byte PRIMITIVE = 32;
+
+        /**
+         * Gets name for corresponding constant value.
+         * 
+         * @param status
+         *            a constant from ones declared in this class
+         * @return String
+         */
+        public static String getName(int status) {
+
+            String returnValue = "";
+            if ((status & VERIFIED) == VERIFIED)
+                returnValue += "|VERIFIED";
+            if ((status & PREPARED) == PREPARED)
+                returnValue += "|PREPARED";
+            if ((status & INITIALIZED) == INITIALIZED)
+                returnValue += "|INITIALIZED";
+            if ((status & ERROR) == ERROR)
+                returnValue += "|ERROR";
+            if ((status & ARRAY) == ARRAY)
+                returnValue += "|ARRAY";
+            if ((status & PRIMITIVE) == PRIMITIVE)
+                returnValue += "|PRIMITIVE";
+
+            if (returnValue.equals("")) {
+                returnValue = "NONE";
+            } else {
+                returnValue = returnValue.substring(1);
+            }
+
+            return returnValue;
+        }
+    }
+
+    /**
+     * JDWP TypeTag constants
+     */
+    public static class TypeTag {
+
+        public static final byte CLASS = 1;
+
+        public static final byte INTERFACE = 2;
+
+        public static final byte ARRAY = 3;
+
+        /**
+         * Gets name for corresponding constant value.
+         * 
+         * @param refTypeTag
+         *            a constant from ones declared in this class
+         * @return String
+         */
+        public static String getName(byte refTypeTag) {
+            switch (refTypeTag) {
+            case CLASS:
+                return "CLASS";
+            case INTERFACE:
+                return "INTERFACE";
+            case ARRAY:
+                return "ARRAY";
+            default:
+                return "<unknown>";
+            }
+        }
+    }
+
+    /**
+     * JDWP Tag constants
+     */
+    public static class Tag {
+
+        public static final byte ARRAY_TAG = 91;
+
+        public static final byte BYTE_TAG = 66;
+
+        public static final byte CHAR_TAG = 67;
+
+        public static final byte OBJECT_TAG = 76;
+
+        public static final byte FLOAT_TAG = 70;
+
+        public static final byte DOUBLE_TAG = 68;
+
+        public static final byte INT_TAG = 73;
+
+        public static final byte LONG_TAG = 74;
+
+        public static final byte SHORT_TAG = 83;
+
+        public static final byte VOID_TAG = 86;
+
+        public static final byte BOOLEAN_TAG = 90;
+
+        public static final byte STRING_TAG = 115;
+
+        public static final byte THREAD_TAG = 116;
+
+        public static final byte THREAD_GROUP_TAG = 103;
+
+        public static final byte CLASS_LOADER_TAG = 108;
+
+        public static final byte CLASS_OBJECT_TAG = 99;
+
+        public static final byte NO_TAG = 0;
+
+        /**
+         * Gets name for corresponding constant value.
+         * 
+         * @param tag
+         *            a constant from ones declared in this class
+         * @return String
+         */
+        public static String getName(byte tag) {
+            switch (tag) {
+            case ARRAY_TAG:
+                return "ARRAY_TAG";
+            case BYTE_TAG:
+                return "BYTE_TAG";
+            case CHAR_TAG:
+                return "CHAR_TAG";
+            case OBJECT_TAG:
+                return "OBJECT_TAG";
+            case FLOAT_TAG:
+                return "FLOAT_TAG";
+            case DOUBLE_TAG:
+                return "DOUBLE_TAG";
+            case INT_TAG:
+                return "INT_TAG";
+            case LONG_TAG:
+                return "LONG_TAG";
+            case SHORT_TAG:
+                return "SHORT_TAG";
+            case VOID_TAG:
+                return "VOID_TAG";
+            case BOOLEAN_TAG:
+                return "BOOLEAN_TAG";
+            case STRING_TAG:
+                return "STRING_TAG";
+            case THREAD_TAG:
+                return "THREAD_TAG";
+            case THREAD_GROUP_TAG:
+                return "THREAD_GROUP_TAG";
+            case CLASS_LOADER_TAG:
+                return "CLASS_LOADER_TAG";
+            case CLASS_OBJECT_TAG:
+                return "CLASS_OBJECT_TAG";
+            case NO_TAG:
+                return "NO_TAG";
+            default:
+                return "<unknown>";
+            }
+        }
+    }
+
+    /**
+     * JDWP EventKind constants
+     */
+    public static class EventKind {
+
+        public static final byte SINGLE_STEP = 1;
+
+        public static final byte BREAKPOINT = 2;
+
+        public static final byte FRAME_POP = 3;
+
+        public static final byte EXCEPTION = 4;
+
+        public static final byte USER_DEFINED = 5;
+
+        public static final byte THREAD_START = 6;
+
+        public static final byte THREAD_END = 7;
+
+        public static final byte THREAD_DEATH = THREAD_END;
+
+        public static final byte CLASS_PREPARE = 8;
+
+        public static final byte CLASS_UNLOAD = 9;
+
+        public static final byte CLASS_LOAD = 10;
+
+        public static final byte FIELD_ACCESS = 20;
+
+        public static final byte FIELD_MODIFICATION = 21;
+
+        public static final byte EXCEPTION_CATCH = 30;
+
+        public static final byte METHOD_ENTRY = 40;
+
+        public static final byte METHOD_EXIT = 41;
+
+        public static final byte VM_INIT = 90;
+
+        public static final byte VM_START = VM_INIT;
+
+        public static final byte VM_DEATH = 99;
+
+        public static final byte VM_DISCONNECTED = 100;
+
+        /**
+         * Gets name for corresponding constant value.
+         * 
+         * @param eventKind
+         *            a constant from ones declared in this class
+         * @return String
+         */
+        public static String getName(byte eventKind) {
+            switch (eventKind) {
+            case SINGLE_STEP:
+                return "SINGLE_STEP";
+            case BREAKPOINT:
+                return "BREAKPOINT";
+            case FRAME_POP:
+                return "FRAME_POP";
+            case EXCEPTION:
+                return "EXCEPTION";
+            case USER_DEFINED:
+                return "USER_DEFINED";
+            case THREAD_START:
+                return "THREAD_START";
+            case THREAD_END:
+                return "THREAD_END";
+            case CLASS_PREPARE:
+                return "CLASS_PREPARE";
+            case CLASS_UNLOAD:
+                return "CLASS_UNLOAD";
+            case CLASS_LOAD:
+                return "CLASS_LOAD";
+            case FIELD_ACCESS:
+                return "FIELD_ACCESS";
+            case FIELD_MODIFICATION:
+                return "FIELD_MODIFICATION";
+            case EXCEPTION_CATCH:
+                return "EXCEPTION_CATCH";
+            case METHOD_ENTRY:
+                return "METHOD_ENTRY";
+            case METHOD_EXIT:
+                return "METHOD_EXIT";
+            case VM_INIT:
+                return "VM_INIT";
+            case VM_DEATH:
+                return "VM_DEATH";
+            case VM_DISCONNECTED:
+                return "VM_DISCONNECTED";
+            default:
+                return "<unknown>";
+            }
+        }
+    }
+
+    /**
+     * JDWP Error constants
+     */
+    public static class Error {
+
+        public static final int NONE = 0;
+
+        public static final int INVALID_THREAD = 10;
+
+        public static final int INVALID_THREAD_GROUP = 11;
+
+        public static final int INVALID_PRIORITY = 12;
+
+        public static final int THREAD_NOT_SUSPENDED = 13;
+
+        public static final int THREAD_SUSPENDED = 14;
+
+        public static final int INVALID_OBJECT = 20;
+
+        public static final int INVALID_CLASS = 21;
+
+        public static final int CLASS_NOT_PREPARED = 22;
+
+        public static final int INVALID_METHODID = 23;
+
+        public static final int INVALID_LOCATION = 24;
+
+        public static final int INVALID_FIELDID = 25;
+
+        public static final int INVALID_FRAMEID = 30;
+
+        public static final int NO_MORE_FRAMES = 31;
+
+        public static final int OPAQUE_FRAME = 32;
+
+        public static final int NOT_CURRENT_FRAME = 33;
+
+        public static final int TYPE_MISMATCH = 34;
+
+        public static final int INVALID_SLOT = 35;
+
+        public static final int DUPLICATE = 40;
+
+        public static final int NOT_FOUND = 41;
+
+        public static final int INVALID_MONITOR = 50;
+
+        public static final int NOT_MONITOR_OWNER = 51;
+
+        public static final int INTERRUPT = 52;
+
+        public static final int INVALID_CLASS_FORMAT = 60;
+
+        public static final int CIRCULAR_CLASS_DEFENITION = 61;
+
+        public static final int FAILS_VERIFICATION = 62;
+
+        public static final int ADD_METHOD_NOT_IMPLEMENTED = 63;
+
+        public static final int SCHEMA_CHANGE_NOT_IMPLEMENTED = 64;
+
+        public static final int INVALID_TYPESTATE = 65;
+
+        public static final int HIERARCHY_CHANGE_NOT_IMPLEMENTED = 66;
+
+        public static final int DELETE_METHOD_NOT_IMPLEMENTED = 67;
+
+        public static final int UNSUPPORTED_VERSION = 68;
+
+        public static final int NAMES_DONT_MATCH = 69;
+
+        public static final int CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED = 70;
+
+        public static final int METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED = 71;
+
+        public static final int NOT_IMPLEMENTED = 99;
+
+        public static final int NULL_POINTER = 100;
+
+        public static final int ABSENT_INFORMATION = 101;
+
+        public static final int INVALID_EVENT_TYPE = 102;
+
+        public static final int ILLEGAL_ARGUMENT = 103;
+
+        public static final int OUT_OF_MEMORY = 110;
+
+        public static final int ACCESS_DENIED = 111;
+
+        public static final int VM_DEAD = 112;
+
+        public static final int INTERNAL = 113;
+
+        public static final int UNATTACHED_THREAD = 115;
+
+        public static final int INVALID_TAG = 500;
+
+        public static final int ALREADY_INVOKING = 502;
+
+        public static final int INVALID_INDEX = 503;
+
+        public static final int INVALID_LENGTH = 504;
+
+        public static final int INVALID_STRING = 506;
+
+        public static final int INVALID_CLASS_LOADER = 507;
+
+        public static final int INVALID_ARRAY = 508;
+
+        public static final int TRANSPORT_LOAD = 509;
+
+        public static final int TRANSPORT_INIT = 510;
+
+        public static final int NATIVE_METHOD = 511;
+
+        public static final int INVALID_COUNT = 512;
+
+        /**
+         * Gets name for corresponding constant value.
+         * 
+         * @param errorCode
+         *            a constant from ones declared in this class
+         * @return String
+         */
+        public static String getName(int errorCode) {
+            switch (errorCode) {
+            case NONE:
+                return "NONE";
+            case INVALID_THREAD:
+                return "INVALID_THREAD";
+            case INVALID_THREAD_GROUP:
+                return "INVALID_THREAD_GROUP";
+            case INVALID_PRIORITY:
+                return "INVALID_PRIORITY";
+            case THREAD_NOT_SUSPENDED:
+                return "THREAD_NOT_SUSPENDED";
+            case THREAD_SUSPENDED:
+                return "THREAD_SUSPENDED";
+            case INVALID_OBJECT:
+                return "INVALID_OBJECT";
+            case INVALID_CLASS:
+                return "INVALID_CLASS";
+            case CLASS_NOT_PREPARED:
+                return "CLASS_NOT_PREPARED";
+            case INVALID_METHODID:
+                return "INVALID_METHODID";
+            case INVALID_LOCATION:
+                return "INVALID_LOCATION";
+            case INVALID_FIELDID:
+                return "INVALID_FIELDID";
+            case INVALID_FRAMEID:
+                return "INVALID_FRAMEID";
+            case NO_MORE_FRAMES:
+                return "NO_MORE_FRAMES";
+            case OPAQUE_FRAME:
+                return "OPAQUE_FRAME";
+            case NOT_CURRENT_FRAME:
+                return "NOT_CURRENT_FRAME";
+            case TYPE_MISMATCH:
+                return "TYPE_MISMATCH";
+            case INVALID_SLOT:
+                return "INVALID_SLOT";
+            case DUPLICATE:
+                return "DUPLICATE";
+            case NOT_FOUND:
+                return "NOT_FOUND";
+            case INVALID_MONITOR:
+                return "INVALID_MONITOR";
+            case NOT_MONITOR_OWNER:
+                return "NOT_MONITOR_OWNER";
+            case INTERRUPT:
+                return "INTERRUPT";
+            case INVALID_CLASS_FORMAT:
+                return "INVALID_CLASS_FORMAT";
+            case CIRCULAR_CLASS_DEFENITION:
+                return "CIRCULAR_CLASS_DEFENITION";
+            case FAILS_VERIFICATION:
+                return "FAILS_VERIFICATION";
+            case ADD_METHOD_NOT_IMPLEMENTED:
+                return "ADD_METHOD_NOT_IMPLEMENTED";
+            case SCHEMA_CHANGE_NOT_IMPLEMENTED:
+                return "SCHEMA_CHANGE_NOT_IMPLEMENTED";
+            case INVALID_TYPESTATE:
+                return "INVALID_TYPESTATE";
+            case HIERARCHY_CHANGE_NOT_IMPLEMENTED:
+                return "HIERARCHY_CHANGE_NOT_IMPLEMENTED";
+            case DELETE_METHOD_NOT_IMPLEMENTED:
+                return "DELETE_METHOD_NOT_IMPLEMENTED";
+            case UNSUPPORTED_VERSION:
+                return "UNSUPPORTED_VERSION";
+            case NAMES_DONT_MATCH:
+                return "NAMES_DONT_MATCH";
+            case CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED:
+                return "CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED";
+            case METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED:
+                return "METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED";
+            case NOT_IMPLEMENTED:
+                return "NOT_IMPLEMENTED";
+            case NULL_POINTER:
+                return "NULL_POINTER";
+            case ABSENT_INFORMATION:
+                return "ABSENT_INFORMATION";
+            case INVALID_EVENT_TYPE:
+                return "INVALID_EVENT_TYPE";
+            case ILLEGAL_ARGUMENT:
+                return "ILLEGAL_ARGUMENT";
+            case OUT_OF_MEMORY:
+                return "OUT_OF_MEMORY";
+            case ACCESS_DENIED:
+                return "ACCESS_DENIED";
+            case VM_DEAD:
+                return "VM_DEAD";
+            case INTERNAL:
+                return "INTERNAL";
+            case UNATTACHED_THREAD:
+                return "UNATTACHED_THREAD";
+            case INVALID_TAG:
+                return "INVALID_TAG";
+            case ALREADY_INVOKING:
+                return "ALREADY_INVOKING";
+            case INVALID_INDEX:
+                return "INVALID_INDEX";
+            case INVALID_LENGTH:
+                return "INVALID_LENGTH";
+            case INVALID_STRING:
+                return "INVALID_STRING";
+            case INVALID_CLASS_LOADER:
+                return "INVALID_CLASS_LOADER";
+            case INVALID_ARRAY:
+                return "INVALID_ARRAY";
+            case TRANSPORT_LOAD:
+                return "TRANSPORT_LOAD";
+            case TRANSPORT_INIT:
+                return "TRANSPORT_INIT";
+            case NATIVE_METHOD:
+                return "NATIVE_METHOD";
+            case INVALID_COUNT:
+                return "INVALID_COUNT";
+            default:
+                return "<unknown>";
+            }
+        }
+    }
+
+    /**
+     * JDWP StepDepth constants
+     */
+    public static class StepDepth {
+
+        public static final byte INTO = 0;
+
+        public static final byte OVER = 1;
+
+        public static final byte OUT = 2;
+
+        /**
+         * Gets name for corresponding constant value.
+         * 
+         * @param code
+         *            a constant from ones declared in this class
+         * @return String
+         */
+        public static String getName(int code) {
+            switch (code) {
+            case INTO:
+                return "INTO";
+            case OVER:
+                return "OVER";
+            case OUT:
+                return "OUT";
+            default:
+                return "<unknown>";
+            }
+        }
+    }
+
+    /**
+     * JDWP StepSize constants
+     */
+    public static class StepSize {
+
+        public static final byte MIN = 0;
+
+        public static final byte LINE = 1;
+
+        /**
+         * Gets name for corresponding constant value.
+         * 
+         * @param code
+         *            a constant from ones declared in this class
+         * @return String
+         */
+        public static String getName(int code) {
+            switch (code) {
+            case MIN:
+                return "MIN";
+            case LINE:
+                return "LINE";
+            default:
+                return "<unknown>";
+            }
+        }
+    }
+
+    /**
+     * JDWP SuspendPolicy constants
+     */
+    public static class SuspendPolicy {
+
+        public static final byte NONE = 0;
+
+        public static final byte EVENT_THREAD = 1;
+
+        public static final byte ALL = 2;
+
+        /**
+         * Gets name for corresponding constant value.
+         * 
+         * @param code
+         *            a constant from ones declared in this class
+         * @return String
+         */
+        public static String getName(int code) {
+            switch (code) {
+            case NONE:
+                return "NONE";
+            case EVENT_THREAD:
+                return "EVENT_THREAD";
+            case ALL:
+                return "ALL";
+            default:
+                return "<unknown>";
+            }
+        }
+    }
+
+    /**
+     * JDWP InvokeOptions constants
+     */
+    public static class InvokeOptions {
+        public static final byte INVOKE_SINGLE_THREADED = 0x01;
+
+        public static final byte INVOKE_NONVIRTUAL = 0x02;
+
+        /**
+         * Gets name for corresponding constant value.
+         * 
+         * @param code
+         *            a constant from ones declared in this class
+         * @return String
+         */
+        public static String getName(int code) {
+            String buf = "NONE";
+            if ((code & INVOKE_SINGLE_THREADED) != 0) {
+                buf += "|INVOKE_SINGLE_THREADED";
+            }
+            if ((code & INVOKE_NONVIRTUAL) != 0) {
+                buf += "|INVOKE_NONVIRTUAL";
+            }
+            if ((code & ~(INVOKE_SINGLE_THREADED | INVOKE_NONVIRTUAL)) != 0) {
+                buf += "|<unknown>";
+            }
+            return buf;
+        }
+    }
+
+    /**
+     * Field access flags
+     */
+    public static class FieldAccess {
+
+        /**
+         * Is public; may be accessed from outside its package; Any field.
+         */
+        public static final int ACC_PUBLIC = 0x0001;
+
+        /**
+         * Is private; usable only within the defining class; Class field.
+         */
+        public static final int ACC_PRIVATE = 0x0002;
+
+        /**
+         * Is protected; may be accessed within subclasses; Class field.
+         */
+        public static final int ACC_PROTECTED = 0x0004;
+
+        /**
+         * Is static; Any field.
+         */
+        public static final int ACC_STATIC = 0x0008;
+
+        /**
+         * Is final; no further overriding or assignment after initialization;
+         * Any field.
+         */
+        public static final int ACC_FINAL = 0x0010;
+
+        /**
+         * Is volatile; cannot be cached; Class field.
+         */
+        public static final int ACC_VOLATILE = 0x0040;
+
+        /**
+         * Is transient; not written or read by a persistent object manager;
+         * Class field.
+         */
+        public static final int ACC_TRANSIENT = 0x0080;
+
+        /**
+         * Gets name for corresponding constant value.
+         * 
+         * @param code
+         *            a constant from ones declared in this class
+         * @return String
+         */
+        public static String getName(int code) {
+            switch (code) {
+            case ACC_PUBLIC:
+                return "ACC_PUBLIC";
+            case ACC_PRIVATE:
+                return "ACC_PRIVATE";
+            case ACC_PROTECTED:
+                return "ACC_PROTECTED";
+            case ACC_STATIC:
+                return "ACC_STATIC";
+            case ACC_FINAL:
+                return "ACC_FINAL";
+            case ACC_VOLATILE:
+                return "ACC_VOLATILE";
+            case ACC_TRANSIENT:
+                return "ACC_TRANSIENT";
+            default:
+                return "<unknown>";
+            }
+        }
+    }
+}

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/JDWPConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/JDWPDebuggeeWrapper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/JDWPDebuggeeWrapper.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/JDWPDebuggeeWrapper.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/JDWPDebuggeeWrapper.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Aleksey V. Yantsen
+ * @version $Revision: 1.5 $
+ */
+
+/**
+ * Created on 10.25.2004
+ */
+package org.apache.harmony.jpda.tests.framework.jdwp;
+
+import org.apache.harmony.jpda.tests.framework.DebuggeeWrapper;
+import org.apache.harmony.jpda.tests.framework.LogWriter;
+import org.apache.harmony.jpda.tests.framework.TestErrorException;
+import org.apache.harmony.jpda.tests.framework.TestOptions;
+import org.apache.harmony.jpda.tests.framework.jdwp.TransportWrapper;
+import org.apache.harmony.jpda.tests.framework.jdwp.VmMirror;
+
+/**
+ * This class represents specific kind of <code>DebuggeeWrapper</code> for JDWP tests.
+ * It encapsulates JDWP connection and communicates with debuggee using 
+ * command, reply, and event packets.
+ */
+public abstract class JDWPDebuggeeWrapper extends DebuggeeWrapper {
+
+    public VmMirror vmMirror;
+
+    /**
+     * Creates an instance of JDWPDebuggeeWrapper.
+     * 
+     * @param settings test run options
+     * @param logWriter logWriter for messages
+     */
+    public JDWPDebuggeeWrapper(TestOptions settings, LogWriter logWriter) {
+        super(settings, logWriter);
+        vmMirror = createVmMirror(settings, logWriter);
+    }
+
+    /**
+     * Creates new instance of appropriate TransportWrapper.
+     * 
+     * @return new instance of TransportWrapper
+     */
+    public TransportWrapper createTransportWrapper() {
+        String name = settings.getTransportWrapperClassName();
+        try {
+            Class cls = Class.forName(name);
+            return (TransportWrapper) cls.newInstance();
+        } catch (Exception e) {
+            throw new TestErrorException(e);
+        }
+    }
+
+    /**
+     * Creates new instance of VmMirror.
+     * 
+     * @return new instance of VmMirror
+     */
+    protected VmMirror createVmMirror(TestOptions settings, LogWriter logWriter) {
+        return new VmMirror(settings, logWriter);
+    }
+
+    /**
+     * Returns opened JDWP connection or null.
+     * 
+     * @return JDWP connection or null
+     */
+    public TransportWrapper getConnection() {
+        return vmMirror.getConnection();
+    }
+
+    /**
+     * Sets opened JDWP connection.
+     * 
+     * @param connection to set
+     */
+    public void setConnection(TransportWrapper connection) {
+        vmMirror.setConnection(connection);
+    }
+   /**
+     * Resumes debuggee VM.
+     */
+    public void resume() {
+        vmMirror.resume();
+    }
+
+    /**
+     * Disposes debuggee VM.
+     */
+    public void dispose() {
+        vmMirror.dispose();
+    }
+
+    /**
+     * Exit target Virtual Machine
+     */
+    public void exit(int exitStatus) {
+        vmMirror.exit(exitStatus);
+    }
+    
+   
+}

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/JDWPDebuggeeWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/Location.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/Location.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/Location.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/Location.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Aleksey V. Yantsen
+ * @version $Revision: 1.3 $
+ */
+
+/**
+ * Created on 10.25.2004
+ */
+package org.apache.harmony.jpda.tests.framework.jdwp;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+
+/**
+ * This class represents Location value in JDWP packet.
+ */
+public class Location {
+    public byte tag;
+    public long classID;
+    public long methodID;
+    public long index;
+
+    /**
+     * Creates new Location value with empty data.
+     */
+    public Location() {
+        tag = JDWPConstants.Tag.NO_TAG;
+        classID = 0;
+        methodID = 0;
+        index = 0;
+    }
+
+    /**
+     * Creates new Location value with specified data.
+     */
+    Location(byte tag, long classID, long methodID, long index) {
+        this.tag = tag;
+        this.classID = classID;
+        this.methodID = methodID;
+        this.index = index;
+    }
+
+    /**
+     * Converts Location to string format for printing.
+     */
+    public String toString() {
+        return "Location: tag="+tag+", classID="+classID+", methodID="+methodID+", index="+index;
+    }
+    
+    /**
+     * Compares this with other Location object.
+     */
+    public boolean equals(Object obj) {
+        if (!(obj instanceof Location))
+            return false;
+        Location loc = (Location )obj;
+        return classID == loc.classID && methodID == loc.methodID
+                    && index == loc.index;
+        
+    }
+}
\ No newline at end of file

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/Location.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/Packet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/Packet.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/Packet.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/Packet.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,1304 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Khen G. Kim, Aleksey V. Yantsen
+ * @version $Revision: 1.6 $
+ */
+
+/**
+ * Created on 10.01.2004
+ */
+package org.apache.harmony.jpda.tests.framework.jdwp;
+
+import java.io.UnsupportedEncodingException;
+
+import org.apache.harmony.jpda.tests.framework.TestErrorException;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.TypesLengths;
+
+/**
+ * This base class represents JDWP packet.
+ */
+public class Packet {
+
+    public static final int REPLY_PACKET_FLAG = 0x80;
+
+    public static final int FLAGS_INDEX = 8;
+
+    public static final int HEADER_SIZE = 11;
+
+    /**
+     * The size in bytes of the BYTE type value.
+     */
+    protected static final int BYTE_SIZE = 1;
+
+    /**
+     * The size in bytes of the SHORT type value.
+     */
+    protected static final int SHORT_SIZE = 2;
+
+    /**
+     * The size in bytes of the INT type value.
+     */
+    protected static final int INT_SIZE = 4;
+
+    /**
+     * The size in bytes of the LONG type value.
+     */
+    protected static final int LONG_SIZE = 8;
+
+    private static final int LENGTH_INDEX = 0;
+
+    private static final int ID_INDEX = 4;
+
+    private int id;
+
+    private byte flags;
+
+    private int length;
+
+    private byte data[];
+
+    private int reading_data_index;
+
+    /**
+     * A constructor that creates an empty CommandPacket with empty header
+     * fields and no data.
+     */
+    public Packet() {
+        reading_data_index = 0;
+        data = new byte[0];
+    }
+
+    /**
+     * A constructor that creates Packet from array of bytes including header
+     * and data sections.
+     * 
+     * @param p array of bytes for new packet.
+     */
+    public Packet(byte p[]) {
+        length = (int) readFromByteArray(p, LENGTH_INDEX, INT_SIZE);
+        if (length < HEADER_SIZE) {
+            throw new TestErrorException(
+                    "Packet creation error: size of packet = " + length
+                            + "is less than header size = " + HEADER_SIZE);
+        }
+        id = (int) readFromByteArray(p, ID_INDEX, INT_SIZE);
+        flags = p[FLAGS_INDEX];
+        data = new byte[p.length - HEADER_SIZE];
+        System.arraycopy(p, HEADER_SIZE, data, 0, p.length - HEADER_SIZE);
+        reading_data_index = 0;
+    }
+
+    /**
+     * Gets the length value of the header of the Packet.
+     * 
+     * @return the length value of the header of the Packet.
+     */
+    public int getLength() {
+        return length;
+    }
+
+    /**
+     * Sets the id value of the header of the Packet.
+     * 
+     * @param i
+     *            the id value of the header of the Packet.
+     */
+    public void setId(int i) {
+        id = i;
+    }
+
+    /**
+     * Gets the id value of the header of the Packet.
+     * 
+     * @return the id value of the header of the Packet.
+     */
+    public int getId() {
+        return id;
+    }
+
+    /**
+     * Sets the flags value of the header of the Packet.
+     * 
+     * @param f
+     *            the flags value of the header of the Packet.
+     */
+    public void setFlags(byte f) {
+        flags = f;
+    }
+
+    /**
+     * Gets the flags value of the header of the Packet.
+     * 
+     * @return the flags value of the header of the Packet.
+     */
+    public byte getFlags() {
+        return flags;
+    }
+
+    /**
+     * Gets the flags value from the header of the Packet.
+     * 
+     * @param tag
+     *            Type tag (see JDWP.tag)
+     * @return the flags value of the header of the Packet.
+     */
+    public boolean isValuePrimitiveType(byte tag) {
+        switch (tag) {
+        case JDWPConstants.Tag.ARRAY_TAG: {
+            return false;
+        }
+        case JDWPConstants.Tag.BYTE_TAG: {
+            return true;
+        }
+        case JDWPConstants.Tag.CHAR_TAG: {
+            return true;
+        }
+        case JDWPConstants.Tag.OBJECT_TAG: {
+            return false;
+        }
+        case JDWPConstants.Tag.FLOAT_TAG: {
+            return true;
+        }
+        case JDWPConstants.Tag.DOUBLE_TAG: {
+            return true;
+        }
+        case JDWPConstants.Tag.INT_TAG: {
+            return true;
+        }
+        case JDWPConstants.Tag.LONG_TAG: {
+            return true;
+        }
+        case JDWPConstants.Tag.SHORT_TAG: {
+            return true;
+        }
+        case JDWPConstants.Tag.VOID_TAG: {
+            return true;
+        }
+        case JDWPConstants.Tag.BOOLEAN_TAG: {
+            return true;
+        }
+        case JDWPConstants.Tag.STRING_TAG: {
+            return false;
+        }
+        case JDWPConstants.Tag.THREAD_TAG: {
+            return false;
+        }
+        case JDWPConstants.Tag.THREAD_GROUP_TAG: {
+            return false;
+        }
+        case JDWPConstants.Tag.CLASS_LOADER_TAG: {
+            return false;
+        }
+        case JDWPConstants.Tag.CLASS_OBJECT_TAG: {
+            return false;
+        }
+        case JDWPConstants.Tag.NO_TAG: {
+            return true;
+        }
+        default: {
+            throw new TestErrorException("Improper JDWP.tag value = " + tag);
+        }
+        }
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as byte.
+     * 
+     * @param val
+     *            the byte value.
+     */
+    public void setNextValueAsByte(byte val) {
+        int new_data_size = data.length + BYTE_SIZE;
+        byte data_temp[] = data;
+        data = new byte[new_data_size];
+        System.arraycopy(data_temp, 0, data, 0, new_data_size - BYTE_SIZE);
+        data[new_data_size - BYTE_SIZE] = val;
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as byte.
+     * 
+     * @return the next value of the data of the Packet as byte.
+     */
+    public byte getNextValueAsByte() {
+        reading_data_index = reading_data_index + BYTE_SIZE;
+        return data[reading_data_index - BYTE_SIZE];
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as boolean.
+     * 
+     * @param val
+     *            the boolean value.
+     */
+    public void setNextValueAsBoolean(boolean val) {
+        int old_data_size = data.length;
+        int new_data_size = old_data_size
+                + TypesLengths.getTypeLength(TypesLengths.BOOLEAN_ID);
+        byte data_temp[] = data;
+        data = new byte[new_data_size];
+        System.arraycopy(data_temp, 0, data, 0, old_data_size);
+        if (val) {
+            data[old_data_size] = 1;
+        } else {
+            data[old_data_size] = 0;
+        }
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as boolean.
+     * 
+     * @return the next value of the data of the Packet as boolean.
+     */
+    public boolean getNextValueAsBoolean() {
+        int res = (int) data[reading_data_index] & 0xFF;
+        reading_data_index = reading_data_index
+                + TypesLengths.getTypeLength(TypesLengths.BOOLEAN_ID);
+        return (res != 0);
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as short.
+     * 
+     * @param val
+     *            the short value.
+     */
+    public void setNextValueAsShort(short val) {
+        int new_data_size = data.length
+                + TypesLengths.getTypeLength(TypesLengths.SHORT_ID);
+        byte data_temp[] = data;
+        data = new byte[new_data_size];
+        System.arraycopy(data_temp, 0, data, 0, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.SHORT_ID));
+        this.writeAtByteArray((long) val, data, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.SHORT_ID),
+                TypesLengths.getTypeLength(TypesLengths.SHORT_ID));
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as short.
+     * 
+     * @return the next value of the data of the Packet as short.
+     */
+    public short getNextValueAsShort() {
+        reading_data_index = reading_data_index
+                + TypesLengths.getTypeLength(TypesLengths.SHORT_ID);
+        return (short) readFromByteArray(data, reading_data_index
+                - TypesLengths.getTypeLength(TypesLengths.SHORT_ID),
+                TypesLengths.getTypeLength(TypesLengths.SHORT_ID));
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as int.
+     * 
+     * @param val
+     *            the int value.
+     */
+    public void setNextValueAsInt(int val) {
+        int new_data_size = data.length
+                + TypesLengths.getTypeLength(TypesLengths.INT_ID);
+        byte data_temp[] = data;
+        data = new byte[new_data_size];
+        System.arraycopy(data_temp, 0, data, 0, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.INT_ID));
+        this.writeAtByteArray((long) val, data, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.INT_ID), TypesLengths
+                .getTypeLength(TypesLengths.INT_ID));
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as int.
+     * 
+     * @return the next value of the data of the Packet as int.
+     */
+    public int getNextValueAsInt() {
+        reading_data_index = reading_data_index
+                + TypesLengths.getTypeLength(TypesLengths.INT_ID);
+        return (int) readFromByteArray(data, reading_data_index
+                - TypesLengths.getTypeLength(TypesLengths.INT_ID), TypesLengths
+                .getTypeLength(TypesLengths.INT_ID));
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as double.
+     * 
+     * @param dval
+     *            the double value.
+     */
+    public void setNextValueAsDouble(double dval) {
+        int new_data_size = data.length
+                + TypesLengths.getTypeLength(TypesLengths.DOUBLE_ID);
+        byte data_temp[] = data;
+        long val = Double.doubleToLongBits(dval);
+        data = new byte[new_data_size];
+        System.arraycopy(data_temp, 0, data, 0, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.DOUBLE_ID));
+        this.writeAtByteArray((long) val, data, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.DOUBLE_ID),
+                TypesLengths.getTypeLength(TypesLengths.DOUBLE_ID));
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as double.
+     * 
+     * @return the next value of the data of the Packet as double.
+     */
+    public double getNextValueAsDouble() {
+        reading_data_index = reading_data_index
+                + TypesLengths.getTypeLength(TypesLengths.DOUBLE_ID);
+        long res = readFromByteArray(data, reading_data_index
+                - TypesLengths.getTypeLength(TypesLengths.DOUBLE_ID),
+                TypesLengths.getTypeLength(TypesLengths.DOUBLE_ID));
+
+        return Double.longBitsToDouble(res);
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as float.
+     * 
+     * @param fval
+     *            the float value.
+     */
+    public void setNextValueAsFloat(float fval) {
+        int new_data_size = data.length
+                + TypesLengths.getTypeLength(TypesLengths.FLOAT_ID);
+        byte data_temp[] = data;
+        long val = Float.floatToIntBits(fval);
+        data = new byte[new_data_size];
+        System.arraycopy(data_temp, 0, data, 0, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.FLOAT_ID));
+        this.writeAtByteArray((long) val, data, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.FLOAT_ID),
+                TypesLengths.getTypeLength(TypesLengths.FLOAT_ID));
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as float.
+     * 
+     * @return the next value of the data of the Packet as float.
+     */
+    public float getNextValueAsFloat() {
+        reading_data_index = reading_data_index
+                + TypesLengths.getTypeLength(TypesLengths.FLOAT_ID);
+        long res = readFromByteArray(data, reading_data_index
+                - TypesLengths.getTypeLength(TypesLengths.FLOAT_ID),
+                TypesLengths.getTypeLength(TypesLengths.FLOAT_ID));
+
+        return Float.intBitsToFloat((int) res);
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as char.
+     * 
+     * @param val
+     *            the char value.
+     */
+    public void setNextValueAsChar(char val) {
+        int new_data_size = data.length
+                + TypesLengths.getTypeLength(TypesLengths.CHAR_ID);
+        byte data_temp[] = data;
+        data = new byte[new_data_size];
+        System.arraycopy(data_temp, 0, data, 0, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.CHAR_ID));
+        this.writeAtByteArray((long) val, data, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.CHAR_ID),
+                TypesLengths.getTypeLength(TypesLengths.CHAR_ID));
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as char.
+     * 
+     * @return the next value of the data of the Packet as char.
+     */
+    public char getNextValueAsChar() {
+        reading_data_index = reading_data_index
+                + TypesLengths.getTypeLength(TypesLengths.CHAR_ID);
+        return (char) readFromByteArray(data, reading_data_index
+                - TypesLengths.getTypeLength(TypesLengths.CHAR_ID),
+                TypesLengths.getTypeLength(TypesLengths.CHAR_ID));
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as long.
+     * 
+     * @param val
+     *            the long value.
+     */
+    public void setNextValueAsLong(long val) {
+        int new_data_size = data.length
+                + TypesLengths.getTypeLength(TypesLengths.LONG_ID);
+        byte data_temp[] = data;
+        data = new byte[new_data_size];
+        System.arraycopy(data_temp, 0, data, 0, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.LONG_ID));
+        this.writeAtByteArray(val, data, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.LONG_ID),
+                TypesLengths.getTypeLength(TypesLengths.LONG_ID));
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as long.
+     * 
+     * @return the next value of the data of the Packet as long.
+     */
+    public long getNextValueAsLong() {
+        reading_data_index = reading_data_index
+                + TypesLengths.getTypeLength(TypesLengths.LONG_ID);
+        return readFromByteArray(data, reading_data_index
+                - TypesLengths.getTypeLength(TypesLengths.LONG_ID),
+                TypesLengths.getTypeLength(TypesLengths.LONG_ID));
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as String in the "UTF-8"
+     * Charset.
+     * 
+     * @param val
+     *            the String in the "UTF-8" Charset.
+     */
+    public void setNextValueAsString(String val) {
+        byte data_temp[] = data;
+        byte val_as_bytes[];
+        try {
+            val_as_bytes = val.getBytes("UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new TestErrorException(e);
+        }
+        int new_data_size = data.length + val_as_bytes.length
+                + TypesLengths.getTypeLength(TypesLengths.INT_ID);
+        data = new byte[new_data_size];
+        System.arraycopy(data_temp, 0, data, 0, new_data_size
+                - val_as_bytes.length
+                - TypesLengths.getTypeLength(TypesLengths.INT_ID));
+        this.writeAtByteArray((long) val_as_bytes.length, data, new_data_size
+                - val_as_bytes.length
+                - TypesLengths.getTypeLength(TypesLengths.INT_ID), TypesLengths
+                .getTypeLength(TypesLengths.INT_ID));
+        System.arraycopy(val_as_bytes, 0, data, new_data_size
+                - val_as_bytes.length, val_as_bytes.length);
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as String in the "UTF-8"
+     * Charset.
+     * 
+     * @return the next value of the data of the Packet as String in the "UTF-8"
+     *         Charset.
+     */
+    public String getNextValueAsString() {
+        int string_length = this.getNextValueAsInt();
+        String res = null;
+        try {
+            res = new String(data, reading_data_index, string_length, "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new TestErrorException(e);
+        }
+        reading_data_index = reading_data_index + string_length;
+        return res;
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as objectID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * val value will be ignored.
+     * 
+     * @param val
+     *            the ObjectID value.
+     */
+    public void setNextValueAsObjectID(long val) {
+        if (TypesLengths.getTypeLength(TypesLengths.OBJECT_ID) < 0
+                || TypesLengths.getTypeLength(TypesLengths.OBJECT_ID) > 8) {
+            throw new TestErrorException("Improper ObjectID value length = "
+                    + TypesLengths.getTypeLength(TypesLengths.OBJECT_ID));
+        }
+        int new_data_size = data.length
+                + TypesLengths.getTypeLength(TypesLengths.OBJECT_ID);
+        byte data_temp[] = data;
+        data = new byte[new_data_size];
+        System.arraycopy(data_temp, 0, data, 0, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.OBJECT_ID));
+        this.writeAtByteArray(val, data, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.OBJECT_ID),
+                TypesLengths.getTypeLength(TypesLengths.OBJECT_ID));
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as objectID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public long getNextValueAsObjectID() {
+        if (TypesLengths.getTypeLength(TypesLengths.OBJECT_ID) < 0
+                || TypesLengths.getTypeLength(TypesLengths.OBJECT_ID) > 8) {
+            throw new TestErrorException("Improper ObjectID value length = "
+                    + TypesLengths.getTypeLength(TypesLengths.OBJECT_ID) + "!");
+        }
+        reading_data_index = reading_data_index
+                + TypesLengths.getTypeLength(TypesLengths.OBJECT_ID);
+        return (int) readFromByteArray(data, reading_data_index
+                - TypesLengths.getTypeLength(TypesLengths.OBJECT_ID),
+                TypesLengths.getTypeLength(TypesLengths.OBJECT_ID));
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as ThreadID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * val value will be ignored.
+     * 
+     * @param val
+     *            the ThreadID value.
+     */
+    public void setNextValueAsThreadID(long val) {
+        this.setNextValueAsObjectID(val);
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as ThreadID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public long getNextValueAsThreadID() {
+        return this.getNextValueAsObjectID();
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as ThreadGroupID
+     * VM-sensitive value. If length is less than 8 bytes, the appropriate high
+     * bits in the val value will be ignored.
+     * 
+     * @param val
+     *            the ThreadGroupID value.
+     */
+    public void setNextValueAsThreadGroupID(long val) {
+        this.setNextValueAsObjectID(val);
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as ThreadGroupID
+     * VM-sensitive value. If length is less than 8 bytes, the appropriate high
+     * bits in the returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public long getNextValueAsThreadGroupID() {
+        return this.getNextValueAsObjectID();
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as StringID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * val value will be ignored.
+     * 
+     * @param val
+     *            the StringID value.
+     */
+    public void setNextValueAsStringID(long val) {
+        this.setNextValueAsObjectID(val);
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as StringID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public long getNextValueAsStringID() {
+        return this.getNextValueAsObjectID();
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as ClassLoaderID
+     * VM-sensitive value. If length is less than 8 bytes, the appropriate high
+     * bits in the val value will be ignored.
+     * 
+     * @param val
+     *            the ClassLoaderID value.
+     */
+    public void setNextValueAsClassLoaderID(long val) {
+        this.setNextValueAsObjectID(val);
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as ClassLoaderID
+     * VM-sensitive value. If length is less than 8 bytes, the appropriate high
+     * bits in the returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public long getNextValueAsClassLoaderID() {
+        return this.getNextValueAsObjectID();
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as ClassObjectID
+     * VM-sensitive value. If length is less than 8 bytes, the appropriate high
+     * bits in the val value will be ignored.
+     * 
+     * @param val
+     *            the ClassObjectID value.
+     */
+    public void setNextValueAsClassObjectID(long val) {
+        this.setNextValueAsObjectID(val);
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as ClassObjectID
+     * VM-sensitive value. If length is less than 8 bytes, the appropriate high
+     * bits in the returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public long getNextValueAsClassObjectID() {
+        return this.getNextValueAsObjectID();
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as ArrayID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * val value will be ignored.
+     * 
+     * @param val
+     *            the ArrayID value.
+     */
+    public void setNextValueAsArrayID(long val) {
+        this.setNextValueAsObjectID(val);
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as ArrayID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public long getNextValueAsClassArrayID() {
+        return this.getNextValueAsObjectID();
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as ReferenceTypeID
+     * VM-sensitive value. If length is less than 8 bytes, the appropriate high
+     * bits in the val value will be ignored.
+     * 
+     * @param val
+     *            the ReferenceTypeID value.
+     */
+    public void setNextValueAsReferenceTypeID(long val) {
+        this.setNextValueAsObjectID(val);
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as ReferenceTypeID
+     * VM-sensitive value. If length is less than 8 bytes, the appropriate high
+     * bits in the returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public long getNextValueAsReferenceTypeID() {
+        return this.getNextValueAsObjectID();
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as ClassID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * val value will be ignored.
+     * 
+     * @param val
+     *            the ClassID value.
+     */
+    public void setNextValueAsClassID(long val) {
+        this.setNextValueAsObjectID(val);
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as ClassID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public long getNextValueAsClassID() {
+        return this.getNextValueAsObjectID();
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as InterfaceID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * val value will be ignored.
+     * 
+     * @param val
+     *            the InterfaceID value.
+     */
+    public void setNextValueAsInterfaceID(long val) {
+        this.setNextValueAsObjectID(val);
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as InterfaceID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public long getNextValueAsInterfaceID() {
+        return this.getNextValueAsObjectID();
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as ArrayTypeID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * val value will be ignored.
+     * 
+     * @param val
+     *            the ArrayTypeID value.
+     */
+    public void setNextValueAsArrayTypeID(long val) {
+        this.setNextValueAsObjectID(val);
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as ArrayTypeID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public long getNextValueAsArrayTypeID() {
+        return this.getNextValueAsObjectID();
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as tagged-objectID
+     * VM-sensitive value. If length is less than 8 bytes, the appropriate high
+     * bits in the val value will be ignored.
+     * 
+     * @param taggedObject
+     *            TaggedObject value.
+     */
+    public void setNextValueAsTaggedObject(TaggedObject taggedObject) {
+        this.setNextValueAsByte(taggedObject.tag);
+        this.setNextValueAsObjectID(taggedObject.objectID);
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as tagged-objectID
+     * VM-sensitive value. If length is less than 8 bytes, the appropriate high
+     * bits in the returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public TaggedObject getNextValueAsTaggedObject() {
+        if (TypesLengths.getTypeLength(TypesLengths.OBJECT_ID) < 0
+                || TypesLengths.getTypeLength(TypesLengths.OBJECT_ID) > 8) {
+            throw new TestErrorException("Improper ObjectID value length = "
+                    + TypesLengths.getTypeLength(TypesLengths.OBJECT_ID));
+        }
+        TaggedObject taggedObject = new TaggedObject();
+        taggedObject.tag = this.getNextValueAsByte();
+        taggedObject.objectID = this.getNextValueAsObjectID();
+        return taggedObject;
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as MethodID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * val value will be ignored.
+     * 
+     * @param methodID
+     *            MethodID value.
+     */
+    public void setNextValueAsMethodID(long methodID) {
+        if (TypesLengths.getTypeLength(TypesLengths.METHOD_ID) < 0
+                || TypesLengths.getTypeLength(TypesLengths.METHOD_ID) > 8) {
+            throw new TestErrorException("Improper MethodID value length = "
+                    + TypesLengths.getTypeLength(TypesLengths.METHOD_ID));
+        }
+        int new_data_size = data.length
+                + TypesLengths.getTypeLength(TypesLengths.METHOD_ID);
+        byte data_temp[] = data;
+        data = new byte[new_data_size];
+        System.arraycopy(data_temp, 0, data, 0, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.METHOD_ID));
+        this.writeAtByteArray(methodID, data, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.METHOD_ID),
+                TypesLengths.getTypeLength(TypesLengths.METHOD_ID));
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as MethodID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public long getNextValueAsMethodID() {
+        if (TypesLengths.getTypeLength(TypesLengths.METHOD_ID) < 0
+                || TypesLengths.getTypeLength(TypesLengths.METHOD_ID) > 8) {
+            throw new TestErrorException("Improper MethodID value length = "
+                    + TypesLengths.getTypeLength(TypesLengths.METHOD_ID));
+        }
+        reading_data_index = reading_data_index
+                + TypesLengths.getTypeLength(TypesLengths.METHOD_ID);
+        long result = readFromByteArray(data, reading_data_index
+                - TypesLengths.getTypeLength(TypesLengths.METHOD_ID),
+                TypesLengths.getTypeLength(TypesLengths.METHOD_ID));
+        return result;
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as FieldID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * val value will be ignored.
+     * 
+     * @param fieldID
+     *            FieldID value.
+     */
+    public void setNextValueAsFieldID(long fieldID) {
+        if (TypesLengths.getTypeLength(TypesLengths.FIELD_ID) < 0
+                || TypesLengths.getTypeLength(TypesLengths.FIELD_ID) > 8) {
+            throw new TestErrorException("Improper FieldID value length = "
+                    + TypesLengths.getTypeLength(TypesLengths.FIELD_ID));
+        }
+        int new_data_size = data.length
+                + TypesLengths.getTypeLength(TypesLengths.FIELD_ID);
+        byte data_temp[] = data;
+        data = new byte[new_data_size];
+        System.arraycopy(data_temp, 0, data, 0, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.FIELD_ID));
+        this.writeAtByteArray(fieldID, data, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.FIELD_ID),
+                TypesLengths.getTypeLength(TypesLengths.FIELD_ID));
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as FieldID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public long getNextValueAsFieldID() {
+        if (TypesLengths.getTypeLength(TypesLengths.FIELD_ID) < 0
+                || TypesLengths.getTypeLength(TypesLengths.FIELD_ID) > 8) {
+            throw new TestErrorException("Improper FieldID value length = "
+                    + TypesLengths.getTypeLength(TypesLengths.FIELD_ID));
+        }
+        reading_data_index = reading_data_index
+                + TypesLengths.getTypeLength(TypesLengths.FIELD_ID);
+        long result = readFromByteArray(data, reading_data_index
+                - TypesLengths.getTypeLength(TypesLengths.FIELD_ID),
+                TypesLengths.getTypeLength(TypesLengths.FIELD_ID));
+        return result;
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as FrameID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * val value will be ignored.
+     * 
+     * @param frameID
+     *            FrameID value.
+     */
+    public void setNextValueAsFrameID(long frameID) {
+        if (TypesLengths.getTypeLength(TypesLengths.FRAME_ID) < 0
+                || TypesLengths.getTypeLength(TypesLengths.FRAME_ID) > 8) {
+            throw new TestErrorException("Improper FrameID value length = "
+                    + TypesLengths.getTypeLength(TypesLengths.FRAME_ID));
+        }
+        int new_data_size = data.length
+                + TypesLengths.getTypeLength(TypesLengths.FRAME_ID);
+        byte data_temp[] = data;
+        data = new byte[new_data_size];
+        System.arraycopy(data_temp, 0, data, 0, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.FRAME_ID));
+        this.writeAtByteArray(frameID, data, new_data_size
+                - TypesLengths.getTypeLength(TypesLengths.FRAME_ID),
+                TypesLengths.getTypeLength(TypesLengths.FRAME_ID));
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as FrameID VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public long getNextValueAsFrameID() {
+        if (TypesLengths.getTypeLength(TypesLengths.FRAME_ID) < 0
+                || TypesLengths.getTypeLength(TypesLengths.FRAME_ID) > 8) {
+            throw new TestErrorException("Improper FrameID value length = "
+                    + TypesLengths.getTypeLength(TypesLengths.FRAME_ID));
+        }
+        reading_data_index = reading_data_index
+                + TypesLengths.getTypeLength(TypesLengths.FRAME_ID);
+        long result = readFromByteArray(data, reading_data_index
+                - TypesLengths.getTypeLength(TypesLengths.FRAME_ID),
+                TypesLengths.getTypeLength(TypesLengths.FRAME_ID));
+        return result;
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as Location VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * val value will be ignored.
+     * 
+     * @param location
+     *            Location value.
+     */
+    public void setNextValueAsLocation(Location location) {
+        this.setNextValueAsByte(location.tag);
+        this.setNextValueAsClassID(location.classID);
+        this.setNextValueAsMethodID(location.methodID);
+        this.setNextValueAsLong(location.index);
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as Location VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public Location getNextValueAsLocation() {
+        Location location = new Location();
+        location.tag = this.getNextValueAsByte();
+        location.classID = this.getNextValueAsClassID();
+        location.methodID = this.getNextValueAsMethodID();
+        location.index = this.getNextValueAsLong();
+        return location;
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as Value VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * val value will be ignored.
+     * 
+     * @param value
+     *            Value value.
+     * @throws UnsupportedEncodingException
+     */
+    public void setNextValueAsValue(Value value) {
+        this.setNextValueAsByte(value.getTag());
+        setNextValueAsUntaggedValue(value);
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as Value VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public Value getNextValueAsValue() {
+        byte tag = this.getNextValueAsByte();
+        return getNextValueAsUntaggedValue(tag);
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as UntaggedValue
+     * VM-sensitive value. If length is less than 8 bytes, the appropriate high
+     * bits in the val value will be ignored.
+     * 
+     * @param value
+     *            UntaggedValue value.
+     * @throws UnsupportedEncodingException
+     */
+    public void setNextValueAsUntaggedValue(Value value) {
+        switch (value.getTag()) {
+        case JDWPConstants.Tag.BOOLEAN_TAG:
+            this.setNextValueAsBoolean(value.getBooleanValue());
+            break;
+        case JDWPConstants.Tag.BYTE_TAG:
+            this.setNextValueAsByte(value.getByteValue());
+            break;
+        case JDWPConstants.Tag.CHAR_TAG:
+            this.setNextValueAsChar(value.getCharValue());
+            break;
+        case JDWPConstants.Tag.DOUBLE_TAG:
+            this.setNextValueAsDouble(value.getDoubleValue());
+            break;
+        case JDWPConstants.Tag.FLOAT_TAG:
+            this.setNextValueAsFloat(value.getFloatValue());
+            break;
+        case JDWPConstants.Tag.INT_TAG:
+            this.setNextValueAsInt(value.getIntValue());
+            break;
+        case JDWPConstants.Tag.LONG_TAG:
+            this.setNextValueAsLong(value.getLongValue());
+            break;
+        case JDWPConstants.Tag.SHORT_TAG:
+            this.setNextValueAsShort(value.getShortValue());
+            break;
+        case JDWPConstants.Tag.STRING_TAG:
+        case JDWPConstants.Tag.ARRAY_TAG:
+        case JDWPConstants.Tag.CLASS_LOADER_TAG:
+        case JDWPConstants.Tag.CLASS_OBJECT_TAG:
+        case JDWPConstants.Tag.OBJECT_TAG:
+        case JDWPConstants.Tag.THREAD_GROUP_TAG:
+        case JDWPConstants.Tag.THREAD_TAG:
+            this.setNextValueAsObjectID(value.getLongValue());
+            break;
+        default:
+            throw new TestErrorException("Illegal tag value = "
+                    + value.getTag());
+        }
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as UntaggedValue
+     * VM-sensitive value. If length is less than 8 bytes, the appropriate high
+     * bits in the returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public Value getNextValueAsUntaggedValue(byte tag) {
+        Value value = null;
+        switch (tag) {
+        case JDWPConstants.Tag.BOOLEAN_TAG:
+            value = new Value(this.getNextValueAsBoolean());
+            break;
+        case JDWPConstants.Tag.BYTE_TAG:
+            value = new Value(this.getNextValueAsByte());
+            break;
+        case JDWPConstants.Tag.CHAR_TAG:
+            value = new Value(this.getNextValueAsChar());
+            break;
+        case JDWPConstants.Tag.DOUBLE_TAG:
+            value = new Value(this.getNextValueAsDouble());
+            break;
+        case JDWPConstants.Tag.FLOAT_TAG:
+            value = new Value(this.getNextValueAsFloat());
+            break;
+        case JDWPConstants.Tag.INT_TAG:
+            value = new Value(this.getNextValueAsInt());
+            break;
+        case JDWPConstants.Tag.LONG_TAG:
+            value = new Value(this.getNextValueAsLong());
+            break;
+        case JDWPConstants.Tag.SHORT_TAG:
+            value = new Value(this.getNextValueAsShort());
+            break;
+        case JDWPConstants.Tag.STRING_TAG:
+        case JDWPConstants.Tag.ARRAY_TAG:
+        case JDWPConstants.Tag.CLASS_LOADER_TAG:
+        case JDWPConstants.Tag.CLASS_OBJECT_TAG:
+        case JDWPConstants.Tag.OBJECT_TAG:
+        case JDWPConstants.Tag.THREAD_GROUP_TAG:
+        case JDWPConstants.Tag.THREAD_TAG:
+            value = new Value(tag, this.getNextValueAsObjectID());
+            break;
+        default:
+            throw new TestErrorException("Illegal tag value = " + tag);
+        }
+        return value;
+    }
+
+    /**
+     * Sets the next value of the data of the Packet as ArrayRegion VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * val value will be ignored.
+     * 
+     * @param array
+     *            ArrayRegion value.
+     * @throws UnsupportedEncodingException
+     */
+    // public void setNextValueAsArrayRegion(ArrayRegion array) throws
+    // UnsupportedEncodingException {
+    public void setNextValueAsArrayRegion(ArrayRegion array) {
+        this.setNextValueAsByte(array.getTag());
+        this.setNextValueAsInt(array.getLength());
+        for (int i = 0; i < array.getLength(); i++) {
+            if (isValuePrimitiveType(array.getTag())) {
+                switch (array.getTag()) {
+                case JDWPConstants.Tag.BOOLEAN_TAG:
+                    this.setNextValueAsBoolean(array.getValue(i)
+                            .getBooleanValue());
+                    break;
+                case JDWPConstants.Tag.BYTE_TAG:
+                    this.setNextValueAsByte(array.getValue(i).getByteValue());
+                    break;
+                case JDWPConstants.Tag.DOUBLE_TAG:
+                    this.setNextValueAsDouble(array.getValue(i)
+                            .getDoubleValue());
+                    break;
+                case JDWPConstants.Tag.FLOAT_TAG:
+                    this.setNextValueAsFloat(array.getValue(i).getFloatValue());
+                    break;
+                case JDWPConstants.Tag.INT_TAG:
+                    this.setNextValueAsInt(array.getValue(i).getIntValue());
+                    break;
+                case JDWPConstants.Tag.LONG_TAG:
+                    this.setNextValueAsLong(array.getValue(i).getLongValue());
+                    break;
+                case JDWPConstants.Tag.SHORT_TAG:
+                    this.setNextValueAsShort(array.getValue(i).getShortValue());
+                    break;
+                default:
+                    throw new TestErrorException("Illegal tag value = "
+                            + array.getTag());
+                }
+            } else {
+                this.setNextValueAsValue(array.getValue(i));
+            }
+        }
+    }
+
+    /**
+     * Gets the next value of the data of the Packet as ArrayRegion VM-sensitive
+     * value. If length is less than 8 bytes, the appropriate high bits in the
+     * returned value can be ignored.
+     * 
+     * @return the next value of the data of the Packet as VM-sensitive value.
+     */
+    public ArrayRegion getNextValueAsArrayRegion() {
+        byte array_tag = this.getNextValueAsByte();
+        int array_length = this.getNextValueAsInt();
+
+        ArrayRegion array = new ArrayRegion(array_tag, array_length);
+
+        for (int i = 0; i < array_length; i++) {
+            if (isValuePrimitiveType(array_tag))
+                array.setValue(i, this.getNextValueAsUntaggedValue(array_tag));
+            else
+                array.setValue(i, this.getNextValueAsValue());
+        }
+        return array;
+    }
+
+    /**
+     * Gets the representation of the Packet as array of bytes in the JDWP
+     * format including header and data sections.
+     * 
+     * @return bytes representation of this packet
+     */
+    public byte[] toBytesArray() {
+        byte res[] = new byte[data.length + HEADER_SIZE];
+        writeAtByteArray(data.length + HEADER_SIZE, res, LENGTH_INDEX, INT_SIZE);
+        writeAtByteArray(id, res, ID_INDEX, INT_SIZE);
+        res[FLAGS_INDEX] = flags;
+        System.arraycopy(data, 0, res, HEADER_SIZE, data.length);
+        return res;
+    }
+
+    /**
+     * Reads value from array of bytes ar[] starting form index and reading size
+     * bytes. If size is less than 8, the appropriate high bits in the resulting
+     * long value will be zero.
+     * 
+     * @param ar
+     *            the array of bytes where the value is read from.
+     * @param from
+     *            index to start reading bytes.
+     * @param size
+     *            number of bytes to read
+     */
+    protected static long readFromByteArray(byte ar[], int from, int size) {
+        long res = 0;
+        byte temp;
+        for (int i = 0; i < size; i++) {
+            temp = ar[from + i];
+            res = (res << 8) | (((long) temp) & 0xFF);
+        }
+        return res;
+    }
+
+    /**
+     * Tells whether the packet is reply.
+     * 
+     * @return true if this packet is reply, false if it is command
+     */
+    public boolean isReply() {
+        return (flags & REPLY_PACKET_FLAG) != 0;
+    }
+
+    /**
+     * Checks whether all data has been read from the packet.
+     * 
+     * @return boolean
+     */
+    public boolean isAllDataRead() {
+        return reading_data_index == data.length;
+    }
+
+    /**
+     * Writes value - val to the array of bytes ar[], beginning from index - to,
+     * size of value is - size bytes. If size is less than 8, the appropriate
+     * high bits in the val value will be ignored.
+     * 
+     * @param val
+     *            the value, which will be written in the array.
+     * @param ar
+     *            the array of bytes where the value is read from.
+     * @param to
+     *            the beginning index in the array of bytes.
+     * @param size
+     *            size of value in bytes.
+     */
+    protected void writeAtByteArray(long val, byte ar[], int to, int size) {
+        for (int i = 0; i < size; i++) {
+            ar[to + i] = (byte) (val >> 8 * (size - 1 - i));
+        }
+    }
+
+    /**
+     * Returns true if this bytes array can be interpreted as reply packet.
+     * 
+     * @param p
+     *            bytes representation of packet
+     * @return true or false
+     */
+    public static boolean isReply(byte[] p) {
+        if (p.length < FLAGS_INDEX)
+            return false;
+        return (p[FLAGS_INDEX] & REPLY_PACKET_FLAG) != 0;
+    }
+
+    /**
+     * Returns packet length from header of given packet bytes.
+     * 
+     * @param p
+     *            bytes representation of packet
+     * @return true or false
+     */
+    public static int getPacketLength(byte[] p) {
+        return (int) readFromByteArray(p, LENGTH_INDEX, INT_SIZE);
+    }
+
+    /**
+     * Enwraps this bytes array either to ReplyPacket or EventPacket instance,
+     * according to result of isReply().
+     * 
+     * @param p
+     *            bytes array to enwrap into packet
+     * @return new created ReplyPacket or CommandPacket
+     */
+    public static Packet interpretPacket(byte[] p) {
+        if (p.length < HEADER_SIZE)
+            throw new TestErrorException("Wrong packet");
+        if (Packet.isReply(p))
+            return new ReplyPacket(p);
+        return new EventPacket(p);
+    }
+}

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/framework/jdwp/Packet.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message