Skip to content

Commit

Permalink
synchronize on module entry
Browse files Browse the repository at this point in the history
  • Loading branch information
javeleon committed Feb 18, 2025
1 parent 2808f36 commit d70f103
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,18 @@ public boolean shouldEnableRedefinition() {
return false;
}

public synchronized void grantReadAccessToUnnamedModules(ModuleTable.ModuleEntry module) {
public void grantReadAccessToUnnamedModules(ModuleTable.ModuleEntry module) {
if (module != null && module.isNamed() && !module.hasDefaultReads()) {
getContext().getMeta().jdk_internal_module_Modules_transformedByAgent.invokeDirect(module.module());
// no reason to call into guest for a module more than once,
// so flip the hasDefaultReads flag
module.setHasDefaultReads();
synchronized (module) {
if (module.hasDefaultReads()) {
// we lost the race, so nothing to do
return;
}
getContext().getMeta().jdk_internal_module_Modules_transformedByAgent.invokeDirect(module.module());
// no reason to call into guest for a module more than once,
// so flip the hasDefaultReads flag
module.setHasDefaultReads();
}
}
}

Expand Down

0 comments on commit d70f103

Please sign in to comment.