← Back to Pull requests

Fix ClassInitializationSuite on JDK 21 #17249

Open
unknown opened this pull request with 396 lines diff across 4 files
View on GitHub
unknown unknown commented on Dec 02, 2026 07:33 UTC
Author

Fixes #17237.

Description

ClassInitializationSuite uses Thread.suspend() and Thread.resume() to force the class-initialization ordering needed to test the former GpuOverrides/SparkShimImpl deadlock. JDK 21 disables those methods, causing the test harness to fail before it can evaluate the production initialization behavior.

This change replaces forced thread suspension with a dependency-free cooperative hook. Its holder and production entry point are public so they remain accessible when multi-shim packaging loads shared and version-specific classes through different class loaders. The constructor and test-only install/clear methods remain non-public. The hook is unset in production and is invoked only once during GpuOverrides class initialization. The child reproducer installs the hook before initialization and uses CountDownLatch instances to signal arrival and release the initializer deterministically. This preserves the original deadlock coverage without JDI or deprecated thread-control APIs.

There is no user-facing behavior or configuration change.

Validation completed:

  • JDK 21, Spark 3.4, Scala 2.12: ClassInitializationSuite passed 2/2 tests. Javac lint was disabled only to bypass the repository's existing Java 8 source/target warning promoted by -Werror.

  • JDK 17, Spark 4.0, Scala 2.13: ClassInitializationSuite passed 2/2 tests.

  • Negative control: temporarily restoring eager shimExecs initialization made the suite detect the original deadlock with exit code 2.

  • Compiled access flags confirm that the holder and production entry point are public while the constructor and test-control methods remain non-public.

  • All-module Scala 2.12 and Scala 2.13 scalastyle passed with 0 errors and 0 warnings.

  • Shim compatibility source-selection review passed with no new findings.
  • Performance validation measured the uninstalled production hook on an Intel Core i7-8700K pinned to one CPU:

  • After 50 million warmup calls, 15 rounds of 100 million calls measured a median of 0.146 ns/call and P95 of 0.182 ns/call on JDK 17, and a median of 0.140 ns/call and P95 of 0.174 ns/call on JDK 21.

  • Across 30 fresh JVMs, the first invocation, including hook class loading and initialization, measured a median of 563.514 microseconds and P95 of 596.562 microseconds on JDK 17, and a median of 300.259 microseconds and P95 of 346.817 microseconds on JDK 21.

  • Production invokes the hook once per GpuOverrides singleton initialization; it is not on a per-query, per-task, or per-batch path.
  • The Spark 5 profile was not run because its current test compilation remains blocked by #17236 and #17241. The JDK 21 behavior covered by this change was validated with the Spark 3.4 profile.

    This change was developed with AI assistance.

    Checklists

    Documentation

  • Updated for new or modified user-facing features or behaviors

  • No user-facing change
  • Testing

  • Added or modified tests to cover new code paths

  • Covered by existing tests

  • Not required
  • Performance

  • Tests ran and results are added in the PR description

  • Issue filed with a link in the PR description

  • Not required
  • Diff: 396 lines (+297 / -99) across 4 files Reviewer: firestarman Review duration: 3370m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 396 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.358
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #17249"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.2% (MEDIUM) · Higher = larger blast radius
    43.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23% · Safe to merge
    23%