Quarkus Extension - Remove a class from dependent library or replace part of a class

Viewed 213

Within a custom Quarkus extension I would like to integrate an existing java library that currently is not compatible to Quarkus.

Are there any examples for the following use cases:

  • remove a java class from a dependency library (library is referenced as maven-dependency)- In this case I'll provide a compatible implementation within the runtime-module.

  • replace specific parts of an existing class form a dependency library (e.g. a default implementation of an interface)

Thanks, Thomas

1 Answers

For the first case, you can use a io.quarkus.deployment.builditem.RemovedResourceBuildItem to have Quarkus essentially remove a class from a dependency.

For the second case, you'll likely need to use a io.quarkus.deployment.builditem.BytecodeTransformerBuildItem which lets you declare an ASM class transformer which can change a class in arbitrary ways.

If you are only looking to change the class for native mode, it's much easier to instead use com.oracle.svm.core.annotate.TargetClass and com.oracle.svm.core.annotate.Substitute.

Related