Skip to content

How to Intercept or Override a Constructor Using ByteBuddy? #1837

@crab890715

Description

@crab890715

Hi,
I'm trying to understand how to intercept or override the constructor of a class using ByteBuddy. Specifically, I want to either代理 (proxy) or重写 (rewrite) the constructor logic at runtime — for example, to perform some actions before or after the original constructor is called, or even replace its behavior entirely.

Could someone please provide an example or point me in the right direction on how to achieve this with ByteBuddy? I’ve looked into MethodDelegation and ConstructorStrategy, but I’m not sure how to apply them correctly in this case.

Thanks in advance for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions