1 Star 0 Fork 47

sandyfog / asmsupport

forked from Small Warm / asmsupport 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 3.08 KB
一键复制 编辑 原始数据 按行查看 历史

asmsupport

Build Status Maven central

中文README

A java class byte code operate framework

The asmsupport is a java class byte code operate library, it make easier to write or modify a class at runtime. This framework developed base on asm framework, but different from asm that avoid use original jvm instruction and avoid maintain stack and local variables.

Modules

Module Description
asmsupport-thrid This modules is a set of third open source code, the benefit is to avoid third library confilict when you use asmsupport.
asmsupport-standard This module is a standard apid definition of asmsupport, you can implement a new framework of asmsupport will be following this standard api.
asmsupport-core This module is the core implement of asmsupport-standard.
asmsupport-client This module is the wrapper of asmsupport-core, and it's also implement the asmsupport-standard api
asmsupport-issues This module is all of the test code for each issue test, the benefit of this modules is make the issue never reproduce again when you run 'mvn test'
asmsupport-sample Some simple sample use asmsupport, such as dynamic proxy, json serialize and so on.

Maven Dependency

<dependency>
    <groupId>cn.wensiqun</groupId>
    <artifactId>asmsupport</artifactId>
    <version>x.x.x</version>
</dependency>

License

Asmsupport is licensed under the GNU Lesser General Public License (LGPL)

First Case

The following code will generate.

public class FirstCase {
    
    public static void main(String[] args) {
        System.out.println("Hello ASMSupport.");
    }
    
}

The following is code to generate preceding case.

DummyClass dummy = new DummyClass("FirstCase").public_()
       .newMethod("main").public_().static_().argTypes(String[].class)
       .body(new MethodBody(){
				public void body(LocalVariable... args) {
					getType(System.class).field("out").call("println", val("Hello ASMSupport."))
					return_();
				}
       });
Class<?> FirstCaseClass = dummy.build();
Method mainMethod = FirstCaseClass.getMethod("main", String[].class);
mainMethod.invoke(FirstCaseClass, mainMethod);

Sample : JSON & Proxy

The JSON sample under the package "cn.wensiqun.asmsupport.sample.client.json下", run the "cn.wensiqun.asmsupport.sample.client.json.demo.Runner" main method, and you can get the generated class in folder "target/asmsupport-test-generated".

The Proxy sample under the package "cn.wensiqun.asmsupport.sample.client.proxy", run the cn.wensiqun.asmsupport.sample.client.proxy.demo.Runner main method, and you can get the generated class in folder "target/asmsupport-test-generated".

1
https://gitee.com/sandyfog/asmsupport.git
git@gitee.com:sandyfog/asmsupport.git
sandyfog
asmsupport
asmsupport
master

搜索帮助