// Handles are value objects and should be trivially copyable.
static_assert(std::is_trivially_copyable<Handle<mirror::Object>>::value, "Handle should be trivially copyable");
static_assert(std::is_trivially_copyable<MutableHandle<mirror::Object>>::value, "MutableHandle should be trivially copyable");
static_assert(std::is_trivially_copyable<ScopedNullHandle<mirror::Object>>::value, "ScopedNullHandle should be trivially copyable");
class HandleScopeTest : public CommonRuntimeTest { protected:
HandleScopeTest() {
use_boot_image_ = true; // Make the Runtime creation cheaper.
}
};
// Test the offsets computed for members of HandleScope. Because of cross-compiling // it is impossible the use OFFSETOF_MEMBER, so we do some reasonable computations ourselves. This // test checks whether we do the right thing.
TEST_F(HandleScopeTest, Offsets) {
ScopedObjectAccess soa(Thread::Current());
ClassLinker* const class_linker = Runtime::Current()->GetClassLinker(); // As the members of HandleScope are private, we cannot use OFFSETOF_MEMBER // here. So do the inverse: set some data, and access it through pointers created from the offsets.
StackHandleScope<0x1> hs0(soa.Self()); staticconst size_t kNumReferences = 0x9ABC;
StackHandleScope<kNumReferences> test_table(soa.Self());
ObjPtr<mirror::Class> c = class_linker->FindSystemClass(soa.Self(), "Ljava/lang/Object;");
test_table.NewHandle(c);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.