kalayciburak opened a new pull request, #3464:
URL: https://github.com/apache/maven-surefire/pull/3464

   `StackWalkerStrategy.<clinit>` loaded `java.lang.StackWalker` through the 
current thread's TCCL. When that loader is `null` (user threads that cleared 
it, or the JVM `Attach Listener` while a dynamic agent is installed), 
`ReflectionUtils.tryLoadClass` threw an uncaught `NullPointerException`. That 
failed class initialization and every later reference became 
`NoClassDefFoundError: Could not initialize class ...StackWalkerStrategy`.
   
   Because console capture walks the stack on every `println`, a write from a 
null-TCCL thread could poison the forked JVM. On 3.6.0 this also surfaces as a 
confusing Byte Buddy / BlockHound self-attach failure when the JDK prints the 
dynamic-agent warning from `Attach Listener`.
   
   This change:
   
   - treats a null `ClassLoader` as "not found" in `tryLoadClass`, and also 
swallows `RuntimeException` so a later NPE cannot poison `<clinit>`
   - resolves `StackWalker` / `StackFrame` from `StackWalkerStrategy`'s 
defining loader (system loader if that is bootstrap `null`), since those types 
are JDK classes and do not need the TCCL
   
   Fixes #3460
   
   Following this checklist to help us incorporate your contribution quickly 
and easily:
   
    - [x] Each commit in the pull request should have a meaningful subject line 
and body.
    - [x] Write a pull request description that is detailed enough to 
understand what the pull request does, how, and why.
    - [x] Run `mvn clean install` to make sure basic checks pass. A more 
thorough check will be performed on your pull request automatically.
    - [ ] You have run the integration tests successfully (`mvn -Prun-its clean 
install`).
   
   Validation (JDK 21, Maven 3.9.11):
   
    - `mvn -pl surefire-api -Dtest=ReflectionUtilsTest,StackTraceProviderTest 
test` — 23 tests, 0 failures
    - `mvn -pl surefire-api test` — 217 tests, 0 failures, 6 skipped
   
   If your pull request is about ~20 lines of code you don't need to sign an
   [Individual Contributor License 
Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
   please ask on the developers list.
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 
2004](http://www.apache.org/licenses/LICENSE-2.0)
   you have to acknowledge this by using the following check-box.
   
    - [x] I hereby declare this contribution to be licenced under the [Apache 
License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   
    - [ ] In any other case, please file an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).


-- 
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