Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

当使用ASM编写的时候 很多情况下需要了解JVM底层的指令的, 并且需要对栈和本地变量显式的进行操作, 如果直接用ASM进行开发势必会付出更多的学习成本和时间成本,并且不易后期的维护。 此框架正好缓解了上述问题。使程序员编写字节码的时候更易于理解和开发,屏蔽了JVM指令以及栈和本地变量的操作,开发的时候更趋近于直接编写java程序。

License

Notifications You must be signed in to change notification settings

chinadci/asmsupport

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

140 Commits

Repository files navigation

ASMSupport

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.

Folder introduction

asmsupport
 |-src/main/java 
 |-java : Maven standard source
 |-.../asmsupport 
 |-standard : The asmsupport api 
 |-client : The dummy api
 |-core : The asmsupport core implements
 |-resource : Maven standard source resources 
 |-src/test
 |-java : Maven standard test
 |-resource : Maven standard test resources
 |-src/third/java : The third-part source code(as source folder)
 |-src/issue/java : The fixed bug test code(as test folder)
 |-src/sample/java : The some simple exampe.(as test folder)
 |-oldApi : The old api example.
 |-dummy : The dummy api example
 |-json : The simple json serialization tool use asmsupport
 |-proxy : The simple dynamic proxy framework use asmsupport
 |-src/site : The project document site folder.

Preceding is all of the sources folder structure and descriptions, if you want import the project to eclipse, you must be manual use ["src/third/java", "src/issue/java", "src/sample/java"] as source folder.

Maven Dependency

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

The last stable version is 0.4

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) {
					call(defType(System.class).field("out"), "println", val("Hello ASMSupport."))
					return_();
				}
 });
Class<?> FirstCaseClass = dummy.build();
//The following code will use reflection to call main method.
Method mainMethod = FirstCaseClass.getMethod("main", String[].class);
mainMethod.invoke(FirstCaseClass, mainMethod);

Sample : JSON & Proxy

The JSON sample under the folder "src/sample/java/json", run the json.demo.Runner main method, and you can get the generated class in folder "target/sample/json".

The Proxy sample under the folder "src/sample/java/proxy", run the json.demo.Runner main method, and you can get the generated class in folder "target/sample/proxy".

About

当使用ASM编写的时候 很多情况下需要了解JVM底层的指令的, 并且需要对栈和本地变量显式的进行操作, 如果直接用ASM进行开发势必会付出更多的学习成本和时间成本,并且不易后期的维护。 此框架正好缓解了上述问题。使程序员编写字节码的时候更易于理解和开发,屏蔽了JVM指令以及栈和本地变量的操作,开发的时候更趋近于直接编写java程序。

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 82.4%
  • HTML 17.6%

AltStyle によって変換されたページ (->オリジナル) /