Skip to content

Commit 046df16

Browse files
committed
[GR-40782] Error encountered while parsing org.graalvm.nativebridge.ForeignException.callCreateForeignException on js-postmerge-pgo-profiles-jdk17-linux-amd64.
PullRequest: graal/12852
2 parents 0728038 + fe422b4 commit 046df16

File tree

9 files changed

+85
-85
lines changed

9 files changed

+85
-85
lines changed

compiler/docs/NativeBridgeProcessor.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ abstract class NativeCalculator extends NativeObject implements Calculator {
2525
}
2626
```
2727

28-
The annotation processor generates class `NativeCalculatorGen` with a static factory method `createHotSpotToNative(NativeIsolate isolate, long handle)`. The method creates an instance of `NativeCalculator` that forwards `add` and `sub` methods from the HotSpot VM to an object in the native image heap. The `jniConfig` attribute will be explained in the [JNIConfig](#JNIConfig) section.
28+
The annotation processor generates class `NativeCalculatorGen` with a static factory method `createHSToNative(NativeIsolate isolate, long handle)`. The method creates an instance of `NativeCalculator` that forwards `add` and `sub` methods from the HotSpot VM to an object in the native image heap. The `jniConfig` attribute will be explained in the [JNIConfig](#JNIConfig) section.
2929

3030
To use the generated stubs we need to first create an isolate and obtain a foreign object handle before we can call into the generated interface.
3131

@@ -34,7 +34,7 @@ long isolateThreadId = ExampleJNIConfig.createIsolate();
3434
long isolateId = ExampleJNIConfig.getIsolateId(isolateThreadId);
3535
long calculatorHandle = ExampleJNIConfig.initializeCalculator(isolateThreadId);
3636
NativeIsolate isolate = NativeIsolate.forIsolateId(isolateId, ExampleJNIConfig.getInstance());
37-
NativeCalculator calculator = NativeCalculatorGen.createHotSpotToNative(isolate, calculatorHandle);
37+
NativeCalculator calculator = NativeCalculatorGen.createHSToNative(isolate, calculatorHandle);
3838
calculator.add(calculator.sub(41, 2), 1);
3939
```
4040

@@ -52,7 +52,7 @@ abstract class HSCalculator extends HSObject implements Calculator {
5252
}
5353
```
5454

55-
The annotation processor generates class `HSCalculatorGen` with a static factory method `createNativeToHotSpot(JNIEnv jniEnv, JObject handle)`. The method creates an instance of `HSCalculator` that forwards `add` and `sub` methods from a Native Image to an object in a HotSpot VM.
55+
The annotation processor generates class `HSCalculatorGen` with a static factory method `createNativeToHS(JNIEnv jniEnv, JObject handle)`. The method creates an instance of `HSCalculator` that forwards `add` and `sub` methods from a Native Image to an object in a HotSpot VM.
5656

5757
### Bridging a class
5858

@@ -80,7 +80,7 @@ abstract class NativeCalculator extends Calculator {
8080
}
8181
```
8282

