Skip to content

How to copy (or invoke) non-static method from one class to another #1870

@dep4

Description

@dep4

Rafael,

First of all, many thanks for this great framework!

How to copy method2 from ClassB into ClassA (or invoke). For simplicity, it does not access any fields and methods in ClassB.

For Advice it needs to be a static method, which it's not.
For MethodCall or MethodDelegation it needs to be a compatible class to be invoked, which it's not.
There's an option with ByteCodeAppender, which I could not find a good a example for.

I spent nearly whole day trying to figure it out, if you could show a brief snippet, I appreciate it.

class ClassA {

  void method1() {
  }
}

class ClassB {

  void method2() {
     System.out.println("method2")
  }
}

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions