spark icon indicating copy to clipboard operation
spark copied to clipboard

[SPARK-48505][CORE] Simplify the implementation of `Utils#isG1GC`

Open LuciferYang opened this issue 1 year ago • 0 comments

What changes were proposed in this pull request?

This PR simplifies the implementation of Utils.isG1GC as follows:

  1. Retain Utils.classForName("com.sun.management.HotSpotDiagnosticMXBean"), the main purpose of this step is to detect whether the HotSpotDiagnosticMXBean class can be initialized.
  2. After successful detection, the code is changed to call the API of HotSpotDiagnosticMXBean instead of reflection.
  3. If the detection fails, it will throw a ClassNotFoundException, Utils.isG1GC will return false since this is a NonFatal.

Why are the changes needed?

Simplify the implementation of Utils.isG1GC, try to avoid using reflection as much as possible.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Pass GitHub Actions

Was this patch authored or co-authored using generative AI tooling?

No

LuciferYang avatar Jun 05 '24 03:06 LuciferYang