summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeffhao <jeffhao@google.com>2011-09-07 16:38:26 -0700
committerjeffhao <jeffhao@google.com>2011-09-07 16:58:24 -0700
commit5dbddeee1cb4e0962c7267db0588b563bf45526f (patch)
tree72ea085f32727295b987199ccea907a9ca731680
parent6108953a145c1affcadc1e0a91b17e647ee52a02 (diff)
downloadandroid_art-5dbddeee1cb4e0962c7267db0588b563bf45526f.tar.gz
android_art-5dbddeee1cb4e0962c7267db0588b563bf45526f.tar.bz2
android_art-5dbddeee1cb4e0962c7267db0588b563bf45526f.zip
Added tests for interfaces that extend other interfaces.
Exercises IsAssignableFrom and FindInterfaceMethod. Also made Class::Implements private again and switched to using IsAssignableFrom. Change-Id: Iea195a2cc124a87ebb3d87d778a7edcd25984b46
-rw-r--r--src/class_linker_test.cc14
-rw-r--r--src/dex_verifier.cc12
-rw-r--r--src/object.h3
-rw-r--r--test/Interfaces/Interfaces.java8
4 files changed, 24 insertions, 13 deletions
diff --git a/src/class_linker_test.cc b/src/class_linker_test.cc
index d30f4bfea5..71cb22eb82 100644
--- a/src/class_linker_test.cc
+++ b/src/class_linker_test.cc
@@ -537,26 +537,38 @@ TEST_F(ClassLinkerTest, Interfaces) {
const ClassLoader* class_loader = LoadDex("Interfaces");
Class* I = class_linker_->FindClass("LInterfaces$I;", class_loader);
Class* J = class_linker_->FindClass("LInterfaces$J;", class_loader);
+ Class* K = class_linker_->FindClass("LInterfaces$K;", class_loader);
Class* A = class_linker_->FindClass("LInterfaces$A;", class_loader);
+ Class* B = class_linker_->FindClass("LInterfaces$B;", class_loader);
EXPECT_TRUE(I->IsAssignableFrom(A));
EXPECT_TRUE(J->IsAssignableFrom(A));
+ EXPECT_TRUE(J->IsAssignableFrom(K));
+ EXPECT_TRUE(K->IsAssignableFrom(B));
+ EXPECT_TRUE(J->IsAssignableFrom(B));
Method* Ii = I->FindVirtualMethod("i", "()V");
Method* Jj1 = J->FindVirtualMethod("j1", "()V");
Method* Jj2 = J->FindVirtualMethod("j2", "()V");
+ Method* Kj1 = K->FindInterfaceMethod("j1", "()V");
+ Method* Kj2 = K->FindInterfaceMethod("j2", "()V");
+ Method* Kk = K->FindInterfaceMethod("k", "()V");
Method* Ai = A->FindVirtualMethod("i", "()V");
Method* Aj1 = A->FindVirtualMethod("j1", "()V");
Method* Aj2 = A->FindVirtualMethod("j2", "()V");
ASSERT_TRUE(Ii != NULL);
ASSERT_TRUE(Jj1 != NULL);
ASSERT_TRUE(Jj2 != NULL);
+ ASSERT_TRUE(Kj1 != NULL);
+ ASSERT_TRUE(Kj2 != NULL);
+ ASSERT_TRUE(Kk != NULL);
ASSERT_TRUE(Ai != NULL);
ASSERT_TRUE(Aj1 != NULL);
ASSERT_TRUE(Aj2 != NULL);
- ASSERT_TRUE(Ii != NULL);
EXPECT_NE(Ii, Ai);
EXPECT_NE(Jj1, Aj1);
EXPECT_NE(Jj2, Aj2);
+ EXPECT_EQ(Kj1, Jj1);
+ EXPECT_EQ(Kj2, Jj2);
EXPECT_EQ(Ai, A->FindVirtualMethodForInterface(Ii));
EXPECT_EQ(Aj1, A->FindVirtualMethodForInterface(Jj1));
EXPECT_EQ(Aj2, A->FindVirtualMethodForInterface(Jj2));
diff --git a/src/dex_verifier.cc b/src/dex_verifier.cc
index 86b119b201..df9d7cb231 100644
--- a/src/dex_verifier.cc
+++ b/src/dex_verifier.cc
@@ -4406,10 +4406,10 @@ Class* DexVerifier::FindCommonSuperclass(Class* c1, Class* c2) {
if (c1 == c2)
return c1;
- if (c1->IsInterface() && c2->Implements(c1)) {
+ if (c1->IsInterface() && c1->IsAssignableFrom(c2)) {
return c1;
}
- if (c2->IsInterface() && c1->Implements(c2)) {
+ if (c2->IsInterface() && c2->IsAssignableFrom(c1)) {
return c2;
}
if (c1->IsArrayClass() && c2->IsArrayClass()) {
@@ -4980,13 +4980,6 @@ Method* DexVerifier::VerifyInvocationArgs(VerifierData* vdata,
}
if (res_method == NULL) {
- /* failed; print a meaningful failure message */
- //const DexFile::MethodId method_id = dex_file->GetMethodId(dec_insn->vB_);
- //const char* method_name = dex_file->dexStringById(method_id.name_idx_);
- //const char* class_name = dex_file->dexStringByTypeIdx(method_id.class_idx_);
-
- //LOG(ERROR) << "VFY: unable to resolve " << (int) method_type << " method "
- //<< dec_insn->vB_ << ": " << class_name << "." << method_name;
LOG(ERROR) << "VFY: unable to resolve called method";
*failure = VERIFY_ERROR_NO_METHOD;
return NULL;
@@ -5112,7 +5105,6 @@ Method* DexVerifier::VerifyInvocationArgs(VerifierData* vdata,
* have been verified, so we can't assume it's properly formed.
*/
for (sig_offset = 1; sig_offset < sig.size(); sig_offset++) {
- //while (*sig != '\0' && *sig != ')') {
if (sig[sig_offset] == ')')
break;
diff --git a/src/object.h b/src/object.h
index 9106472804..f26d9ef219 100644
--- a/src/object.h
+++ b/src/object.h
@@ -1939,9 +1939,8 @@ class Class : public StaticStorageBase {
new_source_file, false);
}
- bool Implements(const Class* klass) const;
-
private:
+ bool Implements(const Class* klass) const;
bool IsArrayAssignableFromArray(const Class* klass) const;
bool IsAssignableFromArray(const Class* klass) const;
bool IsSubClass(const Class* klass) const;
diff --git a/test/Interfaces/Interfaces.java b/test/Interfaces/Interfaces.java
index 0b72e92b24..4bd9bfe2bf 100644
--- a/test/Interfaces/Interfaces.java
+++ b/test/Interfaces/Interfaces.java
@@ -8,9 +8,17 @@ class Interfaces {
public void j1();
public void j2();
}
+ interface K extends J {
+ public void k();
+ }
class A implements I, J {
public void i() {};
public void j1() {};
public void j2() {};
}
+ class B implements K {
+ public void j1() {};
+ public void j2() {};
+ public void k() {};
+ }
}