harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From regi...@apache.org
Subject svn commit: r997994 - /harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.cpp
Date Fri, 17 Sep 2010 06:38:58 GMT
Author: regisxu
Date: Fri Sep 17 06:38:57 2010
New Revision: 997994

URL: http://svn.apache.org/viewvc?rev=997994&view=rev
Log:
'obj' is still useful, delete local reference at more safe place.

Modified:
    harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.cpp

Modified: harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.cpp?rev=997994&r1=997993&r2=997994&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.cpp
(original)
+++ harmony/enhanced/java/branches/java6/jdktools/modules/jpda/src/main/native/jdwp/common/agent/core/PacketParser.cpp
Fri Sep 17 06:38:57 2010
@@ -313,10 +313,11 @@ jclass InputPacketParser::ReadReferenceT
     }
 
     jclass cls = 0;
+    jobject obj = 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);
+        obj = GetObjectManager().MapFromObjectID(jni, rtid);
         if (NULL == obj) {
             JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "MapFromObjectID returned NULL"));
             AgentException ex(JDWP_ERROR_INVALID_OBJECT);
@@ -336,10 +337,10 @@ jclass InputPacketParser::ReadReferenceT
           if (isClass) {
             JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "## ReadReferenceTypeIDOrNul: read : ObjectID
is a ClassObjectID"));
             cls = static_cast<jclass> (obj);
-            jni->DeleteLocalRef(obj);
             
-            jboolean isValidID = GetObjectManager().FindObjectID(jni, cls, rtid); 
+            jboolean isValidID = GetObjectManager().FindObjectID(jni, cls, rtid);
             if(!isValidID) {
+              jni->DeleteLocalRef(obj);
               JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "## ReadReferenceTypeIDOrNul: read :
ID is an invalid ObjectID"));
               AgentException ex(JDWP_ERROR_INVALID_OBJECT);
               JDWP_SET_EXCEPTION(ex);
@@ -369,6 +370,9 @@ jclass InputPacketParser::ReadReferenceT
     
     // make GlobalReference and check if WeakReference was freed
     jclass ref = static_cast<jclass>(jni->NewGlobalRef(cls));
+    if (obj != 0) {
+        jni->DeleteLocalRef(obj);
+    }
     if (ref == 0) {
         if (jni->IsSameObject(cls, 0)) {
             JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Invalid object calling NewGlobalRef"));



Mime
View raw message