Commit 65674c2
authored
fix(bqjdbc): fix BigDecimal usage in mocks (#13207)
`ci / split-units (java-bigquery, 25) ` check in all JDBC PRs suddenly
started failing.
### Root Cause Analysis
#### 1. JDK 25 Class Layout Restructuring
OpenJDK 25 restructured the internal layouts and private fields of core
classes—including `java.math.BigDecimal` and `java.math.BigInteger`—to
lay the groundwork for Project Valhalla's value types and flat objects.
#### 2. Bytecode Compatibility Break
Mockito’s final-class mocking relies on the **ByteBuddy** agent
(v1.12.19 in this module) to instrument core JDK classes at runtime.
Under JDK 25, the restructured bytecode layouts collided with
ByteBuddy's instrumentation patterns. This corrupted internal math
helper methods (such as `needIncrement()` and `divideAndRound()`),
causing subsequent standard `BigDecimal` operations across the JVM
lifecycle to compute incorrect values and trigger the `Rounding
necessary` exception.
#### 3. Strict Module Encapsulation
JDK 25 strictly enforces strong encapsulation of the `java.base` module.
Dynamic runtime bytecode manipulation of core JDK classes is
increasingly unstable without explicit compatibility updates to agents.
### Resolution
By replacing `mock(BigDecimal.class)` with a concrete `new
BigDecimal("123.456")` instance in
[BigQueryCallableStatementTest.java](file:///usr/local/google/home/neenushaji/IdeaProjects/google-cloud-java/java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryCallableStatementTest.java),
we completely bypass runtime bytecode manipulation, ensuring
cross-version compatibility from JDK 11 through JDK 25+.1 parent a36655b commit 65674c2
0 file changed
0 commit comments