Merge "Address post review comments regarding ParseClassPath." into dalvik-dev
diff --git a/Android.mk b/Android.mk
index 0c8b579..8a791fe 100644
--- a/Android.mk
+++ b/Android.mk
@@ -21,15 +21,10 @@
include $(build_path)/Android.common.mk
include $(build_path)/Android.libart.mk
-include $(build_path)/Android.test.mk
include $(build_path)/Android.aexec.mk
-ifeq ($(WITH_HOST_DALVIK),true)
- include $(build_path)/Android.libart.host.mk
- include $(build_path)/Android.test.host.mk
- include $(build_path)/Android.aexec.host.mk
-endif
-
+include $(build_path)/Android.libarttest.mk
+include $(build_path)/Android.test.mk
# "m build-art" for quick minimal build
.PHONY: build-art
diff --git a/build/Android.aexec.host.mk b/build/Android.aexec.host.mk
deleted file mode 100644
index 25a66a8..0000000
--- a/build/Android.aexec.host.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
-LOCAL_MODULE := aexec
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := $(AEXEC_SRC_FILES)
-LOCAL_CFLAGS := $(ART_CFLAGS)
-LOCAL_SHARED_LIBRARIES := libart
-include $(BUILD_HOST_EXECUTABLE)
diff --git a/build/Android.aexec.mk b/build/Android.aexec.mk
index 216cc2c..a7e39b6 100644
--- a/build/Android.aexec.mk
+++ b/build/Android.aexec.mk
@@ -14,12 +14,40 @@
# limitations under the License.
#
-include $(CLEAR_VARS)
-include external/stlport/libstlport.mk
-LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
-LOCAL_MODULE := aexec
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := $(AEXEC_SRC_FILES)
-LOCAL_CFLAGS := $(ART_CFLAGS)
-LOCAL_SHARED_LIBRARIES := libart libstlport
-include $(BUILD_EXECUTABLE)
+# $(1): target or host
+# $(2): ndebug or debug
+define build-aexec
+ include $(CLEAR_VARS)
+ ifeq ($(1),target)
+ include external/stlport/libstlport.mk
+ endif
+ LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
+ ifeq ($(2),ndebug)
+ LOCAL_MODULE := aexec
+ else
+ LOCAL_MODULE := aexecd
+ endif
+ LOCAL_MODULE_TAGS := optional
+ LOCAL_SRC_FILES := $(AEXEC_SRC_FILES)
+ LOCAL_CFLAGS := $(ART_CFLAGS)
+ ifeq ($(2),debug)
+ LOCAL_CFLAGS += -UNDEBUG
+ endif
+ LOCAL_SHARED_LIBRARIES := libart
+ ifeq ($(1),target)
+ LOCAL_SHARED_LIBRARIES += libstlport
+ endif
+ ifeq ($(1),target)
+ include $(BUILD_EXECUTABLE)
+ else
+ include $(BUILD_HOST_EXECUTABLE)
+ endif
+endef
+
+$(eval $(call build-aexec,target,ndebug))
+$(eval $(call build-aexec,target,debug))
+ifeq ($(WITH_HOST_DALVIK),true)
+ $(eval $(call build-aexec,host,ndebug))
+ $(eval $(call build-aexec,host,debug))
+endif
+
diff --git a/build/Android.libart.host.mk b/build/Android.libart.host.mk
deleted file mode 100644
index 9772d63..0000000
--- a/build/Android.libart.host.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
-LOCAL_MODULE := libart
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := $(LIBART_HOST_SRC_FILES)
-LOCAL_CFLAGS := $(ART_CFLAGS)
-LOCAL_C_INCLUDES += src external/gtest/include
-LOCAL_SHARED_LIBRARIES := liblog libz-host
-LOCAL_LDLIBS := -ldl -lpthread -lrt
-include $(BUILD_HOST_SHARED_LIBRARY)
diff --git a/build/Android.libart.mk b/build/Android.libart.mk
index fae5c7e..de07b8c 100644
--- a/build/Android.libart.mk
+++ b/build/Android.libart.mk
@@ -14,13 +14,47 @@
# limitations under the License.
#
-include $(CLEAR_VARS)
-include external/stlport/libstlport.mk
-LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
-LOCAL_MODULE := libart
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := $(LIBART_TARGET_SRC_FILES)
-LOCAL_CFLAGS := $(ART_CFLAGS)
-LOCAL_C_INCLUDES += src external/gtest/include
-LOCAL_SHARED_LIBRARIES := libcutils liblog libstlport libz
-include $(BUILD_SHARED_LIBRARY)
+# $(1): target or host
+# $(2): ndebug or debug
+define build-libart
+ include $(CLEAR_VARS)
+ ifeq ($(1),target)
+ include external/stlport/libstlport.mk
+ endif
+ LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
+ ifeq ($(2),ndebug)
+ LOCAL_MODULE := libart
+ else
+ LOCAL_MODULE := libartd
+ endif
+ LOCAL_MODULE_TAGS := optional
+ ifeq ($(1),target)
+ LOCAL_SRC_FILES := $(LIBART_TARGET_SRC_FILES)
+ else
+ LOCAL_SRC_FILES := $(LIBART_HOST_SRC_FILES)
+ endif
+ LOCAL_CFLAGS := $(ART_CFLAGS)
+ ifeq ($(2),debug)
+ LOCAL_CFLAGS += -UNDEBUG
+ endif
+ LOCAL_C_INCLUDES += src external/gtest/include
+ LOCAL_SHARED_LIBRARIES := liblog
+ ifeq ($(1),target)
+ LOCAL_SHARED_LIBRARIES += libcutils libstlport libz
+ else
+ LOCAL_SHARED_LIBRARIES += libz-host
+ LOCAL_LDLIBS := -ldl -lpthread -lrt
+ endif
+ ifeq ($(1),target)
+ include $(BUILD_SHARED_LIBRARY)
+ else
+ include $(BUILD_HOST_SHARED_LIBRARY)
+ endif
+endef
+
+$(eval $(call build-libart,target,ndebug))
+$(eval $(call build-libart,target,debug))
+ifeq ($(WITH_HOST_DALVIK),true)
+ $(eval $(call build-libart,host,ndebug))
+ $(eval $(call build-libart,host,debug))
+endif
diff --git a/build/Android.libarttest.mk b/build/Android.libarttest.mk
new file mode 100644
index 0000000..37e45a1
--- /dev/null
+++ b/build/Android.libarttest.mk
@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2011 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# $(1): target or host
+define build-libarttest
+ include $(CLEAR_VARS)
+ ifeq ($(1),target)
+ include external/stlport/libstlport.mk
+ endif
+ LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
+ LOCAL_MODULE := libarttest
+ LOCAL_MODULE_TAGS := tests
+ LOCAL_SRC_FILES := $(LIBARTTEST_COMMON_SRC_FILES)
+ LOCAL_CFLAGS := $(ART_CFLAGS) -UNDEBUG
+ ifeq ($(1),target)
+ LOCAL_SHARED_LIBRARIES := libstlport
+ else
+ LOCAL_LDLIBS := -lrt
+ endif
+ ifeq ($(1),target)
+ include $(BUILD_SHARED_LIBRARY)
+ else
+ include $(BUILD_HOST_SHARED_LIBRARY)
+ endif
+endef
+
+$(eval $(call build-libarttest,target))
+ifeq ($(WITH_HOST_DALVIK),true)
+ $(eval $(call build-libarttest,host))
+endif
diff --git a/build/Android.test.host.mk b/build/Android.test.host.mk
deleted file mode 100644
index d440cd1..0000000
--- a/build/Android.test.host.mk
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
-LOCAL_MODULE := libarttest
-LOCAL_MODULE_TAGS := tests
-LOCAL_SRC_FILES := $(LIBARTTEST_COMMON_SRC_FILES)
-LOCAL_CFLAGS := $(ART_CFLAGS)
-LOCAL_LDLIBS := -lrt
-include $(BUILD_HOST_SHARED_LIBRARY)
-
-$(foreach file,$(TEST_HOST_SRC_FILES), \
- $(eval include $(CLEAR_VARS)) \
- $(eval LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)) \
- $(eval LOCAL_MODULE := $(notdir $(basename $(file:%.arm=%)))) \
- $(eval LOCAL_MODULE_TAGS := tests) \
- $(eval LOCAL_SRC_FILES := $(file)) \
- $(eval LOCAL_CFLAGS := $(ART_CFLAGS)) \
- $(eval LOCAL_C_INCLUDES += external/gtest/include) \
- $(eval LOCAL_WHOLE_STATIC_LIBRARIES := libgtest_host libgtest_main_host) \
- $(eval LOCAL_SHARED_LIBRARIES := libarttest libart) \
- $(eval include $(BUILD_HOST_EXECUTABLE)) \
-)
diff --git a/build/Android.test.mk b/build/Android.test.mk
index 908ef20..ba314bd 100644
--- a/build/Android.test.mk
+++ b/build/Android.test.mk
@@ -14,26 +14,34 @@
# limitations under the License.
#
-include $(CLEAR_VARS)
-include external/stlport/libstlport.mk
-LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
-LOCAL_MODULE := libarttest
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := $(LIBARTTEST_COMMON_SRC_FILES)
-LOCAL_CFLAGS := $(ART_CFLAGS)
-LOCAL_SHARED_LIBRARIES := libstlport
-include $(BUILD_SHARED_LIBRARY)
+# $(1): target or host
+# $(2): file name with .cc or .cc.arm extension
+define build-art-test
+ include $(CLEAR_VARS)
+ ifeq ($(1),target)
+ include external/stlport/libstlport.mk
+ endif
+ LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
+ LOCAL_MODULE := $(notdir $(basename $(2:%.arm=%)))
+ LOCAL_MODULE_TAGS := tests
+ LOCAL_SRC_FILES := $(2)
+ LOCAL_CFLAGS := $(ART_CFLAGS)
+ LOCAL_C_INCLUDES += external/gtest/include
+ LOCAL_SHARED_LIBRARIES := libarttest libart
+ ifeq ($(1),target)
+ LOCAL_SHARED_LIBRARIES += libstlport
+ LOCAL_STATIC_LIBRARIES := libgtest libgtest_main
+ else
+ LOCAL_WHOLE_STATIC_LIBRARIES := libgtest_host libgtest_main_host
+ endif
+ ifeq ($(1),target)
+ include $(BUILD_EXECUTABLE)
+ else
+ include $(BUILD_HOST_EXECUTABLE)
+ endif
+endef
-$(foreach file,$(TEST_TARGET_SRC_FILES), \
- $(eval include $(CLEAR_VARS)) \
- $(eval include external/stlport/libstlport.mk) \
- $(eval LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)) \
- $(eval LOCAL_MODULE := $(notdir $(basename $(file:%.arm=%)))) \
- $(eval LOCAL_MODULE_TAGS := tests) \
- $(eval LOCAL_SRC_FILES := $(file)) \
- $(eval LOCAL_CFLAGS := $(ART_CFLAGS)) \
- $(eval LOCAL_C_INCLUDES += external/gtest/include) \
- $(eval LOCAL_STATIC_LIBRARIES := libgtest libgtest_main) \
- $(eval LOCAL_SHARED_LIBRARIES := libarttest libart libstlport) \
- $(eval include $(BUILD_EXECUTABLE)) \
-)
+$(foreach file,$(TEST_TARGET_SRC_FILES), $(eval $(call build-art-test,target,$(file))))
+ifeq ($(WITH_HOST_DALVIK),true)
+ $(foreach file,$(TEST_HOST_SRC_FILES), $(eval $(call build-art-test,host,$(file))))
+endif
diff --git a/src/casts.h b/src/casts.h
index 0534eca..a5e31c4 100644
--- a/src/casts.h
+++ b/src/casts.h
@@ -59,7 +59,8 @@
implicit_cast<From*, To>(0);
}
- assert(f == NULL || dynamic_cast<To>(f) != NULL); // RTTI: debug mode only!
+ //
+ // assert(f == NULL || dynamic_cast<To>(f) != NULL); // RTTI: debug mode only!
return static_cast<To>(f);
}
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 5db2bea..92bb6d4 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -367,8 +367,8 @@
Field* dst) {
const DexFile::FieldId& field_id = dex_file.GetFieldId(src.field_idx_);
dst->klass_ = klass;
- dst->name_ = dex_file.dexStringById(field_id.name_idx_);
- dst->signature_ = dex_file.dexStringByTypeIdx(field_id.type_idx_);
+ dst->name_.set(dex_file.dexStringById(field_id.name_idx_));
+ dst->descriptor_.set(dex_file.dexStringByTypeIdx(field_id.type_idx_));
dst->access_flags_ = src.access_flags_;
}
@@ -1144,9 +1144,6 @@
if (actual_count < max_count) {
// TODO: do not assign to the vtable field until it is fully constructed.
klass->vtable_ = klass->vtable_->CopyOf(actual_count);
- LG << "shrunk vtable: "
- << "was " << max_count << ", "
- << "now " << actual_count;
}
} else {
CHECK(klass->GetDescriptor() == "Ljava/lang/Object;");
@@ -1411,14 +1408,14 @@
if (c != '[' && c != 'L') {
if (!seen_non_ref) {
seen_non_ref = true;
- DCHECK_EQ(klass->num_reference_ifields_, i);
+ DCHECK_EQ(klass->NumReferenceInstanceFields(), i);
}
} else {
DCHECK(!seen_non_ref);
}
}
if (!seen_non_ref) {
- DCHECK(klass->NumInstanceFields(), klass->num_reference_ifields_);
+ DCHECK_EQ(klass->NumInstanceFields(), klass->NumReferenceInstanceFields());
}
#endif
@@ -1457,8 +1454,8 @@
break;
}
}
- klass->SetReferenceOffsets(reference_offsets);
}
+ klass->SetReferenceOffsets(reference_offsets);
}
Class* ClassLinker::ResolveClass(const Class* referrer,
diff --git a/src/class_linker_test.cc b/src/class_linker_test.cc
index 4f921c4..c571d8a 100644
--- a/src/class_linker_test.cc
+++ b/src/class_linker_test.cc
@@ -75,13 +75,107 @@
}
void AssertDexFileClass(const DexFile* dex, const char* descriptor) {
- CHECK(descriptor != NULL);
+ ASSERT_TRUE(descriptor != NULL);
Class* klass = class_linker_->FindClass(descriptor, NULL, dex);
- CHECK(klass != NULL);
+ ASSERT_TRUE(klass != NULL);
+ EXPECT_EQ(descriptor, klass->GetDescriptor());
+ if (klass->descriptor_ == "Ljava/lang/Object;") {
+ EXPECT_FALSE(klass->HasSuperClass());
+ } else {
+ EXPECT_TRUE(klass->HasSuperClass());
+ EXPECT_TRUE(klass->GetSuperClass() != NULL);
+ }
+ // EXPECT_TRUE(klass->GetClassLoader() != NULL); // TODO needs class loader
+ EXPECT_TRUE(klass->GetDexCache() != NULL);
+ EXPECT_TRUE(klass->GetComponentType() == NULL);
+ EXPECT_TRUE(klass->GetComponentType() == NULL);
+ EXPECT_EQ(Class::kStatusResolved, klass->GetStatus());
+ EXPECT_FALSE(klass->IsErroneous());
+ EXPECT_FALSE(klass->IsVerified());
+ EXPECT_TRUE(klass->IsLinked());
+ EXPECT_TRUE(klass->IsLoaded());
+ EXPECT_TRUE(klass->IsInSamePackage(klass));
+ EXPECT_TRUE(Class::IsInSamePackage(klass->GetDescriptor(), klass->GetDescriptor()));
+ if (klass->IsInterface()) {
+ EXPECT_TRUE(klass->IsAbstract());
+ if (klass->NumDirectMethods() == 1) {
+ EXPECT_EQ("<clinit>", klass->GetDirectMethod(0)->GetName());
+ } else {
+ EXPECT_EQ(0U, klass->NumDirectMethods());
+ }
+ } else {
+ if (!klass->IsSynthetic()) {
+ EXPECT_NE(0U, klass->NumDirectMethods());
+ }
+ }
+ if (klass->IsAbstract()) {
+ EXPECT_FALSE(klass->IsFinal());
+ } else {
+ EXPECT_FALSE(klass->IsAnnotation());
+ }
+ if (klass->IsFinal()) {
+ EXPECT_FALSE(klass->IsAbstract());
+ EXPECT_FALSE(klass->IsAnnotation());
+ }
+ if (klass->IsAnnotation()) {
+ EXPECT_FALSE(klass->IsFinal());
+ EXPECT_TRUE(klass->IsAbstract());
+ }
+
+ EXPECT_FALSE(klass->IsPrimitive());
+ EXPECT_TRUE(klass->CanAccess(klass));
+
+ for (size_t i = 0; i < klass->NumDirectMethods(); i++) {
+ Method* method = klass->GetDirectMethod(i);
+ EXPECT_TRUE(method != NULL);
+ }
+
+ for (size_t i = 0; i < klass->NumVirtualMethods(); i++) {
+ Method* method = klass->GetVirtualMethod(i);
+ EXPECT_TRUE(method != NULL);
+ }
+
+ for (size_t i = 0; i < klass->NumInstanceFields(); i++) {
+ InstanceField* field = klass->GetInstanceField(i);
+ EXPECT_TRUE(field != NULL);
+ }
+
+ for (size_t i = 0; i < klass->NumStaticFields(); i++) {
+ StaticField* field = klass->GetStaticField(i);
+ EXPECT_TRUE(field != NULL);
+ }
+
+ // Confirm that all instances fields are packed together at the start
+ EXPECT_GE(klass->NumInstanceFields(), klass->NumReferenceInstanceFields());
+ for (size_t i = 0; i < klass->NumReferenceInstanceFields(); i++) {
+ InstanceField* field = klass->GetInstanceField(i);
+ ASSERT_TRUE(field != NULL);
+ ASSERT_TRUE(field->GetDescriptor() != NULL);
+ Class* fieldType = class_linker_->FindClass(field->GetDescriptor(), NULL, dex);
+ ASSERT_TRUE(fieldType != NULL);
+ EXPECT_FALSE(fieldType->IsPrimitive());
+ }
+ for (size_t i = klass->NumReferenceInstanceFields(); i < klass->NumInstanceFields(); i++) {
+ InstanceField* field = klass->GetInstanceField(i);
+ ASSERT_TRUE(field != NULL);
+ ASSERT_TRUE(field->GetDescriptor() != NULL);
+ Class* fieldType = class_linker_->FindClass(field->GetDescriptor(), NULL, dex);
+ ASSERT_TRUE(fieldType != NULL);
+ EXPECT_TRUE(fieldType->IsPrimitive());
+ }
+
+ size_t total_num_reference_instance_fields = 0;
+ Class* k = klass;
+ while (k != NULL) {
+ total_num_reference_instance_fields += k->NumReferenceInstanceFields();
+ k = k->GetSuperClass();
+ }
+ EXPECT_EQ(klass->GetReferenceOffsets() == 0,
+ total_num_reference_instance_fields == 0);
}
void AssertDexFile(const DexFile* dex) {
- CHECK(dex != NULL);
+ ASSERT_TRUE(dex != NULL);
class_linker_->RegisterDexFile(dex);
for (size_t i = 0; i < dex->NumClassDefs(); i++) {
const DexFile::ClassDef class_def = dex->GetClassDef(i);
diff --git a/src/dex_cache.h b/src/dex_cache.h
index 47f9bcf..5f3c54f 100644
--- a/src/dex_cache.h
+++ b/src/dex_cache.h
@@ -81,16 +81,16 @@
private:
ObjectArray<String>* GetStrings() const {
- return down_cast<ObjectArray<String>*>(Get(kStrings));
+ return static_cast<ObjectArray<String>*>(Get(kStrings));
}
ObjectArray<Class>* GetClasses() const {
- return down_cast<ObjectArray<Class>*>(Get(kClasses));
+ return static_cast<ObjectArray<Class>*>(Get(kClasses));
}
ObjectArray<Method>* GetMethods() const {
- return down_cast<ObjectArray<Method>*>(Get(kMethods));
+ return static_cast<ObjectArray<Method>*>(Get(kMethods));
}
ObjectArray<Field>* GetFields() const {
- return down_cast<ObjectArray<Field>*>(Get(kFields));
+ return static_cast<ObjectArray<Field>*>(Get(kFields));
}
DexCache();
};
diff --git a/src/object.cc b/src/object.cc
index fbcfa8b..69b093d 100644
--- a/src/object.cc
+++ b/src/object.cc
@@ -199,7 +199,7 @@
};
std::ostream& operator<<(std::ostream& os, const Class::Status& rhs) {
if (rhs >= Class::kStatusError && rhs <= Class::kStatusInitialized) {
- os << kClassStatusNames[rhs - 1];
+ os << kClassStatusNames[rhs + 1];
} else {
os << "Class::Status[" << static_cast<int>(rhs) << "]";
}
diff --git a/src/object.h b/src/object.h
index a154959..77eb164 100644
--- a/src/object.h
+++ b/src/object.h
@@ -250,16 +250,16 @@
return declaring_class_;
}
- const char* GetName() const {
+ const StringPiece& GetName() const {
return name_;
}
char GetType() const { // TODO: return type
- return signature_[0];
+ return descriptor_[0];
}
- const char* GetSignature() const {
- return signature_;
+ const StringPiece& GetDescriptor() const {
+ return descriptor_;
}
public: // TODO: private
@@ -277,10 +277,10 @@
// The class in which this field is declared.
Class* declaring_class_;
- const char* name_;
+ StringPiece name_;
// e.g. "I", "[C", "Landroid/os/Debug;"
- const char* signature_;
+ StringPiece descriptor_;
uint32_t access_flags_;
@@ -373,8 +373,7 @@
class Method : public Object {
public:
- // Returns the method name.
- // TODO: example
+ // Returns the method name, e.g. "<init>" or "eatLunch"
const StringPiece& GetName() const {
return name_;
}
@@ -749,6 +748,11 @@
return primitive_type_ != kPrimNot;
}
+ // Returns true if the class is synthetic.
+ bool IsSynthetic() const {
+ return (access_flags_ & kAccSynthetic) != 0;
+ }
+
// Returns true if this class can access that class.
bool CanAccess(const Class* that) const {
return that->IsPublic() || this->IsInSamePackage(that);