From 064d24e921978a1d44f23aced69d2657d81e9af4 Mon Sep 17 00:00:00 2001 From: Jeff Hao Date: Thu, 25 Aug 2016 03:52:40 +0000 Subject: Revert "Revert "Fix debugger calling new String()."" Bug: 30951794 Test: mm -j24 run-jdwp-tests-host This reverts commit 6f48d4c72e7b4011a6d9652734bd1cb0c389790b. This also includes the reversion of commit 528954f55e3173b02df2822c1fc680873d6a91c8. Change-Id: If0b2ae39cb2a9db80b567bb8d5761d504433632d --- runtime/debugger.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'runtime/debugger.cc') diff --git a/runtime/debugger.cc b/runtime/debugger.cc index cbdf3dc636..a5b0689473 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -4058,7 +4058,7 @@ void Dbg::ExecuteMethodWithoutPendingException(ScopedObjectAccess& soa, DebugInv // Prepare JDWP ids for the reply. JDWP::JdwpTag result_tag = BasicTagFromDescriptor(m->GetShorty()); const bool is_object_result = (result_tag == JDWP::JT_OBJECT); - StackHandleScope<2> hs(soa.Self()); + StackHandleScope<3> hs(soa.Self()); Handle object_result = hs.NewHandle(is_object_result ? result.GetL() : nullptr); Handle exception = hs.NewHandle(soa.Self()->GetException()); soa.Self()->ClearException(); @@ -4097,10 +4097,17 @@ void Dbg::ExecuteMethodWithoutPendingException(ScopedObjectAccess& soa, DebugInv // unless we threw, in which case we return null. DCHECK_EQ(JDWP::JT_VOID, result_tag); if (exceptionObjectId == 0) { - // TODO we could keep the receiver ObjectId in the DebugInvokeReq to avoid looking into the - // object registry. - result_value = GetObjectRegistry()->Add(pReq->receiver.Read()); - result_tag = TagFromObject(soa, pReq->receiver.Read()); + if (m->GetDeclaringClass()->IsStringClass()) { + // For string constructors, the new string is remapped to the receiver (stored in ref). + Handle decoded_ref = hs.NewHandle(soa.Self()->DecodeJObject(ref.get())); + result_value = gRegistry->Add(decoded_ref); + result_tag = TagFromObject(soa, decoded_ref.Get()); + } else { + // TODO we could keep the receiver ObjectId in the DebugInvokeReq to avoid looking into the + // object registry. + result_value = GetObjectRegistry()->Add(pReq->receiver.Read()); + result_tag = TagFromObject(soa, pReq->receiver.Read()); + } } else { result_value = 0; result_tag = JDWP::JT_OBJECT; -- cgit v1.2.3-59-g8ed1b