harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r794726 [7/15] - in /harmony/enhanced/jdktools/branches/java6/modules/jpda: ./ src/main/native/include/ src/main/native/jdwp/common/agent/commands/ src/main/native/jdwp/common/agent/core/ src/main/native/jdwp/common/generic/ src/main/native...
Date Thu, 16 Jul 2009 15:57:41 GMT
Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/AgentManager.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/AgentManager.h?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/AgentManager.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/AgentManager.h Thu Jul 16 15:57:37 2009
@@ -15,19 +15,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
-/**
- * @file
- * ClassManager.h
- *
- * Provides access to certain standard Java classes.
- */
-
-/**
- * @author Aleksander V. Budniy
- * @version $Revision: 1.10.2.1 $
- */
-
 /**
  * @file
  * ClassManager.h
@@ -54,59 +41,59 @@
         /**
          * A constructor.
          */
-        AgentManager() throw() {
+        AgentManager() {
             m_isStarted = false;
         }
 
         /**
          * A destructor.
          */
-        ~AgentManager() throw () {
+        ~AgentManager() {
         }
         
         /**
          * Initializes all agent modules.
          */
-        void Init(jvmtiEnv *jvmti, JNIEnv *jni) throw (AgentException);
+        int Init(jvmtiEnv *jvmti, JNIEnv *jni);
 
         /**
          * Start all agent threads.
          */
-        void Start(jvmtiEnv *jvmti, JNIEnv *jni) throw (AgentException);
+        int Start(jvmtiEnv *jvmti, JNIEnv *jni);
 
         /**
          * Stop all agent threads.
          */
-        void Stop(JNIEnv *jni) throw (AgentException);
+        void Stop(JNIEnv *jni);
 
         /**
          * Clean all agent modules.
          */
-        void Clean(JNIEnv *jni) throw (AgentException);
+        void Clean(JNIEnv *jni);
 
         /*                      
          * Returns started status of this agent.
          */
-        bool IsStarted() throw() {
+        bool IsStarted() {
             return m_isStarted;
         }
 
         /*
          * Sets started status of this agent.
          */
-        void SetStarted(bool isStarted) throw() {
+        void SetStarted(bool isStarted) {
             m_isStarted = isStarted;
         }
 
         /**
          * Enables catching initial EXCEPTION event to launch debugger.
          */
-        void EnableInitialExceptionCatch(jvmtiEnv *jvmti, JNIEnv *jni) throw (AgentException);
+        int EnableInitialExceptionCatch(jvmtiEnv *jvmti, JNIEnv *jni);
 
         /**
          * Disables catching initial EXCEPTION event to launch debugger.
          */
-        void DisableInitialExceptionCatch(jvmtiEnv *jvmti, JNIEnv *jni) throw (AgentException);
+        int DisableInitialExceptionCatch(jvmtiEnv *jvmti, JNIEnv *jni);
 
     private :
 

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/AgentMonitor.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/AgentMonitor.cpp?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/AgentMonitor.cpp (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/AgentMonitor.cpp Thu Jul 16 15:57:37 2009
@@ -15,74 +15,61 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
-/**
- * @author Pavel N. Vyssotski
- * @version $Revision: 1.8 $
- */
-// AgentMonitor.cpp
-
 #include "AgentMonitor.h"
+#include "ExceptionManager.h"
 #include "jvmti.h"
 
 using namespace jdwp;
 
-AgentMonitor::AgentMonitor(const char* name) throw(AgentException) {
+AgentMonitor::AgentMonitor(const char* name) {
     jvmtiError err;
-    JVMTI_TRACE(err, AgentBase::GetJvmtiEnv()->CreateRawMonitor(name, &m_monitor));
+    JVMTI_TRACE(LOG_DEBUG, err, AgentBase::GetJvmtiEnv()->CreateRawMonitor(name, &m_monitor));
     if (err != JVMTI_ERROR_NONE) {
-        throw AgentException(err);
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Error calling CreateRawMonitor: %d", err));
     }
 }
 
-AgentMonitor::~AgentMonitor() throw(AgentException) {
+AgentMonitor::~AgentMonitor() {
     jvmtiError err;
-    JVMTI_TRACE(err, AgentBase::GetJvmtiEnv()->DestroyRawMonitor(m_monitor));
+    JVMTI_TRACE(LOG_DEBUG, err, AgentBase::GetJvmtiEnv()->DestroyRawMonitor(m_monitor));
     // check for error only in debug mode
-    JDWP_ASSERT(err==JVMTI_ERROR_NONE);
+    //JDWP_ASSERT(err==JVMTI_ERROR_NONE);
 }
 
-void AgentMonitor::Enter() const throw(AgentException) {
-    jvmtiError err;
-//    JVMTI_TRACE(err, AgentBase::GetJvmtiEnv()->RawMonitorEnter(m_monitor));
-    err = AgentBase::GetJvmtiEnv()->RawMonitorEnter(m_monitor);
+void AgentMonitor::Enter() const {
+    jvmtiError err = AgentBase::GetJvmtiEnv()->RawMonitorEnter(m_monitor);
     if (err != JVMTI_ERROR_NONE) {
-        throw AgentException(err);
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Error calling RawMonitorEnter: %d", err));
     }
 }
 
-void AgentMonitor::Wait(jlong timeout) const throw(AgentException) {
+void AgentMonitor::Wait(jlong timeout) const {
     jvmtiError err;
-    JVMTI_TRACE(err, AgentBase::GetJvmtiEnv()->RawMonitorWait(m_monitor, timeout));
-//    err = AgentBase::GetJvmtiEnv()->RawMonitorWait(m_monitor, timeout);
+    JVMTI_TRACE(LOG_DEBUG, err, AgentBase::GetJvmtiEnv()->RawMonitorWait(m_monitor, timeout));
     if (err != JVMTI_ERROR_NONE) {
-        throw AgentException(err);
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Error calling RawMonitorWait: %d", err));
     }
 }
 
-void AgentMonitor::Notify() const throw(AgentException) {
+void AgentMonitor::Notify() const {
     jvmtiError err;
-    JVMTI_TRACE(err, AgentBase::GetJvmtiEnv()->RawMonitorNotify(m_monitor));
-//    err = AgentBase::GetJvmtiEnv()->RawMonitorNotify(m_monitor);
+    JVMTI_TRACE(LOG_DEBUG, err, AgentBase::GetJvmtiEnv()->RawMonitorNotify(m_monitor));
     if (err != JVMTI_ERROR_NONE) {
-        throw AgentException(err);
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Error calling RawMonitorNotify: %d", err));
     }
 }
 
-void AgentMonitor::NotifyAll() const throw(AgentException) {
+void AgentMonitor::NotifyAll() const {
     jvmtiError err;
-    JVMTI_TRACE(err, AgentBase::GetJvmtiEnv()->RawMonitorNotifyAll(m_monitor));
-//    err = AgentBase::GetJvmtiEnv()->RawMonitorNotifyAll(m_monitor);
+    JVMTI_TRACE(LOG_DEBUG, err, AgentBase::GetJvmtiEnv()->RawMonitorNotifyAll(m_monitor));
     if (err != JVMTI_ERROR_NONE) {
-        throw AgentException(err);
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Error calling RawMonitorNotifyAll: %d", err));
     }
 }
 
-void AgentMonitor::Exit() const throw(AgentException) {
-    jvmtiError err;
-    //JVMTI_TRACE(err, AgentBase::GetJvmtiEnv()->RawMonitorExit(m_monitor));
-    err = AgentBase::GetJvmtiEnv()->RawMonitorExit(m_monitor);
+void AgentMonitor::Exit() const {
+    jvmtiError err = AgentBase::GetJvmtiEnv()->RawMonitorExit(m_monitor);
     if (err != JVMTI_ERROR_NONE) {
-        throw AgentException(err);
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Error calling RawMonitorExit: %d", err));
     }
 }

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/AgentMonitor.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/AgentMonitor.h?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/AgentMonitor.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/AgentMonitor.h Thu Jul 16 15:57:37 2009
@@ -15,12 +15,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
-/**
- * @author Pavel N. Vyssotski
- * @version $Revision: 1.6.2.1 $
- */
-
 /**
  * @file
  * AgentMonitor.h
@@ -52,39 +46,39 @@
          *
          * @param name - monitor name
          */
-        AgentMonitor(const char* name) throw(AgentException);
+        AgentMonitor(const char* name);
 
         /**
          * Destructs the JVMTI raw monitor.
          */
-        ~AgentMonitor() throw(AgentException);
+        ~AgentMonitor();
 
         /**
          * Locks the JVMTI raw monitor.
          */
-        void Enter() const throw(AgentException);
+        void Enter() const;
 
         /**
          * Suspends the current thread for the given time-out.
          *
          * @param timeout - wait time-out
          */
-        void Wait(jlong timeout = 0) const throw(AgentException);
+        void Wait(jlong timeout = 0) const;
 
         /**
          * Notifies the suspended thread waiting on the given monitor.
          */
-        void Notify() const throw(AgentException);
+        void Notify() const;
 
         /**
          * Notifies all suspended threads waiting on the given monitor.
          */
-        void NotifyAll() const throw(AgentException);
+        void NotifyAll() const;
 
         /**
          * Unlocks the JVMTI raw monitor.
          */
-        void Exit() const throw(AgentException);
+        void Exit() const;
 
     private:
         jrawMonitorID m_monitor;
@@ -107,7 +101,9 @@
          */
         MonitorAutoLock(AgentMonitor &monitor
             JDWP_FILE_LINE_PAR) : m_lock(monitor) JDWP_FILE_LINE_INI {
-            JDWP_TRACE_EX(LOG_KIND_MON, m_file, m_line, "Enter: " << &m_lock);
+#ifndef NDEBUG
+            JDWP_TRACE(LOG_DEBUG, (LOG_KIND_MON, m_file, m_line, "Enter: %p", &m_lock));
+#endif // NDEBUG
             m_lock.Enter();
         }
 
@@ -118,7 +114,9 @@
          */
         MonitorAutoLock(AgentMonitor *monitor
             JDWP_FILE_LINE_PAR) : m_lock(*monitor) JDWP_FILE_LINE_INI {
-            JDWP_TRACE_EX(LOG_KIND_MON, m_file, m_line, "Enter: " << &m_lock);
+#ifndef NDEBUG
+            JDWP_TRACE(LOG_DEBUG, (LOG_KIND_MON, m_file, m_line, "Enter: %p", &m_lock));
+#endif // NDEBUG
             m_lock.Enter();
         }
 
@@ -126,7 +124,9 @@
          * The destructor unlocks the agent monitor.
          */
         ~MonitorAutoLock() {
-            JDWP_TRACE_EX(LOG_KIND_MON, m_file, m_line, "Exit : " << &m_lock);
+#ifndef NDEBUG
+            JDWP_TRACE(LOG_DEBUG, (LOG_KIND_MON, m_file, m_line, "Exit : %p", &m_lock));
+#endif // NDEBUG
             m_lock.Exit();
         }
 

Modified: 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=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CallBacks.cpp (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CallBacks.cpp Thu Jul 16 15:57:37 2009
@@ -26,9 +26,9 @@
 //-----------------------------------------------------------------------------
 
      /**
-     * Describes a reference from an object or the VM (the referrer) 
-     * to another object (the referree) or a heap root to a referree. 
-     */
+      * 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, 
@@ -44,53 +44,6 @@
             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;
-     }
      
 //-----------------------------------------------------------------------------
 // Heap callbacks, used in ReferringObject command

Modified: 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=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CallBacks.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CallBacks.h Thu Jul 16 15:57:37 2009
@@ -24,14 +24,17 @@
 
 namespace jdwp {
 
-   //-----------------------------------------------------------------------------
-   // Heap callbacks, used in Instances, InstanceCounts command
+    //-----------------------------------------------------------------------------
+   // Heap callbacks, used in Instances, InstanceCounts,ReferringObject command
    //-----------------------------------------------------------------------------
     namespace CallBacks {
+        //-----------------------------------------------------------------------------
+        // Heap callbacks, used in Instances and InstanceCount command
+        //-----------------------------------------------------------------------------
         /**
          * Describes a reference from an object or the VM (the referrer) 
-        * to another object (the referree) or a heap root to a referree. 
-        */
+         * to another object (the referree) or a heap root to a referree. 
+         */
         jint JNICALL HeapReferenceCallback
         (jvmtiHeapReferenceKind reference_kind, 
          const jvmtiHeapReferenceInfo* reference_info, 
@@ -43,41 +46,6 @@
          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);
          
         //-----------------------------------------------------------------------------
         // Heap callbacks, used in ReferringObject command
@@ -101,3 +69,4 @@
     } //CallBacks namespace
 } // jdwp namesoace
 #endif//_CALL_BACKS_H_
+

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/ClassManager.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/ClassManager.cpp?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/ClassManager.cpp (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/ClassManager.cpp Thu Jul 16 15:57:37 2009
@@ -15,23 +15,16 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
-/**
- * @author Pavel N. Vyssotski
- * @version $Revision: 1.13 $
- */
-// ClassManager.cpp
-
-#include <string.h>
-
 #include "jni.h"
 
 #include "ClassManager.h"
 #include "Log.h"
 
+#include <string.h>
+
 using namespace jdwp;
 
-ClassManager::ClassManager() throw()
+ClassManager::ClassManager()
 {
     m_classClass = 0;
     m_threadClass = 0;
@@ -42,66 +35,83 @@
     m_systemClass = 0;
 }
 
-void ClassManager::Init(JNIEnv *jni) throw(AgentException)
+int ClassManager::Init(JNIEnv *jni)
 {
-    JDWP_TRACE_ENTRY("Init(" << jni << ')');
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "Init(%p)", jni));
     
     m_stringClass = jni->FindClass("java/lang/String");
     if (m_stringClass == 0) {
-        JDWP_INFO("Class not found: java.lang.String");
-        throw InternalErrorException();
+        JDWP_TRACE(LOG_RELEASE, (LOG_INFO_FL, "Class not found: java.lang.String"));
+        AgentException ex(JDWP_ERROR_INTERNAL);
+	    JDWP_SET_EXCEPTION(ex);
+        return JDWP_ERROR_INTERNAL;
     }
     m_stringClass = static_cast<jclass>(jni->NewGlobalRef(m_stringClass));
 
     m_classClass = jni->FindClass("java/lang/Class");
     if (m_classClass == 0) {
-        JDWP_INFO("Class not found: java.lang.Class");
-        throw InternalErrorException();
+        JDWP_TRACE(LOG_RELEASE, (LOG_INFO_FL, "Class not found: java.lang.Class"));
+        AgentException ex(JDWP_ERROR_INTERNAL);
+        JDWP_SET_EXCEPTION(ex);
+        return JDWP_ERROR_INTERNAL;
     }
     m_classClass = static_cast<jclass>(jni->NewGlobalRef(m_classClass));
 
     m_threadClass = jni->FindClass("java/lang/Thread");
     if (m_threadClass == 0) {
-        JDWP_INFO("Class not found: java.lang.Thread");
-        throw InternalErrorException();
+        JDWP_TRACE(LOG_RELEASE, (LOG_INFO_FL, "Class not found: java.lang.Thread"));
+    	AgentException ex(JDWP_ERROR_INTERNAL);
+        JDWP_SET_EXCEPTION(ex);
+        return JDWP_ERROR_INTERNAL;
     }
     m_threadClass = static_cast<jclass>(jni->NewGlobalRef(m_threadClass));
 
     m_threadGroupClass = jni->FindClass("java/lang/ThreadGroup");
     if (m_threadGroupClass == 0) {
-        JDWP_INFO("Class not found: java.lang.ThreadGroup");
-        throw InternalErrorException();
+        JDWP_TRACE(LOG_RELEASE, (LOG_INFO_FL, "Class not found: java.lang.ThreadGroup"));
+        AgentException ex(JDWP_ERROR_INTERNAL);
+        JDWP_SET_EXCEPTION(ex);
+        return JDWP_ERROR_INTERNAL;
     }
     m_threadGroupClass =
         static_cast<jclass>(jni->NewGlobalRef(m_threadGroupClass));
 
     m_classLoaderClass = jni->FindClass("java/lang/ClassLoader");
     if (m_classLoaderClass== 0) {
-        JDWP_INFO("Class not found: java.lang.ClassLoader");
-        throw InternalErrorException();
+        JDWP_TRACE(LOG_RELEASE, (LOG_INFO_FL, "Class not found: java.lang.ClassLoader"));
+        AgentException ex(JDWP_ERROR_INTERNAL);
+        JDWP_SET_EXCEPTION(ex);
+        return JDWP_ERROR_INTERNAL;
     }
     m_classLoaderClass =
         static_cast<jclass>(jni->NewGlobalRef(m_classLoaderClass));
 
     m_OOMEClass = jni->FindClass("java/lang/OutOfMemoryError");
     if (m_OOMEClass == 0) {
-        JDWP_INFO("Class not found: java.lang.OutOfMemoryError");
-        throw InternalErrorException();
+        JDWP_TRACE(LOG_RELEASE, (LOG_INFO_FL, "Class not found: java.lang.OutOfMemoryError"));
+        AgentException ex(JDWP_ERROR_INTERNAL);
+        JDWP_SET_EXCEPTION(ex);
+        return JDWP_ERROR_INTERNAL;
     }
     m_OOMEClass = static_cast<jclass>(jni->NewGlobalRef(m_OOMEClass));
 
     m_systemClass = jni->FindClass("java/lang/System");
     if (m_systemClass == 0) {
-        JDWP_INFO("Class not found: java.lang.System");
-        throw InternalErrorException();
+        JDWP_TRACE(LOG_RELEASE, (LOG_INFO_FL, "Class not found: java.lang.System"));
+        AgentException ex(JDWP_ERROR_INTERNAL);
+        JDWP_SET_EXCEPTION(ex);
+        return JDWP_ERROR_INTERNAL;
     }
     m_systemClass = static_cast<jclass>(jni->NewGlobalRef(m_systemClass));
+
+    return JDWP_ERROR_NONE;
 }
 
-void ClassManager::Clean(JNIEnv *jni) throw()
+void ClassManager::Clean(JNIEnv *jni)
 {
-    JDWP_TRACE_ENTRY("Clean(" << jni << ')');
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "Clean(%p)", jni));
 
+    /* FIXME - Workaround for shutdown crashes
     if (m_classClass != 0)
         jni->DeleteGlobalRef(m_classClass);
     if (m_threadClass != 0)
@@ -115,40 +125,39 @@
     if (m_OOMEClass != 0)
         jni->DeleteGlobalRef(m_OOMEClass);
     if (m_systemClass != 0)
-        jni->DeleteGlobalRef(m_systemClass);
+        jni->DeleteGlobalRef(m_systemClass);*/
 }
 
-void ClassManager::CheckOnException(JNIEnv *jni) const throw(AgentException)
+int ClassManager::CheckOnException(JNIEnv *jni) const
 {
-    jthrowable exception = jni->ExceptionOccurred();
-    if (exception != 0) {
+    if (jni->ExceptionOccurred()) {
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "An exception occurred:"));
+        jni->ExceptionDescribe();
         jni->ExceptionClear();
-        if (jni->IsInstanceOf(exception, m_OOMEClass) == JNI_TRUE) {
-            throw OutOfMemoryException();
-        } else {
-            throw InternalErrorException();
-        }
+        return JDWP_ERROR_INTERNAL;
     }
+    return JDWP_ERROR_NONE;
 }
 
 // returnValue must be freed via GetMemoryManager().Free()
 // returnValue = 0, if there is no property with that name
 char* ClassManager::GetProperty(JNIEnv *jni, const char *str) const
-    throw(AgentException)
 {
     jmethodID mid = jni->GetStaticMethodID(m_systemClass,
         "getProperty", "(Ljava/lang/String;)Ljava/lang/String;");
     if (mid == 0) {
-        JDWP_INFO("Method not found: java.lang.System.getProperty(String)");
-        throw InternalErrorException();
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Method not found: java.lang.System.getProperty(String)"));
+        return 0;
     }
 
     jstring key = jni->NewStringUTF(str);
-    CheckOnException(jni);
+    int ret = CheckOnException(jni);
+    if (ret != JDWP_ERROR_NONE) return 0;
 
     jstring value = static_cast<jstring>
         (jni->CallStaticObjectMethod(m_systemClass, mid, key));
-    CheckOnException(jni);
+    ret = CheckOnException(jni);
+    if (ret != JDWP_ERROR_NONE) return 0;
 
     char *returnValue = 0;
     if (value != 0) {
@@ -157,13 +166,14 @@
             (AgentBase::GetMemoryManager().Allocate(len + 1 JDWP_FILE_LINE));
         jni->GetStringUTFRegion(value, 0, jni->GetStringLength(value),
             returnValue);
+        returnValue[len] = '\0';
     }
 
     return returnValue;
 }
 
 // returnValue must be freed via GetMemoryManager().Free()
-char* ClassManager::GetClassName(const char *signature) const throw(AgentException)
+char* ClassManager::GetClassName(const char *signature) const
 {
     if (signature == 0)
         return 0;
@@ -197,43 +207,47 @@
 }
 
 jclass ClassManager::GetClassForName(JNIEnv *jni,
-    const char *name, jobject loader) const throw(AgentException)
+    const char *name, jobject loader) const
 {
-    JDWP_TRACE_ENTRY("GetClassForName(" << jni << ',' << name << ',' << loader << ')');
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "GetClassForName(%p,%s,%p)", jni, name, loader));
 
     jmethodID mid = jni->GetStaticMethodID(m_classClass, "forName",
         "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;");
-    CheckOnException(jni);
+    int ret = CheckOnException(jni);
+    if (ret != JDWP_ERROR_NONE) return 0;
     if (mid == 0) {
-        JDWP_INFO("Method not found: java.lang.Class.forName(String,boolean,ClassLoader)");
-        throw InternalErrorException();
+        JDWP_TRACE(LOG_RELEASE, (LOG_INFO_FL, "Method not found: java.lang.Class.forName(String,boolean,ClassLoader)"));
+        return 0;
     }
 
     jstring clsName = jni->NewStringUTF(name);
-    CheckOnException(jni);
+    ret = CheckOnException(jni);
+    if (ret != JDWP_ERROR_NONE) return 0;
 
     jclass cls = static_cast<jclass>
         (jni->CallStaticObjectMethod(m_classClass, mid, clsName, JNI_TRUE, loader));
-    CheckOnException(jni);
+    ret = CheckOnException(jni);
+    if (ret != JDWP_ERROR_NONE) return 0;
 
     return cls;
 }
 
 jboolean ClassManager::IsArray(JNIEnv *jni, jobject object) const
-    throw(AgentException)
+   
 {
     jboolean isArray;
     jclass cls = jni->GetObjectClass(object);
     jvmtiError err;
-    JVMTI_TRACE(err, GetJvmtiEnv()->IsArrayClass(cls, &isArray));
+    JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->IsArrayClass(cls, &isArray));
     if (err != JVMTI_ERROR_NONE) {
-        throw AgentException(err);
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Error %d returned calling IsArrayClass()", err));
+        return JNI_FALSE;
     }
     return isArray;
 }
 
 jdwpTag ClassManager::GetJdwpTag(JNIEnv *jni, jobject object) const
-    throw(AgentException)
+   
 {
     if (object == 0) {
         return JDWP_TAG_OBJECT;
@@ -255,7 +269,6 @@
 }
 
 jdwpTag ClassManager::GetJdwpTagFromSignature(const char* signature) const
-throw ()
 {
     switch ( signature[0] ) {
         case 'Z': return JDWP_TAG_BOOLEAN;
@@ -273,33 +286,32 @@
 } // GetJdwpTagFromSignature() 
 
 jboolean ClassManager::IsArrayType(jclass klass) const
-    throw(AgentException)
 {
     jboolean flag;
     jvmtiError err;
-    JVMTI_TRACE(err, GetJvmtiEnv()->IsArrayClass(klass, &flag));
-
-    if (err != JVMTI_ERROR_NONE)
-        throw AgentException(err);
+    JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->IsArrayClass(klass, &flag));
+    if (err != JVMTI_ERROR_NONE) {
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Error %d returned calling IsArrayClass()", err));
+        return JNI_FALSE;
+    }
 
     return flag;
 }
 
 jboolean ClassManager::IsInterfaceType(jclass klass) const
-    throw(AgentException)
 {
     jboolean flag;
     jvmtiError err;
-    JVMTI_TRACE(err, GetJvmtiEnv()->IsInterface(klass, &flag));
-
-    if (err != JVMTI_ERROR_NONE)
-        throw AgentException(err);
+    JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->IsInterface(klass, &flag));
+    if (err != JVMTI_ERROR_NONE) {
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Error %d returned calling IsInterface()", err));
+        return JNI_FALSE;
+    }
 
     return flag;
 }
 
 jdwpTypeTag ClassManager::GetJdwpTypeTag(jclass klass) const
-    throw (AgentException)
 {
     if ( IsInterfaceType(klass) == JNI_TRUE )
         return JDWP_TYPE_TAG_INTERFACE;
@@ -312,10 +324,9 @@
 
 jboolean ClassManager::IsObjectValueFitsFieldType
     (JNIEnv *jni, jobject objectValue, const char* fieldSignature) const 
-    throw(AgentException)
 {
     if ( objectValue == 0 ) {
-        return true;
+        return JNI_TRUE;
     }
 
     jint classCount = 0;
@@ -323,12 +334,15 @@
 
     jvmtiEnv* jvmti = AgentBase::GetJvmtiEnv();
 
+    AgentBase::GetJniEnv()->PushLocalFrame(100);
+
     jvmtiError err;
-    JVMTI_TRACE(err, jvmti->GetLoadedClasses(&classCount, &classes));
+    JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetLoadedClasses(&classCount, &classes));
     JvmtiAutoFree classesAutoFree(classes);
 
     if (err != JVMTI_ERROR_NONE) {
-        throw AgentException(err);
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Error %d returned calling GetLoadedClasses()", err));
+        return JNI_FALSE;
     }
 
     int i;
@@ -336,20 +350,26 @@
     for (i = 0; i < classCount; i++) {
         char* classSignature = 0;
 
-        JVMTI_TRACE(err, jvmti->GetClassSignature(classes[i], &classSignature, 0));
+        JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetClassSignature(classes[i], &classSignature, 0));
         JvmtiAutoFree classSignatureAutoFree(classSignature);
 
         if (err != JVMTI_ERROR_NONE) {
-            throw AgentException(err);
+            JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Error %d returned calling GetClassSignature()", err));
+            return JNI_FALSE;
         }
 
         if ( strcmp(fieldSignature, classSignature) == 0 ) {
             fieldTypeClass = classes[i];
             break;
         }
+
     }
     if ( fieldTypeClass == 0 ) {
-        throw AgentException(JDWP_ERROR_INVALID_FIELDID);
+    	JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Field type class unexpectedly null"));
+        return JNI_FALSE;
     }
-    return  jni->IsInstanceOf(objectValue, fieldTypeClass);
+
+    jboolean rtValue = jni->IsInstanceOf(objectValue, fieldTypeClass);
+    AgentBase::GetJniEnv()->PopLocalFrame(NULL);
+    return rtValue;
 }

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/ClassManager.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/ClassManager.h?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/ClassManager.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/ClassManager.h Thu Jul 16 15:57:37 2009
@@ -15,12 +15,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
-/**
- * @author Pavel N. Vyssotski
- * @version $Revision: 1.10.2.1 $
- */
-
 /**
  * @file
  * ClassManager.h
@@ -32,6 +26,7 @@
 #define _CLASS_MANAGER_H_
 
 #include "AgentBase.h"
+#include "ExceptionManager.h"
 
 namespace jdwp {
 
@@ -45,12 +40,12 @@
         /**
          * A constructor.
          */
-        ClassManager() throw();
+        ClassManager();
 
         /**
          * A destructor.
          */
-        ~ClassManager() throw() {}
+        ~ClassManager() {}
 
         /**
          * Initializes the class manager.
@@ -62,28 +57,28 @@
          *
          * @param jni - the JNI interface pointer
          */
-        void Init(JNIEnv *jni) throw(AgentException);
+        int Init(JNIEnv *jni);
 
         /**
          * Cleanups the class manager.
          *
          * @param jni - the JNI interface pointer
          */
-        void Clean(JNIEnv *jni) throw();
+        void Clean(JNIEnv *jni);
 
         /**
          * Resets the class manager.
          *
          * @param jni - the JNI interface pointer
          */
-        void Reset(JNIEnv *jni) throw() { }
+        void Reset(JNIEnv *jni) { }
 
         /**
          * Gets an instance of the <code>java.lang.Class</code> class.
          *
          * @return Returns  the <code>java.lang.Class</code> jclass.
          */
-        jclass GetClassClass() const throw() {
+        jclass GetClassClass() const {
             return m_classClass;
         }
 
@@ -92,7 +87,7 @@
          *
          * @return Returns the <code>java.lang.Thread</code> jclass.
          */
-        jclass GetThreadClass() const throw() {
+        jclass GetThreadClass() const {
             return m_threadClass;
         }
 
@@ -101,7 +96,7 @@
          *
          * @return Returns the <code>java.lang.ThreadGroup</code> jclass.
          */
-        jclass GetThreadGroupClass() const throw() {
+        jclass GetThreadGroupClass() const {
             return m_threadGroupClass;
         }
 
@@ -110,7 +105,7 @@
          *
          * @return Returns the <code>java.lang.String</code> jclass.
          */
-        jclass GetStringClass() const throw() {
+        jclass GetStringClass() const {
             return m_stringClass;
         }
 
@@ -119,7 +114,7 @@
          * 
          * @return Returns the <code>java.lang.ClassLoader</code> jclass.
          */
-        jclass GetClassLoaderClass() const throw() {
+        jclass GetClassLoaderClass() const {
             return m_classLoaderClass;
         }
 
@@ -128,7 +123,7 @@
          *
          * @return Returns the <code>java.lang.OutOfMemoryError</code> jclass.
          */
-        jclass GetOOMEClass() const throw() {
+        jclass GetOOMEClass() const {
             return m_OOMEClass;
         }
 
@@ -137,7 +132,7 @@
          *
          * @return Returns the <code>java.lang.System</code> jclass.
          */
-        jclass GetSystemClass() const throw() {
+        jclass GetSystemClass() const {
             return m_systemClass;
         }
 
@@ -147,7 +142,7 @@
          *
          * @param jni - the JNI interface pointer
          */
-        void CheckOnException(JNIEnv *jni) const throw(AgentException);
+        int CheckOnException(JNIEnv *jni) const;
 
         /**
          * Returns system property from the Java class <code>java.lang.System</code> 
@@ -161,8 +156,7 @@
          *
          * @return Returns - the Java system property.
          */
-        char* GetProperty(JNIEnv *jni, const char *str) const
-            throw(AgentException);
+        char* GetProperty(JNIEnv *jni, const char *str) const;
 
         /**
          * Returns the class name corresponding to the given signature.
@@ -173,7 +167,7 @@
          *
          * @return Returns the class name corresponding to the given signature.
          */
-        char* GetClassName(const char *signature) const throw(AgentException);
+        char* GetClassName(const char *signature) const;
 
         /**
          * Gets the Java class corresponding to the given name.
@@ -184,8 +178,7 @@
          *
          * @return Returns the Java class for the given name.
          */
-        jclass GetClassForName(JNIEnv *jni, const char *name, jobject loader) const
-            throw(AgentException);
+        jclass GetClassForName(JNIEnv *jni, const char *name, jobject loader) const;
 
         /**
          * Checks whether the given object is the instance of the 
@@ -197,7 +190,7 @@
          * @return <code>TRUE</code> if the object is the instance of 
          *         <code>java.lang.Class</code>, otherwise <code>FALSE</code>.
          */
-        jboolean IsClass(JNIEnv *jni, jobject object) const throw() {
+        jboolean IsClass(JNIEnv *jni, jobject object) const {
             return jni->IsInstanceOf(object, m_classClass);
         }
 
@@ -211,7 +204,7 @@
          * @return <code>TRUE</code> if the object is the instance of 
          *         <code>java.lang.Thread</code>, otherwise <code>FALSE</code>.
          */
-        jboolean IsThread(JNIEnv *jni, jobject object) const throw() {
+        jboolean IsThread(JNIEnv *jni, jobject object) const {
             return jni->IsInstanceOf(object, m_threadClass);
         }
 
@@ -225,7 +218,7 @@
          * @return <code>TRUE</code> if the object is the instance of 
          *         <code>java.lang.ThreadGroup</code>, otherwise <code>FALSE</code>.
          */
-        jboolean IsThreadGroup(JNIEnv *jni, jobject object) const throw() {
+        jboolean IsThreadGroup(JNIEnv *jni, jobject object) const {
             return jni->IsInstanceOf(object, m_threadGroupClass);
         }
 
@@ -239,7 +232,7 @@
          * @return <code>TRUE</code> if the object is the instance of 
          *         <code>java.lang.String</code>, otherwise <code>FALSE</code>.
          */
-        jboolean IsString(JNIEnv *jni, jobject object) const throw() {
+        jboolean IsString(JNIEnv *jni, jobject object) const {
             return jni->IsInstanceOf(object, m_stringClass);
         }
 
@@ -253,7 +246,7 @@
          * @return <code>TRUE<code> if the object is the instance of 
          *         <code>java.lang.ClassLoader</code>, otherwise <code>FALSE</code>.
          */
-        jboolean IsClassLoader(JNIEnv *jni, jobject object) const throw() {
+        jboolean IsClassLoader(JNIEnv *jni, jobject object) const {
             return jni->IsInstanceOf(object, m_classLoaderClass);
         }
 
@@ -267,7 +260,7 @@
          *         otherwise <code>FALSE</code>.
          */
         jboolean IsArray(JNIEnv *jni, jobject object) const
-            throw(AgentException);
+           ;
 
         /**
          * Gets the JDWP tag of the given Java object.
@@ -278,7 +271,7 @@
          * @return Returns the JDWP tag of the Java object.
          */
         jdwpTag GetJdwpTag(JNIEnv *jni, jobject object) const
-            throw(AgentException);
+           ;
 
         /** 
          * Gets jdwpTag indicated by the specified signature.
@@ -291,7 +284,7 @@
          *         such as JDWP_TAG_BYTE, JDWP_TAG_OBJECT and so on, or 
          *         JDWP_TAG_NONE, if the passed signature is incorrect.
          */
-        jdwpTag GetJdwpTagFromSignature(const char* signature) const throw();
+        jdwpTag GetJdwpTagFromSignature(const char* signature) const;
 
         /**
          * Checks whether the given class is the Java array.
@@ -301,7 +294,7 @@
          * @return <code>TRUE</code> if the given class is the array, 
          *         otherwise <code>FALSE</code>.
          */
-        jboolean IsArrayType(jclass klass) const throw(AgentException);
+        jboolean IsArrayType(jclass klass) const;
 
         /**
          * Checks whether the given class is the Java interface.
@@ -311,7 +304,7 @@
          * @return <code>TRUE</code> if the given class is the interface, 
          *         otherwise <code>FALSE</code>.
          */
-        jboolean IsInterfaceType(jclass klass) const throw(AgentException);
+        jboolean IsInterfaceType(jclass klass) const;
 
         /**
          * Gets the JDWP type tag of the given Java class.
@@ -320,8 +313,7 @@
          *
          * @return Returns the JDWP type tag of the Java class.
          */
-        jdwpTypeTag GetJdwpTypeTag(jclass klass) const
-            throw (AgentException);
+        jdwpTypeTag GetJdwpTypeTag(jclass klass) const;
 
         /**
          * Checks the given object value.
@@ -333,7 +325,7 @@
          * @return <code>TRUE</code> if the given value fits the field type.
          */
         jboolean IsObjectValueFitsFieldType(JNIEnv *jni, jobject objectValue, const char* fieldSignature)
-            const throw(AgentException);
+            const;
 
     private:
 

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=794726&r1=794725&r2=794726&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 Thu Jul 16 15:57:37 2009
@@ -15,11 +15,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
-/**
- * @author Vitaly A. Provodin
- * @version $Revision: 1.15 $
- */
 #include "CommandDispatcher.h"
 #include "PacketParser.h"
 #include "TransportManager.h"
@@ -48,8 +43,6 @@
 //-----------------------------------------------------------------------------
 void removeSynchronousHandler(CommandHandler *handler)
 {
-//    JDWP_TRACE_ENTRY("removeSynchronousHandler(" << handler << ')');
-
     if (handler == 0)
         return;
 
@@ -59,10 +52,10 @@
         if (JDWP_TRACE_ENABLED(LOG_KIND_CMD)) {
             jdwpCommandSet cmdSet = handler->GetCommandParser()->command.GetCommandSet();
             jdwpCommand cmdKind = handler->GetCommandParser()->command.GetCommand();
-            JDWP_TRACE_CMD("Remove handler: "
-                << CommandDispatcher::GetCommandSetName(cmdSet) << "/"
-                << CommandDispatcher::GetCommandName(cmdSet, cmdKind)
-                << "[" << cmdSet << "/" << cmdKind << "]");
+            JDWP_TRACE(LOG_RELEASE, (LOG_CMD_FL, "Remove handler: %s/%s[%d/%d]",
+                CommandDispatcher::GetCommandSetName(cmdSet),
+                CommandDispatcher::GetCommandName(cmdSet, cmdKind),
+                cmdSet, cmdKind));
         }
 #endif
         delete handler;
@@ -70,54 +63,62 @@
 }
 //-----------------------------------------------------------------------------
 
-void CommandDispatcher::ExecCommand(JNIEnv* jni, CommandParser *cmdParser)
-    throw (AgentException)
+int CommandDispatcher::ExecCommand(JNIEnv* jni, CommandParser *cmdParser)
 {
-    JDWP_TRACE_ENTRY("ExecCommand(" << jni << ',' << cmdParser << ')');
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "ExecCommand(%p,%p)", jni, cmdParser));
 
+    int ret = JDWP_ERROR_NONE;
     CommandHandler *handler = 0;
     bool isSynchronous = false;
-    jdwpError err = JDWP_ERROR_NONE;
 
     jdwpCommandSet cmdSet = cmdParser->command.GetCommandSet();
     jdwpCommand cmdKind = cmdParser->command.GetCommand();
 
-    try
-    {
-        if (IsDead())
-            throw AgentException(JDWP_ERROR_VM_DEAD);
-
-        JDWP_TRACE_CMD("Create handler: "
-            << GetCommandSetName(cmdSet) << "/"
-            << GetCommandName(cmdSet, cmdKind)
-            << "[" << cmdSet << "/" << cmdKind << "]");
-        handler = CreateCommandHandler(cmdSet, cmdKind);
-        isSynchronous = handler->IsSynchronous();
-
-        handler->Run(jni, cmdParser);
-    }
-    catch (const TransportException &e)
-    {
+    if (IsDead()) {
         if (isSynchronous) {
             removeSynchronousHandler(handler);
         }
-        throw e;
+        cmdParser->reply.SetError(JDWP_ERROR_VM_DEAD);
+        ret = cmdParser->WriteReply(jni);
+        return JDWP_ERROR_VM_DEAD;
     }
-    catch (const AgentException &e)
-    {
-        if (isSynchronous) {
-            removeSynchronousHandler(handler);
-        }
-        err = e.ErrCode();
+
+    JDWP_TRACE(LOG_RELEASE, (LOG_CMD_FL, "Create handler: %s/%s[%d/%d]",
+           GetCommandSetName(cmdSet),
+           GetCommandName(cmdSet, cmdKind),
+           cmdSet, cmdKind));
+    handler = CreateCommandHandler(cmdSet, cmdKind);
+    if (handler == 0) {
+        //Return JDWP_ERROR_NONE since throwing exception is not expected.
+        AgentException aex = GetExceptionManager().GetLastException();
+        jdwpError err = aex.ErrCode();
         cmdParser->reply.SetError(err);
+        cmdParser->WriteReply(jni);
+        return JDWP_ERROR_NONE;
     }
-    
+    isSynchronous = handler->IsSynchronous();
+
+    ret = handler->Run(jni, cmdParser);
+
     if (isSynchronous) {
         removeSynchronousHandler(handler);
     }
 
-    if (err != JDWP_ERROR_NONE)
-        cmdParser->WriteReply(jni);
+    if (ret != JDWP_ERROR_NONE) {
+        AgentException aex = GetExceptionManager().GetLastException();
+        if (aex.Compare(ENUM_TransportException)) {
+            JDWP_SET_EXCEPTION(aex);
+            return ret;
+        }
+        
+        jdwpError err = aex.ErrCode();
+        cmdParser->reply.SetError(err);
+        ret = cmdParser->WriteReply(jni);
+        JDWP_CHECK_RETURN(ret);
+        return err;
+    }
+
+    return JDWP_ERROR_NONE;
 
     //when command is executed asynchronously,
     //memory is released by AsyncCommandHandler::StartExecution()
@@ -127,9 +128,8 @@
 
 CommandHandler*
 CommandDispatcher::CreateCommandHandler(jdwpCommandSet cmdSet, jdwpCommand cmdKind)
-    throw (NotImplementedException, OutOfMemoryException)
 {
-    JDWP_TRACE_ENTRY("CreateCommandHandler(" << cmdSet << ',' << cmdKind << ')');
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "CreateCommandHandler(%d,%d)", cmdSet, cmdKind));
 
     switch (cmdSet)
     {
@@ -501,14 +501,14 @@
 
     }//cmdSet
 
-    JDWP_ERROR("command not implemented "
-                        << GetCommandSetName(cmdSet) << "/"
-                        << GetCommandName(cmdSet, cmdKind)
-                        << "[" << cmdSet << "/" << cmdKind << "]");
-
-    throw NotImplementedException();
 
-    // never reached
+    JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Command not implemented %s/%s[%d/%d]",
+                        GetCommandSetName(cmdSet),
+                        GetCommandName(cmdSet, cmdKind),
+                        cmdSet, cmdKind));
+    /* Error if we reach here */
+    AgentException ex(JDWP_ERROR_NOT_IMPLEMENTED);
+    JDWP_SET_EXCEPTION(ex);
     return 0;
 }
 

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandDispatcher.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandDispatcher.h?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandDispatcher.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandDispatcher.h Thu Jul 16 15:57:37 2009
@@ -15,12 +15,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
-/**
- * @author Vitaly A. Provodin
- * @version $Revision: 1.5.2.1 $
- */
-
 /**
  * @file
  * CommandDispatcher.h
@@ -72,8 +66,7 @@
          *
          * @see CommandParser
          */
-        void ExecCommand(JNIEnv* jni, CommandParser *cmdParser)
-            throw(AgentException);
+        int ExecCommand(JNIEnv* jni, CommandParser *cmdParser);
 
         /**
          * Returns the name corresponding to the given JDWP command set.
@@ -97,8 +90,7 @@
 
     private:
 
-        static CommandHandler* CreateCommandHandler(jdwpCommandSet cmdSet, jdwpCommand cmdKind)
-            throw (NotImplementedException, OutOfMemoryException);
+        static CommandHandler* CreateCommandHandler(jdwpCommandSet cmdSet, jdwpCommand cmdKind);
 
     };//class CommandDispatcher
 

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandHandler.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandHandler.cpp?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandHandler.cpp (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandHandler.cpp Thu Jul 16 15:57:37 2009
@@ -15,18 +15,12 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
-/**
- * @author Vitaly A. Provodin, Viacheslav G. Rybalov
- * @version $Revision: 1.18 $
- */
-
-#include <string.h>
-
 #include "CommandHandler.h"
 #include "PacketParser.h"
 #include "ThreadManager.h"
+#include "ClassManager.h"
 #include "EventDispatcher.h"
+#include "ExceptionManager.h"
 
 using namespace jdwp;
 
@@ -40,24 +34,98 @@
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 
-void SyncCommandHandler::Run(JNIEnv *jni_env, CommandParser *cmd) throw(AgentException)
+int SyncCommandHandler::Run(JNIEnv *jni_env, CommandParser *cmd)
 {
-    JDWP_TRACE_ENTRY("Sync::Run(" << jni_env << ',' << cmd << ')');
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "Sync::Run(%p,%p)", jni_env, cmd));
+    static int count = 0;
+    int ret = 0;
 
-    m_cmdParser = cmd;
-    try
-    {
-        Execute(jni_env);
+    if (count == 0) {
+        GetJniEnv()->PushLocalFrame(100);
     }
-    catch (const AgentException& e)
-    {
-        ComposeError(e);
+
+    m_cmdParser = cmd;
+    ret = Execute(jni_env);
+    if (ret != JDWP_ERROR_NONE) {
+        AgentException aex = GetExceptionManager().GetLastException();
+        ComposeError(aex);
     }
     
     if (cmd->reply.IsPacketInitialized())
     {
-        cmd->WriteReply(jni_env);
+        ret = cmd->WriteReply(jni_env);
+        JDWP_CHECK_RETURN(ret);
+
+    }
+
+    count++;
+    if (count >= 30) {
+        GetJniEnv()->PopLocalFrame(NULL);
+        count = 0;
+    }
+
+    return JDWP_ERROR_NONE;
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+
+WorkerThread* AsyncCommandHandler::worker = 0;
+
+static bool isWorkerInitialized = false;
+
+WorkerThread::WorkerThread(JNIEnv* jni) {
+    m_head = 0;
+    m_tail = 0;
+    m_requestListMonitor = new AgentMonitor("_jdwp_CommandHandler_requestListMonitor");
+
+    m_agentThread = GetThreadManager().RunAgentThread(jni, StartExecution, NULL,
+						      JVMTI_THREAD_MAX_PRIORITY, "_jdwp_AsyncCommandHandler_Worker");
+}
+
+WorkerThread::~WorkerThread() {
+
+}
+
+void JNICALL
+WorkerThread::StartExecution(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg)
+{
+    AsyncCommandHandler::StartExecution(jvmti_env, jni_env, arg);
+}
+
+void WorkerThread::AddRequest(AsyncCommandHandler* handler) {
+    MonitorAutoLock lock(m_requestListMonitor JDWP_FILE_LINE);
+    HandlerNode* node = new HandlerNode();
+    node->m_next = 0;
+    node->m_handler = handler;
+    if (m_tail != 0) {
+	m_tail->m_next = node;
+    }
+    m_tail = node;
+    if (m_head == 0) {
+	m_head = m_tail;
     }
+    m_requestListMonitor->NotifyAll();
+}
+
+AsyncCommandHandler* WorkerThread::RemoveRequest() {
+    MonitorAutoLock lock(m_requestListMonitor JDWP_FILE_LINE);
+
+    while (m_head == 0) {
+	m_requestListMonitor->Wait();
+    }
+
+    HandlerNode* node = m_head;
+    AsyncCommandHandler* handler = m_head->m_handler;
+    if (m_head == m_tail) {
+	m_tail = 0;
+    }
+
+    m_head = m_head->m_next;
+
+    delete node;
+
+    return handler;
 }
 
 //-----------------------------------------------------------------------------
@@ -77,24 +145,21 @@
 
 //-----------------------------------------------------------------------------
 
-void AsyncCommandHandler::Run(JNIEnv *jni_env, CommandParser *cmd) throw(AgentException)
+int AsyncCommandHandler::Run(JNIEnv *jni_env, CommandParser *cmd)
 {
-    JDWP_TRACE_ENTRY("Async::Run(" << jni_env << ',' << cmd << ')');
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "Async::Run(%p,%p)", jni_env, cmd));
 
     m_cmdParser = new CommandParser();
     cmd->MoveData(jni_env, m_cmdParser);
-    try
-    {
-        GetThreadManager().RunAgentThread(jni_env, StartExecution, this,
-            JVMTI_THREAD_MAX_PRIORITY, GetThreadName());
-    }
-    catch (const AgentException& e)
-    {
-        JDWP_ASSERT(e.ErrCode() != JDWP_ERROR_NULL_POINTER);
-        JDWP_ASSERT(e.ErrCode() != JDWP_ERROR_INVALID_PRIORITY);
 
-        throw e;
+    if (worker == 0) {
+        worker = new WorkerThread(jni_env);
+        isWorkerInitialized = true;
     }
+
+    worker->AddRequest(this);
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
@@ -102,39 +167,57 @@
 void JNICALL
 AsyncCommandHandler::StartExecution(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg)
 {
-    JDWP_TRACE_ENTRY("Async::StartExecution(" << jvmti_env << ',' << jni_env << ',' << arg << ')');
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "Async::StartExecution(%p,%p,%p)", jvmti_env, jni_env, arg));
 
-    AsyncCommandHandler *handler = reinterpret_cast<AsyncCommandHandler *>(arg);
+    static int count = 0;
+    int ret = 0;
 
-    try 
-    {
-        handler->Execute(jni_env);
+    while (true) {
+        if (!isWorkerInitialized) {
+            continue;
+        }
+	AsyncCommandHandler* handler = worker->RemoveRequest();
+
+    if (count == 0) {
+        GetJniEnv()->PushLocalFrame(100);
     }
-    catch (const AgentException &e)
-    {
-        handler->ComposeError(e);
+
+    ret = handler->Execute(jni_env);
+    if (ret != JDWP_ERROR_NONE) {
+        AgentException aex = GetExceptionManager().GetLastException();
+        handler->ComposeError(aex);
     }
 
-    try {
-        if (handler->m_cmdParser->reply.IsPacketInitialized())
-        {
-            JDWP_TRACE_CMD("send reply");
-            handler->m_cmdParser->WriteReply(jni_env);
+    if (handler->m_cmdParser->reply.IsPacketInitialized())
+    {
+        JDWP_TRACE(LOG_RELEASE, (LOG_CMD_FL, "send reply"));
+        ret = handler->m_cmdParser->WriteReply(jni_env);
+        if (ret != JDWP_ERROR_NONE) {
+            // cannot report error in async thread, just print warning message
+            AgentException aex = GetExceptionManager().GetLastException();
+            JDWP_TRACE(LOG_RELEASE, (LOG_INFO_FL, "JDWP error in asynchronous command: %s", aex.GetExceptionMessage(jni_env)));
         }
+    }
 
-        JDWP_TRACE_CMD("Removing command handler: "
-            << handler->m_cmdParser->command.GetCommandSet() << "/"
-            << handler->m_cmdParser->command.GetCommand());
+    JDWP_TRACE(LOG_RELEASE, (LOG_CMD_FL, "Removing command handler: %d/%d",
+           handler->m_cmdParser->command.GetCommandSet(),
+           handler->m_cmdParser->command.GetCommand()));
+
+    count++;
+    if (count >= 30) {
+        GetJniEnv()->PopLocalFrame(NULL);
+        count = 0;
+    }
 
-        handler->Destroy();
-    
-    } catch (const AgentException &e) {
-        // cannot report error in async thread, just print warning message
-        JDWP_INFO("JDWP error in asynchronous command: " << e.what() << " [" << e.ErrCode() << "]");
     }
 }
 
 //-----------------------------------------------------------------------------
+void SpecialAsyncCommandHandler::Destroy() {
+}
+
+//-----------------------------------------------------------------------------
+
 
 SpecialAsyncCommandHandler::SpecialAsyncCommandHandler()
 {
@@ -149,16 +232,18 @@
 
 void SpecialAsyncCommandHandler::ExecuteDeferredInvoke(JNIEnv *jni)
 {
-    JDWP_TRACE_ENTRY("Async::ExecuteDeferredInvoke(" << jni << ')');
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "Async::ExecuteDeferredInvoke(%p)", jni));
     ExecuteDeferredFunc(jni);
 }
 
-void SpecialAsyncCommandHandler::WaitDeferredInvocation(JNIEnv *jni)
+int SpecialAsyncCommandHandler::WaitDeferredInvocation(JNIEnv *jni)
 {
-    JDWP_TRACE_ENTRY("Async::WaitDeferredInvocation(" << jni << ')');
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "Async::WaitDeferredInvocation(%p)", jni));
 
-    GetThreadManager().RegisterInvokeHandler(jni, this);
-    GetEventDispatcher().PostInvokeSuspend(jni, this);
+    int ret = GetThreadManager().RegisterInvokeHandler(jni, this);
+    JDWP_CHECK_RETURN(ret);
+    ret = GetEventDispatcher().PostInvokeSuspend(jni, this);
+    return ret;
 }
 
 //-----------------------------------------------------------------------------
@@ -168,7 +253,7 @@
  */
 jint SpecialAsyncCommandHandler::getArgsNumber(char* sig)
 {
-    JDWP_TRACE_ENTRY("Async::getArgsNumber(" << JDWP_CHECK_NULL(sig) << ')');
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "Async::getArgsNumber(%s)", JDWP_CHECK_NULL(sig)));
 
     if (sig == 0) return 0;
 
@@ -181,7 +266,7 @@
         }
         argsCount++;
     }
-    JDWP_TRACE_DATA("getArgsNumber: sig=" << sig << ", args=" << argsCount);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "getArgsNumber: sig=%s, args=%d", sig, argsCount));
 
     return argsCount;
 }
@@ -191,7 +276,7 @@
  */
 jdwpTag SpecialAsyncCommandHandler::getTag(jint index, char* sig)
 {
-    JDWP_TRACE_ENTRY("Async::getArgsNumber(" << index << ',' << JDWP_CHECK_NULL(sig) << ')');
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "Async::getArgsNumber(%d,%s)", index, JDWP_CHECK_NULL(sig)));
 
     if (sig == 0) return JDWP_TAG_NONE;
 
@@ -216,7 +301,7 @@
  */
 bool SpecialAsyncCommandHandler::getClassNameArg(jint index, char* sig, char* name)
 {
-    JDWP_TRACE_ENTRY("Async::getArgsNumber(" << index << ',' << JDWP_CHECK_NULL(sig) << ')');
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "Async::getArgsNumber(%d,%s)", index, JDWP_CHECK_NULL(sig)));
 
     if (sig == 0) return false;
 
@@ -277,16 +362,14 @@
  * @return JNI_FALSE in case of any mismatch or error
  */
 jboolean
-SpecialAsyncCommandHandler::IsArgValid(JNIEnv *jni, jint index,
+SpecialAsyncCommandHandler::IsArgValid(JNIEnv *jni, jclass klass, jint index,
                                        jdwpTaggedValue value, char* sig)
-                                       throw(AgentException)
 {
-    JDWP_TRACE_ENTRY("IsArgValid(" << jni << ',' << index 
-        << ',' << (int)value.tag << ',' << JDWP_CHECK_NULL(sig) << ')');
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "IsArgValid(%p,%d,%d,%s)", jni, index, (int)value.tag, JDWP_CHECK_NULL(sig)));
 
     jdwpTag argTag = getTag(index, sig);
 
-    JDWP_TRACE_DATA("IsArgValid: index=" << index << ", value.tag=" << value.tag << ", argTag=" << argTag);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "IsArgValid: index=%d, value.tag=%d, argTag=%d", index, value.tag, argTag));
 
     switch (value.tag) {
         case JDWP_TAG_BOOLEAN:
@@ -298,14 +381,14 @@
         case JDWP_TAG_FLOAT:
         case JDWP_TAG_DOUBLE:
             if (value.tag != argTag) {
-                JDWP_TRACE_DATA("IsArgValid: mismatched primitive type tag: index=" << index << ", value.tag=" << value.tag << ", argTag=" << argTag);
+                JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "IsArgValid: mismatched primitive type tag: index=%d, value.tag=%d, argTag=%d", index, value.tag, argTag));
                 return JNI_FALSE;
             } else {
                 return JNI_TRUE;
             }
         case JDWP_TAG_ARRAY:
             if ('[' != argTag) {
-                JDWP_TRACE_DATA("IsArgValid: mismatched array type tag: index=" << index << ", value.tag=" << value.tag << ", argTag=" << argTag);
+                JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "IsArgValid: mismatched array type tag: index=%d, value.tag=%d, argTag=%d", index, value.tag, argTag));
                 return JNI_FALSE;
             }
             break;
