summaryrefslogtreecommitdiffstats
path: root/test/135-MirandaDispatch
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2015-03-06 10:59:06 -0800
committerMathieu Chartier <mathieuc@google.com>2015-03-11 12:43:07 -0700
commit091d238936809f6668ca6b7606c62bc224add430 (patch)
tree90feb09ea9d398f1f80ffa407747496e57e592fe /test/135-MirandaDispatch
parent637455782147a41fbde2e284c49ca5e02d3444c2 (diff)
downloadart-091d238936809f6668ca6b7606c62bc224add430.zip
art-091d238936809f6668ca6b7606c62bc224add430.tar.gz
art-091d238936809f6668ca6b7606c62bc224add430.tar.bz2
Fix incompatible class change error for JIT stress mode
There was a problem with miranda methods, when we would dequicken to one of these, it wouldn't resolve as virtual during the method lowering resolve. The solution is to try resolving as interface if we fail to resolve as virtual. Fixed a bug in dequickening where unreachable register lines with quick invokes would cause CHECK failuers. In this case we punt to the interpreter (test 435-try-*). Added test regression test. Example failure: java.lang.IncompatibleClassChangeError: The method 'void Main$TheInterface.m()' was expected to be of type virtual but instead was found to be of type interface (declaration of 'java.lang.reflect.ArtMethod' appears in out/host/linux-x86/framework/core-libart-hostdex.jar) at Main.DoStuff(Main.java:37) at Main.main(Main.java:44) Bug: 17950037 Change-Id: I39c32cc8849bf02032a4f61a7ce57462b7fcac75
Diffstat (limited to 'test/135-MirandaDispatch')
-rw-r--r--test/135-MirandaDispatch/expected.txt1
-rw-r--r--test/135-MirandaDispatch/info.txt6
-rw-r--r--test/135-MirandaDispatch/src/Main.java51
3 files changed, 58 insertions, 0 deletions
diff --git a/test/135-MirandaDispatch/expected.txt b/test/135-MirandaDispatch/expected.txt
new file mode 100644
index 0000000..134d8d0
--- /dev/null
+++ b/test/135-MirandaDispatch/expected.txt
@@ -0,0 +1 @@
+Finishing
diff --git a/test/135-MirandaDispatch/info.txt b/test/135-MirandaDispatch/info.txt
new file mode 100644
index 0000000..22d2777
--- /dev/null
+++ b/test/135-MirandaDispatch/info.txt
@@ -0,0 +1,6 @@
+Regression test for JIT related incompatible class changes caused by miranda methods.
+E.g.
+java.lang.IncompatibleClassChangeError: The method 'void Main$TheInterface.m()' was expected to be of type virtual but instead was found to be of type interface (declaration of 'java.lang.reflect.ArtMethod' appears in out/host/linux-x86/framework/core-libart-hostdex.jar)
+ at Main.DoStuff(Main.java:37)
+ at Main.main(Main.java:44)
+
diff --git a/test/135-MirandaDispatch/src/Main.java b/test/135-MirandaDispatch/src/Main.java
new file mode 100644
index 0000000..bb005b0
--- /dev/null
+++ b/test/135-MirandaDispatch/src/Main.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2015 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 {
+ // Enough to trigger JIT.
+ static final int loopIterations = 5000;
+ static int counter = 0;
+
+ static interface TheInterface {
+ public void m();
+ }
+
+ static abstract class AbstractClass implements TheInterface {
+ }
+
+ static class ConcreteClass extends AbstractClass {
+ public void m() {
+ ++counter;
+ }
+ }
+
+ static void doStuff(AbstractClass c) {
+ for (int i = 0; i < loopIterations; ++i) {
+ c.m();
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ ConcreteClass o = new ConcreteClass();
+ for (int i = 0; i < loopIterations; ++i) {
+ doStuff(o);
+ }
+ if (counter != loopIterations * loopIterations) {
+ System.out.println("Expected " + loopIterations * loopIterations + " got " + counter);
+ }
+ System.out.println("Finishing");
+ }
+}