Comments (1)
ByteBuddy does not directly provide an API for this operation. You need to leverage the visitors provided by ASM to achieve this. You can refer to the suggested approach here for specifics. How to copy method body of a particular method to another method in different class using ASM
Similarly, you may encounter the side effects mentioned therein.
If you're only dealing with the specific requirement described in the issue, you could consider achieving it through redefine
+ visit
, for example:
new ByteBuddy()
.redefine(Child.class)
.name("child2")
.visit(new AsmVisitorWrapper.AbstractBase() {
@Override
public ClassVisitor wrap(TypeDescription instrumentedType, ClassVisitor classVisitor, Implementation.Context implementationContext, TypePool typePool, FieldList<FieldDescription.InDefinedShape> fields, MethodList<?> methods, int writerFlags, int readerFlags) {
return new ClassVisitor(OpenedClassReader.ASM_API, classVisitor) {
@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
super.visit(version, access, name, signature, Type.getInternalName(parentClass), interfaces);
}
};
}
});
However, it still cannot avoid the potential errors mentioned in the link above, so you must be clear about what you are doing and have the ability to handle those issues on your own.
from byte-buddy.
Related Issues (20)
- [Question] AgentBuilder.InitializationStrategy.SelfInjection's behaviour in detail HOT 2
- Java 22 Support HOT 5
- How do I change the method name and keep the original method body HOT 1
- Advice method contains asynchronization code will throw IllegalAccessError HOT 1
- Intercept Input Streams HOT 2
- GraalVM native image fails at run time due to NoClassDefFoundError HOT 3
- StackOverflowError during exception reporting HOT 1
- Question:Error when use maven plugin HOT 3
- Question: How to add some parameters in ByteBuddy starting process when using ByteBuddy dependency HOT 3
- Bytebuddy Advice not called HOT 1
- Android Sample Application HOT 6
- how to enhance thread construct method HOT 7
- byte-buddy J9 attachment only checks for self-owned directories HOT 14
- Why doesn't this simple example work? HOT 5
- Can ByteBuddy add synchronized to intercepted setters? HOT 2
- Can ByteBuddy make a non-static field be final? HOT 1
- seems that namedOneOf isn't working as expected HOT 1
- Release missing of version 1.14.15 HOT 1
- java.lang.NoSuchMethodError when using the agent for method instrumentation HOT 2
- Cannot invoke public constructor HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from byte-buddy.