@@ -316,30 +399,72 @@
         case JDWP_TAG_CLASS_LOADER:
         case JDWP_TAG_CLASS_OBJECT:
             if ('L' != argTag) {
-                JDWP_TRACE_DATA("IsArgValid: mismatched reference type tag: index=" << index << ", value.tag=" << value.tag << ", argTag=" << argTag);
+                JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "IsArgValid: mismatched reference type tag: index=%d, value.tag=%d, argTag=%d", index, value.tag, argTag));
                 return JNI_FALSE;
             }
             break;
         default: 
-            JDWP_TRACE_DATA("IsArgValid: unknown value type tag: index=" << index << ", value.tag=" << value.tag << ", argTag=" << argTag);
+            JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "IsArgValid: unknown value type tag: index=%d, value.tag=%d, argTag=%d", index, value.tag, argTag));
             return JNI_FALSE;
     }
     char* name = reinterpret_cast<char*>(GetMemoryManager().Allocate(strlen(sig) JDWP_FILE_LINE));
     AgentAutoFree afv(name JDWP_FILE_LINE);
     if (!getClassNameArg(index, sig, name)) {
-        JDWP_TRACE_DATA("IsArgValid: bad class name: index=" << index << ", class=" << JDWP_CHECK_NULL(name));
+        JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "IsArgValid: bad class name: index=%d, class=%s", index, JDWP_CHECK_NULL(name)));
         return JNI_FALSE;
     }
