Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/jcl/common/exhelp.c
6000 views
1
/*******************************************************************************
2
* Copyright (c) 1998, 2018 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* 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-exception
21
*******************************************************************************/
22
#include "j9comp.h"
23
#include "jni.h"
24
#include "j9.h"
25
26
/**
27
* Throw java.lang.IndexOutOfBoundsException
28
*/
29
void
30
throwNewIndexOutOfBoundsException(JNIEnv *env, char *message)
31
{
32
jclass exceptionClass = (*env)->FindClass(env, "java/lang/IndexOutOfBoundsException");
33
if (exceptionClass == 0) {
34
/* Just return if we can't load the exception class. */
35
return;
36
}
37
(*env)->ThrowNew(env, exceptionClass, message);
38
}
39
40
41
/**
42
* Throw java.lang.InternalError
43
*/
44
void
45
throwNewInternalError(JNIEnv *env, char *message)
46
{
47
jclass exceptionClass = (*env)->FindClass(env, "java/lang/InternalError");
48
if (exceptionClass == 0) {
49
/* Just return if we can't load the exception class. */
50
return;
51
}
52
(*env)->ThrowNew(env, exceptionClass, message);
53
}
54
55
56
/**
57
* Throw java.lang.NullPointerException with the message provided
58
*/
59
void
60
throwNewNullPointerException(JNIEnv *env, char *message)
61
{
62
jclass exceptionClass = (*env)->FindClass(env, "java/lang/NullPointerException");
63
if (exceptionClass == 0) {
64
/* Just return if we can't load the exception class. */
65
return;
66
}
67
(*env)->ThrowNew(env, exceptionClass, message);
68
}
69
70
71
/**
72
* Throw java.lang.IllegalArgumentException
73
*/
74
void
75
throwNewIllegalArgumentException(JNIEnv *env, char *message)
76
{
77
jclass exceptionClass = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
78
if (exceptionClass == 0) {
79
/* Just return if we can't load the exception class. */
80
return;
81
}
82
(*env)->ThrowNew(env, exceptionClass, message);
83
}
84
85
86
/**
87
* Throw java.lang.IllegalStateException
88
*/
89
void
90
throwNewIllegalStateException(JNIEnv *env, char *message)
91
{
92
jclass exceptionClass = (*env)->FindClass(env, "java/lang/IllegalStateException");
93
if (exceptionClass == 0) {
94
/* Just return if we can't load the exception class. */
95
return;
96
}
97
(*env)->ThrowNew(env, exceptionClass, message);
98
}
99
100
101
/**
102
* Throw java.util.zip.ZipException with the message provided
103
*/
104
void
105
throwNewJavaZIOException(JNIEnv *env, char *message)
106
{
107
jclass exceptionClass = (*env)->FindClass(env, "java/util/zip/ZipException");
108
if (exceptionClass == 0) {
109
/* Just return if we can't load the exception class. */
110
return;
111
}
112
(*env)->ThrowNew(env, exceptionClass, message);
113
}
114
115
/**
116
* Throw java/lang/UnsupportedOperationException
117
*/
118
void
119
throwNewUnsupportedOperationException(JNIEnv *env)
120
{
121
jclass clazz = (*env)->FindClass(env, "java/lang/UnsupportedOperationException");
122
if (NULL != clazz) {
123
(*env)->ThrowNew(env, clazz, NULL);
124
}
125
}
126
127
128