spark
spark copied to clipboard
[SPARK-48505][CORE] Simplify the implementation of `Utils#isG1GC`
What changes were proposed in this pull request?
This PR simplifies the implementation of Utils.isG1GC as follows:
- Retain
Utils.classForName("com.sun.management.HotSpotDiagnosticMXBean"), the main purpose of this step is to detect whether theHotSpotDiagnosticMXBeanclass can be initialized. - After successful detection, the code is changed to call the API of
HotSpotDiagnosticMXBeaninstead of reflection. - If the detection fails, it will throw a
ClassNotFoundException,Utils.isG1GCwill returnfalsesince 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