-    jclass cls = jni->FindClass(name);
-    if (jni->ExceptionCheck() == JNI_TRUE) {
-        jni->ExceptionClear();
-        JDWP_TRACE_DATA("IsArgValid: unknown class name: index=" << index << ", class=" << JDWP_CHECK_NULL(name));
+    // Since jni->FindClass method can't find the required class due to classloader restrications.
+    // The class in method signautre should be found by the same classloader, which loaded the
+    // class of the method.
+    jclass cls = FindClass(klass, name);
+    if (cls == 0) {
+        JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "IsArgValid: unknown class name: index=%d, class=%s", index, JDWP_CHECK_NULL(name)));
         return JNI_FALSE;
     }
     if (!jni->IsInstanceOf(value.value.l, cls)) {
-        JDWP_TRACE_DATA("IsArgValid: unmatched class: index=" << index << ", class=" << JDWP_CHECK_NULL(name));
+        JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "IsArgValid: unmatched class: index=%d, class=%s", index, JDWP_CHECK_NULL(name)));
         return JNI_FALSE;
     }
-    JDWP_TRACE_DATA("IsArgValid: matched class: index=" << index << ", class=" << JDWP_CHECK_NULL(name));
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "IsArgValid: matched class: index=%d, class=%s", index, JDWP_CHECK_NULL(name)));
     return JNI_TRUE;
 }
