@xmcl/asm
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

ASM Module

npm version Downloads Install size npm Build Status

Parse Java bytecode, which port from java asm package.

Usage

Visit java class in jar file

The usage is just like asm library in java:

import { AnnotationVisitor, ClassReader, ClassVisitor, MethodVisitor, Opcodes } from '@xmcl/asm'


class CustomClassVisitor extends ClassVisitor {
    public constructor() {
        super(Opcodes.ASM5);
    }

    // visit the class 
    visit(version: number, access: number, name: string, signature: string, superName: string, interfaces: string[]): void {
    }

    // visit method
    public visitMethod(access: number, name: string, desc: string, signature: string, exceptions: string[]) {
        return null;
    }

    // visit field
    public visitField(access: number, name: string, desc: string, signature: string, value: any) {
        return null;
    }
}

const visitor = new CustomClassVisitor();
const classData: Buffer = await fs.readFile("path/to/some.class");
new ClassReader(classData).accept(visitor);

Readme

Keywords

Package Sidebar

Install

npm i @xmcl/asm

Weekly Downloads

56

Version

1.0.1

License

MIT

Unpacked Size

2.28 MB

Total Files

57

Last publish

Collaborators

  • ci010