class override (same full class name)

Dec 28, 2021


following up with and, there are times where a class defined upstream (either third party or shared library internally) should be overriden.

The trick is to keep the class name exact with the same package name. when maven shaded the class, it would pick up the class from the closest level.

For example, if module ACore has a class names org.wordpress.util.DomainMapper, a class with the exact same name org.wordpress.util.DomainMapper could be created in A1 module to override the provided functionality.

when build module A with -amd, it would generated a A2 jar, which contains the compiled class binary from ACore. while the generated A1 jar, would contain the override class created in A1 module.


Originally published at on December 28, 2021.