Sebastien Hertz | b7054ba | 2014-03-13 11:52:31 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Sebastien Hertz | b7054ba | 2014-03-13 11:52:31 +0100 | [diff] [blame] | 17 | #include <jni.h> |
| 18 | #include <vector> |
| 19 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 20 | #include "art_field-inl.h" |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 21 | #include "base/enums.h" |
Vladimir Marko | 3481ba2 | 2015-04-13 12:22:36 +0100 | [diff] [blame] | 22 | #include "class_linker-inl.h" |
Jeff Hao | db8a664 | 2014-08-14 17:18:52 -0700 | [diff] [blame] | 23 | #include "common_compiler_test.h" |
Hiroshi Yamauchi | 2debd80 | 2015-05-20 15:51:29 -0700 | [diff] [blame] | 24 | #include "mirror/field-inl.h" |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 25 | #include "mirror/method.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 26 | #include "scoped_thread_state_change.h" |
| 27 | |
Sebastien Hertz | b7054ba | 2014-03-13 11:52:31 +0100 | [diff] [blame] | 28 | namespace art { |
| 29 | |
Jeff Hao | db8a664 | 2014-08-14 17:18:52 -0700 | [diff] [blame] | 30 | class ProxyTest : public CommonCompilerTest { |
Sebastien Hertz | b7054ba | 2014-03-13 11:52:31 +0100 | [diff] [blame] | 31 | public: |
| 32 | // Generate a proxy class with the given name and interfaces. This is a simplification from what |
| 33 | // libcore does to fit to our test needs. We do not check for duplicated interfaces or methods and |
| 34 | // we do not declare exceptions. |
| 35 | mirror::Class* GenerateProxyClass(ScopedObjectAccess& soa, jobject jclass_loader, |
| 36 | const char* className, |
| 37 | const std::vector<mirror::Class*>& interfaces) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 38 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Sebastien Hertz | b7054ba | 2014-03-13 11:52:31 +0100 | [diff] [blame] | 39 | mirror::Class* javaLangObject = class_linker_->FindSystemClass(soa.Self(), "Ljava/lang/Object;"); |
| 40 | CHECK(javaLangObject != nullptr); |
| 41 | |
| 42 | jclass javaLangClass = soa.AddLocalReference<jclass>(mirror::Class::GetJavaLangClass()); |
| 43 | |
| 44 | // Builds the interfaces array. |
| 45 | jobjectArray proxyClassInterfaces = soa.Env()->NewObjectArray(interfaces.size(), javaLangClass, |
| 46 | nullptr); |
| 47 | soa.Self()->AssertNoPendingException(); |
| 48 | for (size_t i = 0; i < interfaces.size(); ++i) { |
| 49 | soa.Env()->SetObjectArrayElement(proxyClassInterfaces, i, |
| 50 | soa.AddLocalReference<jclass>(interfaces[i])); |
| 51 | } |
| 52 | |
| 53 | // Builds the method array. |
| 54 | jsize methods_count = 3; // Object.equals, Object.hashCode and Object.toString. |
| 55 | for (mirror::Class* interface : interfaces) { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 56 | methods_count += interface->NumVirtualMethods(); |
Sebastien Hertz | b7054ba | 2014-03-13 11:52:31 +0100 | [diff] [blame] | 57 | } |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 58 | jobjectArray proxyClassMethods = soa.Env()->NewObjectArray( |
| 59 | methods_count, soa.AddLocalReference<jclass>(mirror::Method::StaticClass()), nullptr); |
Sebastien Hertz | b7054ba | 2014-03-13 11:52:31 +0100 | [diff] [blame] | 60 | soa.Self()->AssertNoPendingException(); |
| 61 | |
Sebastien Hertz | b7054ba | 2014-03-13 11:52:31 +0100 | [diff] [blame] | 62 | jsize array_index = 0; |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 63 | // Fill the method array |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 64 | DCHECK_EQ(Runtime::Current()->GetClassLinker()->GetImagePointerSize(), kRuntimePointerSize); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 65 | ArtMethod* method = javaLangObject->FindDeclaredVirtualMethod( |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 66 | "equals", "(Ljava/lang/Object;)Z", kRuntimePointerSize); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 67 | CHECK(method != nullptr); |
Andreas Gampe | e01e364 | 2016-07-25 13:06:04 -0700 | [diff] [blame] | 68 | DCHECK(!Runtime::Current()->IsActiveTransaction()); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 69 | soa.Env()->SetObjectArrayElement( |
| 70 | proxyClassMethods, array_index++, soa.AddLocalReference<jobject>( |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 71 | mirror::Method::CreateFromArtMethod<kRuntimePointerSize, false>(soa.Self(), method))); |
| 72 | method = javaLangObject->FindDeclaredVirtualMethod("hashCode", "()I", kRuntimePointerSize); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 73 | CHECK(method != nullptr); |
| 74 | soa.Env()->SetObjectArrayElement( |
| 75 | proxyClassMethods, array_index++, soa.AddLocalReference<jobject>( |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 76 | mirror::Method::CreateFromArtMethod<kRuntimePointerSize, false>(soa.Self(), method))); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 77 | method = javaLangObject->FindDeclaredVirtualMethod( |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 78 | "toString", "()Ljava/lang/String;", kRuntimePointerSize); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 79 | CHECK(method != nullptr); |
| 80 | soa.Env()->SetObjectArrayElement( |
| 81 | proxyClassMethods, array_index++, soa.AddLocalReference<jobject>( |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 82 | mirror::Method::CreateFromArtMethod<kRuntimePointerSize, false>(soa.Self(), method))); |
Sebastien Hertz | b7054ba | 2014-03-13 11:52:31 +0100 | [diff] [blame] | 83 | // Now adds all interfaces virtual methods. |
| 84 | for (mirror::Class* interface : interfaces) { |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 85 | for (auto& m : interface->GetDeclaredVirtualMethods(kRuntimePointerSize)) { |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 86 | soa.Env()->SetObjectArrayElement( |
| 87 | proxyClassMethods, array_index++, soa.AddLocalReference<jobject>( |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 88 | mirror::Method::CreateFromArtMethod<kRuntimePointerSize, false>(soa.Self(), &m))); |
Sebastien Hertz | b7054ba | 2014-03-13 11:52:31 +0100 | [diff] [blame] | 89 | } |
| 90 | } |
| 91 | CHECK_EQ(array_index, methods_count); |
| 92 | |
| 93 | // Builds an empty exception array. |
| 94 | jobjectArray proxyClassThrows = soa.Env()->NewObjectArray(0, javaLangClass, nullptr); |
| 95 | soa.Self()->AssertNoPendingException(); |
| 96 | |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 97 | mirror::Class* proxyClass = class_linker_->CreateProxyClass( |
| 98 | soa, soa.Env()->NewStringUTF(className), proxyClassInterfaces, jclass_loader, |
| 99 | proxyClassMethods, proxyClassThrows); |
Sebastien Hertz | b7054ba | 2014-03-13 11:52:31 +0100 | [diff] [blame] | 100 | soa.Self()->AssertNoPendingException(); |
| 101 | return proxyClass; |
| 102 | } |
| 103 | }; |
| 104 | |
| 105 | // Creates a proxy class and check ClassHelper works correctly. |
| 106 | TEST_F(ProxyTest, ProxyClassHelper) { |
| 107 | ScopedObjectAccess soa(Thread::Current()); |
| 108 | jobject jclass_loader = LoadDex("Interfaces"); |
Mathieu Chartier | f832284 | 2014-05-16 10:59:25 -0700 | [diff] [blame] | 109 | StackHandleScope<4> hs(soa.Self()); |
Mathieu Chartier | eb8167a | 2014-05-07 15:43:14 -0700 | [diff] [blame] | 110 | Handle<mirror::ClassLoader> class_loader( |
| 111 | hs.NewHandle(soa.Decode<mirror::ClassLoader*>(jclass_loader))); |
Sebastien Hertz | b7054ba | 2014-03-13 11:52:31 +0100 | [diff] [blame] | 112 | |
Mathieu Chartier | f832284 | 2014-05-16 10:59:25 -0700 | [diff] [blame] | 113 | Handle<mirror::Class> I(hs.NewHandle( |
| 114 | class_linker_->FindClass(soa.Self(), "LInterfaces$I;", class_loader))); |
| 115 | Handle<mirror::Class> J(hs.NewHandle( |
| 116 | class_linker_->FindClass(soa.Self(), "LInterfaces$J;", class_loader))); |
| 117 | ASSERT_TRUE(I.Get() != nullptr); |
| 118 | ASSERT_TRUE(J.Get() != nullptr); |
Sebastien Hertz | b7054ba | 2014-03-13 11:52:31 +0100 | [diff] [blame] | 119 | |
Mathieu Chartier | f832284 | 2014-05-16 10:59:25 -0700 | [diff] [blame] | 120 | std::vector<mirror::Class*> interfaces; |
| 121 | interfaces.push_back(I.Get()); |
| 122 | interfaces.push_back(J.Get()); |
| 123 | Handle<mirror::Class> proxy_class(hs.NewHandle( |
| 124 | GenerateProxyClass(soa, jclass_loader, "$Proxy1234", interfaces))); |
| 125 | interfaces.clear(); // Don't least possibly stale objects in the array as good practice. |
| 126 | ASSERT_TRUE(proxy_class.Get() != nullptr); |
Nicolas Geoffray | 3a09092 | 2015-11-24 09:17:30 +0000 | [diff] [blame] | 127 | ASSERT_TRUE(proxy_class->IsProxyClass()); |
Mathieu Chartier | f832284 | 2014-05-16 10:59:25 -0700 | [diff] [blame] | 128 | ASSERT_TRUE(proxy_class->IsInitialized()); |
Sebastien Hertz | b7054ba | 2014-03-13 11:52:31 +0100 | [diff] [blame] | 129 | |
Sebastien Hertz | 4206eb5 | 2014-06-05 10:15:45 +0200 | [diff] [blame] | 130 | EXPECT_EQ(2U, proxy_class->NumDirectInterfaces()); // Interfaces$I and Interfaces$J. |
Mathieu Chartier | f832284 | 2014-05-16 10:59:25 -0700 | [diff] [blame] | 131 | EXPECT_EQ(I.Get(), mirror::Class::GetDirectInterface(soa.Self(), proxy_class, 0)); |
| 132 | EXPECT_EQ(J.Get(), mirror::Class::GetDirectInterface(soa.Self(), proxy_class, 1)); |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 133 | std::string temp; |
| 134 | const char* proxy_class_descriptor = proxy_class->GetDescriptor(&temp); |
| 135 | EXPECT_STREQ("L$Proxy1234;", proxy_class_descriptor); |
Sebastien Hertz | 4206eb5 | 2014-06-05 10:15:45 +0200 | [diff] [blame] | 136 | EXPECT_EQ(nullptr, proxy_class->GetSourceFile()); |
Sebastien Hertz | b7054ba | 2014-03-13 11:52:31 +0100 | [diff] [blame] | 137 | } |
| 138 | |
Sebastien Hertz | 80989a6 | 2014-04-01 14:39:44 +0200 | [diff] [blame] | 139 | // Creates a proxy class and check FieldHelper works correctly. |
| 140 | TEST_F(ProxyTest, ProxyFieldHelper) { |
| 141 | ScopedObjectAccess soa(Thread::Current()); |
| 142 | jobject jclass_loader = LoadDex("Interfaces"); |
Mathieu Chartier | 61c5ebc | 2014-06-05 17:42:53 -0700 | [diff] [blame] | 143 | StackHandleScope<9> hs(soa.Self()); |
Mathieu Chartier | eb8167a | 2014-05-07 15:43:14 -0700 | [diff] [blame] | 144 | Handle<mirror::ClassLoader> class_loader( |
| 145 | hs.NewHandle(soa.Decode<mirror::ClassLoader*>(jclass_loader))); |
Sebastien Hertz | 80989a6 | 2014-04-01 14:39:44 +0200 | [diff] [blame] | 146 | |
Mathieu Chartier | 61c5ebc | 2014-06-05 17:42:53 -0700 | [diff] [blame] | 147 | Handle<mirror::Class> I(hs.NewHandle( |
| 148 | class_linker_->FindClass(soa.Self(), "LInterfaces$I;", class_loader))); |
| 149 | Handle<mirror::Class> J(hs.NewHandle( |
| 150 | class_linker_->FindClass(soa.Self(), "LInterfaces$J;", class_loader))); |
| 151 | ASSERT_TRUE(I.Get() != nullptr); |
| 152 | ASSERT_TRUE(J.Get() != nullptr); |
Sebastien Hertz | 80989a6 | 2014-04-01 14:39:44 +0200 | [diff] [blame] | 153 | |
Mathieu Chartier | 61c5ebc | 2014-06-05 17:42:53 -0700 | [diff] [blame] | 154 | Handle<mirror::Class> proxyClass; |
| 155 | { |
| 156 | std::vector<mirror::Class*> interfaces; |
| 157 | interfaces.push_back(I.Get()); |
| 158 | interfaces.push_back(J.Get()); |
| 159 | proxyClass = hs.NewHandle(GenerateProxyClass(soa, jclass_loader, "$Proxy1234", interfaces)); |
| 160 | } |
| 161 | |
| 162 | ASSERT_TRUE(proxyClass.Get() != nullptr); |
Nicolas Geoffray | 3a09092 | 2015-11-24 09:17:30 +0000 | [diff] [blame] | 163 | ASSERT_TRUE(proxyClass->IsProxyClass()); |
Sebastien Hertz | 80989a6 | 2014-04-01 14:39:44 +0200 | [diff] [blame] | 164 | ASSERT_TRUE(proxyClass->IsInitialized()); |
| 165 | |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 166 | EXPECT_TRUE(proxyClass->GetIFieldsPtr() == nullptr); |
Sebastien Hertz | 80989a6 | 2014-04-01 14:39:44 +0200 | [diff] [blame] | 167 | |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 168 | LengthPrefixedArray<ArtField>* static_fields = proxyClass->GetSFieldsPtr(); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 169 | ASSERT_TRUE(static_fields != nullptr); |
| 170 | ASSERT_EQ(2u, proxyClass->NumStaticFields()); |
Sebastien Hertz | 80989a6 | 2014-04-01 14:39:44 +0200 | [diff] [blame] | 171 | |
Mathieu Chartier | 61c5ebc | 2014-06-05 17:42:53 -0700 | [diff] [blame] | 172 | Handle<mirror::Class> interfacesFieldClass( |
| 173 | hs.NewHandle(class_linker_->FindSystemClass(soa.Self(), "[Ljava/lang/Class;"))); |
| 174 | ASSERT_TRUE(interfacesFieldClass.Get() != nullptr); |
| 175 | Handle<mirror::Class> throwsFieldClass( |
| 176 | hs.NewHandle(class_linker_->FindSystemClass(soa.Self(), "[[Ljava/lang/Class;"))); |
| 177 | ASSERT_TRUE(throwsFieldClass.Get() != nullptr); |
Sebastien Hertz | 80989a6 | 2014-04-01 14:39:44 +0200 | [diff] [blame] | 178 | |
| 179 | // Test "Class[] interfaces" field. |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 180 | ArtField* field = &static_fields->At(0); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 181 | EXPECT_STREQ("interfaces", field->GetName()); |
| 182 | EXPECT_STREQ("[Ljava/lang/Class;", field->GetTypeDescriptor()); |
| 183 | EXPECT_EQ(interfacesFieldClass.Get(), field->GetType<true>()); |
Ian Rogers | 08f1f50 | 2014-12-02 15:04:37 -0800 | [diff] [blame] | 184 | std::string temp; |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 185 | EXPECT_STREQ("L$Proxy1234;", field->GetDeclaringClass()->GetDescriptor(&temp)); |
| 186 | EXPECT_FALSE(field->IsPrimitiveType()); |
Sebastien Hertz | 80989a6 | 2014-04-01 14:39:44 +0200 | [diff] [blame] | 187 | |
| 188 | // Test "Class[][] throws" field. |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 189 | field = &static_fields->At(1); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 190 | EXPECT_STREQ("throws", field->GetName()); |
| 191 | EXPECT_STREQ("[[Ljava/lang/Class;", field->GetTypeDescriptor()); |
| 192 | EXPECT_EQ(throwsFieldClass.Get(), field->GetType<true>()); |
| 193 | EXPECT_STREQ("L$Proxy1234;", field->GetDeclaringClass()->GetDescriptor(&temp)); |
| 194 | EXPECT_FALSE(field->IsPrimitiveType()); |
Sebastien Hertz | 80989a6 | 2014-04-01 14:39:44 +0200 | [diff] [blame] | 195 | } |
Sebastien Hertz | b7054ba | 2014-03-13 11:52:31 +0100 | [diff] [blame] | 196 | |
Hiroshi Yamauchi | 2debd80 | 2015-05-20 15:51:29 -0700 | [diff] [blame] | 197 | // Creates two proxy classes and check the art/mirror fields of their static fields. |
| 198 | TEST_F(ProxyTest, CheckArtMirrorFieldsOfProxyStaticFields) { |
| 199 | ScopedObjectAccess soa(Thread::Current()); |
| 200 | jobject jclass_loader = LoadDex("Interfaces"); |
| 201 | StackHandleScope<7> hs(soa.Self()); |
| 202 | Handle<mirror::ClassLoader> class_loader( |
| 203 | hs.NewHandle(soa.Decode<mirror::ClassLoader*>(jclass_loader))); |
| 204 | |
| 205 | Handle<mirror::Class> proxyClass0; |
| 206 | Handle<mirror::Class> proxyClass1; |
| 207 | { |
| 208 | std::vector<mirror::Class*> interfaces; |
| 209 | proxyClass0 = hs.NewHandle(GenerateProxyClass(soa, jclass_loader, "$Proxy0", interfaces)); |
| 210 | proxyClass1 = hs.NewHandle(GenerateProxyClass(soa, jclass_loader, "$Proxy1", interfaces)); |
| 211 | } |
| 212 | |
| 213 | ASSERT_TRUE(proxyClass0.Get() != nullptr); |
Nicolas Geoffray | 3a09092 | 2015-11-24 09:17:30 +0000 | [diff] [blame] | 214 | ASSERT_TRUE(proxyClass0->IsProxyClass()); |
Hiroshi Yamauchi | 2debd80 | 2015-05-20 15:51:29 -0700 | [diff] [blame] | 215 | ASSERT_TRUE(proxyClass0->IsInitialized()); |
| 216 | ASSERT_TRUE(proxyClass1.Get() != nullptr); |
Nicolas Geoffray | 3a09092 | 2015-11-24 09:17:30 +0000 | [diff] [blame] | 217 | ASSERT_TRUE(proxyClass1->IsProxyClass()); |
Hiroshi Yamauchi | 2debd80 | 2015-05-20 15:51:29 -0700 | [diff] [blame] | 218 | ASSERT_TRUE(proxyClass1->IsInitialized()); |
| 219 | |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 220 | LengthPrefixedArray<ArtField>* static_fields0 = proxyClass0->GetSFieldsPtr(); |
Hiroshi Yamauchi | 2debd80 | 2015-05-20 15:51:29 -0700 | [diff] [blame] | 221 | ASSERT_TRUE(static_fields0 != nullptr); |
Vladimir Marko | 35831e8 | 2015-09-11 11:59:18 +0100 | [diff] [blame] | 222 | ASSERT_EQ(2u, static_fields0->size()); |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 223 | LengthPrefixedArray<ArtField>* static_fields1 = proxyClass1->GetSFieldsPtr(); |
Hiroshi Yamauchi | 2debd80 | 2015-05-20 15:51:29 -0700 | [diff] [blame] | 224 | ASSERT_TRUE(static_fields1 != nullptr); |
Vladimir Marko | 35831e8 | 2015-09-11 11:59:18 +0100 | [diff] [blame] | 225 | ASSERT_EQ(2u, static_fields1->size()); |
Hiroshi Yamauchi | 2debd80 | 2015-05-20 15:51:29 -0700 | [diff] [blame] | 226 | |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 227 | EXPECT_EQ(static_fields0->At(0).GetDeclaringClass(), proxyClass0.Get()); |
| 228 | EXPECT_EQ(static_fields0->At(1).GetDeclaringClass(), proxyClass0.Get()); |
| 229 | EXPECT_EQ(static_fields1->At(0).GetDeclaringClass(), proxyClass1.Get()); |
| 230 | EXPECT_EQ(static_fields1->At(1).GetDeclaringClass(), proxyClass1.Get()); |
Hiroshi Yamauchi | 2debd80 | 2015-05-20 15:51:29 -0700 | [diff] [blame] | 231 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 232 | ASSERT_EQ(Runtime::Current()->GetClassLinker()->GetImagePointerSize(), kRuntimePointerSize); |
Andreas Gampe | e01e364 | 2016-07-25 13:06:04 -0700 | [diff] [blame] | 233 | ASSERT_FALSE(Runtime::Current()->IsActiveTransaction()); |
Hiroshi Yamauchi | 2debd80 | 2015-05-20 15:51:29 -0700 | [diff] [blame] | 234 | Handle<mirror::Field> field00 = |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 235 | hs.NewHandle(mirror::Field::CreateFromArtField<kRuntimePointerSize, false>( |
Andreas Gampe | e01e364 | 2016-07-25 13:06:04 -0700 | [diff] [blame] | 236 | soa.Self(), &static_fields0->At(0), true)); |
Hiroshi Yamauchi | 2debd80 | 2015-05-20 15:51:29 -0700 | [diff] [blame] | 237 | Handle<mirror::Field> field01 = |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 238 | hs.NewHandle(mirror::Field::CreateFromArtField<kRuntimePointerSize, false>( |
Andreas Gampe | e01e364 | 2016-07-25 13:06:04 -0700 | [diff] [blame] | 239 | soa.Self(), &static_fields0->At(1), true)); |
Hiroshi Yamauchi | 2debd80 | 2015-05-20 15:51:29 -0700 | [diff] [blame] | 240 | Handle<mirror::Field> field10 = |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 241 | hs.NewHandle(mirror::Field::CreateFromArtField<kRuntimePointerSize, false>( |
Andreas Gampe | e01e364 | 2016-07-25 13:06:04 -0700 | [diff] [blame] | 242 | soa.Self(), &static_fields1->At(0), true)); |
Hiroshi Yamauchi | 2debd80 | 2015-05-20 15:51:29 -0700 | [diff] [blame] | 243 | Handle<mirror::Field> field11 = |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 244 | hs.NewHandle(mirror::Field::CreateFromArtField<kRuntimePointerSize, false>( |
Andreas Gampe | e01e364 | 2016-07-25 13:06:04 -0700 | [diff] [blame] | 245 | soa.Self(), &static_fields1->At(1), true)); |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 246 | EXPECT_EQ(field00->GetArtField(), &static_fields0->At(0)); |
| 247 | EXPECT_EQ(field01->GetArtField(), &static_fields0->At(1)); |
| 248 | EXPECT_EQ(field10->GetArtField(), &static_fields1->At(0)); |
| 249 | EXPECT_EQ(field11->GetArtField(), &static_fields1->At(1)); |
Hiroshi Yamauchi | 2debd80 | 2015-05-20 15:51:29 -0700 | [diff] [blame] | 250 | } |
| 251 | |
Sebastien Hertz | b7054ba | 2014-03-13 11:52:31 +0100 | [diff] [blame] | 252 | } // namespace art |