} else if (!resolved_method->GetDeclaringClass()->IsAssignableFrom(info.GetTypeHandle().Get())) {
// The method that we're trying to call is not in the receiver's class or super classes.
return nullptr;
+ } else if (info.GetTypeHandle()->IsErroneous()) {
+ // If the type is erroneous, do not go further, as we are going to query the vtable or
+ // imt table, that we can only safely do on non-erroneous classes.
+ return nullptr;
}
ClassLinker* cl = Runtime::Current()->GetClassLinker();
--- /dev/null
+Regression test for the inliner that used to crash while
+trying to find a method for an erroneous class.
--- /dev/null
+# Copyright (C) 2016 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.
+
+.class public LSuperVerifyError;
+
+.super Ljava/lang/Object;
+
+.method public final foo()V
+ .registers 1
+ return-void
+.end method
+
+.method public bar()V
+ .registers 1
+ return-void
+.end method
--- /dev/null
+# Copyright (C) 2016 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.
+
+.class public LTestCase;
+
+.super Ljava/lang/Object;
+
+.method public static topLevel()V
+ .registers 2
+ const v0, 0x1
+ new-array v0, v0, [LVerifyError;
+ invoke-static {v0}, LTestCase;->test([LVerifyError;)V
+ return-void
+.end method
+
+.method public static test([LVerifyError;)V
+ .registers 2
+ const v0, 0x0
+ aget-object v1, v1, v0
+ invoke-virtual {v1}, LSuperVerifyError;->bar()V
+ return-void
+.end method
--- /dev/null
+# Copyright (C) 2016 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.
+
+.class public final LVerifyError;
+
+.super LSuperVerifyError;
+
+# Override a final method to put this class in the error state.
+.method public foo()V
+ .registers 1
+ return-void
+.end method
+
+# Having a static field in the class is needed to get the
+# right initialization for the embedded vtable length of a
+# class.
+.field public static i:I
--- /dev/null
+/*
+ * Copyright (C) 2016 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.
+ */
+
+import java.lang.reflect.InvocationTargetException;
+
+public class Main {
+ public static void main(String[] args) throws Exception {
+ try {
+ Class<?> v = Class.forName("VerifyError");
+ throw new Error("Expected LinkageError");
+ } catch (LinkageError e) {
+ // expected
+ }
+
+ try {
+ Class.forName("TestCase").getMethod("topLevel").invoke(null);
+ throw new Error("Expected InvocationTargetException");
+ } catch (InvocationTargetException e) {
+ if (!(e.getCause() instanceof NullPointerException)) {
+ throw new Error("Expected NullPointerException, got " + e.getCause());
+ }
+ }
+ }
+}