ppkarwasz opened a new pull request, #730:
URL: https://github.com/apache/commons-parent/pull/730

   On Java 28, Mockito 4 can no longer create mocks of concrete classes. It 
goes through Objenesis, which calls 
`ReflectionFactory.newConstructorForSerialization`, and Java 28 now refuses 
that call for classes that are not serializable:
   
   ```
   java.lang.UnsupportedOperationException: Run with 
-Djdk.reflect.allowNonSerializableConstruction=true to temporarily re-enable 
this method
   ```
   
   For example, Commons Compress currently gets 39 errors in its 28-ea job.
   
   ### Changes
   
   1. **Use Mockito 5 on Java 11 and up.** Mockito 5 creates mocks through 
instrumented constructors, with `Unsafe` as a fallback, so Objenesis is no 
longer involved. It also brings Byte Buddy 1.18.17, which supports Java 28 
class files. A new `java-1.8-10` profile keeps Mockito 4.11.0, the last 4.x 
release, on Java 8–10.
      The Mockito 5 version is the **top-level** property on purpose. When a 
property is defined both at the top level and in a profile, Dependabot reads 
and rewrites only the top-level one (see 
[`property_value_finder.rb`](https://github.com/dependabot/dependabot-core/blob/main/maven/lib/dependabot/maven/file_parser/property_value_finder.rb)).
 So Dependabot keeps updating Mockito 5 and never proposes 5.x for the Java 8 
pin.
   2. **Remove the unreleased `java28-tests` profile.** With Mockito 5 on Java 
11 and up, `-Djdk.reflect.allowNonSerializableConstruction=true` is no longer 
needed. This is a separate commit, so it is easy to drop if you prefer to keep 
the profile for a while.
   3. **Test the managed dependencies on every supported Java version.** The 
parent POM manages JUnit, JUnit Pioneer and Mockito but never uses them, so a 
Dependabot update to a version that needs a newer Java would pass CI and only 
break components. A maven-invoker-plugin integration test 
(`<inherited>false</inherited>`, so components don't run it) builds 
`src/it/managed-dependencies` against the freshly built parent. It runs a test 
using JUnit Jupiter (including params), JUnit Pioneer, Mockito and 
`MockitoExtension` with the build JDK, so CI covers Java 8 through 28-ea. It 
adds about 5 seconds to the build.
   4. **CI: only early-access builds may fail.** `continue-on-error: true` 
applied to every job, so a Java 8 failure did not fail the workflow and the new 
test would not gate anything. It now applies only to `experimental` jobs, and 
`fail-fast: false` keeps all Java versions running.
   
   ### Verification
   
   - `mvn` (default goal) passes on Java 8. `mvn clean verify` passes on Java 
8, 11 and 27. The IT resolves Mockito 4.11.0 on Java 8 and Mockito 5.25.0 on 11 
and 27.
   - Negative checks on Java 8, editing `pom.xml` the way a Dependabot PR 
would. Each one makes the IT fail with `class file has wrong version`:
     - `commons.junit.version` 5.14.4 → 6.1.0 (61.0)
     - `commons.junit-pioneer.version` 1.9.1 → 2.3.0 (55.0)
     - the Java 8 Mockito pin 4.11.0 → 5.25.0 (55.0)
   - Commons Compress with Mockito 5.25.0 passes all 4781 tests on Java 11 and 
27.
   - I could not run Java 28 locally; this PR's 28-ea job is the check.
   
   Note: `spdx:createSPDX` forks the lifecycle, so the whole build up to 
`verify` runs twice (this was already the case before this PR). As a result the 
IT also runs twice.
   
   ### Checklist
   
   - [x] Read the contribution guidelines.
   - [x] Read the ASF Generative Tooling Guidance.
   - [x] I used AI to create any part of, or all of, this pull request: Claude 
Code (Claude Opus 5.5) did the investigation and wrote the changes under my 
direction. I reviewed the result.
   - [x] Run a successful build using the default Maven goal with `mvn`.
   - [x] Write tests that fail if the changes are not applied (see the negative 
checks above).
   - [x] Detailed pull request description.
   - [x] Each commit has a meaningful subject line and body.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to