mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-15 16:44:36 +02:00
8349284: Make libExplicitAttach work on static JDK
Reviewed-by: alanb, dholmes
This commit is contained in:
parent
f11a737707
commit
527489c06d
2 changed files with 8 additions and 11 deletions
|
@ -84,7 +84,6 @@ else
|
|||
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libLinkerInvokerModule := -pthread
|
||||
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libLoaderLookupInvoker := -pthread
|
||||
|
||||
BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libExplicitAttach := java.base:libjvm
|
||||
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libExplicitAttach := -pthread
|
||||
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libImplicitAttach := -pthread
|
||||
BUILD_JDK_JTREG_EXCLUDE += exerevokeall.c
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -26,22 +26,20 @@
|
|||
|
||||
#define STACK_SIZE 0x100000
|
||||
|
||||
static JavaVM *vm;
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void* reserved) {
|
||||
vm = jvm;
|
||||
return JNI_VERSION_1_8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach the current thread with JNI AttachCurrentThread, call a method, and detach.
|
||||
*/
|
||||
void* thread_main(void* arg) {
|
||||
JavaVM *vm;
|
||||
JNIEnv *env;
|
||||
JavaVMInitArgs vm_args;
|
||||
jsize count;
|
||||
jint res;
|
||||
|
||||
res = JNI_GetCreatedJavaVMs(&vm, 1, &count);
|
||||
if (res != JNI_OK) {
|
||||
fprintf(stderr, "JNI_GetCreatedJavaVMs failed: %d\n", res);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
res = (*vm)->AttachCurrentThread(vm, (void **) &env, NULL);
|
||||
if (res != JNI_OK) {
|
||||
fprintf(stderr, "AttachCurrentThreadAsDaemon failed: %d\n", res);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue