/*******************************************************************************1* Copyright (c) 1998, 2018 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception20*******************************************************************************/21#include "j9comp.h"22#include "jni.h"23#include "j9.h"2425/**26* Throw java.lang.IndexOutOfBoundsException27*/28void29throwNewIndexOutOfBoundsException(JNIEnv *env, char *message)30{31jclass exceptionClass = (*env)->FindClass(env, "java/lang/IndexOutOfBoundsException");32if (exceptionClass == 0) {33/* Just return if we can't load the exception class. */34return;35}36(*env)->ThrowNew(env, exceptionClass, message);37}383940/**41* Throw java.lang.InternalError42*/43void44throwNewInternalError(JNIEnv *env, char *message)45{46jclass exceptionClass = (*env)->FindClass(env, "java/lang/InternalError");47if (exceptionClass == 0) {48/* Just return if we can't load the exception class. */49return;50}51(*env)->ThrowNew(env, exceptionClass, message);52}535455/**56* Throw java.lang.NullPointerException with the message provided57*/58void59throwNewNullPointerException(JNIEnv *env, char *message)60{61jclass exceptionClass = (*env)->FindClass(env, "java/lang/NullPointerException");62if (exceptionClass == 0) {63/* Just return if we can't load the exception class. */64return;65}66(*env)->ThrowNew(env, exceptionClass, message);67}686970/**71* Throw java.lang.IllegalArgumentException72*/73void74throwNewIllegalArgumentException(JNIEnv *env, char *message)75{76jclass exceptionClass = (*env)->FindClass(env, "java/lang/IllegalArgumentException");77if (exceptionClass == 0) {78/* Just return if we can't load the exception class. */79return;80}81(*env)->ThrowNew(env, exceptionClass, message);82}838485/**86* Throw java.lang.IllegalStateException87*/88void89throwNewIllegalStateException(JNIEnv *env, char *message)90{91jclass exceptionClass = (*env)->FindClass(env, "java/lang/IllegalStateException");92if (exceptionClass == 0) {93/* Just return if we can't load the exception class. */94return;95}96(*env)->ThrowNew(env, exceptionClass, message);97}9899100/**101* Throw java.util.zip.ZipException with the message provided102*/103void104throwNewJavaZIOException(JNIEnv *env, char *message)105{106jclass exceptionClass = (*env)->FindClass(env, "java/util/zip/ZipException");107if (exceptionClass == 0) {108/* Just return if we can't load the exception class. */109return;110}111(*env)->ThrowNew(env, exceptionClass, message);112}113114/**115* Throw java/lang/UnsupportedOperationException116*/117void118throwNewUnsupportedOperationException(JNIEnv *env)119{120jclass clazz = (*env)->FindClass(env, "java/lang/UnsupportedOperationException");121if (NULL != clazz) {122(*env)->ThrowNew(env, clazz, NULL);123}124}125126127128