https://github.com/taketoday/today-method-invoker
:green_apple: Java Byte Code Method Invoker
https://github.com/taketoday/today-method-invoker
bytecode invoke invoker java java-byte-code method
Last synced: 12 months ago
JSON representation
:green_apple: Java Byte Code Method Invoker
- Host: GitHub
- URL: https://github.com/taketoday/today-method-invoker
- Owner: TAKETODAY
- License: gpl-3.0
- Created: 2019-10-18T16:10:36.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-01-03T13:40:33.000Z (over 5 years ago)
- Last Synced: 2025-03-25T00:42:37.355Z (about 1 year ago)
- Topics: bytecode, invoke, invoker, java, java-byte-code, method
- Language: Java
- Homepage: https://taketoday.cn
- Size: 118 KB
- Stars: 3
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Java Byte Code Method Invoker
[](https://www.codacy.com/manual/TAKETODAY/today-method-invoker?utm_source=github.com&utm_medium=referral&utm_content=TAKETODAY/today-method-invoker&utm_campaign=Badge_Grade)

## :memo: 使用说明
```java
public class TestHandlerInvoker {
public static void main(String[] args) throws Exception {
System.setProperty("cglib.debugLocation", "D:/debug");
{
final Method main = Bean.class.getDeclaredMethod("main");
final Invoker mainInvoker = MethodInvokerCreator.create(main);
mainInvoker.invoke(null, null);
}
{
final Method test = Bean.class.getDeclaredMethod("test", short.class);
final Invoker mainInvoker = MethodInvokerCreator.create(test);
mainInvoker.invoke(null, new Object[] { (short) 1 });
}
final Invoker create = MethodInvokerCreator.create(Bean.class, "test");
create.invoke(new Bean(), null);
final Invoker itself = MethodInvokerCreator.create(Bean.class, "test", Bean.class);
itself.invoke(new Bean(), new Object[] { new Bean() });
}
public static class Bean {
public static void test(short i) throws Throwable {
System.err.println("static main " + i);
}
protected static void main() throws Throwable {
System.err.println("static main");
}
public void test() throws Throwable {
System.err.println("instance test");
}
void test(Bean itself) {
System.err.println("instance test :" + itself);
}
}
}
```
## 🙏 鸣谢
本项目的诞生离不开以下项目:
* [ASM](https://asm.ow2.io): ASM is an all purpose Java bytecode manipulation and analysis framework
* [Cglib](https://github.com/cglib/cglib): Byte Code Generation Library
## 📄 开源协议
使用 [GNU GENERAL PUBLIC LICENSE](https://github.com/TAKETODAY/today-method-invoker/blob/master/LICENSE) 开源协议