harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lvj...@apache.org
Subject svn commit: r635886 - in /harmony/enhanced/jdktools/branches/java6/modules/jpda: make/ src/main/native/jdwp/common/agent/commands/ src/main/native/jdwp/common/agent/core/ src/main/native/jdwp/common/generic/ src/main/native/jdwp/unix/agent/ src/main/na...
Date Tue, 11 Mar 2008 11:11:32 GMT
Author: lvjing
Date: Tue Mar 11 04:11:20 2008
New Revision: 635886

URL: http://svn.apache.org/viewvc?rev=635886&view=rev
Log:
Apply patch for HARMONY-5591,[jdktools][jdwp6] Add new jdwp command "InstanceCount" for jdwp
6

Added:
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CallBacks.cpp
  (with props)
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CallBacks.h
  (with props)
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/InstanceCountsDebuggee.java
  (with props)
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/InstanceCountsTest.java
  (with props)
Modified:
    harmony/enhanced/jdktools/branches/java6/modules/jpda/make/exclude.common
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.h
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/VirtualMachine.cpp
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/VirtualMachine.h
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandDispatcher.cpp
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/agent/makefile
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/makefile
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/TestOptions.java
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/JDWPCommands.java

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/make/exclude.common
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/make/exclude.common?rev=635886&r1=635885&r2=635886&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/make/exclude.common (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/make/exclude.common Tue Mar 11 04:11:20
2008
@@ -11,4 +11,6 @@
 #5564
 org/apache/harmony/jpda/tests/jdwp/ReferenceType/InstancesTest.java
 #5587
-org/apache/harmony/jpda/tests/jdwp/ReferenceType/ConstantPoolTest
\ No newline at end of file
+org/apache/harmony/jpda/tests/jdwp/ReferenceType/ConstantPoolTest
+#5591
+org/apache/harmony/jpda/tests/jdwp/VirtualMachine/InstanceCountsTest

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp?rev=635886&r1=635885&r2=635886&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp
(original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp
Tue Mar 11 04:11:20 2008
@@ -23,10 +23,12 @@
 #include "ReferenceType.h"
 #include "PacketParser.h"
 #include "ClassManager.h"
+#include "CallBacks.h"
 #include <cstring>
 
 using namespace jdwp;
 using namespace ReferenceType;
+using namespace CallBacks;
 
 //------------------------------------------------------------------------------
 //SignatureFileHandler(1)----------------------------------------------------------
@@ -884,19 +886,22 @@
     hcbs.string_primitive_value_callback = &StringPrimitiveValueCallback;
 
     jvmtiError err;
+    //This tag is used to mark instance that is reachable for garbage collection purpose
+    const jlong tag_value = 0xfffff;
+
     //It initiates a traversal over the objects that are directly and indirectly reachable
from the heap roots.
     JVMTI_TRACE(err, GetJvmtiEnv()->FollowReferences(0, jvmClass,  NULL,
-         &hcbs, NULL));
+         &hcbs, &tag_value));
      if (err != JVMTI_ERROR_NONE) {
         // Can be: JVMTI_ERROR_MUST_POSSESS_CAPABILITY, JVMTI_ERROR_INVALID_CLASS
         // JVMTI_ERROR_INVALID_OBJECT, JVMTI_ERROR_NULL_POINTER 
         throw AgentException(err);
      }
 
-     const jlong tags[1] = {EXPECTED_INSTANCE_TAG};
-     int reachableInstancesNum = 0;
+     const jlong tags[1] = {tag_value};
+     jint reachableInstancesNum = 0;
      jobject * pResultObjects = 0;
-     // Return the instances that have been marked EXPECTED_INSTANCE_TAG tag.
+     // Return the instances that have been marked expectd tag_value tag.
      JVMTI_TRACE(err, GetJvmtiEnv()->GetObjectsWithTags(1, tags, &reachableInstancesNum,
             &pResultObjects, NULL));
      JvmtiAutoFree afResultObjects(pResultObjects);
@@ -1021,69 +1026,3 @@
 
 }
 
