Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support CRaC with Java agents that use appendToBootstrapClassLoaderSearch #162

Draft
wants to merge 1 commit into
base: crac
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/hotspot/os/linux/crac_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@ bool VM_Crac::check_fds() {
}
}

if (ClassLoader::is_in_boot_append_entries(details)) {
print_resources("OK: appended to bootclasspath\n");
continue;
}

print_resources("BAD: opened by application\n");
ok = false;

Expand Down
11 changes: 11 additions & 0 deletions src/hotspot/share/classfile/classLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,17 @@ void ClassLoader::add_to_boot_append_entries(ClassPathEntry *new_entry) {
}
}

bool ClassLoader::is_in_boot_append_entries(const char* path) {
ClassPathEntry* e = first_append_entry();
while (e != nullptr) {
if (strcmp(e->name(), path) == 0) {
return true;
}
e = e->next();
}
Comment on lines +829 to +835
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nitpick:

Suggested change
ClassPathEntry* e = first_append_entry();
while (e != nullptr) {
if (strcmp(e->name(), path) == 0) {
return true;
}
e = e->next();
}
for (ClassPathEntry* e = first_append_entry(); e != nullptr; e = e->next()) {
if (strcmp(e->name(), path) == 0) {
return true;
}
}

return false;
}

// Record the path entries specified in -cp during dump time. The recorded
// information will be used at runtime for loading the archived app classes.
//
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/classfile/classLoader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ class ClassLoader: AllStatic {

// adds a class path to the boot append entries
static void add_to_boot_append_entries(ClassPathEntry* new_entry);
static bool is_in_boot_append_entries(const char* path);

// creates a class path zip entry (returns null if JAR file cannot be opened)
static ClassPathZipEntry* create_class_path_zip_entry(const char *apath, bool is_boot_append);
Expand Down