+
+/**
+ * Retrieve a class object from a fully-qualified name, or 0 if the class cannot be found.
+ *
+ * @return a class object from a fully-qualified name, or 0 if the class cannot be found. 
+ */
+jclass SpecialAsyncCommandHandler::FindClass(jclass klass, char *name)
+{	
+    if(name == 0) {
+       return 0;
+    }
+    int len = strlen(name);
+    char* signature = (char*)GetMemoryManager().Allocate(len + 1 JDWP_FILE_LINE);
+    // replace '/' to '.'
+    for (int i = 0; i < len; ++i) {
+	if (name[i] == '/') {
+	    signature[i] = '.';
+	} else {
+	    signature[i] = name[i];
+	}
+    }
+    signature[len] = 0;
+
+    jvmtiEnv* jvmti = AgentBase::GetJvmtiEnv();
+
+    jvmtiError err;
+    jobject classLoader;
+
+    JVMTI_TRACE(LOG_RELEASE, err, jvmti->GetClassLoader(klass, &classLoader));
+
+    if (err != JVMTI_ERROR_NONE) {
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Error calling GetClassLoader()"));
+        return 0;
+    }
+
+    jclass cls = AgentBase::GetClassManager().GetClassForName(AgentBase::GetJniEnv(), signature, classLoader);
+    GetMemoryManager().Free(signature JDWP_FILE_LINE);
+    return cls;
+}
+

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandHandler.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandHandler.h?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandHandler.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandHandler.h Thu Jul 16 15:57:37 2009
@@ -15,12 +15,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
-/**
- * @author Vitaly A. Provodin, Viacheslav G. Rybalov
- * @version $Revision: 1.16.2.1 $
- */
-
 /**
  * @file
  * CommandHandler.h
@@ -37,10 +31,14 @@
 #include "AgentException.h"
 #include "AgentMonitor.h"
 
+#include <string.h>
+
 namespace jdwp {
 
     class CommandParser;
 
+    class AsyncCommandHandler;
+
     /**
      * A command handler is an object responsible for executing a
      * JDWP command and composing a reply.
@@ -84,7 +82,7 @@
          * @exception The implementations of the given interface may throw
          *            <code>AgentException</code>.
          */
