No description, website, or topics provided.
Python Java
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
templates
.gitignore
LICENSE
MANIFEST.MF
Makefile
README.md
Rewriter.java
Transformer.java
translator.py

README.md

java2asm

Simple tool to make generation of ASM API calls easier.

Basically, it parses javac's classfile output and creates a ClassFileTransformer that appends and / or replaces method calls.

Dependencies

python-javatools version >= 1.4.0. Currently PyPI only has 1.3.0, so install it from GitHub.

asm-4.1.jar. Put this in the source directory.

Limitations

No branching / exception handling opcodes have been implemented. But you can insert method calls to external functions and do all your control flow there, so this shouldn't be a real issue.

Example

Example.java:

@interface prepend {}
@interface replace {}

public class Example {
    
    @prepend
    public void foo() {
        System.out.println("Hello world");
    }

    @replace
    public void bar() {
        System.out.println("Hello world");
    }
}

javac Example.java && PATCHES=Example.class make