diff options
| author | 2011-10-04 17:37:27 -0700 | |
|---|---|---|
| committer | 2011-10-04 17:56:41 -0700 | |
| commit | 20cde9033d51103f31e21436e88f80e1170c78ad (patch) | |
| tree | 4b7c66092d988a9ed9345b66868da9cdf5cc8b4a /src/class_linker_test.cc | |
| parent | b408de744566a5c5a80be1ba7f5c88407e816945 (diff) | |
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
Diffstat (limited to 'src/class_linker_test.cc')
| -rw-r--r-- | src/class_linker_test.cc | 33 |
1 files changed, 33 insertions, 0 deletions
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 |