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