From 61c5ebc6aee2cac1c363de6fbdac25ada1697fdb Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Thu, 5 Jun 2014 17:42:53 -0700 Subject: Change FieldHelper to use a handle. Fixed compaction bugs related to FieldHelper::GetType in: artSet32InstanceFromCode SetFieldValueImpl CheckReceiver Field_set interpreter::DoFieldPut MethodVerifier::VerifyISGet MethodVerifier::VerifyISPut MethodVerifier::VerifyIGetQuick Bug: 13077697 Change-Id: I7de9ded2893b5568d43e4daa86fd135bf5508b72 --- runtime/proxy_test.cc | 66 +++++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 29 deletions(-) (limited to 'runtime/proxy_test.cc') diff --git a/runtime/proxy_test.cc b/runtime/proxy_test.cc index f38fb2155b..76badc82e3 100644 --- a/runtime/proxy_test.cc +++ b/runtime/proxy_test.cc @@ -140,52 +140,60 @@ TEST_F(ProxyTest, ProxyClassHelper) { TEST_F(ProxyTest, ProxyFieldHelper) { ScopedObjectAccess soa(Thread::Current()); jobject jclass_loader = LoadDex("Interfaces"); - StackHandleScope<1> hs(soa.Self()); + StackHandleScope<9> hs(soa.Self()); Handle class_loader( hs.NewHandle(soa.Decode(jclass_loader))); - mirror::Class* I = class_linker_->FindClass(soa.Self(), "LInterfaces$I;", class_loader); - mirror::Class* J = class_linker_->FindClass(soa.Self(), "LInterfaces$J;", class_loader); - ASSERT_TRUE(I != nullptr); - ASSERT_TRUE(J != nullptr); - std::vector interfaces; - interfaces.push_back(I); - interfaces.push_back(J); + Handle I(hs.NewHandle( + class_linker_->FindClass(soa.Self(), "LInterfaces$I;", class_loader))); + Handle J(hs.NewHandle( + class_linker_->FindClass(soa.Self(), "LInterfaces$J;", class_loader))); + ASSERT_TRUE(I.Get() != nullptr); + ASSERT_TRUE(J.Get() != nullptr); + + Handle proxyClass; + { + std::vector interfaces; + interfaces.push_back(I.Get()); + interfaces.push_back(J.Get()); + proxyClass = hs.NewHandle(GenerateProxyClass(soa, jclass_loader, "$Proxy1234", interfaces)); + } - mirror::Class* proxyClass = GenerateProxyClass(soa, jclass_loader, "$Proxy1234", interfaces); - ASSERT_TRUE(proxyClass != nullptr); + ASSERT_TRUE(proxyClass.Get() != nullptr); ASSERT_TRUE(proxyClass->IsProxyClass()); ASSERT_TRUE(proxyClass->IsInitialized()); - mirror::ObjectArray* instance_fields = proxyClass->GetIFields(); - EXPECT_TRUE(instance_fields == nullptr); + Handle> instance_fields( + hs.NewHandle(proxyClass->GetIFields())); + EXPECT_TRUE(instance_fields.Get() == nullptr); - mirror::ObjectArray* static_fields = proxyClass->GetSFields(); - ASSERT_TRUE(static_fields != nullptr); + Handle> static_fields( + hs.NewHandle(proxyClass->GetSFields())); + ASSERT_TRUE(static_fields.Get() != nullptr); ASSERT_EQ(2, static_fields->GetLength()); - mirror::Class* interfacesFieldClass = class_linker_->FindSystemClass(soa.Self(), - "[Ljava/lang/Class;"); - ASSERT_TRUE(interfacesFieldClass != nullptr); - mirror::Class* throwsFieldClass = class_linker_->FindSystemClass(soa.Self(), - "[[Ljava/lang/Class;"); - ASSERT_TRUE(throwsFieldClass != nullptr); + Handle interfacesFieldClass( + hs.NewHandle(class_linker_->FindSystemClass(soa.Self(), "[Ljava/lang/Class;"))); + ASSERT_TRUE(interfacesFieldClass.Get() != nullptr); + Handle throwsFieldClass( + hs.NewHandle(class_linker_->FindSystemClass(soa.Self(), "[[Ljava/lang/Class;"))); + ASSERT_TRUE(throwsFieldClass.Get() != nullptr); // Test "Class[] interfaces" field. - FieldHelper fh(static_fields->Get(0)); - EXPECT_EQ("interfaces", std::string(fh.GetName())); - EXPECT_EQ("[Ljava/lang/Class;", std::string(fh.GetTypeDescriptor())); - EXPECT_EQ(interfacesFieldClass, fh.GetType()); + FieldHelper fh(hs.NewHandle(static_fields->Get(0))); + EXPECT_EQ("interfaces", std::string(fh.GetField()->GetName())); + EXPECT_EQ("[Ljava/lang/Class;", std::string(fh.GetField()->GetTypeDescriptor())); + EXPECT_EQ(interfacesFieldClass.Get(), fh.GetType()); EXPECT_EQ("L$Proxy1234;", std::string(fh.GetDeclaringClassDescriptor())); - EXPECT_FALSE(fh.IsPrimitiveType()); + EXPECT_FALSE(fh.GetField()->IsPrimitiveType()); // Test "Class[][] throws" field. fh.ChangeField(static_fields->Get(1)); - EXPECT_EQ("throws", std::string(fh.GetName())); - EXPECT_EQ("[[Ljava/lang/Class;", std::string(fh.GetTypeDescriptor())); - EXPECT_EQ(throwsFieldClass, fh.GetType()); + EXPECT_EQ("throws", std::string(fh.GetField()->GetName())); + EXPECT_EQ("[[Ljava/lang/Class;", std::string(fh.GetField()->GetTypeDescriptor())); + EXPECT_EQ(throwsFieldClass.Get(), fh.GetType()); EXPECT_EQ("L$Proxy1234;", std::string(fh.GetDeclaringClassDescriptor())); - EXPECT_FALSE(fh.IsPrimitiveType()); + EXPECT_FALSE(fh.GetField()->IsPrimitiveType()); } } // namespace art -- cgit v1.2.3