-        virtual void Run(JNIEnv *jni, CommandParser *cmd) throw (AgentException) = 0;
+        virtual int Run(JNIEnv *jni, CommandParser *cmd) { return JDWP_ERROR_NONE; };
 
         /**
          * Retuns the internal <code>CommandParser</code> instance.
@@ -99,7 +97,7 @@
          * @return Returns <code>TRUE</code> if JDWP-commands are executed
          *         synchronously, otherwise <code>FALSE</code>.
          */
-        virtual bool IsSynchronous() = 0;
+        virtual bool IsSynchronous() {return true;};
 
     protected:
         CommandParser *m_cmdParser;
@@ -116,7 +114,7 @@
          * @exception The implementations of the given interface
          * may throw AgentException.         
          */
-        virtual void Execute(JNIEnv* jni) throw (AgentException) = 0;
+        virtual int Execute(JNIEnv* jni) { return JDWP_ERROR_NONE; };
 
         /**
          * Makes up reply with error based on the <code>AgentException<code> 
@@ -143,7 +141,7 @@
          * @exception If the reply to the given command can not be sent,
          * TransportException is thrown.
          */
-        virtual void Run(JNIEnv *jni, CommandParser *cmd) throw (AgentException);
+        virtual int Run(JNIEnv *jni, CommandParser *cmd);
 
         /**
          * Identifies if the command handler does execution synchronously.
@@ -156,11 +154,81 @@
 
 
     /**
+     * Worker thread for executing asynchronous commands
+     */
+    class WorkerThread : public AgentBase
+    {
+
+    public:
+
+	WorkerThread(JNIEnv* jni);
+
+	~WorkerThread();
+
+	/**
+	 * Add asynchronous command request
+	 */
+	void AddRequest(AsyncCommandHandler* handler);
+
+	/**
+	 * Remove asynchronous command request
+	 */
+	AsyncCommandHandler* RemoveRequest();
+
+    protected:
+
+        static void JNICALL StartExecution(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg);
+
+    private:
+
+	/**
+	 * Helper class as node of request chain
+	 */
+	class HandlerNode {
+	public:
+	    HandlerNode() {
+		m_handler = 0;
+		m_next = 0;
+	    };
+
+	    ~HandlerNode() {
+		m_handler = 0;
+		m_next = 0;
+	    }
+
+	    AsyncCommandHandler* m_handler;
+
+	    HandlerNode* m_next;
+	};
+
+	/**
+	 * The agent thread
+	 */
+	jthread m_agentThread;
+
+	/**
+	 * Head of the request chain. Requests consumed from the head.
+	 */
+	HandlerNode* m_head;
+
+	/**
+	 * Tail of the request chain. New request added to the tail.
+	 */
+	HandlerNode* m_tail;
+
+	/**
+	 * Monitor for the request chain.
+	 */
+	AgentMonitor *m_requestListMonitor;
+    };
+
+    /**
      * Base class for asynchronous command handlers.
      */
     class AsyncCommandHandler : public CommandHandler
     {
     public:
+
         ~AsyncCommandHandler();
 
         /**
@@ -178,7 +246,7 @@
          * @exception <code>InternalErrorException</code> is thrown in any 
          * other cases.
          */
-        virtual void Run(JNIEnv *jni, CommandParser *cmd) throw (AgentException);
+        virtual int Run(JNIEnv *jni, CommandParser *cmd);
 
         /**
          * Identifies if the command handler does execution synchronously.
@@ -200,7 +268,6 @@
          */
         virtual void Destroy() {delete this;}
 
-    protected:
         /**
          * The given method is passed as a parameter to the 
          * <code>RunAgentThread()</code> method of the 
@@ -212,6 +279,10 @@
          */
         static void JNICALL StartExecution(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg);
 
+    protected:
+
+	static WorkerThread* worker;
+
     };//class AsyncCommandHandler
 
     /**
@@ -235,7 +306,7 @@
          * Does not delete the given asynchronous command after execution.
          * <code>ThreadManager</code> or <code>EventHandler</code> deletes it.
          */