-//-----------------------------------------------------------------------------
-// Heap callbacks, used in Instances command
-//-----------------------------------------------------------------------------
-
-     /**
-     * Describes a reference from an object or the VM (the referrer) 
-     * to another object (the referree) or a heap root to a referree. 
-     */
-     jint JNICALL ReferenceType::HeapReferenceCallback
-        (jvmtiHeapReferenceKind reference_kind, 
-         const jvmtiHeapReferenceInfo* reference_info, 
-         jlong class_tag, 
-         jlong referrer_class_tag, 
-         jlong size, 
-         jlong* tag_ptr, 
-         jlong* referrer_tag_ptr, 
-         jint length, 
-         void* user_data) {
-            *tag_ptr = EXPECTED_INSTANCE_TAG;
-            return JVMTI_VISIT_OBJECTS;
-     }
-
-    /**
-     * This callback will describe a static field if the object is a class, 
-     * and otherwise will describe an instance field. 
-     */
-     jint JNICALL ReferenceType::PrimitiveFieldCallback
-        (jvmtiHeapReferenceKind kind, 
-         const jvmtiHeapReferenceInfo* info, 
-         jlong object_class_tag, 
-         jlong* object_tag_ptr, 
-         jvalue value, 
-         jvmtiPrimitiveType value_type, 
-         void* user_data) {
-              *object_tag_ptr = EXPECTED_INSTANCE_TAG;
-              return JVMTI_VISIT_OBJECTS;
-     }
-     
-    /**
-     * Describes the values in an array of a primitive type.
-     */
-     jint JNICALL ReferenceType::ArrayPrimitiveValueCallback
-        (jlong class_tag, 
-         jlong size, 
-         jlong* tag_ptr, 
-         jint element_count, 
-         jvmtiPrimitiveType element_type, 
-         const void* elements, 
-         void* user_data) {
-             *tag_ptr = EXPECTED_INSTANCE_TAG;
-             return JVMTI_VISIT_OBJECTS;
-     }
-     
-    /**
-     * Describes the value of a java.lang.String. 
-     */ 
-     jint JNICALL ReferenceType::StringPrimitiveValueCallback
-        (jlong class_tag, 
-         jlong size, 
-         jlong* tag_ptr, 
-         const jchar* value, 
-         jint value_length, 
-         void* user_data) {
-             *tag_ptr = EXPECTED_INSTANCE_TAG;
-             return JVMTI_VISIT_OBJECTS;
-     }

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.h?rev=635886&r1=635885&r2=635886&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.h
(original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.h
Tue Mar 11 04:11:20 2008
@@ -33,10 +33,6 @@
 #include "AgentException.h"
 #include "CommandHandler.h"
 
-//This tag is used to mark instance that is reachable for garbage collection purpose
-//It will be used in Instances command
-#define   EXPECTED_INSTANCE_TAG  0xfffff
-
 namespace jdwp {
 
     /**
@@ -403,59 +399,6 @@
         };//ConstantPoolHandler class
 
    // =========================================================================
-   //-----------------------------------------------------------------------------
-   // Heap callbacks, used in Instances command
-   //-----------------------------------------------------------------------------
-    /**
-     * Describes a reference from an object or the VM (the referrer) 
-     * to another object (the referree) or a heap root to a referree. 
-     */
-     jint JNICALL HeapReferenceCallback
-        (jvmtiHeapReferenceKind reference_kind, 
-         const jvmtiHeapReferenceInfo* reference_info, 
-         jlong class_tag, 
-         jlong referrer_class_tag, 
-         jlong size, 
-         jlong* tag_ptr, 
-         jlong* referrer_tag_ptr, 
-         jint length, 
-         void* user_data) ;
-
-    /**
-     * This callback will describe a static field if the object is a class, 
-     * and otherwise will describe an instance field. 
-     */
-     jint JNICALL PrimitiveFieldCallback
-        (jvmtiHeapReferenceKind kind, 
-         const jvmtiHeapReferenceInfo* info, 
-         jlong object_class_tag, 
-         jlong* object_tag_ptr, 
-         jvalue value, 
-         jvmtiPrimitiveType value_type, 
-         void* user_data);
-     
-    /**
-     * Describes the values in an array of a primitive type.
-     */
-     jint JNICALL ArrayPrimitiveValueCallback
-        (jlong class_tag, 
-         jlong size, 
-         jlong* tag_ptr, 
-         jint element_count, 
-         jvmtiPrimitiveType element_type, 
-         const void* elements, 
-         void* user_data);
-     
-    /**
-     * Describes the value of a java.lang.String. 
-     */ 
-     jint JNICALL StringPrimitiveValueCallback
-        (jlong class_tag, 
-         jlong size, 
-         jlong* tag_ptr, 
-         const jchar* value, 
-         jint value_length, 
-         void* user_data);
 
     } // ReferenceType namespace
 

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/VirtualMachine.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/VirtualMachine.cpp?rev=635886&r1=635885&r2=635886&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/VirtualMachine.cpp
(original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/VirtualMachine.cpp
Tue Mar 11 04:11:20 2008
@@ -31,9 +31,11 @@
 #include "ObjectManager.h"
 #include "EventDispatcher.h"
 #include "TransportManager.h"
+#include "CallBacks.h"
 
 using namespace jdwp;
 using namespace VirtualMachine;
+using namespace CallBacks;
 
 //-----------------------------------------------------------------------------
 //VersionHandler---------------------------------------------------------------
@@ -767,6 +769,85 @@
          << JDWP_CHECK_NULL(generic) << ", status=" << status);
 
     return 0;
+}
+
+// New command for Java 6
+//-----------------------------------------------------------------------------
+//InstanceCountsHandler-------------------------------------------------
+
+void
+VirtualMachine::InstanceCountsHandler::Execute(JNIEnv *jni) throw(AgentException)
+{
+    jint refTypesCount = m_cmdParser->command.ReadInt();
+    // Illegal argument
+    if(refTypesCount < 0) {
+        throw AgentException(JDWP_ERROR_ILLEGAL_ARGUMENT);
+    }
+
+    m_cmdParser->reply.WriteInt(refTypesCount);
+    JDWP_TRACE_DATA("InstanceCounts: return the number of counts that follow:" << refTypesCount);
+
+    // Number of reference types equals zero
+    if(0 == refTypesCount) {
+        return;
+    }
+
+    jclass jvmClass;
+    jvmtiError err;
+    char* signature = 0;
+    // Tag is used to mark object which is reported in FollowReferences
+    jlong tag_value = 0xffff;
+    jlong tags[1] = {tag_value};
+    jint reachableInstancesNum = 0;
+
+    // Initial callbacks for FollowReferences
+    // These callbacks will tag the expected objects which are reported in FollowReferences
+    jvmtiHeapCallbacks hcbs;
+    memset(&hcbs, 0, sizeof(hcbs));
+    hcbs.heap_iteration_callback = NULL;
+    hcbs.heap_reference_callback = &HeapReferenceCallback;
+    hcbs.primitive_field_callback = &PrimitiveFieldCallback;
+    hcbs.array_primitive_value_callback = &ArrayPrimitiveValueCallback;
+    hcbs.string_primitive_value_callback = &StringPrimitiveValueCallback;
+
+    for(int i = 0; i < refTypesCount;i++) {
+         jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni);
+        // Can be: InternalErrorException, OutOfMemoryException,
+        // JDWP_ERROR_INVALID_CLASS, JDWP_ERROR_INVALID_OBJECT
+#ifndef NDEBUG
+        if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
+            JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature,
0));
+            JvmtiAutoFree afcs(signature);
+            JDWP_TRACE_DATA("SourceDebugExtension: received: refTypeID=" << jvmClass
+                << ", classSignature=" << JDWP_CHECK_NULL(signature));
+        }
+#endif
+        
+        //It initiates a traversal over the objects that are directly and indirectly reachable
from the heap roots.
+        JVMTI_TRACE(err, GetJvmtiEnv()->FollowReferences(0, jvmClass,  NULL,
+             &hcbs, &tag_value));
+        if (err != JVMTI_ERROR_NONE) {
+            // Can be: JVMTI_ERROR_MUST_POSSESS_CAPABILITY, JVMTI_ERROR_INVALID_CLASS
+            // JVMTI_ERROR_INVALID_OBJECT, JVMTI_ERROR_NULL_POINTER 
+            throw AgentException(err);
+        }
+
+        // Return the instances that have been marked expected tag_value tag.
+        JVMTI_TRACE(err, GetJvmtiEnv()->GetObjectsWithTags(1, tags, &reachableInstancesNum,
+            NULL, NULL));
+  
+        if (err != JVMTI_ERROR_NONE) {
+            // Can be: JVMTI_ERROR_MUST_POSSESS_CAPABILITY, JVMTI_ERROR_ILLEGAL_ARGUMENT

+            // JVMTI_ERROR_ILLEGAL_ARGUMENT, JVMTI_ERROR_NULL_POINTER  
+            throw AgentException(err);
+        }
+
+        m_cmdParser->reply.WriteLong(reachableInstancesNum);
+        JDWP_TRACE_DATA("InstanceCounts: return the number of instances for the corresponding
 reference type:"
+            << reachableInstancesNum);
+        // tag_value is changed to indicate instances of other types 
+        tags[0] = ++tag_value;
+    }
 }
 
 //-----------------------------------------------------------------------------

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/VirtualMachine.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/VirtualMachine.h?rev=635886&r1=635885&r2=635886&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/VirtualMachine.h
(original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/VirtualMachine.h
Tue Mar 11 04:11:20 2008
@@ -417,6 +417,23 @@
 
         };//AllClassesWithGenericHandler
 