83-
The annotation processor generates class `NativeCalculatorGen` with a static `createHotSpotToNative(NativeIsolate isolate, long handle)` factory method creating a `NativeCalculator` instance forwarding `add` and `sub` methods from the HotSpot VM to an object in the native image heap. The `jniConfig` attribute will be explained in the [JNIConfig](#JNIConfig) section.
83+
The annotation processor generates class `NativeCalculatorGen` with a static `createHSToNative(NativeIsolate isolate, long handle)` factory method creating a `NativeCalculator` instance forwarding `add` and `sub` methods from the HotSpot VM to an object in the native image heap. The `jniConfig` attribute will be explained in the [JNIConfig](#JNIConfig) section.
8484

8585
To use the generated stubs we need to first create an isolate and obtain a foreign object handle before we can call into the generated interface.
8686

@@ -89,7 +89,7 @@ long isolateThreadId = ExampleJNIConfig.createIsolate();
8989
long isolateId = ExampleJNIConfig.getIsolateId(isolateThreadId);
9090
long calculatorHandle = ExampleJNIConfig.initializeCalculator(isolateThreadId);
9191
NativeIsolate isolate = NativeIsolate.forIsolateId(isolateId, ExampleJNIConfig.getInstance());
92-
NativeCalculator calculator = NativeCalculatorGen.createHotSpotToNative(new NativeObject(isolate, calculatorHandle));
92+
NativeCalculator calculator = NativeCalculatorGen.createHSToNative(new NativeObject(isolate, calculatorHandle));
9393
calculator.add(calculator.sub(41, 2), 1);
9494
```
9595

@@ -108,7 +108,7 @@ abstract class HSCalculator extends Calculator {
108108
}
109109
```
110110

111-
The annotation processor generates class `HSCalculatorGen` with a static `createNativeToHotSpot(HSObject delegate, JNIEnv jniEnv)` factory method creating an `HSCalculator` instance forwarding `add` and `sub` methods from a Native Image to an object in a HotSpot VM.
111+
The annotation processor generates class `HSCalculatorGen` with a static `createNativeToHS(HSObject delegate, JNIEnv jniEnv)` factory method creating an `HSCalculator` instance forwarding `add` and `sub` methods from a Native Image to an object in a HotSpot VM.
112112

113113
### Bridging a class with a custom dispatch
114114

@@ -154,7 +154,7 @@ To generate a bridge from a HotSpot VM to a Native Image, create an abstract bas
154154
@GenerateHotSpotToNativeBridge(jniConfig = ExampleJNIConfig.class)
155155
abstract class NativeLanguageDispatch extends AbstractLanguageDispatch {
156156

157-
private static final NativeLanguageDispatch INSTANCE = NativeLanguageDispatchGen.createHotSpotToNative();
157+
private static final NativeLanguageDispatch INSTANCE = NativeLanguageDispatchGen.createHSToNative();
158158

159159
@CustomDispatchAccessor
160160
static AbstractLanguageDispatch getDispatch(Language language) {
@@ -173,7 +173,7 @@ abstract class NativeLanguageDispatch extends AbstractLanguageDispatch {
173173
}
174174
```
175175

176-
The annotation processor generates class `NativeLanguageDispatchGen` with a static `createHotSpotToNative()` factory method creating a `NativeLanguageDispatch` instance forwarding methods from the HotSpot VM to an object in the native image heap. The `jniConfig` attribute will be explained in the [JNIConfig](#JNIConfig) section.
176+
The annotation processor generates class `NativeLanguageDispatchGen` with a static `createHSToNative()` factory method creating a `NativeLanguageDispatch` instance forwarding methods from the HotSpot VM to an object in the native image heap. The `jniConfig` attribute will be explained in the [JNIConfig](#JNIConfig) section.
177177

178178
To use the generated stubs we need to first create an isolate and obtain a foreign object handle before we can call into the generated interface.
179179

compiler/src/org.graalvm.jniutils/src/org/graalvm/jniutils/HotSpotCalls.java renamed to compiler/src/org.graalvm.jniutils/src/org/graalvm/jniutils/JNICalls.java

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -44,42 +44,42 @@
4444

4545
/**
4646
* Support for calling into HotSpot using JNI. In addition to calling a method using JNI, the
47-
* {@code HotSpotCalls} also perform JNI call tracing and exception handling. All JNI calls into
48-
* HotSpot must use this support to correctly merge HotSpot and native image stack traces.
47+
* {@code JNICalls} also perform JNI call tracing and exception handling. All JNI calls into HotSpot
48+
* must use this support to correctly merge HotSpot and native image stack traces.
4949
*/
50-
public final class HotSpotCalls {
50+
public final class JNICalls {
5151

52-
private static final HotSpotCalls INSTANCE = new HotSpotCalls(ExceptionHandler.DEFAULT);
52+
private static final JNICalls INSTANCE = new JNICalls(ExceptionHandler.DEFAULT);
5353

5454
private static final ThreadLocal<Boolean> inTrace = ThreadLocal.withInitial(() -> false);
5555

5656
private final ExceptionHandler exceptionHandler;
5757

58-
private HotSpotCalls(ExceptionHandler exceptionHandler) {
58+
private JNICalls(ExceptionHandler exceptionHandler) {
5959
this.exceptionHandler = exceptionHandler;
6060
}
6161

6262
/**
63-
* Returns a {@link HotSpotCalls} instance with a default exception handler. The default
64-
* exception handler rethrows any pending JNI exception as a {@link JNIExceptionWrapper}.
63+
* Returns a {@link JNICalls} instance with a default exception handler. The default exception
64+
* handler rethrows any pending JNI exception as a {@link JNIExceptionWrapper}.
6565
*/
66-
public static HotSpotCalls getDefault() {
66+
public static JNICalls getDefault() {
6767
return INSTANCE;
6868
}
6969

7070
/**
71-
* Creates a new {@link HotSpotCalls} instance with a custom exception handler. The given
72-
* exception handler is used to handle pending JNI exceptions.
71+
* Creates a new {@link JNICalls} instance with a custom exception handler. The given exception
72+
* handler is used to handle pending JNI exceptions.
7373
*/
74-
public static HotSpotCalls createWithExceptionHandler(ExceptionHandler handler) {
74+
public static JNICalls createWithExceptionHandler(ExceptionHandler handler) {
7575
Objects.requireNonNull(handler, "Handler must be non null.");
76-
return new HotSpotCalls(handler);
76+
return new JNICalls(handler);
7777
}
7878

7979
/**
8080
* Performs a JNI call of a static void method.
8181
*/
82-
@HotSpotCall
82+
@JNICall
8383
public void callStaticVoid(JNIEnv env, JClass clazz, JNIMethod method, JNI.JValue args) {
8484
traceCall(env, clazz, method);
8585
env.getFunctions().getCallStaticVoidMethodA().call(env, clazz, method.getJMethodID(), args);
@@ -89,7 +89,7 @@ public void callStaticVoid(JNIEnv env, JClass clazz, JNIMethod method, JNI.JValu
8989
/**
9090
* Performs a JNI call of a static method returning {@code boolean}.
9191
*/
92-
@HotSpotCall
92+
@JNICall
9393
public boolean callStaticBoolean(JNIEnv env, JClass clazz, JNIMethod method, JNI.JValue args) {
9494
traceCall(env, clazz, method);
9595
boolean res = env.getFunctions().getCallStaticBooleanMethodA().call(env, clazz, method.getJMethodID(), args);
@@ -100,7 +100,7 @@ public boolean callStaticBoolean(JNIEnv env, JClass clazz, JNIMethod method, JNI
100100
/**
101101
* Performs a JNI call of a static method returning {@code long}.
102102
*/
103-
@HotSpotCall
103+
@JNICall
104104
public long callStaticLong(JNIEnv env, JClass clazz, JNIMethod method, JNI.JValue args) {
105105
traceCall(env, clazz, method);
106106
long res = env.getFunctions().getCallStaticLongMethodA().call(env, clazz, method.getJMethodID(), args);
@@ -111,7 +111,7 @@ public long callStaticLong(JNIEnv env, JClass clazz, JNIMethod method, JNI.JValu
111111
/**
112112
* Performs a JNI call of a static method returning {@code int}.
113113
*/
114-
@HotSpotCall
114+
@JNICall
115115
public int callStaticInt(JNIEnv env, JClass clazz, JNIMethod method, JNI.JValue args) {
116116
traceCall(env, clazz, method);
117117
int res = env.getFunctions().getCallStaticIntMethodA().call(env, clazz, method.getJMethodID(), args);
@@ -123,7 +123,7 @@ public int callStaticInt(JNIEnv env, JClass clazz, JNIMethod method, JNI.JValue
123123
* Performs a JNI call of a static method returning {@link Object}.
124124
*/
125125
@SuppressWarnings("unchecked")
126-
@HotSpotCall
126+
@JNICall
127127
public <R extends JObject> R callStaticJObject(JNIEnv env, JClass clazz, JNIMethod method, JNI.JValue args) {
128128
traceCall(env, clazz, method);
129129
JNI.JObject res = env.getFunctions().getCallStaticObjectMethodA().call(env, clazz, method.getJMethodID(), args);
@@ -134,7 +134,7 @@ public <R extends JObject> R callStaticJObject(JNIEnv env, JClass clazz, JNIMeth
134134
/**
135135
* Creates a new object instance using a given constructor.
136136
*/
137-
@HotSpotCall
137+
@JNICall
138138
@SuppressWarnings("unchecked")
139139
public <R extends JObject> R callNewObject(JNIEnv env, JClass clazz, JNIMethod constructor, JNI.JValue args) {
140140
traceCall(env, clazz, constructor);
@@ -146,7 +146,7 @@ public <R extends JObject> R callNewObject(JNIEnv env, JClass clazz, JNIMethod c
146146
/**
147147
* Performs a JNI call of a void method.
148148
*/
149-
@HotSpotCall
149+
@JNICall
150150
public void callVoid(JNIEnv env, JObject object, JNIMethod method, JNI.JValue args) {
151151
traceCall(env, object, method);
152152
env.getFunctions().getCallVoidMethodA().call(env, object, method.getJMethodID(), args);
@@ -156,7 +156,7 @@ public void callVoid(JNIEnv env, JObject object, JNIMethod method, JNI.JValue ar
156156
/**
157157
* Performs a JNI call of a method returning {@link Object}.
158158
*/
159-
@HotSpotCall
159+
@JNICall
160160
@SuppressWarnings("unchecked")
161161
public <R extends JObject> R callJObject(JNIEnv env, JObject object, JNIMethod method, JNI.JValue args) {
162162
traceCall(env, object, method);
@@ -168,7 +168,7 @@ public <R extends JObject> R callJObject(JNIEnv env, JObject object, JNIMethod m
168168
/**
169169
* Performs a JNI call of a method returning {@code boolean}.
170170
*/
171-
@HotSpotCall
171+
@JNICall
172172
public boolean callBoolean(JNIEnv env, JObject object, JNIMethod method, JNI.JValue args) {
173173
traceCall(env, object, method);
174174
boolean res = env.getFunctions().getCallBooleanMethodA().call(env, object, method.getJMethodID(), args);
@@ -179,7 +179,7 @@ public boolean callBoolean(JNIEnv env, JObject object, JNIMethod method, JNI.JVa
179179
/**
180180
* Performs a JNI call of a method returning {@code short}.
181181
*/
182-
@HotSpotCall
182+
@JNICall
183183
public short callShort(JNIEnv env, JObject object, JNIMethod method, JNI.JValue args) {
184184
traceCall(env, object, method);
185185
short res = env.getFunctions().getCallShortMethodA().call(env, object, method.getJMethodID(), args);
@@ -190,7 +190,7 @@ public short callShort(JNIEnv env, JObject object, JNIMethod method, JNI.JValue
190190
/**
191191
* Performs a JNI call of a method returning {@code int}.
192192
*/
193-
@HotSpotCall
193+
@JNICall
194194
public int callInt(JNIEnv env, JObject object, JNIMethod method, JNI.JValue args) {
195195
traceCall(env, object, method);
196196
int res = env.getFunctions().getCallIntMethodA().call(env, object, method.getJMethodID(), args);
@@ -201,7 +201,7 @@ public int callInt(JNIEnv env, JObject object, JNIMethod method, JNI.JValue args
201201
/**
202202
* Performs a JNI call of a method returning {@code long}.
203203
*/
204-
@HotSpotCall
204+
@JNICall
205205
public long callLong(JNIEnv env, JObject object, JNIMethod method, JNI.JValue args) {
206206
traceCall(env, object, method);
207207
long res = env.getFunctions().getCallLongMethodA().call(env, object, method.getJMethodID(), args);
@@ -212,7 +212,7 @@ public long callLong(JNIEnv env, JObject object, JNIMethod method, JNI.JValue ar
212212
/**
213213
* Performs a JNI call of a method returning {@code double}.
214214
*/
215-
@HotSpotCall
215+
@JNICall
216216
public double callDouble(JNIEnv env, JObject object, JNIMethod method, JNI.JValue args) {
217217
traceCall(env, object, method);
218218
double res = env.getFunctions().getCallDoubleMethodA().call(env, object, method.getJMethodID(), args);
@@ -223,7 +223,7 @@ public double callDouble(JNIEnv env, JObject object, JNIMethod method, JNI.JValu
223223
/**
224224
* Performs a JNI call of a method returning {@code float}.
225225
*/
226-
@HotSpotCall
226+
@JNICall
227227
public float callFloat(JNIEnv env, JObject object, JNIMethod method, JNI.JValue args) {
228228
traceCall(env, object, method);
229229
float res = env.getFunctions().getCallFloatMethodA().call(env, object, method.getJMethodID(), args);
@@ -234,7 +234,7 @@ public float callFloat(JNIEnv env, JObject object, JNIMethod method, JNI.JValue
234234
/**
235235
* Performs a JNI call of a method returning {@code byte}.
236236
*/
237-
@HotSpotCall
237+
@JNICall
238238
public byte callByte(JNIEnv env, JObject object, JNIMethod method, JNI.JValue args) {
239239
traceCall(env, object, method);
240240
byte res = env.getFunctions().getCallByteMethodA().call(env, object, method.getJMethodID(), args);
@@ -245,7 +245,7 @@ public byte callByte(JNIEnv env, JObject object, JNIMethod method, JNI.JValue ar
245245
/**
246246
* Performs a JNI call of a method returning {@code char}.
247247
*/
248-
@HotSpotCall
248+
@JNICall
249249
public char callChar(JNIEnv env, JObject object, JNIMethod method, JNI.JValue args) {
250250
traceCall(env, object, method);
251251
char res = env.getFunctions().getCallCharMethodA().call(env, object, method.getJMethodID(), args);
@@ -344,6 +344,6 @@ public String toString() {
344344
*/
345345
@Retention(RetentionPolicy.RUNTIME)
346346
@Target(ElementType.METHOD)
347-
@interface HotSpotCall {
347+
@interface JNICall {
348348
}
349349
}

0 commit comments

Comments
 (0)