-        virtual void Destroy() {}
+        virtual void Destroy();
 
         /**
          * Returns method invocation options.
@@ -284,17 +355,28 @@
          */
         void ExecuteDeferredInvoke(JNIEnv *jni);
 
+        /**
+         * Retrieve a class object from a fully-qualified name, or 0 if the class cannot be found.
+         *
+         * @param klass the class loaded by the same classloader with target class
+         * @param name the full-qualified name of target calss
+         *
+         * @return a class object from a fully-qualified name, or 0 if the class cannot be found.
+         *
+         */
+        jclass FindClass(jclass cls, char *name);
+
     protected:
         
         /**
          * Initiates deferred invocation and waits for its completion.
          */
-        void WaitDeferredInvocation(JNIEnv *jni);
+        int WaitDeferredInvocation(JNIEnv *jni);
 
         /**
          * The function to execute in deferred method invocation.
          */
-        virtual void ExecuteDeferredFunc(JNIEnv *jni) = 0;
+        virtual void ExecuteDeferredFunc(JNIEnv *jni) {};
 
         /**
          * Calculates number of arguments for the given method signature.
@@ -305,7 +387,7 @@
          * Checks if provided method arguments are valid for the given method
          * signature.
          */
-        jboolean IsArgValid(JNIEnv *jni, jint index, jdwpTaggedValue value, char* methodSig) throw(AgentException);
+        jboolean IsArgValid(JNIEnv *jni, jclass cls, jint index, jdwpTaggedValue value, char* methodSig);
 
         /**
          * The error occurred in method invocation.



Mime
View raw message