summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorIm Sooin <ciecet@gmail.com>2012-02-09 15:39:05 +0900
committerElliott Hughes <enh@google.com>2012-07-10 17:13:52 -0700
commit2fa5a86e48ac27992664f1677ce2ea5f441dc143 (patch)
tree161a7f150bf15e371ae1bf94ba6b02a2bff13b15 /tests
parent202bc301c313b4b49b04bdc59e484b439222462d (diff)
downloadandroid_dalvik-2fa5a86e48ac27992664f1677ce2ea5f441dc143.tar.gz
android_dalvik-2fa5a86e48ac27992664f1677ce2ea5f441dc143.tar.bz2
android_dalvik-2fa5a86e48ac27992664f1677ce2ea5f441dc143.zip
Avoid method overriding if its super method is inaccessible.
A call to package private method could be redirected to subclass which was not in the same package. Modified vtable to retain virtual super methods which cannot be accessed. This change affects vtable index in optimized dex. Change-Id: I9cc7e309c305bca12e5061009c4245fb70014681 Signed-off-by: Im Sooin <ciecet@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/300-package-override/expected.txt1
-rw-r--r--tests/300-package-override/info.txt2
-rw-r--r--tests/300-package-override/src/Main.java22
-rw-r--r--tests/300-package-override/src/p1/BaseClass.java22
-rw-r--r--tests/300-package-override/src/p2/DerivedClass.java21
5 files changed, 68 insertions, 0 deletions
diff --git a/tests/300-package-override/expected.txt b/tests/300-package-override/expected.txt
new file mode 100644
index 000000000..b0aad4deb
--- /dev/null
+++ b/tests/300-package-override/expected.txt
@@ -0,0 +1 @@
+passed
diff --git a/tests/300-package-override/info.txt b/tests/300-package-override/info.txt
new file mode 100644
index 000000000..0ed59eb0f
--- /dev/null
+++ b/tests/300-package-override/info.txt
@@ -0,0 +1,2 @@
+Tests a dalvik bug where we'd allow subclasses to override package-protected
+methods. \ No newline at end of file
diff --git a/tests/300-package-override/src/Main.java b/tests/300-package-override/src/Main.java
new file mode 100644
index 000000000..ad7eaaf5b
--- /dev/null
+++ b/tests/300-package-override/src/Main.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+public class Main {
+ public static void main(String args[]) throws Exception {
+ p1.BaseClass c = new p2.DerivedClass();
+ c.run();
+ }
+}
diff --git a/tests/300-package-override/src/p1/BaseClass.java b/tests/300-package-override/src/p1/BaseClass.java
new file mode 100644
index 000000000..1c048ac8f
--- /dev/null
+++ b/tests/300-package-override/src/p1/BaseClass.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+package p1;
+
+public class BaseClass {
+ public void run() { foo(); }
+ void foo() { System.out.println("passed"); } // It should not be possible to override this.
+}
diff --git a/tests/300-package-override/src/p2/DerivedClass.java b/tests/300-package-override/src/p2/DerivedClass.java
new file mode 100644
index 000000000..860f50ccd
--- /dev/null
+++ b/tests/300-package-override/src/p2/DerivedClass.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+package p2;
+
+public class DerivedClass extends p1.BaseClass {
+ void foo() { System.out.println("DerivedClass overrode package-private method!"); } // This should not override BaseClass.foo.
+}