Skip to content

Commit

Permalink
8349122: -XX:+AOTClassLinking is not compatible with jdwp
Browse files Browse the repository at this point in the history
Reviewed-by: jrose, kvn
Backport-of: 03f5c33
  • Loading branch information
iklam committed Jan 31, 2025
1 parent 89c46f1 commit 2a1a416
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/hotspot/share/cds/filemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2511,6 +2511,13 @@ bool FileMapInfo::validate_aot_class_linking() {
log_error(cds)("CDS archive has aot-linked classes. It cannot be used with -Djava.security.manager=%s.", prop);
return false;
}

#if INCLUDE_JVMTI
if (Arguments::has_jdwp_agent()) {
log_error(cds)("CDS archive has aot-linked classes. It cannot be used with JDWP agent");
return false;
}
#endif
}

return true;
Expand Down
7 changes: 6 additions & 1 deletion src/hotspot/share/runtime/arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ bool Arguments::_ClipInlining = ClipInlining;
size_t Arguments::_default_SharedBaseAddress = SharedBaseAddress;

bool Arguments::_enable_preview = false;
bool Arguments::_has_jdwp_agent = false;

LegacyGCLogging Arguments::_legacyGCLogging = { nullptr, 0 };

Expand Down Expand Up @@ -2021,7 +2022,7 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs *vm_options_args,
return JNI_OK;
}

#if !INCLUDE_JVMTI
#if !INCLUDE_JVMTI || INCLUDE_CDS
// Checks if name in command-line argument -agent{lib,path}:name[=options]
// represents a valid JDWP agent. is_path==true denotes that we
// are dealing with -agentpath (case where name is a path), otherwise with
Expand Down Expand Up @@ -2319,6 +2320,10 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, JVMFlagOrigin
"Debugging agents are not supported in this VM\n");
return JNI_ERR;
}
#elif INCLUDE_CDS
if (valid_jdwp_agent(name, is_absolute_path)) {
_has_jdwp_agent = true;
}
#endif // !INCLUDE_JVMTI
JvmtiAgentList::add(name, options, is_absolute_path);
os::free(name);
Expand Down
8 changes: 7 additions & 1 deletion src/hotspot/share/runtime/arguments.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
Expand Down Expand Up @@ -254,6 +254,9 @@ class Arguments : AllStatic {
// preview features
static bool _enable_preview;

// jdwp
static bool _has_jdwp_agent;

// Used to save default settings
static bool _AlwaysCompileLoopMethods;
static bool _UseOnStackReplacement;
Expand Down Expand Up @@ -506,6 +509,9 @@ class Arguments : AllStatic {
static void set_enable_preview() { _enable_preview = true; }
static bool enable_preview() { return _enable_preview; }

// jdwp
static bool has_jdwp_agent() { return _has_jdwp_agent; }

// Utility: copies src into buf, replacing "%%" with "%" and "%p" with pid.
static bool copy_expand_pid(const char* src, size_t srclen, char* buf, size_t buflen);

Expand Down

0 comments on commit 2a1a416

Please sign in to comment.