1 /** 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef PANDA_RUNTIME_EXCEPTIONS_H_ 16 #define PANDA_RUNTIME_EXCEPTIONS_H_ 17 18 #include "runtime/include/class-inl.h" 19 #include "runtime/include/coretypes/array.h" 20 #include "runtime/include/language_context.h" 21 #include "runtime/include/method.h" 22 23 namespace panda { 24 25 void ThrowException(const LanguageContext &ctx, ManagedThread *thread, const uint8_t *mutf8_name, 26 const uint8_t *mutf8_msg); 27 28 void ThrowNullPointerException(); 29 // This function could be used in case there are no managed stack frames. 30 // For example when the main thread creates an instance of VM and calls 31 // a native function which throws an exception. In this case there is no need to 32 // get current executing method from the managed stack. 33 void ThrowNullPointerException(const LanguageContext &ctx, ManagedThread *thread); 34 35 void ThrowStackOverflowException(ManagedThread *thread); 36 37 void ThrowArrayIndexOutOfBoundsException(coretypes::array_ssize_t idx, coretypes::array_size_t length); 38 void ThrowArrayIndexOutOfBoundsException(coretypes::array_ssize_t idx, coretypes::array_size_t length, 39 const LanguageContext &ctx, ManagedThread *thread); 40 41 void ThrowIndexOutOfBoundsException(coretypes::array_ssize_t idx, coretypes::array_ssize_t length); 42 43 void ThrowIllegalStateException(const PandaString &msg); 44 45 void ThrowStringIndexOutOfBoundsException(coretypes::array_ssize_t idx, coretypes::array_size_t length); 46 47 void ThrowNegativeArraySizeException(coretypes::array_ssize_t size); 48 49 void ThrowNegativeArraySizeException(const PandaString &msg); 50 51 void ThrowArithmeticException(); 52 53 void ThrowClassCastException(const Class *dst_type, const Class *src_type); 54 55 void ThrowAbstractMethodError(const Method *method); 56 57 void ThrowIncompatibleClassChangeErrorForMethodConflict(const Method *method); 58 59 void ThrowArrayStoreException(const Class *array_class, const Class *element_class); 60 61 void ThrowArrayStoreException(const PandaString &msg); 62 63 void ThrowRuntimeException(const PandaString &msg); 64 65 void ThrowFileNotFoundException(const PandaString &msg); 66 67 void ThrowIOException(const PandaString &msg); 68 69 void ThrowIllegalArgumentException(const PandaString &msg); 70 71 void ThrowClassCircularityError(const PandaString &class_name, const LanguageContext &ctx); 72 73 void ThrowOutOfMemoryError(ManagedThread *thread, const PandaString &msg); 74 75 void ThrowOutOfMemoryError(const PandaString &msg); 76 77 void FindCatchBlockInCallStack(ManagedThread *thread); 78 79 void FindCatchBlockInCFrames(ManagedThread *thread, StackWalker *stack, Frame *orig_frame); 80 81 void ThrowIllegalAccessException(const PandaString &msg); 82 83 void ThrowUnsupportedOperationException(); 84 85 void ThrowVerificationException(const PandaString &msg); 86 87 void ThrowVerificationException(const LanguageContext &ctx, const PandaString &msg); 88 89 void ThrowInstantiationError(const PandaString &msg); 90 91 void ThrowNoClassDefFoundError(const PandaString &msg); 92 93 void ThrowTypedErrorDyn(const std::string &msg); 94 95 void ThrowReferenceErrorDyn(const std::string &msg); 96 97 void ThrowIllegalMonitorStateException(const PandaString &msg); 98 99 void ThrowCloneNotSupportedException(); 100 101 } // namespace panda 102 103 #endif // PANDA_RUNTIME_EXCEPTIONS_H_ 104