From 6a144338023bdc0ca6954fc71a1f9b4d94088ee4 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 3 Apr 2012 13:07:11 -0700 Subject: Switch to Thread::WalkStack rather than manual Frame::Next. Also fix test 039. Change-Id: I07d0559bb86d67a7f7947768bd8370fb4cf06c26 --- src/java_lang_Class.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/java_lang_Class.cc') diff --git a/src/java_lang_Class.cc b/src/java_lang_Class.cc index fcd168974c..17b584a340 100644 --- a/src/java_lang_Class.cc +++ b/src/java_lang_Class.cc @@ -17,6 +17,7 @@ #include "jni_internal.h" #include "class_linker.h" #include "class_loader.h" +#include "nth_caller_visitor.h" #include "object.h" #include "object_utils.h" #include "ScopedLocalRef.h" @@ -422,12 +423,10 @@ static jobject Class_newInstanceImpl(JNIEnv* env, jobject javaThis) { // Second, make sure it has permission to invoke the constructor. The // constructor must be public or, if the caller is in the same package, // have package scope. - // TODO: need SmartFrame (Thread::WalkStack-like iterator). - Frame frame = Thread::Current()->GetTopOfStack(); - frame.Next(); - frame.Next(); - Method* caller_caller = frame.GetMethod(); - Class* caller_class = caller_caller->GetDeclaringClass(); + + NthCallerVisitor visitor(2); + Thread::Current()->WalkStack(&visitor); + Class* caller_class = visitor.declaring_class; ClassHelper caller_ch(caller_class); if (!caller_class->CanAccess(c)) { -- cgit v1.2.3-59-g8ed1b