nicoloboschi opened a new pull request #14098:
URL: https://github.com/apache/pulsar/pull/14098


   ### Motivation
   
   PowerMockito static mocks don't work well with the latest JDK class 
encapsulation mechanisms. The main problem is that PowerMockito, in order to 
mock a single static method of a class, try to setAccessible a lot of other 
apparently related classes. This means, starting from JDK17, you need to add 
`--add-opens` to the Java runtime options in order to avoid runtime errors.
   
   PowerMockito development isn't much active and they don't seem to be ready 
for the new JDK releases. 
   The best replacement is to use 
[mockito-inline](https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#48)
 (additional part of `mockito-core`), which uses a different algorithm in order 
to mock static methods - a lot less invasive.  
   
   ### Modifications
   
   * Replaced PowerMockito#mockStatic usages with MockedStatic
   * Added a Factory to NarClassLoader since it's not possible to mock 
`ClassLoader` classes in mockito-inline. The API for the NarClassLoader is 
internal so no problem changing it.
   
   
   ### Documentation
   
   - [x] `no-need-doc` 
     


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