Skip to content

Commit

Permalink
- Fix build failure caused by missing 'IsStaticJDK' declaration in aw…
Browse files Browse the repository at this point in the history
…t_LoadLibrary.c.

- Fix erroneous dlsym call in jdk.jdwp.agent/unix/native/libjdwp/linker_md.c.
  Tested the change by running:
  bin/javastatic -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=0 HelloWorld
  • Loading branch information
jianglizhou committed Aug 14, 2023
1 parent 9e3c81b commit a46c9f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ JNIEXPORT jboolean JNICALL AWTIsHeadless() {
#define HEADLESS_PATH "/libawt_headless.so"
#endif

typedef jboolean (*JLI_IsStaticJDK_t)();
static JLI_IsStaticJDK_t IsStaticJDK = NULL;

jint
AWT_OnLoad(JavaVM *vm, void *reserved)
{
Expand Down
6 changes: 5 additions & 1 deletion src/jdk.jdwp.agent/unix/native/libjdwp/linker_md.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ void * dbgsysFindLibraryEntry(void *handle, const char *name)
return dlsym(handle, name);
}

typedef jboolean (*JLI_IsStaticJDK_t)();

jboolean dbgsysIsStaticJDK()
{
return dlsym(NULL, "IsStaticJDK") != NULL;
// JLI_IsStaticJDK is defined by libjli. Check if it is statically linked.
JLI_IsStaticJDK_t IsStaticJDK = (JLI_IsStaticJDK_t)dlsym(RTLD_DEFAULT, "JLI_IsStaticJDK");
return (IsStaticJDK != NULL) && (IsStaticJDK)();
}

0 comments on commit a46c9f6

Please sign in to comment.