Skip to content

Commit

Permalink
Fix AttachCurrentThread: must set the env in penvPtr
Browse files Browse the repository at this point in the history
  • Loading branch information
gilles-duboscq committed Apr 29, 2023
1 parent 23fc78c commit ab02b62
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1534,21 +1534,22 @@ public int AttachCurrentThread(@Pointer TruffleObject vmPtr_, @Pointer TruffleOb
private int attachCurrentThread(@SuppressWarnings("unused") @Pointer TruffleObject penvPtr, @Pointer TruffleObject argsPtr, boolean daemon) {
StaticObject group = null;
String name = null;
if (!InteropLibrary.getUncached().isNull(argsPtr)) {
if (InteropLibrary.getUncached().isNull(argsPtr)) {
getLogger().fine("AttachCurrentThread with null args");
} else {
JavaVMAttachArgs.JavaVMAttachArgsWrapper attachArgs = getStructs().javaVMAttachArgs.wrap(jni(), argsPtr);
if (JVM_IsSupportedJNIVersion(attachArgs.version())) {
group = attachArgs.group();
name = NativeUtils.fromUTF8Ptr(attachArgs.name());
} else {
getLogger().warning(String.format("AttachCurrentThread with unsupported JavaVMAttachArgs version: 0x%08x", attachArgs.version()));
}
} else {
getLogger().warning("AttachCurrentThread with null args");
}
StaticObject thread = getContext().createThread(Thread.currentThread(), group, name);
if (daemon) {
getContext().getThreadAccess().setDaemon(thread, true);
}
NativeUtils.writeToPointerPointer(getUncached(), penvPtr, jniEnv.getNativePointer());
return JNI_OK;
}

Expand Down

0 comments on commit ab02b62

Please sign in to comment.