harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r794726 [10/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/nativ...
Date Thu, 16 Jul 2009 15:57:41 GMT
Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/PacketDispatcher.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/PacketDispatcher.h?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/PacketDispatcher.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/PacketDispatcher.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.8.2.1 $
- */
-
 /**
  * @file
  * PacketDispatcher.h
@@ -65,7 +59,7 @@
         /**
          * Constructs a new <code>PacketDispatcher</code> object.
          */
-        PacketDispatcher() throw();
+        PacketDispatcher();
 
         /**
          * Initializes the <code>PacketDispatcher</code>'s thread.
@@ -74,7 +68,7 @@
          *
          * @exception If any error occurs, <code>AgentException</code> is thrown.
          */
-        void Init(JNIEnv *jni) throw(AgentException);
+        void Init(JNIEnv *jni);
 
         /**
          * Starts the <code>PacketDispatcher</code>'s thread.
@@ -83,7 +77,7 @@
          *
          * @exception If any error occurs, <code>AgentException</code> is thrown.
          */
-        void Start(JNIEnv *jni) throw(AgentException);
+        int Start(JNIEnv *jni);
 
         /**
          * Stops the <code>PacketDispatcher</code>'s thread.
@@ -92,7 +86,7 @@
          *
          * @exception If any error occurs, <code>AgentException</code> is thrown.
          */
-        void Stop(JNIEnv *jni) throw(AgentException);
+        void Stop(JNIEnv *jni);
 
         /**
          * Resets the <code>PacketDispatcher</code> object.
@@ -101,7 +95,7 @@
          *
          * @exception If any error occurs, <code>AgentException</code> is thrown.
          */
-        void Reset(JNIEnv *jni) throw(AgentException);
+        void Reset(JNIEnv *jni);
 
         /**
          * Cleans the <code>PacketDispatcher</code> object.
@@ -110,7 +104,7 @@
          *
          * @exception If any error occurs, <code>AgentException</code> is thrown.
          */
-        void Clean(JNIEnv *jni) throw(AgentException);
+        void Clean(JNIEnv *jni);
 
         /**
          * Resets all agent modules.
@@ -119,7 +113,7 @@
          *
          * @exception If any error occurs, <code>AgentException</code> is thrown.
          */
-        void ResetAll(JNIEnv *jni) throw(AgentException);
+        int ResetAll(JNIEnv *jni);
 
         /**
          * Shutdowns all agent modules.
@@ -128,7 +122,7 @@
          *
          * @exception If any error occurs, <code>AgentException</code> is thrown.
          */
-//        void ShutdownAll(JNIEnv *jni) throw(AgentException);
+//        void ShutdownAll(JNIEnv *jni);
 
         /**
          * Determines if the <code>PacketDispatcher</code> object is already

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.cpp?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.cpp (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.cpp Thu Jul 16 15:57:37 2009
@@ -15,23 +15,23 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
-/**
- * @author Anton V. Karnachuk
- * @version $Revision: 1.18 $
- */
-// PacketParser.cpp: implementation of the PacketParser class.
-//
-//////////////////////////////////////////////////////////////////////
-
 #include "PacketParser.h"
 #include "jdwpTypes.h"
+#include "hycomp.h"
 #include "MemoryManager.h"
 #include "ObjectManager.h"
 #include "TransportManager.h"
 #include "ClassManager.h"
+#include "ExceptionManager.h"
+
+#include <string.h>
 
-#include <cstring>
+// Defined to parse bytes order for x86 platform
+#ifdef HY_LITTLE_ENDIAN
+#define IS_LITTLE_ENDIAN_PLATFORM 1
+#else
+#define IS_LITTLE_ENDIAN_PLATFORM 0
+#endif
 
 using namespace jdwp;
 
@@ -41,6 +41,9 @@
 const size_t ALLOCATION_STEP = 0x10;
 const jbyte PACKET_IS_UNINITIALIZED = 0x03;
 
+// Constant defining initial value for ReferenceTypeID to be different from  ObjectID values
+extern const ReferenceTypeID REFTYPEID_MINIMUM;
+
 // GCList
 PacketWrapper::GCList::GCList() :
     m_memoryRefAllocatedSize(0),
@@ -57,9 +60,6 @@
         while (m_memoryRefPosition-- > 0) {
             GetMemoryManager().Free(m_memoryRef[m_memoryRefPosition] JDWP_FILE_LINE);
         }
-        GetMemoryManager().Free(m_memoryRef JDWP_FILE_LINE);
-        m_memoryRef = 0;
-        m_memoryRefAllocatedSize = 0;
         m_memoryRefPosition = 0;
     }
 
@@ -67,14 +67,26 @@
         while (m_globalRefPosition-- > 0) {
             jni->DeleteGlobalRef(m_globalRef[m_globalRefPosition]);
         }
+        m_globalRefPosition = 0;
+    }
+}
+
+void PacketWrapper::GCList::ReleaseData() {
+    Reset(AgentBase::GetJniEnv());
+    if (m_memoryRef != 0) {
+        GetMemoryManager().Free(m_memoryRef JDWP_FILE_LINE);
+        m_memoryRef = 0;
+        m_memoryRefAllocatedSize = 0;
+    }
+
+    if (m_globalRef != 0) {
         GetMemoryManager().Free(m_globalRef JDWP_FILE_LINE);
         m_globalRef = 0;
         m_globalRefAllocatedSize = 0;
-        m_globalRefPosition = 0;
     }
 }
 
