Make ICCE logic common, refactor throws.
There were 2 sets of ICCE logic in ClassLinker::ResolveMethod and
Method::CheckIncompatibleClassChange, merged into just 1 piece of logic
in Method::CheckIncompatibleClassChange.
Move Throw... routines into own file and make adding the dex location to
the detail message more thorough.
Change-Id: I953dbfa3fed3767f35799b2f82b16637c437dbbe
diff --git a/src/common_throws.h b/src/common_throws.h
new file mode 100644
index 0000000..47186b0
--- /dev/null
+++ b/src/common_throws.h
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+#ifndef ART_SRC_COMMON_THROWS__H_
+#define ART_SRC_COMMON_THROWS_H_
+
+#include "mutex.h"
+#include "object.h"
+
+namespace art {
+
+// NullPointerException
+
+void ThrowNullPointerExceptionForFieldAccess(Field* field, bool is_read)
+ SHARED_LOCKS_REQUIRED(GlobalSynchronization::mutator_lock_);
+
+void ThrowNullPointerExceptionForMethodAccess(Method* caller, uint32_t method_idx, InvokeType type)
+ SHARED_LOCKS_REQUIRED(GlobalSynchronization::mutator_lock_);
+
+void ThrowNullPointerExceptionFromDexPC(Method* throw_method, uint32_t dex_pc)
+ SHARED_LOCKS_REQUIRED(GlobalSynchronization::mutator_lock_);
+
+// IllegalAccessError
+
+void ThrowIllegalAccessErrorClass(Class* referrer, Class* accessed)
+ SHARED_LOCKS_REQUIRED(GlobalSynchronization::mutator_lock_);
+
+void ThrowIllegalAccessErrorClassForMethodDispatch(Class* referrer, Class* accessed,
+ const Method* caller, const Method* called,
+ InvokeType type)
+ SHARED_LOCKS_REQUIRED(GlobalSynchronization::mutator_lock_);
+
+void ThrowIllegalAccessErrorMethod(Class* referrer, Method* accessed)
+ SHARED_LOCKS_REQUIRED(GlobalSynchronization::mutator_lock_);
+
+void ThrowIllegalAccessErrorField(Class* referrer, Field* accessed)
+ SHARED_LOCKS_REQUIRED(GlobalSynchronization::mutator_lock_);
+
+void ThrowIllegalAccessErrorFinalField(const Method* referrer, Field* accessed)
+ SHARED_LOCKS_REQUIRED(GlobalSynchronization::mutator_lock_);
+
+// IncompatibleClassChangeError
+
+void ThrowIncompatibleClassChangeError(InvokeType expected_type, InvokeType found_type,
+ Method* method, const Method* referrer)
+ SHARED_LOCKS_REQUIRED(GlobalSynchronization::mutator_lock_);
+
+void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(const Method* interface_method,
+ Object* this_object,
+ const Method* referrer)
+ SHARED_LOCKS_REQUIRED(GlobalSynchronization::mutator_lock_);
+
+void ThrowIncompatibleClassChangeErrorField(const Field* resolved_field, bool is_static,
+ const Method* referrer)
+ SHARED_LOCKS_REQUIRED(GlobalSynchronization::mutator_lock_);
+
+// NoSuchMethodError
+
+void ThrowNoSuchMethodError(InvokeType type, Class* c, const StringPiece& name,
+ const StringPiece& signature, const Method* referrer)
+ SHARED_LOCKS_REQUIRED(GlobalSynchronization::mutator_lock_);
+
+void ThrowNoSuchMethodError(uint32_t method_idx, const Method* referrer)
+ SHARED_LOCKS_REQUIRED(GlobalSynchronization::mutator_lock_);
+
+} // namespace art
+
+#endif // ART_SRC_COMMON_THROWS_H_