+        // New command for Java 6
+        /**
+         * The class implements the <code>InstanceCounts</code> command from
the
+         * VirtualMachine command set.
+         */
+        class InstanceCountsHandler : public SyncCommandHandler {
+        protected:
+
+            /**
+             * Executes the <code>InstanceCounts</code> JDWP command for the
+             * VirtualMachine command set.
+             *
+             * @param jni - the JNI interface pointer
+             */
+            virtual void Execute(JNIEnv *jni) throw(AgentException);
+
+        };//InstanceCountsHandler
     } // VirtualMachine
 
 } //jdwp

Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CallBacks.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CallBacks.cpp?rev=635886&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CallBacks.cpp
(added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CallBacks.cpp
Tue Mar 11 04:11:20 2008
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#include "CallBacks.h"
+
+using namespace jdwp;
+using namespace CallBacks;
+
+//-----------------------------------------------------------------------------
+// Heap callbacks, used in Instances, InstanceCounts command
+//-----------------------------------------------------------------------------
+
+     /**
+     * Describes a reference from an object or the VM (the referrer) 
+     * to another object (the referree) or a heap root to a referree. 
+     */
+    jint JNICALL CallBacks::HeapReferenceCallback
+        (jvmtiHeapReferenceKind reference_kind, 
+         const jvmtiHeapReferenceInfo* reference_info, 
+         jlong class_tag, 
+         jlong referrer_class_tag, 
+         jlong size, 
+         jlong* tag_ptr, 
+         jlong* referrer_tag_ptr, 
+         jint length, 
+         void* user_data) {
+             jlong tag_value = *(static_cast<jlong *>(user_data));
+            *tag_ptr = tag_value;
+            return JVMTI_VISIT_OBJECTS;
+     }
+
+    /**
+     * This callback will describe a static field if the object is a class, 
+     * and otherwise will describe an instance field. 
+     */
+     jint JNICALL CallBacks::PrimitiveFieldCallback
+        (jvmtiHeapReferenceKind kind, 
+         const jvmtiHeapReferenceInfo* info, 
+         jlong object_class_tag, 
+         jlong* object_tag_ptr, 
+         jvalue value, 
+         jvmtiPrimitiveType value_type, 
+         void* user_data) {
+             jlong tag_value = *(static_cast<jlong *>(user_data));
+              *object_tag_ptr = tag_value;
+              return JVMTI_VISIT_OBJECTS;
+     }
+     
+    /**
+     * Describes the values in an array of a primitive type.
+     */
+     jint JNICALL CallBacks::ArrayPrimitiveValueCallback
+        (jlong class_tag, 
+         jlong size, 
+         jlong* tag_ptr, 
+         jint element_count, 
+         jvmtiPrimitiveType element_type, 
+         const void* elements, 
+         void* user_data) {
+             jlong tag_value = *(static_cast<jlong *>(user_data));
+             *tag_ptr = tag_value;
+             return JVMTI_VISIT_OBJECTS;
+     }
+     
+    /**
+     * Describes the value of a java.lang.String. 
+     */ 
+     jint JNICALL CallBacks::StringPrimitiveValueCallback
+        (jlong class_tag, 
+         jlong size, 
+         jlong* tag_ptr, 
+         const jchar* value, 
+         jint value_length, 
+         void* user_data) {
+             jlong tag_value = *(static_cast<jlong *>(user_data));
+             *tag_ptr = tag_value;
+             return JVMTI_VISIT_OBJECTS;
+     }

Propchange: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CallBacks.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CallBacks.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CallBacks.h?rev=635886&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CallBacks.h
(added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CallBacks.h
Tue Mar 11 04:11:20 2008
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#ifndef _CALL_BACKS_H_
+#define _CALL_BACKS_H_
+
+#include "jni.h"
+#include "jvmti.h"
+
+namespace jdwp {
+
+     //-----------------------------------------------------------------------------
+   // Heap callbacks, used in Instances, InstanceCounts command
+   //-----------------------------------------------------------------------------
+    namespace CallBacks {
+        /**
+         * Describes a reference from an object or the VM (the referrer) 
+        * to another object (the referree) or a heap root to a referree. 
+        */
+        jint JNICALL HeapReferenceCallback
+        (jvmtiHeapReferenceKind reference_kind, 
+         const jvmtiHeapReferenceInfo* reference_info, 
+         jlong class_tag, 
+         jlong referrer_class_tag, 
+         jlong size, 
+         jlong* tag_ptr, 
+         jlong* referrer_tag_ptr, 
+         jint length, 
+         void* user_data) ;
+
+        /**
+        * This callback will describe a static field if the object is a class, 
+        * and otherwise will describe an instance field. 
+        */
+        jint JNICALL PrimitiveFieldCallback
+        (jvmtiHeapReferenceKind kind, 
+         const jvmtiHeapReferenceInfo* info, 
+         jlong object_class_tag, 
+         jlong* object_tag_ptr, 
+         jvalue value, 
+         jvmtiPrimitiveType value_type, 
+         void* user_data);
+     
+        /**
+        * Describes the values in an array of a primitive type.
+        */
+         jint JNICALL ArrayPrimitiveValueCallback
+        (jlong class_tag, 
+         jlong size, 
+         jlong* tag_ptr, 
+         jint element_count, 
+         jvmtiPrimitiveType element_type, 
+         const void* elements, 
+         void* user_data);
+     
+        /**
+        * Describes the value of a java.lang.String. 
+        */ 
+        jint JNICALL StringPrimitiveValueCallback
+        (jlong class_tag, 
+         jlong size, 
+         jlong* tag_ptr, 
+         const jchar* value, 
+         jint value_length, 
+         void* user_data);
+    } //CallBacks namespace
+} // jdwp namesoace
+#endif//_CALL_BACKS_H_
\ No newline at end of file

Propchange: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CallBacks.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandDispatcher.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandDispatcher.cpp?rev=635886&r1=635885&r2=635886&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandDispatcher.cpp
(original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandDispatcher.cpp
Tue Mar 11 04:11:20 2008
@@ -197,6 +197,10 @@
         case JDWP_COMMAND_VM_ALL_CLASSES_WITH_GENERIC:
             return new VirtualMachine::AllClassesWithGenericHandler();
 
+        // New commands for Java 6
+        case JDWP_COMMAND_VM_INSTANCE_COUNTS:
+            return new VirtualMachine::InstanceCountsHandler();
+
         }//JDWP_COMMAND_SET_VIRTUAL_MACHINE
         break;
 

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h?rev=635886&r1=635885&r2=635886&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h
(original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h
Tue Mar 11 04:11:20 2008
@@ -83,6 +83,8 @@
     JDWP_COMMAND_VM_REDEFINE_CLASSES = 18,
     JDWP_COMMAND_VM_SET_DEFAULT_STRATUM = 19,
     JDWP_COMMAND_VM_ALL_CLASSES_WITH_GENERIC= 20,
+	//New commands for Java 6
+    JDWP_COMMAND_VM_INSTANCE_COUNTS = 21,
 
     /* Commands ReferenceType */
     JDWP_COMMAND_RT_SIGNATURE = 1,

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/agent/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/agent/makefile?rev=635886&r1=635885&r2=635886&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/agent/makefile
(original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/agent/makefile
Tue Mar 11 04:11:20 2008
@@ -53,6 +53,7 @@
     $(CMNAGENT)core/ObjectManager.o $(CMNAGENT)core/OptionParser.o $(CMNAGENT)core/PacketDispatcher.o
\
     $(CMNAGENT)core/PacketParser.o $(CMNAGENT)core/RequestManager.o $(CMNAGENT)core/RequestModifier.o
\
     $(CMNAGENT)core/ThreadManager.o $(CMNAGENT)core/TransportManager.o $(CMNAGENT)core/AgentManager.o
\
+    $(CMNAGENT)core/CallBacks.o \
     core/TransportManager_pd.o
 
 MDLLIBFILES = 

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/makefile?rev=635886&r1=635885&r2=635886&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/makefile
(original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/makefile
Tue Mar 11 04:11:20 2008
@@ -55,6 +55,7 @@
     $(CMNAGENT)core\ObjectManager.obj $(CMNAGENT)core\OptionParser.obj $(CMNAGENT)core\PacketDispatcher.obj
\
     $(CMNAGENT)core\PacketParser.obj $(CMNAGENT)core\RequestManager.obj $(CMNAGENT)core\RequestModifier.obj
\
     $(CMNAGENT)core\ThreadManager.obj $(CMNAGENT)core\TransportManager.obj $(CMNAGENT)core\AgentManager.obj
\
+    $(CMNAGENT)core\CallBacks.obj \
     core\TransportManager_pd.obj
 
 VIRTFILES = 

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/TestOptions.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/TestOptions.java?rev=635886&r1=635885&r2=635886&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/TestOptions.java
(original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/TestOptions.java
Tue Mar 11 04:11:20 2008
@@ -216,7 +216,7 @@
 
         return getProperty("jpda.settings.debuggeeAgentOptions",
                 "transport=dt_socket,address=" + address + ",server=" + serv
-                + ",suspend=" + getDebuggeeSuspend() + agentExtraOptions);
+                + ",suspend=" + getDebuggeeSuspend() + agentExtraOptions + ",trace=all");
     }
 
     /**

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/JDWPCommands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/JDWPCommands.java?rev=635886&r1=635885&r2=635886&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/JDWPCommands.java
(original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/JDWPCommands.java
Tue Mar 11 04:11:20 2008
@@ -77,6 +77,8 @@
         public static final byte SetDefaultStratumCommand = 19;
 
         public static final byte AllClassesWithGenericCommand = 20;
+        
+        public static final byte InstanceCountsCommand = 21;
     }
 
     /**

Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/InstanceCountsDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/InstanceCountsDebuggee.java?rev=635886&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/InstanceCountsDebuggee.java
(added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/InstanceCountsDebuggee.java
Tue Mar 11 04:11:20 2008
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
+
+import java.util.ArrayList;
+import java.util.Random;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class InstanceCountsDebuggee extends SyncDebuggee {
+
+	static final int maxNum = 17;
+	
+	static int reachableObjNumOfClass1;
+	
+	static int reachableObjNumOfClass2;
+    
+	static {
+        reachableObjNumOfClass1 = new Random().nextInt(maxNum) + 2;
+        reachableObjNumOfClass2 = new Random().nextInt(maxNum) + 2;
+	}
+
+	@SuppressWarnings("unchecked")
+    @Override
+	public void run() {
+		//Objects reachable for garbage collection purpose
+		ArrayList reachableObjs = new ArrayList();
+        
+		for(int i = 0; i < reachableObjNumOfClass1; i++) {
+			reachableObjs.add(new MockClass1(true));
+		}
+        for(int i = 0; i < reachableObjNumOfClass2; i++) {
+            reachableObjs.add(new MockClass2(true));
+        }
+       
+		//Objects unreachable
+		for(int i = 0; i < reachableObjNumOfClass1/2; i++) {
+			new MockClass1(false);
+		}
+        for(int i = 0; i < reachableObjNumOfClass2/2; i++) {
+            new MockClass2(false);
+        }
+        
+		synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        logWriter.println("--> Debuggee: InstancesDebuggee...");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+	}
+
+	public static void main(String[] args) {
+		runDebuggee(InstanceCountsDebuggee.class);
+	}
+
+}
+
+class MockClass1 {
+	private boolean isReachable;
+	MockClass1(boolean isReachable){
+		this.isReachable = isReachable;
+	}
+}
+
+class MockClass2{
+    private boolean isReachable;
+    
+    MockClass2(boolean isReachable){
+        this.isReachable = isReachable;
+    }    
+}

Propchange: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/InstanceCountsDebuggee.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/InstanceCountsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/InstanceCountsTest.java?rev=635886&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/InstanceCountsTest.java
(added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/InstanceCountsTest.java
Tue Mar 11 04:11:20 2008
@@ -0,0 +1,254 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.Value;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+public class InstanceCountsTest extends JDWPSyncTestCase {
+
+    static final int testStatusPassed = 0;
+
+    static final int testStatusFailed = -1;
+
+    static final String thisCommandName = "VirtualMachine.InstanceCounts command ";
+
+    static final String mockClass1Signature = "Lorg/apache/harmony/jpda/tests/jdwp/VirtualMachine/MockClass1;";
+    
+    static final String mockClass2Signature = "Lorg/apache/harmony/jpda/tests/jdwp/VirtualMachine/MockClass2;";
+
+    static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/VirtualMachine/InstanceCountsDebuggee;";
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.VirtualMachine.InstanceCountsDebuggee";
+    }
+    
+    // InstanceCounts need canGetInstanceInfo VM capability support
+    private boolean isCapability() {
+        // check capability, relevant for this test
+        logWriter.println("=> Check capability: canGetInstanceInfo");
+        debuggeeWrapper.vmMirror.capabilities();
+        boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canGetInstanceInfo;
+        return isCapability;
+    }
+
+    /**
+     * This testcase exercises VirtualMachine.InstanceCounts command.
+     * <BR>The test starts InstanceCountsDebuggee class, requests referenceTypeId,

+     * MockClass1, MockClass2 for this class by VirtualMachine.ClassesBySignature command,

+     * then performs VirtualMachine.InstanceCounts command and checks that returned
+     * Reachable Objects of MockClass1 and MockClass2 are equal to the actual ones.
+     */
+    public void testInstanceCounts_Normal() {
+        String thisTestName = "testInstanceCounts_Normal";
+
+        if (!isCapability()) {
+            logWriter.println("##WARNING: this VM dosn't possess capability: canGetInstanceInfo");
+            return;
+        }
+
+        logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        long debuggeeRefTypeID = getClassIDBySignature(debuggeeSignature);
+        long mockClassRefTypeIDOfClass1 = getClassIDBySignature(mockClass1Signature);
+        long mockClassRefTypeIDOfClass2 = getClassIDBySignature(mockClass2Signature);
+
+        //Get the number of reachable objects of MockClass1 and MockClass2 in debuggee class
+        long reachableObjNumOfClass1ID = debuggeeWrapper.vmMirror.getFieldID(
+                debuggeeRefTypeID, "reachableObjNumOfClass1");
+        long reachableObjNumOfClass2ID = debuggeeWrapper.vmMirror.getFieldID(
+                debuggeeRefTypeID, "reachableObjNumOfClass2");
+        
+        long[] fieldIDs = new long[2];
+        fieldIDs[0] = reachableObjNumOfClass1ID;
+        fieldIDs[1] = reachableObjNumOfClass2ID;
+
+        Value[] values = debuggeeWrapper.vmMirror.getReferenceTypeValues(
+                debuggeeRefTypeID, fieldIDs);
+        int expectedObjNumOfClass1 = values[0].getIntValue();
+        int expectedObjNumOfClass2 = values[1].getIntValue();
+        
+        logWriter.println("=> ReachableObjNum of MockClass1 in debuggee is: " + expectedObjNumOfClass1);
+        logWriter.println("=> ReachableObjNum of MockClass2 in debuggee is: " + expectedObjNumOfClass2);
+        
+        logWriter.println("=> CHECK: send " + thisCommandName
+                + " and check reply for ERROR...");
+
+        // Compose InstanceCounts commnad
+        CommandPacket InstanceCountsCommand = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.InstanceCountsCommand);
+        
+        final int refTypesCount = 2;
+        InstanceCountsCommand.setNextValueAsInt(refTypesCount);
+        InstanceCountsCommand.setNextValueAsReferenceTypeID(mockClassRefTypeIDOfClass1);
+        InstanceCountsCommand.setNextValueAsReferenceTypeID(mockClassRefTypeIDOfClass2);
+
+        // Perform InstanceCounts command and attain reply package
+        ReplyPacket checkedReply = debuggeeWrapper.vmMirror
+                .performCommand(InstanceCountsCommand);
+        InstanceCountsCommand = null;
+
+        short errorCode = checkedReply.getErrorCode();
+        if (errorCode != JDWPConstants.Error.NONE) {
+            if (errorCode == JDWPConstants.Error.NOT_IMPLEMENTED) {
+                logWriter.println("=> CHECK PASSED: Expected error (NOT_IMPLEMENTED) is
returned");
+                return;
+            }
+            else if(errorCode == JDWPConstants.Error.ILLEGAL_ARGUMENT) {
+                logWriter.println("=> CHECK PASSED: Expected error (ILLEGAL_ARGUMENT)
is returned");
+                return;
+            }
+        }
+
+        //Check the reference types count that returned. 
+        int returnedRefTypesCount = checkedReply.getNextValueAsInt();
+        assertEquals(thisCommandName + "returned reference types count is wrong.",
+                refTypesCount, returnedRefTypesCount, null, null);
+        logWriter.println("=> CHECK: PASSED: expected reference types count is returned:");
+        logWriter.println("=> Returned reference types count is " + returnedRefTypesCount);
+
+        long returnedObjNumOfClass1 = checkedReply.getNextValueAsLong();
+        assertEquals(thisCommandName + "returned instance count of MockClass1 is wrong.",
+                expectedObjNumOfClass1, returnedObjNumOfClass1, null, null);
+        logWriter.println("=> CHECK: PASSED: expected instance count of MockClass1 is
returned:");
+        logWriter.println("=> Returned instance count of MockClass1 is " + returnedObjNumOfClass1);
+
+        long returnedObjNumOfClass2 = checkedReply.getNextValueAsLong();
+        assertEquals(thisCommandName + "returned instance count of MockClass2 is wrong.",
+                expectedObjNumOfClass2, returnedObjNumOfClass2, null, null);
+        logWriter.println("=> CHECK: PASSED: expected instance count of MockClass2 is
returned:");
+        logWriter.println("=> Returned instance count of MockClass2 is " + returnedObjNumOfClass2);
+        
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+        assertAllDataRead(checkedReply);
+    }
+
+    /**
+     * This testcase exercises ReferenceType.InstanceCounts command. <BR>
+     * Compose a InstanceCounts command with negative reference types count
+     * The vm should throw a ILLEGAL_ARGUMENT exception.
+     */
+    public void testInstanceCounts_IllegalArgument() {
+        String thisTestName = "testInstanceCounts_IllegalArgument";
+        
+        if (!isCapability()) {
+            logWriter.println("##WARNING: this VM dosn't possess capability: canGetInstanceInfo");
+            return;
+        }
+        
+        int refTypesCount = -1;
+        
+        logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        // Compose InstanceCounts commnad
+        CommandPacket InstanceCountsCommand = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.InstanceCountsCommand);
+        
+        InstanceCountsCommand.setNextValueAsInt(refTypesCount);
+        InstanceCountsCommand.setNextValueAsReferenceTypeID(0);
+        
+        // Perform InstanceCounts command and attain reply package
+        ReplyPacket checkedReply = debuggeeWrapper.vmMirror
+                .performCommand(InstanceCountsCommand);
+        InstanceCountsCommand = null;
+
+        short errorCode = checkedReply.getErrorCode();
+        if (errorCode != JDWPConstants.Error.NONE) {
+            if (errorCode == JDWPConstants.Error.NOT_IMPLEMENTED) {
+                logWriter.println("=> CHECK PASSED: Expected error (NOT_IMPLEMENTED) is
returned");
+                return;
+            }
+            else if(errorCode == JDWPConstants.Error.ILLEGAL_ARGUMENT) {
+                logWriter.println("=> CHECK PASSED: Expected error (ILLEGAL_ARGUMENT)
is returned");
+                return;
+            }
+        }
+        printErrorAndFail(thisCommandName + " should throw ILLEGAL_ARGUMENT exception when
refTypesCount is negative.");
+    }
+    
+
+    /**
+     * This testcase exercises ReferenceType.InstanceCounts command. <BR>
+     * Compose a InstanceCounts command with zero reference types count.
+     * The data following the reference types count should be ignored.
+     * And debuggee vm should return a package with zero reference types count.
+     */
+    public void testInstanceCounts_Zero() {
+        String thisTestName = "testInstanceCounts_Zero";
+        
+        if (!isCapability()) {
+            logWriter.println("##WARNING: this VM dosn't possess capability: canGetInstanceInfo");
+            return;
+        }
+        
+        int refTypesCount = 0;
+        
+        logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        // Compose InstanceCounts commnad
+        CommandPacket InstanceCountsCommand = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.InstanceCountsCommand);
+        
+        InstanceCountsCommand.setNextValueAsInt(refTypesCount);
+        InstanceCountsCommand.setNextValueAsReferenceTypeID(0);
+        
+        // Perform InstanceCounts command and attain reply package
+        ReplyPacket checkedReply = debuggeeWrapper.vmMirror
+                .performCommand(InstanceCountsCommand);
+        InstanceCountsCommand = null;
+
+        short errorCode = checkedReply.getErrorCode();
+        if (errorCode != JDWPConstants.Error.NONE) {
+            if (errorCode == JDWPConstants.Error.NOT_IMPLEMENTED) {
+                logWriter.println("=> CHECK PASSED: Expected error (NOT_IMPLEMENTED) is
returned");
+                return;
+            }
+            else if(errorCode == JDWPConstants.Error.ILLEGAL_ARGUMENT) {
+                logWriter.println("=> CHECK PASSED: Expected error (ILLEGAL_ARGUMENT)
is returned");
+                return;
+            }
+        }
+        
+        int returnedRefTypesCount = checkedReply.getNextValueAsInt();
+        assertEquals(thisCommandName + "returned reference types count is wrong.",
+                refTypesCount, returnedRefTypesCount, null, null);
+        
+        logWriter.println("=> CHECK: PASSED: expected reference types count is returned:");
+        logWriter.println("=> Returned reference types count is " + returnedRefTypesCount);
+        assertAllDataRead(checkedReply); 
+    }
+    
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(InstanceCountsTest.class);
+
+    }
+
+}

Propchange: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/InstanceCountsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message