RFR: 8320002: Remove obsolete CDS check in Reflection::verify_class_access()

Ioi Lam iklam at openjdk.org
Wed Jan 24 14:20:27 UTC 2024


On Wed, 3 Jan 2024 00:39:52 GMT, Calvin Cheung <ccheung at openjdk.org> wrote:

> This fix removes an obsolete CDS check. Please review.
> 
> Passed tiers 1 - 4 testing.

LGTM.

The code that Calvin is removing is very old code. I guess at one time during the initial development of modules in JDK 9, even when the access was perfectly OK, the "real" check would fail because some information were not properly set up. So as a hack, someone added:


if (DumpSharedSpaces) {
  return ACCESS_OK
}
if (some_real_check()) { // <-- would cause failures/assert/etc if DumpSharedSpaces==true
}


Unfortunately there's no history for why this hack was added:

https://github.com/openjdk/jdk/blame/6e86904a94d2ed2815aa6e3364c048dac595320d/src/hotspot/share/runtime/reflection.cpp#L458-L466

However, that problem doesn't exist anymore, so we can remove this hack.

Yes, this changes behavior. However, we run a very limited set of Java code during "java -Xshare:dump". Specifically, we never execute any user-supplied code. So even if we perform the real checks, we should always get ACCESS_OK anyway. If we don't, that will be a bug, and we better know about it.

-------------

Marked as reviewed by iklam (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/17232#pullrequestreview-1841485689
PR Comment: https://git.openjdk.org/jdk/pull/17232#issuecomment-1908217749


More information about the hotspot-runtime-dev mailing list