-void PacketWrapper::GCList::StoreStringRef(char* ref) throw (OutOfMemoryException) {
+void PacketWrapper::GCList::StoreStringRef(char* ref){
     if (m_memoryRefPosition >= m_memoryRefAllocatedSize) {
         // then reallocate buffer
         size_t oldAllocatedSize = this->m_memoryRefAllocatedSize;
@@ -91,7 +103,7 @@
     m_memoryRef[m_memoryRefPosition++] = ref;
 }
 
-void PacketWrapper::GCList::StoreGlobalRef(jobject globalRef) throw (OutOfMemoryException) {
+void PacketWrapper::GCList::StoreGlobalRef(jobject globalRef){
     if (m_globalRefPosition >= m_globalRefAllocatedSize) {
         // then reallocate buffer
         size_t oldAllocatedSize = m_globalRefAllocatedSize;
@@ -151,6 +163,17 @@
     m_packet.type.cmd.flags = PACKET_IS_UNINITIALIZED;
 }
 
+void PacketWrapper::ReleaseData() {
+    m_garbageList.ReleaseData();
+    // free packet's data
+    if (m_packet.type.cmd.data!=0) {
+        GetMemoryManager().Free(m_packet.type.cmd.data JDWP_FILE_LINE);
+        m_packet.type.cmd.data = 0;
+    }
+
+    m_packet.type.cmd.flags = PACKET_IS_UNINITIALIZED;
+}
+
 bool PacketWrapper::IsPacketInitialized() {
     return ((m_packet.type.cmd.flags & PACKET_IS_UNINITIALIZED) == 0);
 }
@@ -173,75 +196,77 @@
 // InputPacketParser - sequential reading of m_packet data
 //////////////////////////////////////////////////////////////////////
 
-void InputPacketParser::ReadPacketFromTransport() throw (TransportException) {
+int InputPacketParser::ReadPacketFromTransport() {
     JDWP_ASSERT(!IsPacketInitialized());
-    GetTransportManager().Read(&m_packet);
+    return GetTransportManager().Read(&m_packet);
 }
 
-void InputPacketParser::ReadBigEndianData(void* data, int len) throw (InternalErrorException) {
+void InputPacketParser::ReadBigEndianData(void* data, int len) {
     JDWP_ASSERT(IsPacketInitialized());
 
     if (m_position+len>m_packet.type.cmd.len-JDWP_MIN_PACKET_LENGTH) {
-        throw InternalErrorException();
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Error reading data - attempting to read past end of packet"));
+        return;
     }
   
-    #if IS_BIG_ENDIAN_PLATFORM
+    #if IS_LITTLE_ENDIAN_PLATFORM
     jbyte* from = static_cast<jbyte*>(&m_packet.type.cmd.data[m_position]);
     jbyte* to = static_cast<jbyte*>(data);
     for (int i=0; i<len; i++) {
         to[i] = from[len-i-1];
     }    
     #else
-    memcpy(data, &m_packet.type.cmd.data[m_position], length);
+    memcpy(data, &m_packet.type.cmd.data[m_position], len);
     #endif
     m_position += len;
 }
 
-void InputPacketParser::ReadRawData(void* data, int len) throw (InternalErrorException) {
+/*void InputPacketParser::ReadRawData(void* data, int len) {
     JDWP_ASSERT(IsPacketInitialized());
 
     if (m_position+len>m_packet.type.cmd.len-JDWP_MIN_PACKET_LENGTH) {
-        throw InternalErrorException();
+        AgentException ex(JDWP_ERROR_INTERNAL);
+        THROW(ex);
     }
   
     memcpy(data, &m_packet.type.cmd.data[m_position], len);
     
     m_position += len;
-}
+}*/
 
 
 
-jbyte InputPacketParser::ReadByte() throw (InternalErrorException) {
+jbyte InputPacketParser::ReadByte() {
     jbyte data = 0;
     ReadBigEndianData(&data, sizeof(jbyte));
     return data;
 }
 
-jboolean InputPacketParser::ReadBoolean() throw (InternalErrorException) {
+jboolean InputPacketParser::ReadBoolean() {
     jboolean data = 0;
     ReadBigEndianData(&data, sizeof(jboolean));
     return data;
 }
 
-jint InputPacketParser::ReadInt() throw (InternalErrorException) {
+jint InputPacketParser::ReadInt() {
     jint res = 0;
     ReadBigEndianData(&res, sizeof(jint));
     return res;
 }
 
-jlong InputPacketParser::ReadLong() throw (InternalErrorException) {
+jlong InputPacketParser::ReadLong() {
     jlong data = 0;
     ReadBigEndianData(&data, sizeof(jlong));
     return data;
 }
 
-ObjectID InputPacketParser::ReadRawObjectID() throw (InternalErrorException) {
+ObjectID InputPacketParser::ReadRawObjectID() {
     ObjectID data = 0;
     ReadBigEndianData(&data, OBJECT_ID_SIZE);
     return data;
 }
 
-jobject InputPacketParser::ReadObjectIDOrNull(JNIEnv *jni) throw (AgentException) {
+jobject InputPacketParser::ReadObjectIDOrNull(JNIEnv *jni) {
     // read raw ObjectID and check for null
     ObjectID oid = ReadRawObjectID();
     if (oid == 0) {
@@ -250,15 +275,26 @@
 
     // convert to jobject (actually to WeakReference or GlobalReference)
     jobject obj = GetObjectManager().MapFromObjectID(jni, oid);
-    JDWP_ASSERT(obj !=  NULL);
+    if (NULL == obj) {
+        JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "MapFromObjectID returned NULL"));
+        AgentException ex(JDWP_ERROR_INVALID_OBJECT);
+        JDWP_SET_EXCEPTION(ex);
+        return 0;
+    }
 
     // make GlobalReference and check if WeakReference was freed
     jobject ref = jni->NewGlobalRef(obj);
     if (ref == 0) {
         if (jni->IsSameObject(obj, 0)) {
-            throw AgentException(JDWP_ERROR_INVALID_OBJECT);
+            JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Invalid object calling NewGlobalRef"));
+            AgentException ex(JDWP_ERROR_INVALID_OBJECT);
+            JDWP_SET_EXCEPTION(ex);
+            return 0;
         } else {
-            throw OutOfMemoryException();
+            JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Out of memory calling NewGlobalRef"));
+            AgentException ex(JDWP_ERROR_OUT_OF_MEMORY);
+            JDWP_SET_EXCEPTION(ex);
+            return 0;
         }
     }
 
@@ -267,32 +303,54 @@
     return ref;
 }
 
-jobject InputPacketParser::ReadObjectID(JNIEnv *jni) throw (AgentException) {
+jobject InputPacketParser::ReadObjectID(JNIEnv *jni) {
     jobject obj = ReadObjectIDOrNull(jni);
-    if (obj == 0) {
-        throw AgentException(JDWP_ERROR_INVALID_OBJECT);
-    }
     return obj;
 }
 
-jclass InputPacketParser::ReadReferenceTypeIDOrNull(JNIEnv *jni) throw (AgentException) {
+jclass InputPacketParser::ReadReferenceTypeIDOrNull(JNIEnv *jni) {
     ReferenceTypeID rtid = 0;
     ReadBigEndianData(&rtid, REFERENCE_TYPE_ID_SIZE);
+	JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ReadReferenceTypeIDOrNul: read : ReferenceTypeID=%p", rtid));
+
     if (rtid == 0) {
         return 0;
     }
 
-    // convert to jclass (actually to WeakReference or GlobalReference)
-    jclass cls = GetObjectManager().MapFromReferenceTypeID(jni, rtid);
+    jclass cls = 0;
+    if(rtid < REFTYPEID_MINIMUM) {
+        // For a ObjectID, we should convert it to ReferenceTypeID 
+        // if it is a ClassObjectID
+        jobject obj = GetObjectManager().MapFromObjectID(jni, rtid);
+        jclass clsType = jni->GetObjectClass(obj);
+        jboolean isClass = jni->IsAssignableFrom(clsType, jni->GetObjectClass(clsType)); 
+        if (!isClass){
+            JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "## ReadReferenceTypeIDOrNul: read : ObjectID is not a ClassObjectID"));
+            return 0;
+        }
+        
+        cls = static_cast<jclass> (obj);
+        jboolean isValidID = GetObjectManager().FindObjectID(jni, cls, rtid); 
+        if(!isValidID){
+            JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "## ReadReferenceTypeIDOrNul: read : ID is an invalid ObjectID"));
+            return 0;
+        }
+    }else { 
+        // convert to jclass (actually to WeakReference or GlobalReference)
+        cls = GetObjectManager().MapFromReferenceTypeID(jni, rtid);
+    }
+
     JDWP_ASSERT(cls != 0);
     
     // make GlobalReference and check if WeakReference was freed
     jclass ref = static_cast<jclass>(jni->NewGlobalRef(cls));
     if (ref == 0) {
         if (jni->IsSameObject(cls, 0)) {
-            throw AgentException(JDWP_ERROR_INVALID_OBJECT);
+            JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Invalid object calling NewGlobalRef"));
+            return 0;
         } else {
-            throw OutOfMemoryException();
+            JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Out of memory calling NewGlobalRef"));
+            return 0;
         }
     }
 
@@ -301,36 +359,33 @@
     return ref;
 }
 
-jclass InputPacketParser::ReadReferenceTypeID(JNIEnv *jni) throw (AgentException) {
+jclass InputPacketParser::ReadReferenceTypeID(JNIEnv *jni) {
     jclass cls = ReadReferenceTypeIDOrNull(jni);
-    if (cls == 0) {
-        throw AgentException(JDWP_ERROR_INVALID_OBJECT);
-    }
     return cls;
 }
 
-jfieldID InputPacketParser::ReadFieldID(JNIEnv *jni) throw (AgentException) {
+jfieldID InputPacketParser::ReadFieldID(JNIEnv *jni) {
     FieldID fid = 0;
     ReadBigEndianData(&fid, FIELD_ID_SIZE);
     jfieldID res = GetObjectManager().MapFromFieldID(jni, fid);
     return res;
 }
 
-jmethodID InputPacketParser::ReadMethodID(JNIEnv *jni) throw (AgentException) {
+jmethodID InputPacketParser::ReadMethodID(JNIEnv *jni) {
     MethodID mid = 0;
     ReadBigEndianData(&mid, METHOD_ID_SIZE);
     jmethodID res = GetObjectManager().MapFromMethodID(jni, mid);
     return res;
 }
 
-jint InputPacketParser::ReadFrameID(JNIEnv *jni) throw (AgentException) {
+jint InputPacketParser::ReadFrameID(JNIEnv *jni) {
     FrameID fid;
     ReadBigEndianData(&fid, FRAME_ID_SIZE);
     jint res = GetObjectManager().MapFromFrameID(jni, fid);
     return res;
 }
 
-jdwpLocation InputPacketParser::ReadLocation(JNIEnv *jni) throw (AgentException) {
+jdwpLocation InputPacketParser::ReadLocation(JNIEnv *jni) {
     jdwpLocation res;
     res.typeTag = static_cast<jdwpTypeTag>(ReadByte());
     res.classID = ReadReferenceTypeID(jni);
@@ -339,41 +394,88 @@
     return res;
 }
 
-jthread InputPacketParser::ReadThreadID(JNIEnv *jni) throw (AgentException) {
-    return static_cast<jthread>(ReadObjectID(jni));
+jthread InputPacketParser::ReadThreadIDOrNull(JNIEnv *jni) {
+    // read raw ThreadID and check for null
+    ObjectID oid = ReadRawObjectID();
+    if (oid == 0) {
+        AgentException ex(JDWP_ERROR_INVALID_THREAD);
+        JDWP_SET_EXCEPTION(ex);
+        return 0;
+    }
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ReadThreadIDOrNull: read : ThreadID=%lld", oid));
+    
+    // if oid is a reference type, throw INVALID_THREAD exception
+    // Bug fix, INVALID_THREAD error reply is required
+    if( GetObjectManager().IsValidReferenceTypeID(jni, oid) ) {
+        AgentException ex(JDWP_ERROR_INVALID_THREAD);
+        JDWP_SET_EXCEPTION(ex);
+        return 0;
+    }    
+
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ReadObjectIDOrNull: read : ObjectID=%lld", oid));
+    
+    // convert to jobject (actually to WeakReference or GlobalReference)
+    jobject obj = GetObjectManager().MapFromObjectID(jni, oid);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ReadObjectIDOrNull: read : jobject=%p", obj));
+    JDWP_ASSERT(obj !=  NULL);
+
+    // make GlobalReference and check if WeakReference was freed
+    jobject ref = jni->NewGlobalRef(obj);
+    if (ref == 0) {
+        if (jni->IsSameObject(obj, 0)) {
+            AgentException ex(JDWP_ERROR_INVALID_OBJECT);
+            JDWP_SET_EXCEPTION(ex);
+            return 0;
+        } else {
+            AgentException ex(JDWP_ERROR_OUT_OF_MEMORY);
+            JDWP_SET_EXCEPTION(ex);
+            return 0;
+        }
+    }
+ 
+    jthread thrd = static_cast<jthread>(ref);
+    // store GlobalReference for futher disposal
+    m_garbageList.StoreGlobalRef(thrd);
+    return thrd;
+}
+    
+jthread InputPacketParser::ReadThreadID(JNIEnv *jni) {
+    jthread thrd = ReadThreadIDOrNull(jni);
+    return thrd;
 }
 
-jthreadGroup InputPacketParser::ReadThreadGroupID(JNIEnv *jni) throw (AgentException) {
+jthreadGroup InputPacketParser::ReadThreadGroupID(JNIEnv *jni) {
     return static_cast<jthreadGroup>(ReadObjectID(jni));
 }
 
-jstring InputPacketParser::ReadStringID(JNIEnv *jni) throw (AgentException) {
+jstring InputPacketParser::ReadStringID(JNIEnv *jni) {
     return static_cast<jstring>(ReadObjectID(jni));
 }
 
-jarray InputPacketParser::ReadArrayID(JNIEnv *jni) throw (AgentException) {
+jarray InputPacketParser::ReadArrayID(JNIEnv *jni) {
     return static_cast<jarray>(ReadObjectID(jni));
 }
 
-char* InputPacketParser::ReadStringNoFree()  throw (InternalErrorException, OutOfMemoryException) {
+char* InputPacketParser::ReadStringNoFree() {
     jint len = ReadInt();
     if (m_position+len>m_packet.type.cmd.len) {
-        throw InternalErrorException();
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Attempting to read past end of packet"));
+        return NULL;
     }
     char* res = static_cast<char*>(GetMemoryManager().Allocate(len+1 JDWP_FILE_LINE));
-    strncpy(res, reinterpret_cast<char*>(&m_packet.type.cmd.data[m_position]), len);
+    memcpy(res, reinterpret_cast<char*>(&m_packet.type.cmd.data[m_position]), len);
     res[len] = '\0';
     m_position += len;
     return res;
 }
 
-char* InputPacketParser::ReadString()  throw (InternalErrorException, OutOfMemoryException) {
+char* InputPacketParser::ReadString() {
     char* res = ReadStringNoFree();
     m_garbageList.StoreStringRef(res);
     return res;
 }
 
-jdwpTaggedValue InputPacketParser::ReadValue(JNIEnv *jni)  throw (AgentException) {
+jdwpTaggedValue InputPacketParser::ReadValue(JNIEnv *jni)  {
     //The first byte is a signature byte which is used to identify the type
     jdwpTaggedValue tv;
     tv.tag = static_cast<jdwpTag>(ReadByte());
@@ -381,7 +483,7 @@
     return tv;
 }
 
-jvalue InputPacketParser::ReadUntaggedValue(JNIEnv *jni, jdwpTag tagPtr)  throw (AgentException) {
+jvalue InputPacketParser::ReadUntaggedValue(JNIEnv *jni, jdwpTag tagPtr)  {
     jvalue value;
 
     switch (tagPtr) {
@@ -433,30 +535,30 @@
     case JDWP_TAG_CLASS_OBJECT:
         value.l = ReadObjectIDOrNull(jni);
         break;
-    default: JDWP_ERROR("Illegal jdwp-tag value: " << tagPtr);
+    default: JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Illegal jdwp-tag value: %d", tagPtr));
     }
     return value;
 }
 
 // InputPacket's private methods
 
-jchar InputPacketParser::ReadChar() throw (InternalErrorException) {
+jchar InputPacketParser::ReadChar() {
     jchar data = 0;
     ReadBigEndianData(&data, sizeof(jchar));
     return data;
 }
-jshort InputPacketParser::ReadShort() throw (InternalErrorException) {
+jshort InputPacketParser::ReadShort() {
     jshort data = 0;
     ReadBigEndianData(&data, sizeof(jshort));
     return data;
 }
 
-jfloat InputPacketParser::ReadFloat() throw (InternalErrorException) {
+jfloat InputPacketParser::ReadFloat() {
     jfloat data = 0;
     ReadBigEndianData(&data, sizeof(jfloat));
     return data;
 }
-jdouble InputPacketParser::ReadDouble() throw (InternalErrorException) {
+jdouble InputPacketParser::ReadDouble() {
     jdouble data = 0;
     ReadBigEndianData(&data, sizeof(jdouble));
     return data;
@@ -467,6 +569,11 @@
     m_position = 0;
 }
 
+void InputPacketParser::ReleaseData() {
+    PacketWrapper::ReleaseData();
+    m_position = 0;
+}
+
 void InputPacketParser::MoveData(JNIEnv *jni, InputPacketParser* to) {
     PacketWrapper::MoveData(jni, to);
     m_position = 0;
@@ -475,15 +582,19 @@
 //////////////////////////////////////////////////////////////////////
 // OutputPacketComposer - sequential writing of m_packet data
 //////////////////////////////////////////////////////////////////////
-void OutputPacketComposer::WritePacketToTransport() throw (TransportException) {
+int OutputPacketComposer::WritePacketToTransport() {
     JDWP_ASSERT(IsPacketInitialized());
-    GetTransportManager().Write(&m_packet);
-    if ( GetError() == JDWP_ERROR_NONE ) {
+    int ret = GetTransportManager().Write(&m_packet);
+    JDWP_CHECK_RETURN(ret);
+
+    if (GetError() == JDWP_ERROR_NONE) {
        IncreaseObjectIDRefCounts();
     }
+
+    return JDWP_ERROR_NONE;
 }
 
-void OutputPacketComposer::AllocateMemoryForData(int length) throw (OutOfMemoryException) {
+void OutputPacketComposer::AllocateMemoryForData(int length){
     size_t newPosition = m_position + static_cast<size_t>(length);
     if (newPosition >= m_allocatedSize) {
         // then reallocate buffer
@@ -509,7 +620,7 @@
     m_position = newPosition;
 }
 
-void OutputPacketComposer::WriteRawData(const void* data, int length) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteRawData(const void* data, int length){
     AllocateMemoryForData(length);
     
     memcpy(&m_packet.type.cmd.data[m_position], data, length);
@@ -519,11 +630,11 @@
 }
 
 
-void OutputPacketComposer::WriteBigEndianData(void* data, int length) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteBigEndianData(void* data, int length){
     JDWP_ASSERT(length <= sizeof(jlong));
     AllocateMemoryForData(length);
     
-    #if IS_BIG_ENDIAN_PLATFORM
+    #if IS_LITTLE_ENDIAN_PLATFORM
         const jbyte* from = static_cast<jbyte*>(const_cast<void*>(data));
         jbyte* to = static_cast<jbyte*>(&m_packet.type.cmd.data[m_position]);
         for (int i=0; i<length; i++) {
@@ -538,89 +649,86 @@
      
 }
 
-void OutputPacketComposer::WriteByte(jbyte value) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteByte(jbyte value){
     WriteBigEndianData(&value, sizeof(value));
 }
-void OutputPacketComposer::WriteBoolean(jboolean value) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteBoolean(jboolean value){
     WriteBigEndianData(&value, sizeof(value));
 }
-void OutputPacketComposer::WriteInt(jint value) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteInt(jint value){
     WriteBigEndianData(&value, sizeof(value));
 }
-void OutputPacketComposer::WriteLong(jlong value) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteLong(jlong value){
     WriteBigEndianData(&value, sizeof(value));
 }
 
-void OutputPacketComposer::WriteObjectID(JNIEnv *jni, jobject value) throw (AgentException) {
+void OutputPacketComposer::WriteObjectID(JNIEnv *jni, jobject value) {
     ObjectID id = GetObjectManager().MapToObjectID(jni, value);
     WriteBigEndianData(&id, OBJECT_ID_SIZE);
     RegisterObjectID(id);
 }
 
-void OutputPacketComposer::WriteReferenceTypeID(JNIEnv *jni, jclass value) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteReferenceTypeID(JNIEnv *jni, jclass value){
     ReferenceTypeID id = GetObjectManager().MapToReferenceTypeID(jni, value);
     WriteBigEndianData(&id, REFERENCE_TYPE_ID_SIZE);
 }
 
-void OutputPacketComposer::WriteFieldID(JNIEnv *jni, jfieldID value) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteFieldID(JNIEnv *jni, jfieldID value){
     FieldID id = GetObjectManager().MapToFieldID(jni, value);
     WriteBigEndianData(&id, FIELD_ID_SIZE);
 }
 
-void OutputPacketComposer::WriteMethodID(JNIEnv *jni, jmethodID value) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteMethodID(JNIEnv *jni, jmethodID value){
     MethodID id = GetObjectManager().MapToMethodID(jni, value);
     WriteBigEndianData(&id, METHOD_ID_SIZE);
 }
 
-void OutputPacketComposer::WriteFrameID(JNIEnv *jni, jthread jvmThread, jint frameDepth, jint framesCount) 
-throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteFrameID(JNIEnv *jni, jthread jvmThread, jint frameDepth, jint framesCount) {
     FrameID id = GetObjectManager().MapToFrameID(jni, jvmThread, frameDepth, framesCount);
     WriteBigEndianData(&id, FRAME_ID_SIZE);
 }
 
 void OutputPacketComposer::WriteLocation(JNIEnv *jni, jdwpTypeTag typeTag, jclass clazz, 
-                                         jmethodID method, jlocation location) 
-throw (OutOfMemoryException) {
+                                         jmethodID method, jlocation location) {
     WriteByte(static_cast<jbyte>(typeTag));
     WriteReferenceTypeID(jni, clazz);
     WriteMethodID(jni, method);
     WriteLong(static_cast<jlong>(location));
 }
 
-void OutputPacketComposer::WriteLocation(JNIEnv *jni, jdwpLocation *location) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteLocation(JNIEnv *jni, jdwpLocation *location){
     WriteLocation(jni, location->typeTag, location->classID, location->methodID, location->loc);
 }
 
-void OutputPacketComposer::WriteThreadID(JNIEnv *jni, jthread value) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteThreadID(JNIEnv *jni, jthread value){
     WriteObjectID(jni, value);
 }
 
-void OutputPacketComposer::WriteThreadGroupID(JNIEnv *jni, jthreadGroup value) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteThreadGroupID(JNIEnv *jni, jthreadGroup value){
     WriteObjectID(jni, value);
 }
 
-void OutputPacketComposer::WriteStringID(JNIEnv *jni, jstring value) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteStringID(JNIEnv *jni, jstring value){
     WriteObjectID(jni, value);
 }
 
-void OutputPacketComposer::WriteArrayID(JNIEnv *jni, jarray value) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteArrayID(JNIEnv *jni, jarray value){
     WriteObjectID(jni, value);
 }
 
-void OutputPacketComposer::WriteString(const char* value) throw (OutOfMemoryException) {
-    jint len = static_cast<jint>((value == 0) ? 0 : std::strlen(value));
+void OutputPacketComposer::WriteString(const char* value){
+    jint len = static_cast<jint>((value == 0) ? 0 : strlen(value));
     WriteString(value, len);
 }
 
-void OutputPacketComposer::WriteString(const char* value, jint length) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteString(const char* value, jint length){
     WriteBigEndianData(&length, sizeof(jint));
     if (length > 0) {
         WriteRawData(value, length);
     }
 }
 
-void OutputPacketComposer::WriteUntaggedValue(JNIEnv *jni, jdwpTag tag, jvalue value) 
-throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteUntaggedValue(JNIEnv *jni, jdwpTag tag, jvalue value) {
     //The first byte is a signature byte which is used to identify the type
     switch (tag) {
     case JDWP_TAG_ARRAY:
@@ -671,43 +779,52 @@
     case JDWP_TAG_CLASS_OBJECT:
         WriteObjectID(jni, value.l);
         break;
-    default: JDWP_ERROR("Illegal jdwp-tag value: " << tag);
+    default: JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Illegal jdwp-tag value: %d", tag));
     }
 }
 
-void OutputPacketComposer::WriteValue(JNIEnv *jni, jdwpTag tag, jvalue value) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteValue(JNIEnv *jni, jdwpTag tag, jvalue value){
     WriteByte(static_cast<jbyte>(tag));
     WriteUntaggedValue(jni, tag, value);
 }
 
-void OutputPacketComposer::WriteTaggedObjectID(JNIEnv *jni, jobject object) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteTaggedObjectID(JNIEnv *jni, jobject object){
     jdwpTag tag = GetClassManager().GetJdwpTag(jni, object);
     WriteByte(static_cast<jbyte>(tag));
     WriteObjectID(jni, object);
 }
 
 void OutputPacketComposer::WriteValues(JNIEnv *jni, jdwpTag tag, 
-                           jint length, jvalue* value) throw (OutOfMemoryException) {
+                           jint length, jvalue* value){
     WriteByte(static_cast<jbyte>(tag));
     WriteInt(length);
     for (int i=0; i<length; i++)
         WriteUntaggedValue(jni, tag, value[i]);
 }
 
-void OutputPacketComposer::WriteByteArray(jbyte* byte, jint length) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteByteArray(jbyte* byte, jint length){
     WriteInt(length);
     WriteRawData(byte, length);
 }
 
 void OutputPacketComposer::Reset(JNIEnv *jni) {
-    PacketWrapper::Reset(jni);
+    // clear links
+    m_garbageList.Reset(jni);
+    m_packet.type.cmd.flags = PACKET_IS_UNINITIALIZED;
     m_position = 0;
-    m_allocatedSize = 0;
     if (m_registeredObjectIDCount != 0) {
+        m_registeredObjectIDCount = 0;
+    }
+}
+
+void OutputPacketComposer::ReleaseData() {
+    PacketWrapper::ReleaseData();
+    m_allocatedSize = 0;
+
+    if (m_registeredObjectIDTable != 0) {
         GetMemoryManager().Free(m_registeredObjectIDTable JDWP_FILE_LINE);
         m_registeredObjectIDTable = 0;
         m_registeredObjectIDCount = 0;
-        m_registeredObjectIDTableSise = 0;
     }
 }
 
@@ -718,21 +835,20 @@
 }
 
 // OutputPacketComposer's private methods
-void OutputPacketComposer::WriteChar(jchar value) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteChar(jchar value){
     WriteBigEndianData(&value, sizeof(value));
 }
-void OutputPacketComposer::WriteShort(jshort value) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteShort(jshort value){
     WriteBigEndianData(&value, sizeof(value));
 }
-void OutputPacketComposer::WriteFloat(jfloat value) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteFloat(jfloat value){
     WriteBigEndianData(&value, sizeof(value));
 }
-void OutputPacketComposer::WriteDouble(jdouble value) throw (OutOfMemoryException) {
+void OutputPacketComposer::WriteDouble(jdouble value){
     WriteBigEndianData(&value, sizeof(value));
 }
 
-void OutputPacketComposer::RegisterObjectID(ObjectID objectID)
-    throw (AgentException) {
+void OutputPacketComposer::RegisterObjectID(ObjectID objectID) {
 
     if ( objectID == JDWP_OBJECT_ID_NULL ) {
         return;
@@ -766,37 +882,40 @@
 }
 
 // new reply
-void OutputPacketComposer::CreateJDWPReply(jint id, jdwpError errorCode) throw (InternalErrorException) {
+void OutputPacketComposer::CreateJDWPReply(jint id, jdwpError errorCode) {
     JDWP_ASSERT(!IsPacketInitialized());
     m_packet.type.reply.id = id;
     m_packet.type.reply.len = JDWP_MIN_PACKET_LENGTH;
     m_packet.type.reply.flags = JDWP_FLAG_REPLY_PACKET;
-    m_packet.type.reply.errorCode = errorCode;
+    m_packet.type.reply.errorCode = (jshort)errorCode;
 }
 
 // new event
-void OutputPacketComposer::CreateJDWPEvent(jint id, jdwpCommandSet commandSet, jdwpCommand command) 
-throw (InternalErrorException) {
+void OutputPacketComposer::CreateJDWPEvent(jint id, jdwpCommandSet commandSet, jdwpCommand command) {
     JDWP_ASSERT(!IsPacketInitialized());
     m_packet.type.cmd.id = id;
     m_packet.type.cmd.len = JDWP_MIN_PACKET_LENGTH;
     m_packet.type.cmd.flags = 0;
-    m_packet.type.cmd.cmdSet = commandSet;
-    m_packet.type.cmd.cmd = command;
+    m_packet.type.cmd.cmdSet = (jbyte)commandSet;
+    m_packet.type.cmd.cmd = (jbyte)command;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 // CommandParser
 ///////////////////////////////////////////////////////////////////////////////
 
-void CommandParser::ReadCommand() throw (TransportException) {
-    command.ReadPacketFromTransport();
+int CommandParser::ReadCommand() {
+    int ret = command.ReadPacketFromTransport();
+    JDWP_CHECK_RETURN(ret);
     reply.CreateJDWPReply(command.GetId(), JDWP_ERROR_NONE);
+    return JDWP_ERROR_NONE;
 }
 
-void CommandParser::WriteReply(JNIEnv *jni) throw (TransportException) {
-    reply.WritePacketToTransport();
+int CommandParser::WriteReply(JNIEnv *jni) {
+    int ret = reply.WritePacketToTransport();
+    JDWP_CHECK_RETURN(ret);
     Reset(jni);
+    return JDWP_ERROR_NONE;
 }
 
 void CommandParser::Reset(JNIEnv *jni) {
@@ -809,6 +928,11 @@
     reply.MoveData(jni, &to->reply);
 }
 
+CommandParser::~CommandParser() {
+    reply.ReleaseData();
+    command.ReleaseData();
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 // EventComposer
 ///////////////////////////////////////////////////////////////////////////////
@@ -823,16 +947,19 @@
     m_isWaiting = false;
     m_isReleased = false;
     m_isAutoDeathEvent = false;
-    event.WriteByte(sp);
+    event.WriteByte((jbyte)sp);
+}
+
+EventComposer::~EventComposer() {
+    event.ReleaseData();
 }
 
 void EventComposer::WriteThread(JNIEnv *jni, jthread thread)
-    throw (OutOfMemoryException)
 {
     event.WriteThreadID(jni, thread);
     m_thread = jni->NewGlobalRef(thread);
     if (m_thread == 0) {
-        throw OutOfMemoryException();
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Out of memory calling NewGlobalRef"));
     }
 }
 
@@ -845,9 +972,11 @@
     event.Reset(jni);
 }
 
-void EventComposer::WriteEvent(JNIEnv *jni) throw (TransportException)
+int EventComposer::WriteEvent(JNIEnv *jni)
 {
-    event.WritePacketToTransport();
+    int ret = event.WritePacketToTransport();
+    JDWP_CHECK_RETURN(ret);
     m_isSent = true;
     event.Reset(jni);
+    return JDWP_ERROR_NONE;
 }

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.h?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.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 Anton V. Karnachuk
- * @version $Revision: 1.16.2.1 $
- */
-
 /**
  * @file
  * PacketParser.h
@@ -120,14 +114,14 @@
              *
              * @param ref - string
              */
-            void StoreStringRef(char* ref) throw (OutOfMemoryException);
+            void StoreStringRef(char* ref);
 
             /**
              * Stores the reference to the JNI global reference.
              *
              * @param globalRef - global reference
              */
-            void StoreGlobalRef(jobject globalRef) throw (OutOfMemoryException);
+            void StoreGlobalRef(jobject globalRef);
 
             /**
              * Deletes all stored references.
@@ -136,6 +130,8 @@
              */
             void Reset(JNIEnv *jni);
 
+            void ReleaseData();
+
             /**
              * Moves all data to other GCList instance.
              *
@@ -165,6 +161,8 @@
          */
         void Reset(JNIEnv *jni);
 
+        void ReleaseData();
+
         /**
          * Moves all data to another PacketWrapper instance.
          *
@@ -199,7 +197,7 @@
          * @throws InternalErrorException if not enough bytes in 
          *         the packet data exist.
          */
-        void ReadPacketFromTransport() throw (TransportException);
+        int ReadPacketFromTransport();
 
         /** 
          * Sequentially reads the byte value from the JDWP packet's data. 
@@ -209,7 +207,7 @@
          * @throws InternalErrorException if the number of bytes in the packet
          *         data is not enough.
          */
-        jbyte ReadByte() throw (InternalErrorException);
+        jbyte ReadByte();
 
         /**
          * Sequentially reads boolean value from the JDWP packet's data. 
@@ -219,7 +217,7 @@
          * @throws InternalErrorException if the number of bytes 
          *         in the packet data is not enough.
          */
-        jboolean ReadBoolean() throw (InternalErrorException);
+        jboolean ReadBoolean();
 
         /** 
          * Sequentially reads int value from the JDWP packet's data. 
@@ -229,7 +227,7 @@
          * @throws InternalErrorException if the number 
          * of bytes in the packet data is not enough.
          */
-        jint ReadInt() throw (InternalErrorException);
+        jint ReadInt();
 
         /** 
          * Sequentially reads a long value from the JDWP packet's data.
@@ -239,7 +237,7 @@
          * @throws InternalErrorException if the number 
          * of bytes in the packet data is not enough.
          */
-        jlong ReadLong() throw (InternalErrorException);
+        jlong ReadLong();
         
         /**
          * Sequentially reads <code>ObjectID</code> value from the JDWP 
@@ -253,7 +251,7 @@
          * @throws InternalErrorException if the number of bytes
          *         in the packet data is not enough.
          */
-        ObjectID ReadRawObjectID() throw (InternalErrorException);
+        ObjectID ReadRawObjectID();
 
         /** 
          * Sequentially reads <code>ObjectID</code> value from JDWP 
@@ -279,7 +277,7 @@
          *         <code>ObjectID</code> is invalid or the object was 
          *         garbage-collected.
          */
-        jobject ReadObjectIDOrNull(JNIEnv *jni) throw (AgentException);
+        jobject ReadObjectIDOrNull(JNIEnv *jni);
 
         /** 
          * Sequentially reads <code>ObjectID</code> value from the JDWP 
@@ -302,7 +300,7 @@
          * @throws AgentException(JDWP_ERROR_NULL_POINTER) if 
          *         <code>ObjectID</code> is null.
          */
-        jobject ReadObjectID(JNIEnv *jni) throw (AgentException);
+        jobject ReadObjectID(JNIEnv *jni);
 
         /** 
          * Sequentially reads the <code>ReferenceTypeID</code> value from 
@@ -330,7 +328,7 @@
          * @throws AgentException(JDWP_ERROR_INVALID_OBJECT) if 
          *         the corresponding class was garbage-collected.
          */
-        jclass ReadReferenceTypeIDOrNull(JNIEnv *jni) throw (AgentException);
+        jclass ReadReferenceTypeIDOrNull(JNIEnv *jni);
 
         /** 
          * Sequentially reads the <code>ReferenceTypeID</code> value from the 
@@ -359,7 +357,7 @@
          * @throws AgentException(JDWP_ERROR_NULL_POINTER) 
          *         if <code>ReferenceTypeID</code> is null.
          */
-        jclass ReadReferenceTypeID(JNIEnv *jni) throw (AgentException);
+        jclass ReadReferenceTypeID(JNIEnv *jni);
 
         /** 
          * Sequentially reads the <code>FieldID</code> value from the JDWP 
@@ -375,7 +373,7 @@
          * @throws OutOfMemoryException if cannot create 
          *         a global reference.
          */
-        jfieldID ReadFieldID(JNIEnv *jni) throw (AgentException);
+        jfieldID ReadFieldID(JNIEnv *jni);
 
         /** 
          * Sequentially reads the <code>MethodID</code> value from the JDWP 
@@ -391,7 +389,7 @@
          * @throws OutOfMemoryException if cannot create 
          *         a global reference.
          */
-        jmethodID ReadMethodID(JNIEnv *jni) throw (AgentException);
+        jmethodID ReadMethodID(JNIEnv *jni);
 
         /** 
          * Sequentially reads the <code>FrameID</code> value from the JDWP 
@@ -406,7 +404,7 @@
          * @throws OutOfMemoryException if cannot create a 
          *         global reference.
          */
-        jint ReadFrameID(JNIEnv *jni) throw (AgentException);
+        jint ReadFrameID(JNIEnv *jni);
 
         /** 
          * Sequentially reads the <code>Location</code> object from the 
@@ -422,9 +420,35 @@
          * @throws OutOfMemoryException if cannot create a 
          *         global reference.
          */
-        jdwpLocation ReadLocation(JNIEnv *jni) throw (AgentException);
+        jdwpLocation ReadLocation(JNIEnv *jni);
 
         /** 
+         * Sequentially reads <code>ThreadID</code> value from JDWP 
+         * packet's data and converts it to <code>jthread</code> through 
+         * <code>ObjectManager</code>. Returns the JNI global reference to 
+         * <code>jthread</code> or null. 
+         * The given global reference is stored inside PacketWrapper 
+         * and can be destroyed with the method Reset().
+         * The given method should be used only in special cases where null 
+         * <code>ThreadID</code> is acceptible.
+         * In usual cases the method <code>ReadThreadID()</code> should be used.
+         *
+         * @param jni - the JNI interface pointer
+         * 
+         * @return The JNI global reference to <code>jthread</code> or null 
+         * reference for null <code>ThreadID</code>.
+         *
+         * @throws InternalErrorException if the number of bytes 
+         *         in the packet data is not enough.
+         * @throws OutOfMemoryException if cannot create a global 
+         *         reference.
+         * @throws AgentException(JDWP_ERROR_INVALID_OBJECT) if 
+         *         <code>ThreadID</code> is invalid or the object was 
+         *         garbage-collected.
+         */
+        jthread ReadThreadIDOrNull(JNIEnv *jni);
+        
+        /** 
          * Sequentially reads the <code>ThreadID</code> value from the JDWP
          * packet's data and convert it to <code>jthreadGroup</code> through 
          * <code>ObjectManager</code>. Returns JNI global reference to the 
@@ -445,7 +469,7 @@
          * @throws AgentException(JDWP_ERROR_NULL_POINTER) if 
          *         <code>ThreadID</code> is null.
          */
-        jthread ReadThreadID(JNIEnv *jni) throw (AgentException);
+        jthread ReadThreadID(JNIEnv *jni);
 
         /** 
          * Sequentially reads the <code>ThreadGroupID</code> value from the 
@@ -469,7 +493,7 @@
          * @throws AgentException(JDWP_ERROR_NULL_POINTER) if 
          *         <code>ThreadGroupID</code> is null.
          */
-        jthreadGroup ReadThreadGroupID(JNIEnv *jni) throw (AgentException);
+        jthreadGroup ReadThreadGroupID(JNIEnv *jni);
 
         /** 
          * Sequentially reads the <code>StringID</code> value from the JDWP 
@@ -495,7 +519,7 @@
          * @throws AgentException(JDWP_ERROR_NULL_POINTER) 
          *         if <code>StringID</code> is null.
          */
-        jstring ReadStringID(JNIEnv *jni) throw (AgentException);
+        jstring ReadStringID(JNIEnv *jni);
 
         /** 
          * Sequentially reads the <code>ArrayID</code> value from the JDWP 
@@ -521,7 +545,7 @@
          * @throws AgentException(JDWP_ERROR_NULL_POINTER) if 
          * <code>ArrayID</code> is null.
          */
-        jarray ReadArrayID(JNIEnv *jni) throw (AgentException);
+        jarray ReadArrayID(JNIEnv *jni);
 
         /** 
          * Sequentially reads the string value from the JDWP packet's data.
@@ -536,7 +560,7 @@
          * @throws OutOfMemoryException if cannot create a global 
          *         reference.
          */
-        char* ReadString() throw (InternalErrorException, OutOfMemoryException);
+        char* ReadString();
 
         /** 
          * Sequentially reads the string value from the JDWP packet's data.
@@ -550,7 +574,7 @@
          * @throws OutOfMemoryException if cannot create a global 
          *         reference.
          */
-        char* ReadStringNoFree() throw (InternalErrorException, OutOfMemoryException);
+        char* ReadStringNoFree();
 
         /** 
          * Sequentially reads the <code>JDWP.Tag</code> value and the following 
@@ -574,7 +598,7 @@
          * @throws AgentException(JDWP_ERROR_NULL_POINTER) if 
          *         <code>ObjectID</code> is null.
          */
-        jdwpTaggedValue ReadValue(JNIEnv *jni) throw (AgentException);
+        jdwpTaggedValue ReadValue(JNIEnv *jni);
 
         /** 
          * Sequentially reads the JDWP value for the selected <code>JDWP.Tag</code> 
@@ -599,7 +623,7 @@
          * @throws AgentException(JDWP_ERROR_NULL_POINTER) if 
          *         <code>ObjectID</code> is null.
          */
-        jvalue ReadUntaggedValue(JNIEnv *jni, jdwpTag tag) throw (AgentException);
+        jvalue ReadUntaggedValue(JNIEnv *jni, jdwpTag tag);
 
         /** 
          * Disposes all stored global references and allocated strings 
@@ -618,17 +642,19 @@
          */
         void MoveData(JNIEnv *jni, InputPacketParser* to);
 
+        void ReleaseData();
+
     protected:
-        jchar ReadChar() throw (InternalErrorException);
-        jshort ReadShort() throw (InternalErrorException);
-        jfloat ReadFloat() throw (InternalErrorException);
-        jdouble ReadDouble() throw (InternalErrorException);
+        jchar ReadChar();
+        jshort ReadShort();
+        jfloat ReadFloat();
+        jdouble ReadDouble();
 
     private:
         int m_position;
 
-        void ReadBigEndianData(void* data, int len) throw (InternalErrorException); 
-        void ReadRawData(void* data, int len) throw (InternalErrorException);
+        void ReadBigEndianData(void* data, int len); 
+        //void ReadRawData(void* data, int len);
     };
 
     /**
@@ -650,6 +676,8 @@
          */
         size_t GetPosition();
 
+        void ReleaseData();
+
         /** 
          * Sets current position in reply packet
          * to the newPosition, passed as parameter.
@@ -702,7 +730,7 @@
          * @param id        - the reply ID
          * @param errorCode - the JDWP error code
          */
-        void CreateJDWPReply(jint id, jdwpError errorCode) throw (InternalErrorException);
+        void CreateJDWPReply(jint id, jdwpError errorCode);
 
         /**
          * Fills header fields with the values specific for the new JDWP event.
@@ -713,14 +741,14 @@
          *
          * @throws InternalErrorException
          */
-        void CreateJDWPEvent(jint id, jdwpCommandSet commandSet, jdwpCommand command) throw (InternalErrorException);
+        void CreateJDWPEvent(jint id, jdwpCommandSet commandSet, jdwpCommand command);
         
         /**
          * Writes an enclosed packet to transport.
          * 
          * @throws TransportException.
          */
-        void WritePacketToTransport() throw (TransportException);
+        int WritePacketToTransport();
 
         /** 
          * Sets an error code.
@@ -729,7 +757,7 @@
          * @param error - the JDWP error code
          */
         void SetError(jdwpError error) {
-            m_packet.type.reply.errorCode = error;
+            m_packet.type.reply.errorCode = (jshort)error;
         }
 
         /**
@@ -739,7 +767,7 @@
          *
          * @throws OutOfMemoryException.
          */
-        void WriteByte(jbyte value) throw (OutOfMemoryException);
+        void WriteByte(jbyte value);
 
         /**
          * Sequentially writes the boolean value to the JDWP packet's data.
@@ -748,7 +776,7 @@
          *
          * @throws OutOfMemoryException.
          */
-        void WriteBoolean(jboolean value) throw (OutOfMemoryException);
+        void WriteBoolean(jboolean value);
 
         /**
          * Sequentially writes the int value to the JDWP packet's data.
@@ -756,7 +784,7 @@
          * @param value - the <code>jint</code> value
          * @throws OutOfMemoryException.
          */
-        void WriteInt(jint value) throw (OutOfMemoryException);
+        void WriteInt(jint value);
 
         /**
          * Sequentially writes the long value to the JDWP packet's data.
@@ -764,7 +792,7 @@
          * @param value- the <code>jlong</code> value
          * @throws OutOfMemoryException.
          */
-        void WriteLong(jlong value) throw (OutOfMemoryException);
+        void WriteLong(jlong value);
         
         /**
          * Sequentially writes the <code>jobject</code> value to the 
@@ -775,7 +803,7 @@
          *
          * @throws AgentException.
          */
-        void WriteObjectID(JNIEnv *jni, jobject value) throw (AgentException);
+        void WriteObjectID(JNIEnv *jni, jobject value);
 
         /**
          * Sequentially writes the <code>jclass</code> value to  
@@ -786,7 +814,7 @@
          *
          * @throws OutOfMemoryException.
          */
-        void WriteReferenceTypeID(JNIEnv *jni, jclass value) throw (OutOfMemoryException);
+        void WriteReferenceTypeID(JNIEnv *jni, jclass value);
 
         /**
          * Sequentially writes the <code>jfieldID</code> value to 
@@ -797,7 +825,7 @@
          *
          * @throws OutOfMemoryException.
          */
-        void WriteFieldID(JNIEnv *jni, jfieldID value) throw (OutOfMemoryException);
+        void WriteFieldID(JNIEnv *jni, jfieldID value);
 
         /**
          * Sequentially writes the <code>jmethodID</code> value to the JDWP
@@ -808,7 +836,7 @@
          * 
          * @throws OutOfMemoryException.
          */
-        void WriteMethodID(JNIEnv *jni, jmethodID value) throw (OutOfMemoryException);
+        void WriteMethodID(JNIEnv *jni, jmethodID value);
 
         /**
          * Sequentially writes the <code>jthread</code> value to the JDWP 
@@ -821,7 +849,7 @@
          *
          * @throws OutOfMemoryException.
          */
-        void WriteFrameID(JNIEnv *jni, jthread jvmThread, jint frameDepth, jint framesCount) throw (OutOfMemoryException);
+        void WriteFrameID(JNIEnv *jni, jthread jvmThread, jint frameDepth, jint framesCount);
 
         /**
          * Sequentially writes the location value to the JDWP packet's data.
@@ -834,7 +862,7 @@
          *
          * @throws OutOfMemoryException.
          */
-        void WriteLocation(JNIEnv *jni, jdwpTypeTag typeTag, jclass classID, jmethodID methodID, jlocation location) throw (OutOfMemoryException);
+        void WriteLocation(JNIEnv *jni, jdwpTypeTag typeTag, jclass classID, jmethodID methodID, jlocation location);
 
         /**
          * Sequentially writes the location value to the JDWP packet's data.
@@ -844,7 +872,7 @@
          *
          * @throws OutOfMemoryException.
          */
-        void WriteLocation(JNIEnv *jni, jdwpLocation *location) throw (OutOfMemoryException);
+        void WriteLocation(JNIEnv *jni, jdwpLocation *location);
 
         /**
          * Sequentially writes the <code>jthread</code> value to the JDWP 
@@ -855,7 +883,7 @@
          *
          * @throws OutOfMemoryException.
          */
-        void WriteThreadID(JNIEnv *jni, jthread value) throw (OutOfMemoryException);
+        void WriteThreadID(JNIEnv *jni, jthread value);
 
         /**
          * Sequentially writes the <code>jthreadGroup</code> value to the JDWP 
@@ -866,7 +894,7 @@
          *
          * @throws OutOfMemoryException.
          */
-        void WriteThreadGroupID(JNIEnv *jni, jthreadGroup value) throw (OutOfMemoryException);
+        void WriteThreadGroupID(JNIEnv *jni, jthreadGroup value);
 
         /**
          * Sequentially writes the <code>jstring</code> value to the JDWP 
@@ -877,7 +905,7 @@
          *
          * @throws OutOfMemoryException.
          */
-        void WriteStringID(JNIEnv *jni, jstring value) throw (OutOfMemoryException);
+        void WriteStringID(JNIEnv *jni, jstring value);
 
         /**
          * Sequentially writes the <code>jarray</code> value to the JDWP 
@@ -888,7 +916,7 @@
          *
          * @throws OutOfMemoryException.
          */
-        void WriteArrayID(JNIEnv *jni, jarray value) throw (OutOfMemoryException);
+        void WriteArrayID(JNIEnv *jni, jarray value);
         
         /**
          * Sequentially writes the string to the JDWP packet's data.
@@ -897,7 +925,7 @@
          *
          * @throws OutOfMemoryException.
          */
-        void WriteString(const char* value) throw (OutOfMemoryException);
+        void WriteString(const char* value);
 
         /**
          * Sequentially writes the string to the JDWP packet's data.
@@ -907,7 +935,7 @@
          *
          * @throws OutOfMemoryException.
          */
-        void WriteString(const char* value, jint length) throw (OutOfMemoryException);
+        void WriteString(const char* value, jint length);
 
         /**
          * Sequentially writes the tagged-object ID.
@@ -917,7 +945,7 @@
          *
          * @throws OutOfMemoryException.
          */
-        void WriteTaggedObjectID(JNIEnv *jni, jobject object) throw (OutOfMemoryException);
+        void WriteTaggedObjectID(JNIEnv *jni, jobject object);
 
         /**
          * Sequentially writes the value object to the JDWP packet's data.
@@ -928,7 +956,7 @@
          *
          * @throws OutOfMemoryException.
          */
-        void WriteValue(JNIEnv *jni, jdwpTag tag, jvalue value) throw (OutOfMemoryException);
+        void WriteValue(JNIEnv *jni, jdwpTag tag, jvalue value);
 
         /**
          * Sequentially writes the array of value objects to the JDWP packet's 
@@ -941,7 +969,7 @@
          *
          * @throws OutOfMemoryException.
          */
-        void WriteValues(JNIEnv *jni, jdwpTag tag, jint length, jvalue* value) throw (OutOfMemoryException);
+        void WriteValues(JNIEnv *jni, jdwpTag tag, jint length, jvalue* value);
 
         /**
          * Sequentially writes the untagged value object to the JDWP 
@@ -953,7 +981,7 @@
          *
          * @throws OutOfMemoryException.
          */
-        void WriteUntaggedValue(JNIEnv *jni, jdwpTag tag, jvalue value) throw (OutOfMemoryException);
+        void WriteUntaggedValue(JNIEnv *jni, jdwpTag tag, jvalue value);
 
         /**
          * Sequentially writes the array length, then the byte array values 
@@ -964,7 +992,7 @@
          *
          * @throws OutOfMemoryException.
          */
-        void WriteByteArray(jbyte* byte, jint length) throw (OutOfMemoryException);
+        void WriteByteArray(jbyte* byte, jint length);
 
         /** 
          * Disposes all stored references and prepares 
@@ -986,13 +1014,13 @@
     protected:
         void SetId(jint id) { m_packet.type.cmd.id = id; }
         void SetFlags(jbyte flags) { m_packet.type.cmd.flags = flags; }
-        void SetCommandSet(jdwpCommandSet cmdSet) { m_packet.type.cmd.cmdSet = cmdSet; }
-        void SetCommand(jdwpCommand command) { m_packet.type.cmd.cmd = command; }
+        void SetCommandSet(jdwpCommandSet cmdSet) { m_packet.type.cmd.cmdSet = (jbyte)cmdSet; }
+        void SetCommand(jdwpCommand command) { m_packet.type.cmd.cmd = (jbyte)command; }
 
-        void WriteChar(jchar value) throw (OutOfMemoryException);
-        void WriteShort(jshort value) throw (OutOfMemoryException);
-        void WriteFloat(jfloat value) throw (OutOfMemoryException);
-        void WriteDouble(jdouble value) throw (OutOfMemoryException);
+        void WriteChar(jchar value);
+        void WriteShort(jshort value);
+        void WriteFloat(jfloat value);
+        void WriteDouble(jdouble value);
 
     private:
         size_t m_position;
@@ -1002,10 +1030,10 @@
         int m_registeredObjectIDCount;
         int m_registeredObjectIDTableSise; // in ObjectID
 
-        void AllocateMemoryForData(int length) throw (OutOfMemoryException);
-        void WriteData(const void* data, int length) throw (OutOfMemoryException);
-        void WriteRawData(const void* data, int length) throw (OutOfMemoryException);
-        void WriteBigEndianData(void* data, int length) throw (OutOfMemoryException);
+        void AllocateMemoryForData(int length);
+        void WriteData(const void* data, int length);
+        void WriteRawData(const void* data, int length);
+        void WriteBigEndianData(void* data, int length);
 
         /** 
          * Registers given <code>objectID</code> in a special table containing 
@@ -1024,7 +1052,7 @@
          *            <code>AgentException(JDWP_ERROR_INTERNAL)</code> - if an 
          *            unexpected internal JDWP agent error has occurred.
          */
-        void RegisterObjectID(ObjectID objectID) throw (AgentException);
+        void RegisterObjectID(ObjectID objectID);
 
         /** 
          * Increases by one the count of references for all <code>ObjectID</code> values
@@ -1053,7 +1081,7 @@
          * 
          * @exception TransportException.
          */
-        void ReadCommand() throw (TransportException);
+        int ReadCommand();
 
         /**
          * Writes the reply packet to the transport and resets the 
@@ -1063,7 +1091,7 @@
          *
          * @exception TransportException
          */
-        void WriteReply(JNIEnv *jni) throw (TransportException);
+        int WriteReply(JNIEnv *jni);
 
         /**
          * Moves all data to another CommandParser  instance.
@@ -1083,13 +1111,15 @@
          */
         OutputPacketComposer reply;
 
-    private:
-
         /**
          * Resets the given CommandParser  object.
          */
         void Reset(JNIEnv *jni);
 
+        ~CommandParser();
+
+    private:
+
     };
 
     /**
@@ -1111,6 +1141,8 @@
         EventComposer(jint id, jdwpCommandSet commandSet, jdwpCommand command,
             jdwpSuspendPolicy sp);
 
+        ~EventComposer();
+
         /**
          * Writes a thread ID to the output packet and creates a global reference
          * to the thread.
@@ -1120,8 +1152,7 @@
          *
          * @exception OutOfMemoryException.
          */
-        void WriteThread(JNIEnv *jni, jthread thread)
-            throw (OutOfMemoryException);
+        void WriteThread(JNIEnv *jni, jthread thread);
 
         /**
          * Disposes all stored references and prepares CommandParser 
@@ -1131,7 +1162,7 @@
          *
          * @exception TransportException.
          */
-        void WriteEvent(JNIEnv *jni) throw (TransportException);
+        int WriteEvent(JNIEnv *jni);
 
         /**
          * Resets the current JDWP event.



Mime
View raw message