Skip to content

Commit b7172be

Browse files
committed
More JNI functions
1 parent 44ceffd commit b7172be

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

JvmSpecNotes.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
http://www.javaseiten.de/jvmisi.html#iload_1
2-
https://jvilk.com/blog/java-8-wtf-ambiguous-method-lookup/
3-
https://stackoverflow.com/questions/13978355/on-signature-polymorphic-methods-in-java-7/14000576#14000576
1+
- http://www.javaseiten.de/jvmisi.html#iload_1
2+
- https://jvilk.com/blog/java-8-wtf-ambiguous-method-lookup/
3+
- https://stackoverflow.com/questions/13978355/on-signature-polymorphic-methods-in-java-7/14000576#14000576
4+
- https://docs.oracle.com/javase/9/docs/specs/jni/functions.html
45

56
# Chapter 2: The Structure of the Java Virtual Machine
67

src/jni.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,24 @@ jobject NewLocalRef
262262
UNIMPLEMENTED("NewLocalRef");
263263
}
264264

265+
// TODO should this be configureable?
266+
// jdk11u-dev/src/hotspot/share/runtime/globals.hpp
267+
// https://docs.oracle.com/javase/9/docs/specs/jni/functions.html#ensurelocalcapacity
268+
static const jint MaxJNILocalCapacity = -1;
269+
265270
jint EnsureLocalCapacity
266271
(JNIEnv *env, jint capacity) {
267-
UNIMPLEMENTED("EnsureLocalCapacity");
272+
LOG("EnsureLocalCapacity");
273+
274+
jint ret;
275+
if (capacity >= 0 &&
276+
((MaxJNILocalCapacity <= 0) || (capacity <= MaxJNILocalCapacity))) {
277+
ret = JNI_OK;
278+
} else {
279+
ret = JNI_ERR;
280+
}
281+
282+
return ret;
268283
}
269284

270285
jobject AllocObject
@@ -906,7 +921,9 @@ void DeleteWeakGlobalRef
906921

907922
jboolean ExceptionCheck
908923
(JNIEnv *env) {
909-
UNIMPLEMENTED("ExceptionCheck");
924+
LOG("ExceptionCheck");
925+
auto *thread = (Thread *) env->functions->reserved0;
926+
return thread->current_exception != JAVA_NULL;
910927
}
911928

912929
jobject NewDirectByteBuffer

0 commit comments

Comments
 (0)