From 20cde9033d51103f31e21436e88f80e1170c78ad Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 4 Oct 2011 17:37:27 -0700 Subject: Add Class::IsFinalizable and Object::AddFinalizerReference. Also correctly set the special bit in Class' flags. We need compiler support before I can go further. Change-Id: Ib7a637d7140a6f8c416635738d4d0b57c17ad628 --- src/class_linker_test.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/class_linker_test.cc') diff --git a/src/class_linker_test.cc b/src/class_linker_test.cc index 18a3f928ff..8be1b905dd 100644 --- a/src/class_linker_test.cc +++ b/src/class_linker_test.cc @@ -969,4 +969,37 @@ TEST_F(ClassLinkerTest, InitializeStaticStorageFromCode) { EXPECT_EQ(init, clinit->GetDexCacheInitializedStaticStorage()->Get(type_idx)); } +TEST_F(ClassLinkerTest, FinalizableBit) { + Class* c; + + // Object has a finalize method, but we know it's empty. + c = class_linker_->FindSystemClass("Ljava/lang/Object;"); + EXPECT_FALSE(c->IsFinalizable()); + + // Enum has a finalize method to prevent its subclasses from implementing one. + c = class_linker_->FindSystemClass("Ljava/lang/Enum;"); + EXPECT_FALSE(c->IsFinalizable()); + + // RoundingMode is an enum. + c = class_linker_->FindSystemClass("Ljava/math/RoundingMode;"); + EXPECT_FALSE(c->IsFinalizable()); + + // RandomAccessFile extends Object and overrides finalize. + c = class_linker_->FindSystemClass("Ljava/io/RandomAccessFile;"); + EXPECT_TRUE(c->IsFinalizable()); + + // FileInputStream is finalizable and extends InputStream which isn't. + c = class_linker_->FindSystemClass("Ljava/io/InputStream;"); + EXPECT_FALSE(c->IsFinalizable()); + c = class_linker_->FindSystemClass("Ljava/io/FileInputStream;"); + EXPECT_TRUE(c->IsFinalizable()); + + // ScheduledThreadPoolExecutor doesn't have a finalize method but + // extends ThreadPoolExecutor which does. + c = class_linker_->FindSystemClass("Ljava/util/concurrent/ThreadPoolExecutor;"); + EXPECT_TRUE(c->IsFinalizable()); + c = class_linker_->FindSystemClass("Ljava/util/concurrent/ScheduledThreadPoolExecutor;"); + EXPECT_TRUE(c->IsFinalizable()); +} + } // namespace art -- cgit v1.2.3-59-g8ed1b